#include <stdio.h>
#include <unistd.h>
-#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <sys/stat.h>
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h>
+#include <systemd/sd-daemon.h>
+#endif
#include <pulse/xmalloc.h>
-#include <pulse/timeval.h>
-#include <pulsecore/core-error.h>
#include <pulsecore/module.h>
#include <pulsecore/log.h>
#include <pulsecore/hashmap.h>
#include <pulsecore/idxset.h>
-#include <pulsecore/core-util.h>
-#include <pulsecore/namereg.h>
-#include <pulsecore/core-scache.h>
#include <pulsecore/modargs.h>
#include <pulsecore/dbus-shared.h>
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);
dbus_error_init(&error);
+#ifdef HAVE_SYSTEMD
+ /* If systemd support is enabled and we boot on systemd we
+ shouldn't watch ConsoleKit but systemd's logind service. */
+ if (sd_booted() > 0)
+ return 0;
+#endif
+
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
goto fail;
void pa__done(pa_module *m) {
struct userdata *u;
- struct session *session;
pa_assert(m);
if (!(u = m->userdata))
return;
- if (u->sessions) {
- while ((session = pa_hashmap_steal_first(u->sessions)))
- free_session(session);
-
- pa_hashmap_free(u->sessions, NULL, NULL);
- }
+ if (u->sessions)
+ pa_hashmap_free(u->sessions, (pa_free_cb_t) free_session);
if (u->connection) {
pa_dbus_remove_matches(