AddMatch method using Glib bindings

João Valverde backup95 at netcabo.pt
Mon Jun 16 19:35:07 PDT 2008


Hello,

I'm trying to monitor a process registered under the name 
'org.testing.daemon'. Any reason why the following method call (I tried 
to adapt this from the tutorial) should produce 4 method calls on the 
bus, including a "GetNameOwner"? I only desired the last one below.



proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS, 
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);

/* Call AddMatch method, wait for reply */
error = NULL;
char *arg = 
"type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.testing.daemon'";

if  (!dbus_g_proxy_call (proxy, "AddMatch", &error, G_TYPE_STRING, arg, 
G_TYPE_INVALID, G_TYPE_INVALID)) {
    /* check for error */
}

dbus_g_proxy_add_signal (proxy, "NameOwnerChanged", G_TYPE_STRING, 
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);

dbus_g_proxy_connect_signal (proxy, "NameOwnerChanged", 
G_CALLBACK(daemon_status_cb), NULL, NULL);



dbus-monitor output:

method call sender=:1.136 -> dest=org.freedesktop.DBus 
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string 
"type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
method call sender=:1.136 -> dest=org.freedesktop.DBus 
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string 
"type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus'"
method call sender=:1.136 -> dest=org.freedesktop.DBus 
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; 
member=GetNameOwner
   string "org.freedesktop.DBus"
method call sender=:1.136 -> dest=org.freedesktop.DBus 
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string 
"type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.testing.daemon'"



It kinda sorta works but I get several signals everytime my process 
starts or stops (because it registers several repeated matches I guess), 
and I receive the private name changes too. I was trying to discriminate 
against that by using "arg0='org.testing.daemon'". Does this work? What 
am I doing wrong?

Thank you for your time,

João V.






More information about the dbus mailing list