Properties interface additions

Thiago Macieira thiago at kde.org
Wed Jan 28 15:15:02 PST 2009


David Zeuthen wrote:
>Sounds OK though I'm concerned this will take some time. Does anyone
>know exactly what bindings, aside from EggDBus, that maps D-Bus
>properties to native properties/attributes/etc?

QtDBus maps D-Bus properties to the static QObject properties.

The Qt Obejct model has two property types: static and dynamic. Static 
properties are defined in the .h file for the class with the Q_PROPERTY 
macro, then processed by moc and hardcoded. You can query the QMetaObject 
for that class what the properties are. The moc program simply creates a 
function that, given a property ID will call the correct getter or setter 
function, after casting a QVariant to the appropriate type.

However, if you were to call setProperty("name", value) where "name" is  
not a known property, then you are creating a dynamic property. Those are 
not supported at all by QtDBus.

The interesting problem is that there is no change notification for static 
properties, since they are basically moc glue on top of C++ methods. I.e.:

	Q_PROPERTY(int value READ value WRITE setValue) // expands to nothing
	int value() const;
	void setValue(int x);

And C++ methods can be called directly, bypassing setProperty and, 
therefore, any trap mechanism we might set.

On the other hand, dynamic properties must be modified with setProperty 
and there's an event sent whenever they are changed. But we don' t support 
them, since they are not known to be valid in every single object of that 
class and, therefore, cannot be listed in the introspection's XML.

In other words, QtDBus would always have emits-changed="false" or would 
have an empty list of property names that supports change notification.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20090129/af435cce/attachment.pgp 


More information about the dbus mailing list