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
#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");
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) {
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);
}
add_session(u, path);
- return DBUS_HANDLER_RESULT_HANDLED;
} else if (dbus_message_is_signal(message, "org.freedesktop.ConsoleKit.Seat", "SessionRemoved")) {
}
remove_session(u, path);
- return DBUS_HANDLER_RESULT_HANDLED;
}
finish:
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;
goto fail;
}
- dbus_bus_add_match(pa_dbus_connection_get(connection), "type='signal',sender='org.freedesktop.ConsoleKit', interface='org.freedesktop.ConsoleKit.Seat'", &error);
- if (dbus_error_is_set(&error)) {
+ 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'",
+ "type='signal',sender='org.freedesktop.ConsoleKit',interface='org.freedesktop.ConsoleKit.Seat',member='SessionRemoved'", NULL) < 0) {
pa_log_error("Unable to subscribe to ConsoleKit signals: %s: %s", error.name, error.message);
goto fail;
}
}
if (u->connection) {
- DBusError error;
- dbus_error_init(&error);
-
- dbus_bus_remove_match(pa_dbus_connection_get(u->connection), "type='signal',sender='org.freedesktop.ConsoleKit', interface='org.freedesktop.ConsoleKit.Seat'", &error);
- dbus_error_free(&error);
+ pa_dbus_remove_matches(
+ pa_dbus_connection_get(u->connection),
+ "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);
}