From 6173641c60e3025527dcec7fdbf2e9320d93f898 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 12 Oct 2009 20:15:46 -0400 Subject: [PATCH 15/21] Remove inhibitors automatically Remove inhibitors when their initiator drops off the bus. --- src/ck-manager.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/src/ck-manager.c b/src/ck-manager.c index 9b6afd9..da2522b 100644 --- a/src/ck-manager.c +++ b/src/ck-manager.c @@ -2264,6 +2264,22 @@ remove_sessions_for_connection (CkManager *manager, } static void +remove_inhibitors_for_connection (CkManager *manager, + const char *service_name) +{ + GHashTableIter iter; + CkInhibitor *inhibitor; + + g_hash_table_iter_init (&iter, manager->priv->inhibitors); + while (g_hash_table_iter_next (&iter, NULL, (gpointer*)&inhibitor)) { + if (g_strcmp0 (service_name, ck_inhibitor_peek_bus_name (inhibitor)) == 0) { + g_signal_emit (manager, signals[INHIBITOR_REMOVED], 0, ck_inhibitor_peek_id (inhibitor)); + g_hash_table_iter_remove (&iter); + } + } +} + +static void bus_name_owner_changed (DBusGProxy *bus_proxy, const char *service_name, const char *old_service_name, @@ -2271,6 +2287,7 @@ bus_name_owner_changed (DBusGProxy *bus_proxy, CkManager *manager) { if (strlen (new_service_name) == 0) { + remove_inhibitors_for_connection (manager, old_service_name); remove_sessions_for_connection (manager, old_service_name); } -- 1.6.5.rc2