Arbitrary string to DBus path

Ted Gould ted at gould.cx
Fri Nov 15 09:21:48 PST 2013


Hello,

One problem we've had is taking arbitrary string (usually application
names) and putting them into object paths on DBus.  The characters
allowed in the path is limited, which is fine, but we need some way to
represent the string we're passed through that.  libnih has a small
function[1] that does this by taking any character that isn't an ASCII
character or digit and putting it's value as ASCII digits after an
underscore.  We've been using this in various places, and I think it'd
be useful if there was an algorithm that was included in the DBus spec.

As a concrete example we're using this in the Unity HUD service.  Each
application that it knows about, it registers an object on DBus where
the application can control the behavior of its items in the HUD.
Because application names don't have the same restrictions as DBus paths
we're forced to transform the name into something that can be
represented on DBus.  We do this using the libnih algorithm, and then
application can predict where they'll show up without needing to query
the HUD service.  We can also easily find them using debugging tools
like D-Feet.

I'm putting forward the libnih algorithm as the proposal for this.  To
me it has some advantages:


      * It is mostly human readable
      * It is reversible
      * It'll work for any characters we throw at it


The biggest downside to me:


      * It is kinda verbose


Thoughts?  Is this something the spec needs?  Are people generally happy
with the libnih algorithm?  If there's no complains I'll move to making
a patch to the spec.

Ted

[1]
http://bazaar.launchpad.net/~scott/libnih/trunk/view/head:/nih-dbus/dbus_util.c#L38
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20131115/0d7917cc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20131115/0d7917cc/attachment.pgp>


More information about the dbus mailing list