diff options
author | William Jon McCann <jmccann@redhat.com> | 2008-05-05 13:34:08 -0400 |
---|---|---|
committer | William Jon McCann <jmccann@redhat.com> | 2008-05-05 13:34:08 -0400 |
commit | 8ec523138671a8fe93748a0b75adaaca96e2392e (patch) | |
tree | 67121dfc70bb186a471ec0396e0ecdddb82d4f9a /src/main.c | |
parent | c7116a525f643dead46873a81cf7a03bf5c54d55 (diff) | |
download | ConsoleKit2-8ec523138671a8fe93748a0b75adaaca96e2392e.tar.gz |
exit with the bus now that we're activated by the bus
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 65 |
1 files changed, 8 insertions, 57 deletions
@@ -44,9 +44,6 @@ #define CK_DBUS_NAME "org.freedesktop.ConsoleKit" -static void bus_proxy_destroyed_cb (DBusGProxy *bus_proxy, - CkManager *manager); - static gboolean timed_exit_cb (GMainLoop *loop) { @@ -138,60 +135,12 @@ get_system_bus (void) return bus; } -static gboolean -bus_reconnect (CkManager *manager) -{ - DBusGConnection *bus; - DBusGProxy *bus_proxy; - gboolean ret; - - ret = TRUE; - - bus = get_system_bus (); - if (bus == NULL) { - goto out; - } - - bus_proxy = get_bus_proxy (bus); - if (bus_proxy == NULL) { - g_warning ("Could not construct bus_proxy object; will retry"); - goto out; - } - - if (! acquire_name_on_proxy (bus_proxy) ) { - g_warning ("Could not acquire name; will retry"); - goto out; - } - - manager = ck_manager_new (); - if (manager == NULL) { - g_warning ("Could not construct manager object"); - exit (1); - } - - g_signal_connect (bus_proxy, - "destroy", - G_CALLBACK (bus_proxy_destroyed_cb), - manager); - - g_debug ("Successfully reconnected to D-Bus"); - - ret = FALSE; - - out: - return ret; -} - static void bus_proxy_destroyed_cb (DBusGProxy *bus_proxy, - CkManager *manager) + GMainLoop *loop) { g_debug ("Disconnected from D-Bus"); - - g_object_unref (manager); - manager = NULL; - - g_timeout_add (3000, (GSourceFunc)bus_reconnect, manager); + g_main_loop_quit (loop); } static void @@ -371,12 +320,12 @@ main (int argc, goto out; } + loop = g_main_loop_new (NULL, FALSE); + g_signal_connect (bus_proxy, "destroy", G_CALLBACK (bus_proxy_destroyed_cb), - manager); - - loop = g_main_loop_new (NULL, FALSE); + loop); if (do_timed_exit) { g_timeout_add (1000 * 30, (GSourceFunc) timed_exit_cb, loop); @@ -384,7 +333,9 @@ main (int argc, g_main_loop_run (loop); - g_object_unref (manager); + if (manager != NULL) { + g_object_unref (manager); + } g_main_loop_unref (loop); |