signals and proxies for names
Colin Walters
walters at verbum.org
Mon Jun 27 15:57:56 PDT 2005
So I was looking at why, with the current GLib bindings, you need to do
dbus_g_proxy_new_for_name_owner instead of dbus_g_proxy_new_for_name to
get signals.
It turns out to be because internally in the GLib bindings we keep track
of proxies by the tuple of (name, path, interface), and dispatch signals
based on that. However, when we create a proxy with _for_name, the name
used is like "org.freedesktop.DBus", as opposed to e.g. ":12". This
means the lookup fails inside the filter function.
The Python bindings attempt to solve this by doing this:
def add_signal_receiver(self, handler_function, signal_name=None, dbus_interface=None, named_service=None, path=None):
if (named_service and named_service[0] != ':'):
bus_object = self.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
named_service = bus_object.GetNameOwner(named_service, dbus_interface='org.freedesktop.DBus')
...
But this seems wrong to me. If the service changes owner, then you
won't get any signals from it then, right? That seems to kind of defeat
the purpose of having a proxy for the name as opposed to the name owner.
So how to solve this correctly? When we get a signal, we need to
dispatch to all proxies which were for that name. But the signal
doesn't tell us what names the sending service owned; it just gives us
the connection id. My first thought was that we could watch the
NameOwnerChanged signal from the bus and keep track of the current owner
for proxies that are for a name.
Does that make sense?
-------------- 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/20050627/4e4fb7ba/attachment.pgp
More information about the dbus
mailing list