]> code.delx.au - pulseaudio/blobdiff - src/modules/module-console-kit.c
Fix up according to Coding Style
[pulseaudio] / src / modules / module-console-kit.c
index 805f5eef1bb88c7c2506377b3bd04dca133eeb8a..d52cc2448f6c3cdf307d02ae922e1a1c2c349b2b 100644 (file)
@@ -5,7 +5,7 @@
 
     PulseAudio is free software; you can redistribute it and/or modify
     it under the terms of the GNU Lesser General Public License as published
 
     PulseAudio is free software; you can redistribute it and/or modify
     it under the terms of the GNU Lesser General Public License as published
-    by the Free Software Foundation; either version 2 of the License,
+    by the Free Software Foundation; either version 2.1 of the License,
     or (at your option) any later version.
 
     PulseAudio is distributed in the hope that it will be useful, but
     or (at your option) any later version.
 
     PulseAudio is distributed in the hope that it will be useful, but
@@ -44,8 +44,8 @@
 #include <pulsecore/namereg.h>
 #include <pulsecore/core-scache.h>
 #include <pulsecore/modargs.h>
 #include <pulsecore/namereg.h>
 #include <pulsecore/core-scache.h>
 #include <pulsecore/modargs.h>
+#include <pulsecore/dbus-shared.h>
 
 
-#include "dbus-util.h"
 #include "module-console-kit-symdef.h"
 
 PA_MODULE_AUTHOR("Lennart Poettering");
 #include "module-console-kit-symdef.h"
 
 PA_MODULE_AUTHOR("Lennart Poettering");
@@ -67,6 +67,7 @@ struct userdata {
     pa_core *core;
     pa_dbus_connection *connection;
     pa_hashmap *sessions;
     pa_core *core;
     pa_dbus_connection *connection;
     pa_hashmap *sessions;
+    pa_bool_t filter_added;
 };
 
 static void add_session(struct userdata *u, const char *id) {
 };
 
 static void add_session(struct userdata *u, const char *id) {
@@ -76,7 +77,7 @@ static void add_session(struct userdata *u, const char *id) {
     struct session *session;
     pa_client_new_data data;
 
     struct session *session;
     pa_client_new_data data;
 
-    dbus_error_init (&error);
+    dbus_error_init(&error);
 
     if (pa_hashmap_get(u->sessions, id)) {
         pa_log_warn("Duplicate session %s, ignoring.", id);
 
     if (pa_hashmap_get(u->sessions, id)) {
         pa_log_warn("Duplicate session %s, ignoring.", id);
@@ -187,7 +188,6 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *message, vo
         }
 
         add_session(u, path);
         }
 
         add_session(u, path);
-        return DBUS_HANDLER_RESULT_HANDLED;
 
     } else if (dbus_message_is_signal(message, "org.freedesktop.ConsoleKit.Seat", "SessionRemoved")) {
 
 
     } else if (dbus_message_is_signal(message, "org.freedesktop.ConsoleKit.Seat", "SessionRemoved")) {
 
@@ -202,7 +202,6 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *message, vo
         }
 
         remove_session(u, path);
         }
 
         remove_session(u, path);
-        return DBUS_HANDLER_RESULT_HANDLED;
     }
 
 finish:
     }
 
 finish:
@@ -302,7 +301,7 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
         goto fail;
     }
 
-    m->userdata = u = pa_xnew(struct userdata, 1);
+    m->userdata = u = pa_xnew0(struct userdata, 1);
     u->core = m->core;
     u->module = m;
     u->connection = connection;
     u->core = m->core;
     u->module = m;
     u->connection = connection;
@@ -313,6 +312,8 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
         goto fail;
     }
 
+    u->filter_added = TRUE;
+
     if (pa_dbus_add_matches(
                 pa_dbus_connection_get(connection), &error,
                 "type='signal',sender='org.freedesktop.ConsoleKit',interface='org.freedesktop.ConsoleKit.Seat',member='SessionAdded'",
     if (pa_dbus_add_matches(
                 pa_dbus_connection_get(connection), &error,
                 "type='signal',sender='org.freedesktop.ConsoleKit',interface='org.freedesktop.ConsoleKit.Seat',member='SessionAdded'",
@@ -361,7 +362,9 @@ void pa__done(pa_module *m) {
                 "type='signal',sender='org.freedesktop.ConsoleKit',interface='org.freedesktop.ConsoleKit.Seat',member='SessionAdded'",
                 "type='signal',sender='org.freedesktop.ConsoleKit',interface='org.freedesktop.ConsoleKit.Seat',member='SessionRemoved'", NULL);
 
                 "type='signal',sender='org.freedesktop.ConsoleKit',interface='org.freedesktop.ConsoleKit.Seat',member='SessionAdded'",
                 "type='signal',sender='org.freedesktop.ConsoleKit',interface='org.freedesktop.ConsoleKit.Seat',member='SessionRemoved'", NULL);
 
-        dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
+        if (u->filter_added)
+            dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
+
         pa_dbus_connection_unref(u->connection);
     }
 
         pa_dbus_connection_unref(u->connection);
     }