Bug 45844 - Status messages should be able to carry structured XML or JSON content
Summary: Status messages should be able to carry structured XML or JSON content
Status: NEW
Alias: None
Product: Ytstenut
Classification: Unclassified
Component: protocol (show other bugs)
Version: unspecified
Hardware: Other All
: medium major
Assignee: Robert Staudinger
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-09 08:27 UTC by Olli Salli
Modified: 2012-08-16 15:46 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Olli Salli 2012-02-09 08:27:03 UTC
The Ytstenut statuses offer a useful mechanism for Ytstenut applications to broadcast their state to all interested receivers. This is more efficient than sending unicast Ytstenut messages/commands when there are many receivers, and works in the presence of client-only applications, which can't receive incoming commands.

However, the spec document currently restricts the contents of the <ytstenut:status/> elements to a flat list of <ytstenut:description/> nodes. Arbitrary attributes are supported on the <ytstenut:status/> node itself, but these are not sufficient for many kinds of data.

I propose adding an optional <ytstenut:payload/> element to those allowed as children of <ytstenut:status/> nodes. If present, this element could contain arbitrary XML structured content. I think a separate container element is nice to have for this free-form payload, so it won't get confused / collide with the <ytstenut:description/>s of the status itself.

E.g. a music player might want to transmit the contents of its playlist to allow choosing the next song like this:

<ytstenut:status version='1.0'
from-service='org.kde.Amarok'
capability='yts-caps-audio'
activity='yts-activity-play'
uri='file:///song1.mp3'
volume='0.75'>

<ytstenut:description xml:lang='en-GB'>
Playing a song about indifference towards weather.
</ytstenut:description>

<ytstenut:payload>
    <playlist>
      <entry uri='file:///song1.mp3' artist='Art Blakey &amp; The Jazz Messengers' title='Come Rain or Come Shine' />
      <entry uri='file:///song2.mp3' artist='Art Blakey &amp; The Jazz Messengers' title='Moanin&apos;' />
    </playlist>
</ytstenut:payload>

</ytstenut:status>

A client receiving this would be in a good position to issue a ytstenut/command with activity='yts-activity-play' uri='file:///song2.mp3' if they want to switch to the true masterpiece from the album.
Comment 1 Olli Salli 2012-02-09 08:30:26 UTC
FWIW the C stack allows sending freely structured XML content already.
Comment 2 Robert Staudinger 2012-02-09 10:37:32 UTC
Would there be any reason not to support arbitrary XML inside <ytstenut:status> ? I'd favour that and maybe even get rid of <ytstenut:description>, but restrict the possible xml attributes of <ytstenut:status> in exchange.
Comment 3 Olli Salli 2012-02-09 10:47:43 UTC
(In reply to comment #2)
> Would there be any reason not to support arbitrary XML inside <ytstenut:status>
> ? I'd favour that and maybe even get rid of <ytstenut:description>, but
> restrict the possible xml attributes of <ytstenut:status> in exchange.

The <yts:descr>s are mandatory, so unless we remove them I think it'd be weird to have free-form optional stuff mixed with them.

Why restrict the attributes? Attributes can be namespaced just like element tags, so foreign ones can be easily ignored. We might want to mandate an XML namespace for non-standard attributes though?
Comment 4 Robert Staudinger 2012-02-09 11:38:38 UTC
(In reply to comment #3)
> Why restrict the attributes? Attributes can be namespaced just like element
> tags, so foreign ones can be easily ignored. We might want to mandate an XML
> namespace for non-standard attributes though?

The plan we discussed with Will in November was to move to JSON payload for messages and status. By not allowing custom attributes and encoding the payload inside in JSON we have a clean separation of protocol and data.

You can of course still use XML payloads, but ytstenut-glib will not offer any facilities for that, you'll just have to pass the xml string.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.