n00b: signals with an extensible message

Thiago Macieira thiago at kde.org
Mon Feb 15 23:22:03 PST 2010


Em Terça-feira 16. Fevereiro 2010, às 03.04.23, Tim Hockin escreveu:
> Hey there,
> 
> I'm finally getting around to adding dbus support to some tools, and
> I'm not sure how to do the payload.
> 
> What I have is a data structure.  It has about 10 fields (all numeric,
> a mix of sizes and signedness) right now, but I know it will grow in
> the future (new fields, not modifying or removing old ones).  I want
> to send signals which carry the equivalent of this data structure.
> What I don't know is how to do this safely through DBUS.
> 
> What happens if the server is newer and has more fields than the
> client knows about?
> 
> What happens if the server is older and has less fields than the
> client knows about?
> 
> Is there a canonical answer to this?

Yes: it's not safe to do what you want.

If you change the structure (adding or removing elements), the signal will 
change its signature, so the lookup & connection mechanism will probably fail.

If you have a variable-sized argument, I recommend you consider using a hash 
or array (av or a{sv}).

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      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: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20100216/b388110d/attachment.pgp 


More information about the dbus mailing list