PropertiesChanged signal
David Zeuthen
zeuthen at gmail.com
Fri May 7 10:06:16 PDT 2010
Hey,
Many people have asked for a generic mechanism to convey that one or
more properties has changed on an object so they don't have to roll
their own signals for this. Attached is a spec patch to define such a
mechanism. Some notes
- this new signal is optional
- even if implemented, a service may opt to avoid using it for huge properties
(e.g. probably want to avoid using it on a a 300 element a{i{tt}ss} property
called ChatRoomParticipants)
Ideally we'd make this signal mandatory but that would be an ABI break.
We could have D-Bus annotations on properties specifying whether a
given property will emit this signal or not when changed. I think such
a change, if we want it, is separate from this.
Existing art
- EggDBus (which is used in production in all recent distros) has a very
similar signal called EggDBusPropertiesChanged() (also on the
org.freedesktop.DBus.Properties interface)
- NetworkManager has a PropertiesChanged() signal on each different
interface (e.g. not org.fd.D.P) that it implements, see [0] for an example
- GDBus, an implementation of the D-Bus protocol in GLib, already
implements this signal
Now for a subjective view: If you examine the D-Bus services on a
typical Linux desktop, you will find that a lot of them don't use
properties when "they should". Which is too bad, because it makes
things harder to debug, for example, you have to call GetXYZ() instead
of just using d-feet or gdbus(1) (see [0] below again) to quickly
inspect the property XYZ. I think the existence of the
PropertiesChanged() signal, plus the availability of bindings
supporting it (such as GDBus), will make it a lot more appealing for
D-Bus service authors to use D-Bus properties when "they should".
FWIW, I originally proposed this back in 2009 - see
http://lists.freedesktop.org/archives/dbus/2009-January/010848.html
and surrounding messages for discussion.
David
[0] :
$ gdbus introspect --system --dest org.freedesktop.NetworkManager
--object-path /org/freedesktop/NetworkManager
node /org/freedesktop/NetworkManager {
interface org.freedesktop.DBus.Introspectable {
methods:
Introspect(out s data);
};
interface org.freedesktop.DBus.Properties {
methods:
Get(in s interface,
in s propname,
out v value);
Set(in s interface,
in s propname,
in v value);
GetAll(in s interface,
out a{sv} props);
};
interface org.freedesktop.NetworkManager {
methods:
state(out u state);
wake();
sleep();
SetLogging(in s level,
in s domains);
Sleep(in b sleep);
DeactivateConnection(in o active_connection);
ActivateConnection(in s service_name,
in o connection,
in o device,
in o specific_object,
out o active_connection);
GetDevices(out ao devices);
signals:
StateChange(u arg_0);
DeviceRemoved(o arg_0);
DeviceAdded(o arg_0);
PropertiesChanged(a{sv} arg_0);
StateChanged(u arg_0);
properties:
readonly u State = 3;
readonly ao ActiveConnections =
['/org/freedesktop/NetworkManager/ActiveConnection/0',
'/org/freedesktop/NetworkManager/ActiveConnection/1'];
readonly b WwanHardwareEnabled = true;
readwrite b WwanEnabled = true;
readonly b WirelessHardwareEnabled = true;
readwrite b WirelessEnabled = true;
};
node AccessPoint
node ActiveConnection
node DHCP4Config
node Devices
node IP4Config
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-an-optional-PropertiesChanged-signal.patch
Type: application/octet-stream
Size: 1732 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20100507/4351606a/attachment.obj>
More information about the dbus
mailing list