diff -Nur -x '*.orig' -x '*~' gnome-user-share-2.25.92/src/user_share.c gnome-user-share-2.25.92.new/src/user_share.c --- gnome-user-share-2.25.92/src/user_share.c 2009-01-27 10:55:29.000000000 -0500 +++ gnome-user-share-2.25.92.new/src/user_share.c 2009-04-29 16:13:36.000000000 -0400 @@ -81,71 +81,16 @@ } static void -sessionchanged_cb (void) +sessionchanged_cb (DBusGProxy *proxy, + gboolean active) { - DBusGConnection *dbus_connection; - DBusGProxy *proxy_ck_manager; - DBusGProxy *proxy_ck_session; - - gchar *ck_session_path; - gboolean is_active = FALSE; - GError *error = NULL; - - g_message ("Active session changed"); - - dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - if (!dbus_connection) { - g_warning ("Unable to connect to dbus"); - dbus_g_connection_unref (dbus_connection); - return; - } - - proxy_ck_manager = dbus_g_proxy_new_for_name (dbus_connection, - CK_NAME, - CK_MANAGER_PATH, - CK_MANAGER_INTERFACE); - if (dbus_g_proxy_call (proxy_ck_manager, "GetCurrentSession", - &error, G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &ck_session_path, - G_TYPE_INVALID) == FALSE) { - g_warning ("Couldn't request the name: %s", error->message); - dbus_g_connection_unref (dbus_connection); - g_object_unref (proxy_ck_manager); - g_error_free (error); - return; - } - - proxy_ck_session = dbus_g_proxy_new_for_name (dbus_connection, - CK_NAME, - ck_session_path, - CK_SESSION_INTERFACE); - - if (dbus_g_proxy_call (proxy_ck_session, "IsActive", - &error, G_TYPE_INVALID, - G_TYPE_BOOLEAN, &is_active, - G_TYPE_INVALID) == FALSE) { - - g_warning ("Couldn't request the name: %s", error->message); - dbus_g_connection_unref (dbus_connection); - g_object_unref (proxy_ck_manager); - g_object_unref (proxy_ck_session); - g_error_free (error); - return; - } - - if (is_active) { - obex_services_start (); - } else { - obex_services_shutdown (); - } + g_debug ("sessionchanged_cb: %s", active ? "Active" : "Inactive"); - dbus_g_connection_unref (dbus_connection); - g_free (ck_session_path); - g_object_unref (proxy_ck_manager); - g_object_unref (proxy_ck_session); - if (error != NULL) { - g_error_free (error); - } + if (active) { + obex_services_start (); + } else { + obex_services_shutdown (); + } } static void @@ -153,10 +98,7 @@ { DBusGConnection *dbus_connection; DBusGProxy *proxy_ck_manager; - DBusGProxy *proxy_ck_session; - DBusGProxy *proxy_ck_seat; - gchar *ck_session_path; - gchar *ck_seat_path; + DBusGProxy *proxy_session; GError *error = NULL; dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); @@ -166,14 +108,16 @@ dbus_g_connection_unref (dbus_connection); return; } - - proxy_ck_manager = dbus_g_proxy_new_for_name (dbus_connection, - CK_NAME, - CK_MANAGER_PATH, - CK_MANAGER_INTERFACE); + + + proxy_ck_manager = proxy_session = dbus_g_proxy_new_for_name (dbus_connection, + CK_NAME, + CK_MANAGER_PATH, + CK_MANAGER_INTERFACE); + if (dbus_g_proxy_call (proxy_ck_manager, "GetCurrentSession", &error, G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &ck_session_path, + DBUS_TYPE_G_PROXY, &proxy_session, G_TYPE_INVALID) == FALSE) { g_warning ("Couldn't request the name: %s", error->message); @@ -181,34 +125,17 @@ return; } - proxy_ck_session = dbus_g_proxy_new_for_name (dbus_connection, - CK_NAME, - ck_session_path, - CK_SESSION_INTERFACE); - if (dbus_g_proxy_call (proxy_ck_session, "GetSeatId", - &error, G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &ck_seat_path, - G_TYPE_INVALID) == FALSE) { - - g_warning ("Couldn't request the name: %s", error->message); - g_object_unref (proxy_ck_session); - return; - } - - proxy_ck_seat = dbus_g_proxy_new_for_name (dbus_connection, - CK_NAME, - ck_seat_path, - CK_SEAT_INTERFACE); - dbus_g_proxy_add_signal (proxy_ck_seat, "ActiveSessionChanged", - G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (proxy_ck_seat, "ActiveSessionChanged", - G_CALLBACK (sessionchanged_cb), NULL, NULL); - if (error != NULL) { - g_error_free (error); - } - g_object_unref (proxy_ck_manager); - g_object_unref (proxy_ck_session); - g_free (ck_seat_path); + + dbus_g_proxy_set_interface (proxy_session, + "org.freedesktop.ConsoleKit.Session"); + dbus_g_proxy_add_signal (proxy_session, "ActiveChanged", + G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (proxy_session, "ActiveChanged", + G_CALLBACK (sessionchanged_cb), + NULL, + NULL); + + g_object_unref (proxy_ck_manager); dbus_g_connection_unref (dbus_connection); }