diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/session-service.c | 104 | ||||
-rw-r--r-- | src/users-service-dbus.c | 66 | ||||
-rw-r--r-- | src/users-service-dbus.h | 2 |
5 files changed, 64 insertions, 112 deletions
diff --git a/Makefile.am b/Makefile.am index 0233fbf..3d97874 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = \ data \ po -EXTRA_DIST = COPYING.LGPL +EXTRA_DIST = COPYING.LGPL autogen.sh DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/configure.ac b/configure.ac index 5ccc43d..1b4ecfa 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-session.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-session, 0.2.1) +AM_INIT_AUTOMAKE(indicator-session, 0.2.2) AM_MAINTAINER_MODE diff --git a/src/session-service.c b/src/session-service.c index b414328..d074cb8 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -45,9 +45,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "users-service-dbus.h" #include "lock-helper.h" -#define DKP_ADDRESS "org.freedesktop.DeviceKit.Power" -#define DKP_OBJECT "/org/freedesktop/DeviceKit/Power" -#define DKP_INTERFACE "org.freedesktop.DeviceKit.Power" +#define UP_ADDRESS "org.freedesktop.UPower" +#define UP_OBJECT "/org/freedesktop/UPower" +#define UP_INTERFACE "org.freedesktop.UPower" #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" @@ -73,8 +73,8 @@ static GList *users; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; -static DBusGProxy * dkp_main_proxy = NULL; -static DBusGProxy * dkp_prop_proxy = NULL; +static DBusGProxy * up_main_proxy = NULL; +static DBusGProxy * up_prop_proxy = NULL; static DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; @@ -148,14 +148,14 @@ machine_sleep (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { gchar * type = (gchar *)userdata; - if (dkp_main_proxy == NULL) { - g_warning("Can not %s as no DeviceKit Power Proxy", type); + if (up_main_proxy == NULL) { + g_warning("Can not %s as no upower proxy", type); } screensaver_throttle(type); lock_screen(NULL, 0, NULL); - dbus_g_proxy_begin_call(dkp_main_proxy, + dbus_g_proxy_begin_call(up_main_proxy, type, sleep_response, NULL, @@ -214,17 +214,17 @@ hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) /* A signal that we need to recheck to ensure we can still hibernate and/or suspend */ static void -dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) +up_changed_cb (DBusGProxy * proxy, gpointer user_data) { /* Start Async call to see if we can hibernate */ if (suspend_call == NULL) { - suspend_call = dbus_g_proxy_begin_call(dkp_prop_proxy, + suspend_call = dbus_g_proxy_begin_call(up_prop_proxy, "Get", suspend_prop_cb, NULL, NULL, G_TYPE_STRING, - DKP_INTERFACE, + UP_INTERFACE, G_TYPE_STRING, "can-suspend", G_TYPE_INVALID, @@ -234,13 +234,13 @@ dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) /* Start Async call to see if we can suspend */ if (hibernate_call == NULL) { - hibernate_call = dbus_g_proxy_begin_call(dkp_prop_proxy, + hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, "Get", hibernate_prop_cb, NULL, NULL, G_TYPE_STRING, - DKP_INTERFACE, + UP_INTERFACE, G_TYPE_STRING, "can-hibernate", G_TYPE_INVALID, @@ -255,39 +255,39 @@ dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) DKp checking. We're even setting up the calls for the props we need */ static void -setup_dkp (void) { +setup_up (void) { DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); g_return_if_fail(bus != NULL); - if (dkp_main_proxy == NULL) { - dkp_main_proxy = dbus_g_proxy_new_for_name(bus, - DKP_ADDRESS, - DKP_OBJECT, - DKP_INTERFACE); + if (up_main_proxy == NULL) { + up_main_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, + UP_INTERFACE); } - g_return_if_fail(dkp_main_proxy != NULL); + g_return_if_fail(up_main_proxy != NULL); - if (dkp_prop_proxy == NULL) { - dkp_prop_proxy = dbus_g_proxy_new_for_name(bus, - DKP_ADDRESS, - DKP_OBJECT, + if (up_prop_proxy == NULL) { + up_prop_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, DBUS_INTERFACE_PROPERTIES); } - g_return_if_fail(dkp_prop_proxy != NULL); + g_return_if_fail(up_prop_proxy != NULL); /* Connect to changed signal */ - dbus_g_proxy_add_signal(dkp_main_proxy, + dbus_g_proxy_add_signal(up_main_proxy, "Changed", G_TYPE_INVALID); - dbus_g_proxy_connect_signal(dkp_main_proxy, + dbus_g_proxy_connect_signal(up_main_proxy, "Changed", - G_CALLBACK(dpk_changed_cb), + G_CALLBACK(up_changed_cb), NULL, NULL); /* Force an original "changed" event */ - dpk_changed_cb(dkp_main_proxy, NULL); + up_changed_cb(up_main_proxy, NULL); return; } @@ -438,6 +438,10 @@ rebuild_items (DbusmenuMenuitem *root, if (can_activate == TRUE) { + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator1); + if (check_guest_session ()) { mi = dbusmenu_menuitem_new (); @@ -446,6 +450,26 @@ rebuild_items (DbusmenuMenuitem *root, g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL); } + if (check_new_session ()) + { + ensure_gconf_client (); + + switch_menuitem = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); + dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); + dbusmenu_menuitem_child_append (root, switch_menuitem); + g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); + + if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) + { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } + else + { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } + } + if (count > MINIMUM_USERS && count < MAXIMUM_USERS) { if (users != NULL) @@ -476,26 +500,6 @@ rebuild_items (DbusmenuMenuitem *root, g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); } } - - if (check_new_session ()) - { - ensure_gconf_client (); - - switch_menuitem = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); - dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); - dbusmenu_menuitem_child_append (root, switch_menuitem); - g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); - - if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } - else - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } } DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); @@ -641,7 +645,7 @@ main (int argc, char ** argv) G_CALLBACK (user_removed), root_menuitem); - setup_dkp(); + setup_up(); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, root_menuitem); diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index e05eaf5..d377089 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -443,37 +443,6 @@ get_unix_user (UsersServiceDbus *service, return TRUE; } -static gchar * -get_session_for_user (UsersServiceDbus *service, - UserData *user) -{ - GList *l; - - if (!users_service_dbus_can_activate_session (service)) - { - return NULL; - } - - if (!user->sessions || g_list_length (user->sessions) == 0) - { - return NULL; - } - - for (l = user->sessions; l != NULL; l = l->next) - { - const char *ssid; - - ssid = l->data; - - if (ssid) - { - return g_strdup (ssid); - } - } - - return NULL; -} - static gboolean do_add_session (UsersServiceDbus *service, UserData *user, @@ -1035,17 +1004,6 @@ users_service_dbus_get_user_list (UsersServiceDbus *self) return g_hash_table_get_values (priv->users); } -/* - * XXX - TODO: Right now we switch to a session that another user - * already has open, but if there are no open sessions - * for this user we go to the login screen and the - * user at the seat must select a user and enter a - * password. This kind of defeats the purpose of - * actually selecting a username, since selecting any - * user will do the same thing here. We need to change - * it so you only need to enter a password for the - * specified user. - */ gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user) @@ -1054,32 +1012,20 @@ users_service_dbus_activate_user_session (UsersServiceDbus *self, DBusMessage *message = NULL; DBusMessage *reply = NULL; DBusError error; - gchar *ssid; dbus_error_init (&error); - if (!priv->seat) - priv->seat = get_seat (self); - - ssid = get_session_for_user (self, user); - - if (!ssid) - { - return start_new_user_session (self, user); - } - - if (!(message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", - priv->seat, - "org.freedesktop.ConsoleKit.Seat", - "ActivateSession"))) + if (!(message = dbus_message_new_method_call ("org.gnome.DisplayManager", + "/org/gnome/DisplayManager/LocalDisplayFactory", + "org.gnome.DisplayManager.LocalDisplayFactory", + "SwitchToUser"))) { g_warning ("failed to create new message"); return FALSE; } if (!dbus_message_append_args (message, - DBUS_TYPE_OBJECT_PATH, - &ssid, + DBUS_TYPE_STRING, &user->user_name, DBUS_TYPE_INVALID)) { g_warning ("failed to append args"); @@ -1110,6 +1056,8 @@ users_service_dbus_activate_user_session (UsersServiceDbus *self, dbus_message_unref (reply); } + dbus_error_free (&error); + return TRUE; } diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index 9ba05c9..41052f8 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -54,7 +54,7 @@ struct _UserData * got some gdm issues worked out. */ #define MINIMUM_USERS 1 -#define MAXIMUM_USERS 1 +#define MAXIMUM_USERS 7 struct _UsersServiceDbus { GObject parent; |