[mpris] [ANN] MPRIS v2.0

Lennart Poettering lennart at poettering.net
Thu Aug 12 20:16:00 CEST 2010


On Thu, 12.08.10 09:56, Ian Monroe (ian at monroe.nu) wrote:

> 
> On Thu, Aug 12, 2010 at 9:17 AM, Mirsal Ennaime
> <mirsal.ennaime at gmail.com> wrote:
> > On Thu, Aug 12, 2010 at 4:05 PM, Ian Monroe <ian at monroe.nu> wrote:
> >> I don't even understand what an object path for tracks means. You want
> >> all implementation to have to implement a memory costly map of fake
> >> DBus object paths to tracks, instead of just using an internal string
> >> representation that they'd have already? It makes absolutely no sense
> >> to me.
> >
> > There is no need to maintain a map, as they can be generated on the fly, and
> > the spec does not mandate that they are exposed on the bus.
> >
> > This way, if a media player wants to expose them on the bus, it can.
> > Clients can use introspection to find out what interface they implement if any.
> 
> Actually just now looking at the D-Bus spec:
> http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path
> 
> The requirement that "Each element must only contain the ASCII
> characters "[A-Z][a-z][0-9]_" does mean that a map might have to be
> maintained. Or some sort of coding and decoding function that I
> haven't heard of needs to be used, or else we're kinda screwed when it
> comes to non-ASCII characters in the file name. (If it allowed % it
> would be easy, just use HTML encoding, but it doesn't).

You can easily escape things. Many projects do things like that. HAL
did, systemd does, almost everything else does that too.

Here's a little example how to do this, just to make a point:

<snip>
char *bus_path_escape(const char *s) {
        char *r, *t;
        const char *f;

        assert(s);

        /* Escapes all chars that D-Bus' object path cannot deal
         * with. Can be reverse with bus_path_unescape() */

        if (!(r = new(char, strlen(s)*3+1)))
                return NULL;

        for (f = s, t = r; *f; f++) {

                if (!(*f >= 'A' && *f <= 'Z') &&
                    !(*f >= 'a' && *f <= 'z') &&
                    !(*f >= '0' && *f <= '9')) {
                        *(t++) = '_';
                        *(t++) = hexchar(*f >> 4);
                        *(t++) = hexchar(*f);
                } else
                        *(t++) = *f;
        }

        *t = 0;

        return r;
}
</snip>

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the mpris mailing list