From 94cd451d64dec28a5649038b3de1c5971f8f6137 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 19:58:54 -0500 Subject: Adding a way to activate the guest session through GDM --- src/session-service.c | 7 +++++++ src/users-service-dbus.c | 8 ++++++++ src/users-service-dbus.h | 1 + 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fb20f3b..cb36e9c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -386,6 +386,13 @@ activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_da lock_if_possible(); + if (dbusmenu_menuitem_property_get_bool(mi, USER_ITEM_PROP_LOGGED_IN)) { + if (users_service_dbus_activate_guest_session(USERS_SERVICE_DBUS(user_data))) { + return; + } + g_warning("Unable to activate guest session, falling back to command line activation."); + } + if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER, &error)) { g_warning("Unable to start guest session: %s", error->message); g_error_free(error); diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 4aefdff..556af98 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -1005,6 +1005,14 @@ users_service_dbus_get_user_list (UsersServiceDbus *self) return g_hash_table_get_values (priv->users); } +/* Activates the guest account if it can. */ +gboolean +users_service_dbus_activate_guest_session (UsersServiceDbus *self) +{ + + return FALSE; +} + gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user) diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index bba88a7..29f6690 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -80,6 +80,7 @@ GList *users_service_dbus_get_user_list (UsersServiceDbus *self); gboolean users_service_dbus_can_activate_session (UsersServiceDbus *self); gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user); +gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self); G_END_DECLS -- cgit v1.2.3 From 9d36c2090992551a961005bf359cdab739c8beed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 20:32:20 -0500 Subject: Adding in the GDM local display DBus interface spec. --- src/Makefile.am | 9 +++++++++ src/gdm-local-display-factory.xml | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/gdm-local-display-factory.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index db41db6..01a88a3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,13 @@ consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml --output=consolekit-manager-client.h \ $(srcdir)/consolekit-manager.xml +gdm-local-display-factory-client.h: $(srcdir)/gdm-local-display-factory.xml + dbus-binding-tool \ + --prefix=_gdm_local_display_factory_client \ + --mode=glib-client \ + --output=gdm-local-display-factory-client.h \ + $(srcdir)/gdm-local-display-factory.xml + users-service-client.h: $(srcdir)/users-service.xml dbus-binding-tool \ --prefix=_users_service_client \ @@ -113,6 +120,7 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + gdm-local-display-factory-client.h \ session-dbus-client.h \ session-dbus-server.h \ upower-client.h \ @@ -122,6 +130,7 @@ BUILT_SOURCES = \ EXTRA_DIST = \ consolekit-manager.xml \ + gdm-local-display-factory.xml \ session-dbus.xml \ upower.xml \ users-service.xml \ diff --git a/src/gdm-local-display-factory.xml b/src/gdm-local-display-factory.xml new file mode 100644 index 0000000..66fb77c --- /dev/null +++ b/src/gdm-local-display-factory.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 1a451a7dbf5eed2b4ea8fd1e221bac036c3b9d4b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 20:42:58 -0500 Subject: Building a proxy to the local display factory --- src/users-service-dbus.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 556af98..80ab5be 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -31,6 +31,7 @@ #include #include "dbus-shared-names.h" +#include "gdm-local-display-factory-client.h" #include "users-service-dbus.h" #include "users-service-client.h" #include "users-service-marshal.h" @@ -80,6 +81,7 @@ struct _UsersServiceDbusPrivate DBusGConnection *system_bus; DBusGProxy *gdm_proxy; + DBusGProxy *gdm_local_proxy; DBusGProxy *ck_proxy; DBusGProxy *seat_proxy; DBusGProxy *session_proxy; @@ -266,6 +268,11 @@ create_gdm_proxy (UsersServiceDbus *self) G_CALLBACK (user_updated), self, NULL); + + priv->gdm_local_proxy = dbus_g_proxy_new_for_name (priv->system_bus, + "org.gnome.DisplayManager", + "/org/gnome/DisplayManager/LocalDisplayFactory", + "org.gnome.DisplayManager.LocalDisplayFactory"); } static void -- cgit v1.2.3 From 5a06c7033c279c5421894ed99d01adb449568521 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 20:51:22 -0500 Subject: Switching both of these function to using the generated header file. --- src/users-service-dbus.c | 58 +++++------------------------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 80ab5be..9e7af5d 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -1016,65 +1016,17 @@ users_service_dbus_get_user_list (UsersServiceDbus *self) gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self) { - - return FALSE; + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + return org_gnome_DisplayManager_LocalDisplayFactory_switch_to_user(priv->gdm_local_proxy, "guest", NULL, NULL); } +/* Activates a specific user */ gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user) { - UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - DBusMessage *message = NULL; - DBusMessage *reply = NULL; - DBusError error; - - dbus_error_init (&error); - - 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_STRING, &user->user_name, - DBUS_TYPE_INVALID)) - { - g_warning ("failed to append args"); - return FALSE; - } - - if (!(reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (priv->system_bus), - message, - -1, - &error))) - { - if (dbus_error_is_set (&error)) - { - g_warning ("Failed to send message: %s", error.message); - dbus_error_free (&error); - - return FALSE; - } - } - - if (message) - { - dbus_message_unref (message); - } - - if (reply) - { - dbus_message_unref (reply); - } - - dbus_error_free (&error); - - return TRUE; + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + return org_gnome_DisplayManager_LocalDisplayFactory_switch_to_user(priv->gdm_local_proxy, user->user_name, NULL, NULL); } gboolean -- cgit v1.2.3 From 41fb4503ec3443835be5176733158cf5bcf372d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:46:42 -0500 Subject: Adding a menuitem property to the user data structure. --- src/users-service-dbus.c | 1 + src/users-service-dbus.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 9e7af5d..d0b52a9 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -664,6 +664,7 @@ sync_users (UsersServiceDbus *self) user->login_count = g_value_get_int (g_value_array_get_nth (values, 4)); user->icon_url = g_strdup (g_value_get_string (g_value_array_get_nth (values, 5))); user->real_name_conflict = FALSE; + user->menuitem = NULL; g_hash_table_insert (priv->users, g_strdup (user->user_name), diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index 29f6690..15dd71b 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -22,6 +22,7 @@ #include #include +#include G_BEGIN_DECLS @@ -47,7 +48,10 @@ struct _UserData GList *sessions; + /* Whether the real name here conflicts with another in the system */ gboolean real_name_conflict; + /* The menuitem representing this user if there is one. */ + DbusmenuMenuitem * menuitem; UsersServiceDbus *service; }; -- cgit v1.2.3 From 6b1354f942d4482e85c1f15b3d3649cb7c20ea63 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:47:45 -0500 Subject: Setting the menuitem for the user. --- src/session-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index cb36e9c..bc88473 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -599,6 +599,7 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); + user->menuitem = mi; } } -- cgit v1.2.3 From 8dddf3fd91765a2811732e1c5dc4a533e55bc5cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:52:29 -0500 Subject: When a session is added or removed we need to change the state of that user item. --- src/users-service-dbus.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index d0b52a9..f3952ed 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -498,6 +498,10 @@ do_add_session (UsersServiceDbus *service, g_debug ("Adding session %s", ssid); user->sessions = g_list_prepend (user->sessions, g_strdup (ssid)); + + if (user->menuitem != NULL) { + dbusmenu_menuitem_property_set_bool(user->menuitem, USER_ITEM_PROP_LOGGED_IN, TRUE); + } } else { @@ -599,6 +603,9 @@ seat_proxy_session_removed (DBusGProxy *seat_proxy, g_free (l->data); user->sessions = g_list_delete_link (user->sessions, l); + if (user->menuitem != NULL && user->sessions == NULL) { + dbusmenu_menuitem_property_set_bool(user->menuitem, USER_ITEM_PROP_LOGGED_IN, FALSE); + } } else { -- cgit v1.2.3 From 7e38445544d5d0b000336d99b3f91462e63523f5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:56:38 -0500 Subject: Adding a guest_item for the guest menu item and a function to set it. --- src/users-service-dbus.c | 12 ++++++++++++ src/users-service-dbus.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index f3952ed..c8974b9 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -88,6 +88,8 @@ struct _UsersServiceDbusPrivate GHashTable *exclusions; GHashTable *sessions; + + DbusmenuMenuitem * guest_item; }; #define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate)) @@ -157,6 +159,7 @@ users_service_dbus_init (UsersServiceDbus *self) priv->users = NULL; priv->count = 0; + priv->guest_item = NULL; /* Get the system bus */ priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); @@ -1069,3 +1072,12 @@ users_service_dbus_can_activate_session (UsersServiceDbus *self) return can_activate; } + +/* Sets the menu item that represents the guest account */ +void +users_service_dbus_set_guest_item (UsersServiceDbus * self, DbusmenuMenuitem * mi) +{ + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + priv->guest_item = mi; + return; +} diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index 15dd71b..4798d64 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -85,6 +85,8 @@ gboolean users_service_dbus_can_activate_session (UsersServiceDbus *self); gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user); gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self); +void users_service_dbus_set_guest_item (UsersServiceDbus * self, + DbusmenuMenuitem * mi); G_END_DECLS -- cgit v1.2.3 From 2e0cbb1a5a969eb5b983e9b899a3638d5b8136d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:58:59 -0500 Subject: Setting the guest item once it gets built. --- src/session-service.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index bc88473..379a0a2 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -526,6 +526,9 @@ rebuild_items (DbusmenuMenuitem *root, } } + /* Set to NULL just incase we don't end up building one */ + users_service_dbus_set_guest_item(service, NULL); + /* Build all of the user switching items */ if (can_activate == TRUE) { @@ -543,6 +546,7 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); dbusmenu_menuitem_child_append (root, guest_mi); g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL); + users_service_dbus_set_guest_item(service, guest_mi); } if (check_new_session ()) -- cgit v1.2.3 From 6193ab20bfa8d93f5c3fcf70284fbe7beef69fff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 22:23:37 -0500 Subject: Setting the logged in parameter on the guest item and tracking the session ID of the guest session. --- src/users-service-dbus.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index c8974b9..3156802 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -90,6 +90,7 @@ struct _UsersServiceDbusPrivate GHashTable *sessions; DbusmenuMenuitem * guest_item; + gchar * guest_session_id; }; #define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate)) @@ -160,6 +161,7 @@ users_service_dbus_init (UsersServiceDbus *self) priv->users = NULL; priv->count = 0; priv->guest_item = NULL; + priv->guest_session_id = NULL; /* Get the system bus */ priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); @@ -203,6 +205,13 @@ users_service_dbus_dispose (GObject *object) static void users_service_dbus_finalize (GObject *object) { + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (object); + + if (priv->guest_session_id != NULL) { + g_free(priv->guest_session_id); + priv->guest_session_id = NULL; + } + G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object); } @@ -570,6 +579,16 @@ seat_proxy_session_added (DBusGProxy *seat_proxy, return; } + /* We need to special case guest here because it doesn't + show up in the GDM user tables. */ + if (g_strcmp0("guest", pwent->pw_name) == 0) { + if (priv->guest_item != NULL) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, TRUE); + } + priv->guest_session_id = g_strdup(session_id); + return; + } + user = g_hash_table_lookup (priv->users, pwent->pw_name); if (!user) { @@ -590,8 +609,14 @@ seat_proxy_session_removed (DBusGProxy *seat_proxy, GList *l; username = g_hash_table_lookup (priv->sessions, session_id); - if (!username) + if (!username) { + if (g_strcmp0(session_id, priv->guest_session_id) == 0) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, FALSE); + g_free(priv->guest_session_id); + priv->guest_session_id = NULL; + } return; + } user = g_hash_table_lookup (priv->users, username); if (!user) @@ -1079,5 +1104,10 @@ users_service_dbus_set_guest_item (UsersServiceDbus * self, DbusmenuMenuitem * m { UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); priv->guest_item = mi; + + if (priv->guest_session_id != NULL) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, TRUE); + } + return; } -- cgit v1.2.3 From da26ce14f49d21e1cb72167f9e1bf43069b4f0d0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 22:58:30 -0500 Subject: Switching to using sesson proxies for the session we want to look at instead of our session --- src/users-service-dbus.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 3156802..3589a6a 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -66,7 +66,7 @@ static void seat_proxy_session_removed (DBusGProxy *seat_ static gboolean do_add_session (UsersServiceDbus *service, UserData *user, const gchar *ssid); -static gchar * get_seat_internal (UsersServiceDbus *self); +static gchar * get_seat_internal (DBusGProxy *proxy); /* Private */ typedef struct _UsersServiceDbusPrivate UsersServiceDbusPrivate; @@ -402,19 +402,18 @@ get_seat (UsersServiceDbus *service) priv->ssid = ssid; create_cksession_proxy (service); - seat = get_seat_internal (service); + seat = get_seat_internal (priv->session_proxy); return seat; } static gchar * -get_seat_internal (UsersServiceDbus *self) +get_seat_internal (DBusGProxy *proxy) { - UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); GError *error = NULL; gchar *seat = NULL; - if (!dbus_g_proxy_call (priv->session_proxy, + if (!dbus_g_proxy_call (proxy, "GetSeatId", &error, G_TYPE_INVALID, @@ -440,8 +439,14 @@ get_unix_user (UsersServiceDbus *service, UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service); GError *error = NULL; guint uid; + DBusGProxy *session_proxy; + + session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, + "org.freedesktop.ConsoleKit", + session_id, + "org.freedesktop.ConsoleKit.Session"); - if (dbus_g_proxy_call (priv->session_proxy, + if (dbus_g_proxy_call (session_proxy, "GetUnixUser", &error, G_TYPE_INVALID, @@ -454,6 +459,7 @@ get_unix_user (UsersServiceDbus *service, g_error_free (error); } + g_object_unref(session_proxy); return FALSE; } @@ -462,6 +468,7 @@ get_unix_user (UsersServiceDbus *service, *uidp = (uid_t)uid; } + g_object_unref(session_proxy); return TRUE; } @@ -474,14 +481,22 @@ do_add_session (UsersServiceDbus *service, GError *error = NULL; gchar *seat = NULL; gchar *xdisplay = NULL; + DBusGProxy * session_proxy; GList *l; - seat = get_seat_internal (service); + session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, + "org.freedesktop.ConsoleKit", + ssid, + "org.freedesktop.ConsoleKit.Session"); - if (!seat || !priv->seat || strcmp (seat, priv->seat) != 0) + seat = get_seat_internal (session_proxy); + + if (!seat || !priv->seat || strcmp (seat, priv->seat) != 0) { + g_object_unref(session_proxy); return FALSE; + } - if (!dbus_g_proxy_call (priv->session_proxy, + if (!dbus_g_proxy_call (session_proxy, "GetX11Display", &error, G_TYPE_INVALID, @@ -494,9 +509,12 @@ do_add_session (UsersServiceDbus *service, g_error_free (error); } + g_object_unref(session_proxy); return FALSE; } + g_object_unref(session_proxy); + if (!xdisplay || xdisplay[0] == '\0') return FALSE; -- cgit v1.2.3 From 8b77c4fe175b42d06e3e37be5645edafde53ae58 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 08:09:07 -0500 Subject: Grabbing the session interface from consolekit --- src/Makefile.am | 9 + src/consolekit-session.xml | 435 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 444 insertions(+) create mode 100644 src/consolekit-session.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 01a88a3..24e00e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,13 @@ consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml --output=consolekit-manager-client.h \ $(srcdir)/consolekit-manager.xml +consolekit-session-client.h: $(srcdir)/consolekit-session.xml + dbus-binding-tool \ + --prefix=_consolekit_session_client \ + --mode=glib-client \ + --output=consolekit-session-client.h \ + $(srcdir)/consolekit-session.xml + gdm-local-display-factory-client.h: $(srcdir)/gdm-local-display-factory.xml dbus-binding-tool \ --prefix=_gdm_local_display_factory_client \ @@ -120,6 +127,7 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + consolekit-session-client.h \ gdm-local-display-factory-client.h \ session-dbus-client.h \ session-dbus-server.h \ @@ -130,6 +138,7 @@ BUILT_SOURCES = \ EXTRA_DIST = \ consolekit-manager.xml \ + consolekit-session.xml \ gdm-local-display-factory.xml \ session-dbus.xml \ upower.xml \ diff --git a/src/consolekit-session.xml b/src/consolekit-session.xml new file mode 100644 index 0000000..b6e1cdb --- /dev/null +++ b/src/consolekit-session.xml @@ -0,0 +1,435 @@ + + + + + + + Session objects represent and store information + related to a user session. + + The properties associated with the Session + specifically refer to the properties of the "session leader". + + + + + + + Session ID + + + + Returns the ID for Session. + + + + + + + Seat ID + + + + Returns the ID for the Seat the Session is + attached to. + + org.freedesktop.ConsoleKit.Seat + + + + + + Session type + + + + + Returns the type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + session-type + + + + + + User ID + + + + Returns the user that the session belongs to. + + + user + + + + + + POSIX User ID + + + + Returns the POSIX user ID that the session belongs to. + + unix-user + + + + + + The value of the X11 display + + + + Returns the value of the X11 DISPLAY for this session + if one is present. + + x11-display + + + + + + The value of the X11 display device + + + + Returns the value of the display device (aka TTY) that the + X11 display for the session is connected to. If there is no x11-display set then this value + is undefined. + + x11-display-device + + + + + + The value of the display device + + + + Returns the value of the display device (aka TTY) that the + session is connected to. + + display-device + + + + + + The remote host name + + + + Returns the value of the remote host name for the session. + + + remote-host-name + + + + + + The value of the native system login session ID + + + + Returns the value of the login session ID that the + underlying system uses to enforce session boundaries. If there is no login session ID + set then this value is an empty string. + + + + + + + TRUE if the session is active, otherwise FALSE + + + + Returns whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + active + + + + + + TRUE if the session is local, otherwise FALSE + + + + Returns whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + is-local + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time that the session was opened. + + + + + + + + + + Attempt to activate the this session. In most + cases, if successful, this will cause the session to + become visible and become active on the seat that it + is attached to. + + Seat.ActivateSession() + + + + + + + This will cause a Lock + signal to be emitted for this session. + + + This method is restricted to privileged users by D-Bus policy. + Lock signal + + + + + + + This will cause an Unlock + signal to be emitted for this session. + + This can be used by login managers to unlock a session before it is + re-activated during fast-user-switching. + + + This method is restricted to privileged users by D-Bus policy. + Unlock signal + + + + + + + The value of the idle-hint + + + + + Gets the value of the idle-hint + property. + + + idle-hint + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time of the last change of the idle-hint. + + + + + + + + + boolean value to set the idle-hint to + + + + + This may be used by the session to indicate that + it is idle. + + Use of this method is restricted to the user + that owns the session. + + + + + + + + TRUE if the session is active, otherwise FALSE + + + + + Emitted when the active property has changed. + + + + + + + the new value of idle-hint + + + + + Emitted when the idle-hint property has changed. + + + + + + + Emitted in response to a call to the Lock() method. + It is intended that the screensaver for the session should lock the screen in response to this signal. + + + + + + + Emitted in response to a call to the Unlock() method. + It is intended that the screensaver for the session should unlock the screen in response to this signal. + + + + + + + + The user assigned to the session. + + + + + + + The user assigned to the session. + + + + + + + + The type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + + + + + + The remote host name for the session. + + This will be set in situations where the session is + opened and controlled from a remote system. + + For example, this value will be set when the + session is created from an SSH or XDMCP connection. + + + + + + + + The display device (aka TTY) that the + session is connected to. + + + + + + + + Value of the X11 DISPLAY for this session + if one is present. + + + + + + + + + The display device (aka TTY) that the X11 display for the + session is connected to. If there is no x11-display set then + this value is undefined. + + + + + + + + + Whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + + + + + + + Whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + + + + + + + This is a hint used to indicate that the session may be idle. + + + For sessions with a x11-display set (ie. graphical + sessions), it is up to each session to delegate the + responsibility for updating this value. Typically, the + screensaver will set this. + + However, for non-graphical sessions with a display-device set + the Session object itself will periodically update this value based + on the activity detected on the display-device itself. + + + This should not be considered authoritative. + + + + + + + -- cgit v1.2.3 From 494bb4fa4748456f16e5a852fd939b9500deb61e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 08:15:09 -0500 Subject: Switching to the generated dbus interface --- src/users-service-dbus.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 3589a6a..5d157ee 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -36,6 +36,7 @@ #include "users-service-client.h" #include "users-service-marshal.h" #include "consolekit-manager-client.h" +#include "consolekit-session-client.h" static void users_service_dbus_class_init (UsersServiceDbusClass *klass); static void users_service_dbus_init (UsersServiceDbus *self); @@ -413,12 +414,7 @@ get_seat_internal (DBusGProxy *proxy) GError *error = NULL; gchar *seat = NULL; - if (!dbus_g_proxy_call (proxy, - "GetSeatId", - &error, - G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &seat, - G_TYPE_INVALID)) + if (!org_freedesktop_ConsoleKit_Session_get_seat_id (proxy, &seat, &error)) { if (error) { @@ -446,12 +442,7 @@ get_unix_user (UsersServiceDbus *service, session_id, "org.freedesktop.ConsoleKit.Session"); - if (dbus_g_proxy_call (session_proxy, - "GetUnixUser", - &error, - G_TYPE_INVALID, - G_TYPE_UINT, &uid, - G_TYPE_INVALID)) + if (org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) { if (error) { @@ -496,12 +487,7 @@ do_add_session (UsersServiceDbus *service, return FALSE; } - if (!dbus_g_proxy_call (session_proxy, - "GetX11Display", - &error, - G_TYPE_INVALID, - G_TYPE_STRING, &xdisplay, - G_TYPE_INVALID)) + if (!org_freedesktop_ConsoleKit_Session_get_x11_display (session_proxy, &xdisplay, &error)) { if (error) { @@ -776,12 +762,7 @@ session_is_login_window (UsersServiceDbus *self, return FALSE; } - if (!dbus_g_proxy_call (proxy, - "GetSessionType", - &error, - G_TYPE_INVALID, - G_TYPE_STRING, &type, - G_TYPE_INVALID)) + if (!org_freedesktop_ConsoleKit_Session_get_session_type (proxy, &type, &error)) { g_warning ("Can't call GetSessionType: %s", error->message); g_error_free (error); -- cgit v1.2.3 From 05b52fcee1c26b0f8dd703a61226ffdb60ff301e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 10:56:28 -0500 Subject: Switching to getting locked proxies. Just to have more error handling. --- src/users-service-dbus.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 5d157ee..5b1bcd7 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -437,10 +437,17 @@ get_unix_user (UsersServiceDbus *service, guint uid; DBusGProxy *session_proxy; - session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, - "org.freedesktop.ConsoleKit", - session_id, - "org.freedesktop.ConsoleKit.Session"); + session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, + "org.freedesktop.ConsoleKit", + session_id, + "org.freedesktop.ConsoleKit.Session", + &error); + + if (error != NULL) { + g_warning("Unable to get CK Session proxy: %s", error->message); + g_error_free(error); + return FALSE; + } if (org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) { @@ -475,10 +482,17 @@ do_add_session (UsersServiceDbus *service, DBusGProxy * session_proxy; GList *l; - session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, - "org.freedesktop.ConsoleKit", - ssid, - "org.freedesktop.ConsoleKit.Session"); + session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, + "org.freedesktop.ConsoleKit", + ssid, + "org.freedesktop.ConsoleKit.Session", + &error); + + if (error != NULL) { + g_warning("Unable to get CK Session proxy: %s", error->message); + g_error_free(error); + return FALSE; + } seat = get_seat_internal (session_proxy); -- cgit v1.2.3 From 89fe9da54e180a055eb155b94002ff1393d44a9f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 14:00:06 -0500 Subject: Using defines to make sure the strings are right. --- src/users-service-dbus.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 5b1bcd7..504eeee 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -38,6 +38,10 @@ #include "consolekit-manager-client.h" #include "consolekit-session-client.h" +#define CK_ADDR "org.freedesktop.ConsoleKit" +#define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session" + + static void users_service_dbus_class_init (UsersServiceDbusClass *klass); static void users_service_dbus_init (UsersServiceDbus *self); static void users_service_dbus_dispose (GObject *object); @@ -361,9 +365,9 @@ create_cksession_proxy (UsersServiceDbus *service) UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service); priv->session_proxy = dbus_g_proxy_new_for_name (priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, priv->ssid, - "org.freedesktop.ConsoleKit.Session"); + CK_SESSION_IFACE); if (!priv->session_proxy) { @@ -437,10 +441,11 @@ get_unix_user (UsersServiceDbus *service, guint uid; DBusGProxy *session_proxy; + g_debug("Building session proxy for: %s", session_id); session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, session_id, - "org.freedesktop.ConsoleKit.Session", + CK_SESSION_IFACE, &error); if (error != NULL) { @@ -483,9 +488,9 @@ do_add_session (UsersServiceDbus *service, GList *l; session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, ssid, - "org.freedesktop.ConsoleKit.Session", + CK_SESSION_IFACE, &error); if (error != NULL) { @@ -767,9 +772,9 @@ session_is_login_window (UsersServiceDbus *self, char *type = NULL; if (!(proxy = dbus_g_proxy_new_for_name (priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, ssid, - "org.freedesktop.ConsoleKit.Session"))) + CK_SESSION_IFACE))) { g_warning ("Failed to get ConsoleKit proxy"); -- cgit v1.2.3 From 8ab1eb8c5cb2e0c64681e473131b957818a74d82 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 15:05:46 -0500 Subject: Uhg, false sucks. --- src/users-service-dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 504eeee..d581887 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -454,7 +454,7 @@ get_unix_user (UsersServiceDbus *service, return FALSE; } - if (org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) + if (!org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) { if (error) { -- cgit v1.2.3 From 1d79b928f9df7e3185ba5846b06f3c7675ba4fea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 15:20:21 -0500 Subject: Some debugging an checking to ensure the menu item is not NULL --- src/users-service-dbus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index d581887..86007c3 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -609,6 +609,7 @@ seat_proxy_session_added (DBusGProxy *seat_proxy, dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, TRUE); } priv->guest_session_id = g_strdup(session_id); + g_debug("Found guest session: %s", priv->guest_session_id); return; } @@ -634,7 +635,10 @@ seat_proxy_session_removed (DBusGProxy *seat_proxy, username = g_hash_table_lookup (priv->sessions, session_id); if (!username) { if (g_strcmp0(session_id, priv->guest_session_id) == 0) { - dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, FALSE); + g_debug("Removing guest session: %s", priv->guest_session_id); + if (priv->guest_item != NULL) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, FALSE); + } g_free(priv->guest_session_id); priv->guest_session_id = NULL; } -- cgit v1.2.3 From 6a3728388fdf6454d2029c3d6ae0b1c71ad6222e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 15:28:46 -0500 Subject: Watch for the logged in property changing and hide or show the logged in widget depending on it. --- src/indicator-session.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..9cf58a5 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -216,6 +216,19 @@ get_icon (IndicatorObject * io) return INDICATOR_SESSION(io)->status_image; } +static void +user_property_change (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) +{ + if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { + if (g_value_get_boolean(value)) { + gtk_widget_show(GTK_WIDGET(user_data)); + } else { + gtk_widget_hide(GTK_WIDGET(user_data)); + } + } + return; +} + /* Builds an item with a hip little logged in icon. */ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) @@ -242,6 +255,8 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(user_property_change), icon); + return TRUE; } -- cgit v1.2.3