aboutsummaryrefslogtreecommitdiff
path: root/src/user-menu-mgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user-menu-mgr.c')
-rw-r--r--src/user-menu-mgr.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index bf3b77f..f2757ad 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -29,6 +29,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
static GConfClient * gconf_client = NULL;
static DbusmenuMenuitem *switch_menuitem = NULL;
+
struct _UserMenuMgr
{
GObject parent_instance;
@@ -56,6 +57,11 @@ static void user_change (UsersServiceDbus *service,
gpointer user_data);
static void ensure_gconf_client ();
+static gboolean check_guest_session (void);
+static void activate_guest_session (DbusmenuMenuitem * mi,
+ guint timestamp,
+ gpointer user_data);
+
G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT);
@@ -121,6 +127,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
/* Build all of the user switching items */
if (can_activate == TRUE)
{
+
if (check_new_session ()){
switch_menuitem = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (switch_menuitem,
@@ -134,8 +141,33 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK (activate_new_session),
self->users_dbus_interface);
+ }
+
+ if (check_guest_session ())
+ {
+ g_debug ("ADDING GUEST SESSION");
+ guest_mi = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (guest_mi,
+ DBUSMENU_MENUITEM_PROP_TYPE,
+ USER_ITEM_TYPE);
+ dbusmenu_menuitem_property_set (guest_mi,
+ USER_ITEM_PROP_NAME,
+ _("Guest Session"));
+ dbusmenu_menuitem_property_set_bool (guest_mi,
+ USER_ITEM_PROP_LOGGED_IN,
+ FALSE);
+ dbusmenu_menuitem_child_append (self->root_item, guest_mi);
+ g_signal_connect (G_OBJECT (guest_mi),
+ DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK (activate_guest_session),
+ self);
+ users_service_dbus_set_guest_item (self->users_dbus_interface,
+ guest_mi);
}
-
+ else{
+ g_debug ("NOT ADDING GUEST SESSION");
+ }
+
GList * users = NULL;
users = users_service_dbus_get_user_list (self->users_dbus_interface);
self->user_count = g_list_length(users);
@@ -354,6 +386,34 @@ user_mgr_get_root_item (UserMenuMgr* self)
return self->root_item;
}
+/* Checks to see if we should show the guest suession item */
+static gboolean
+check_guest_session (void)
+{
+ if (geteuid() < 500) {
+ /* System users shouldn't have guest account shown. Mosly
+ this would be the case of the guest user itself. */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Called when someone clicks on the guest session item. */
+static void
+activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data)
+{
+ g_return_if_fail (USER_IS_MENU_MGR (user_data));
+ UserMenuMgr* user_mgr = USER_MENU_MGR(user_data);
+ UsersServiceDbus *service = user_mgr->users_dbus_interface;
+
+ lock_if_possible();
+
+ if (users_service_dbus_activate_guest_session(service)) {
+ return;
+ }
+}
+
/*
* Clean Entry Point