]> code.delx.au - pulseaudio/commitdiff
dbus-protocol: Fix signal sending for the case when the client doesn't listen
authorTanu Kaskinen <tanuk@iki.fi>
Mon, 10 Aug 2009 07:40:40 +0000 (10:40 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 10 Aug 2009 07:40:40 +0000 (10:40 +0300)
for all signals.

src/pulsecore/protocol-dbus.c
src/pulsecore/protocol-dbus.h

index 62f74a564c0cb5b5b5a4018daa8a607b25def3ed..012857055c5a1e1946db2ed18080d6922bcd38ad 100644 (file)
@@ -848,6 +848,8 @@ void pa_dbus_protocol_add_signal_listener(pa_dbus_protocol *p, DBusConnection *c
         for (i = 0; i < n_objects; ++i)
             pa_idxset_put(object_set, pa_xstrdup(objects[i]), NULL);
 
+        pa_hashmap_put(conn_entry->listening_signals, signal, object_set);
+
     } else {
         conn_entry->listening_for_all_signals = TRUE;
 
@@ -892,10 +894,15 @@ void pa_dbus_protocol_send_signal(pa_dbus_protocol *p, DBusMessage *signal) {
     void *state = NULL;
     pa_idxset *object_set;
     DBusMessage *signal_copy;
+    char *signal_string;
 
     pa_assert(p);
     pa_assert(signal);
     pa_assert(dbus_message_get_type(signal) == DBUS_MESSAGE_TYPE_SIGNAL);
+    pa_assert_se(dbus_message_get_interface(signal));
+    pa_assert_se(dbus_message_get_member(signal));
+
+    signal_string = pa_sprintf_malloc("%s.%s", dbus_message_get_interface(signal), dbus_message_get_member(signal));
 
     PA_HASHMAP_FOREACH(conn_entry, p->connections, state) {
         if ((conn_entry->listening_for_all_signals /* Case 1: listening for all signals */
@@ -903,7 +910,7 @@ void pa_dbus_protocol_send_signal(pa_dbus_protocol *p, DBusMessage *signal) {
                  || pa_idxset_isempty(conn_entry->all_signals_objects)))
 
             || (!conn_entry->listening_for_all_signals /* Case 2: not listening for all signals */
-                && (object_set = pa_hashmap_get(conn_entry->listening_signals, signal))
+                && (object_set = pa_hashmap_get(conn_entry->listening_signals, signal_string))
                 && (pa_idxset_get_by_data(object_set, dbus_message_get_path(signal), NULL)
                     || pa_idxset_isempty(object_set)))) {
 
@@ -912,6 +919,8 @@ void pa_dbus_protocol_send_signal(pa_dbus_protocol *p, DBusMessage *signal) {
             dbus_message_unref(signal_copy);
         }
     }
+
+    pa_xfree(signal_string);
 }
 
 const char **pa_dbus_protocol_get_extensions(pa_dbus_protocol *p, unsigned *n) {
index 38ba8a18ec5ab1514ed81da767d1d496bdf734f4..d771b4fc515ded1c8ee5388bd0409e48a92d8bab 100644 (file)
@@ -129,7 +129,8 @@ int pa_dbus_protocol_unregister_connection(pa_dbus_protocol *p, DBusConnection *
 pa_client *pa_dbus_protocol_get_client(pa_dbus_protocol *p, DBusConnection *conn);
 
 /* Enables signal receiving for the given connection. The connection must have
- * been registered earlier.
+ * been registered earlier. The signal string must contain both the signal
+ * interface and the signal name, concatenated using a period as the separator.
  *
  * If the signal argument is NULL, all signals will be sent to the connection,
  * otherwise calling this function only adds the given signal to the list of