PropertiesChanged signal, take 2

David Zeuthen zeuthen at gmail.com
Tue May 11 15:08:48 PDT 2010


Hey,

On Tue, May 11, 2010 at 5:21 PM, Thiago Macieira <thiago at kde.org> wrote:
> Ok, so from what I understand from your proposed changes, we'd add two
> properties to org.freedesktop.DBus.Properties, which control whether the
> signal is emitted and, if it's emitted, whether the value is emitted alongside
> it.
>
> That would mean the setting is per object, which means we have a good deal of
> control of whether signals are emitted unnecessarily or not.

Well, these are _annotations_ to properties, not properties. It's a
very important difference. And you'd only these annotations if

 1. you implement PropertiesChanged(); and
 2. changes in the property does not cause signal emissions.

So you'd only need them for such properties.

> You're also saying that an object that has properties changing far too
> frequently should set its flag to off.

No. I'm saying that it's part of the _ABI_ if the service emits PropertyChanged.

(Just like it's part of the udisks ABI that it emits
org.fd.udisks.Device.Changed() if one or more properties currently
change. Or that ConsoleKit emits the org.fd.ConsoleKit.SessionAdded()
signal if a new session object is added.)

> Would this property be read-only or not?
> If it's read-write, then remote apps should set the flag to true to enable the
> emission of the signal.
>
> Do I understand it correctly?

No, because they are not properties... they are annotations... and
they wouldn't be able to change. The same way that ABI normally can't
be tuned.

> Problems I see in the proposal:
> 1) the property names aren't very descriptive. I recommend
> "PropertyChangedSignalEnabled" or "EmitsPropertyChangedSignal".
>
> 2) I think the two properties should be one property with three different
> states.

Would changing the annotation name to

 EmitsPropertyChanged

with the possible values 'true','novalue','false' and defaulting to
'true' help? Here's a concrete example

<node name="/org/freedesktop/UDisks/devices/sda">
  [...]
  <interface name="org.freedesktop.DBus.Properties">
    [...]
    <signal name="PropertiesChanged">
      <arg name="interface_name" type="s"/>
      <arg name="changed_props" direction="out" type="a{sv}"/>
    </signal>
    [...]
  </interface>

  <interface name="org.freedesktop.UDisks.Device">
    <property name="SmartData" type="ay" access="readonly">
      <annotation
name="org.freedesktop.DBus.Properties.EmitsPropertyChanged"
value="false"/>
    </property>
    <property name="DeviceName" type="s" access="readonly"/>
    <property name="DeviceNumber" type="t" access="readonly"/>
  </interface>
  [...]
</node>

This introspection data tells you that

 - This object does emit the PropertiesChanged() signal

 - This signal is guaranteed be emitted when the DeviceName and
   DeviceNumber properties change

 - Even if the SmartData property changes you will not get a
   PropertiesChanged() signal
   - (now, whether the SmartData property change is not specified. It might.
      It might not.)

Hope this makes it very clear what's going on. I' m not replying to
questions 3-7 since we're talking about annotations, not
properties....

Thanks,
David


More information about the dbus mailing list