Properties interface additions

David Zeuthen david at fubar.dk
Wed Jan 14 13:32:45 PST 2009


On Wed, 2009-01-14 at 14:50 -0500, David Zeuthen wrote:
> Hey,
> 
> So in EggDBus [1], I ended up mapping D-Bus properties directly to
> GObject properties and I think this is working out really well. I'm also
> using an EggDBus specific signal on the org.freedesktop.Properties
> interface
> 
> http://people.freedesktop.org/~david/eggdbus-0.1-docs/eggdbus-eggdbusproperties.html
> 
> to indicate property changes. Of course this only works if the other end
> is using EggDBus but for the projects I'm working on this happens the
> case. Still, I'd like to propose that we add a Changed() signal to the
> D-Bus specification. I've attached a patch for this. OK to commit?

Simon had a good list of questions related to bindings; here's the cheat
sheet for EggDBus

> * Are "complete" bindings required to support properties of the same
>   name in different interfaces?

EggDBus supports this; there's object proxies and interface proxies.

> * Are "complete" bindings required to support properties whose name is
>  any valid D-Bus member name? (e.g. "__IAm____OnCrack")

Property names are translated to GObject style properties, e.g. the
property ThisIsAProperty is translated into this-is-a-property. I
haven't added code to handle collisions but it's doable.

> * Is it true that setting a property can never fail? (My opinion: no,
>   it can fail, and clients must not assume it will succeed)

In EggDBus you can set properties in three ways

 o g_object_set()

 o you can use the generated C API, for example
http://people.freedesktop.org/~david/eggdbus-0.1-docs/tests-testtweak.html#test-tweak-set-some-read-write-property

 o you can use the set() functions on the generated GInterface for
   org.freedesktop.DBus.Properties:
http://people.freedesktop.org/~david/eggdbus-0.1-docs/eggdbus-eggdbusproperties.html
   (which is generated exactly the same way as other interfaces)

Now, my view is that org.fd.DBus.Properties.Set() _can_ fail and if it
does, it should be documented in the API. However, most APIs should be
designed in a way such that setting a property can't fail.

> * Is it true that all properties must accept *all* correctly-typed
>   values? (My opinion: no, it can fail, e.g. rejecting non-ASCII
>   strings, or it can quietly "normalize" values, e.g. forcing strings
>   to lower-case)

I agree that the service is free to do whatever it wants; e.g. there's
no guarantee that

 obj.set ("foo", 42)
 assert (obj.get ("foo") == 42);

won't assert.

> * Can specification writers assume that services using "complete"
>   bindings will be able to run arbitrary code in response to a
>   property being set?

I would think so.

    David




More information about the dbus mailing list