← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~cjcurran/indicator-session/hasguestaccount-support into lp:indicator-session

 

Conor Curran has proposed merging lp:~cjcurran/indicator-session/hasguestaccount-support into lp:indicator-session.

Requested reviews:
  Ted Gould (ted)

For more details, see:
https://code.launchpad.net/~cjcurran/indicator-session/hasguestaccount-support/+merge/74510

Display manager's new property HasGuestAccount on the seat should now be supported
-- 
https://code.launchpad.net/~cjcurran/indicator-session/hasguestaccount-support/+merge/74510
Your team ayatana-commits is subscribed to branch lp:indicator-session.
=== modified file 'src/user-menu-mgr.c'
--- src/user-menu-mgr.c	2011-09-06 15:52:08 +0000
+++ src/user-menu-mgr.c	2011-09-07 20:06:55 +0000
@@ -65,6 +65,7 @@
 static void activate_guest_session (DbusmenuMenuitem * mi,
                                     guint timestamp,
                                     gpointer user_data);
+                                    
 
 G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT);
 
@@ -129,6 +130,25 @@
   if (can_activate == TRUE)
   {
     
+    gboolean guest_enabled = users_service_dbus_guest_session_enabled (self->users_dbus_interface);
+    GList * users = NULL;
+    users = users_service_dbus_get_user_list (self->users_dbus_interface);
+    self->user_count = g_list_length(users);
+    
+    gboolean gsettings_user_menu_is_visible = should_show_user_menu();
+    
+    if (gsettings_user_menu_is_visible == FALSE || greeter_mode == TRUE){
+      session_dbus_set_user_menu_visibility (self->session_dbus_interface,
+                                             FALSE);
+    }
+    else{
+      // This needs to be updated once the ability to query guest session support is available
+      session_dbus_set_user_menu_visibility (self->session_dbus_interface,
+                                             guest_enabled || self->user_count > 1);
+    }
+    
+    // TODO we should really return here if the menu is not going to be shown.
+    
     if (check_new_session ()){
       switch_menuitem = dbusmenu_menuitem_new ();
       dbusmenu_menuitem_property_set (switch_menuitem,
@@ -144,7 +164,7 @@
                         self->users_dbus_interface);
     }    
     
-    if (is_this_guest_session ())
+    if ( !is_this_guest_session () && guest_enabled)
     {
       guest_mi = dbusmenu_menuitem_new ();
       dbusmenu_menuitem_property_set (guest_mi,
@@ -169,21 +189,6 @@
                                         _("Guest"));      
     }
     
-    GList * users = NULL;
-    users = users_service_dbus_get_user_list (self->users_dbus_interface);
-    self->user_count = g_list_length(users);
-    
-    gboolean user_menu_is_visible = should_show_user_menu();
-    
-    if (user_menu_is_visible == FALSE || greeter_mode == TRUE){
-      session_dbus_set_user_menu_visibility (self->session_dbus_interface,
-                                             FALSE);
-    }
-    else{
-      // This needs to be updated once the ability to query guest session support is available
-      session_dbus_set_user_menu_visibility (self->session_dbus_interface,
-                                             user_menu_is_visible);
-    }
     
 
     if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) {
@@ -420,10 +425,10 @@
 	if (geteuid() < 500) {
 		/* System users shouldn't have guest account shown.  Mostly
 		   this would be the case of the guest user itself. */
-		return FALSE;
+		return TRUE;
 	}
 
-	return TRUE;
+	return FALSE;
 }
 
 /* Called when someone clicks on the guest session item. */

=== modified file 'src/users-service-dbus.c'
--- src/users-service-dbus.c	2011-08-22 19:24:56 +0000
+++ src/users-service-dbus.c	2011-09-07 20:06:55 +0000
@@ -86,6 +86,7 @@
 
   DBusGProxy *accounts_service_proxy;
   DBusGProxy *display_manager_proxy;
+  DBusGProxy *display_manager_props_proxy;
   DBusGProxy *ck_proxy;
   DBusGProxy *seat_proxy;
   DBusGProxy *session_proxy;
@@ -95,6 +96,7 @@
 
   DbusmenuMenuitem * guest_item;
   gchar * guest_session_id;
+  gboolean guest_session_enabled;
 };
 
 #define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate))
@@ -148,6 +150,8 @@
   priv->count = 0;
   priv->guest_item = NULL;
   priv->guest_session_id = NULL;
+  
+  priv->guest_session_enabled = FALSE;
 
   /* Get the system bus */
   priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -194,6 +198,7 @@
   G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object);
 }
 
+
 static void
 create_display_manager_proxy (UsersServiceDbus *self)
 {
@@ -202,7 +207,7 @@
   GError *error = NULL;
   const gchar *cookie = NULL;
   gchar *seat = NULL;
-
+  
   cookie = g_getenv ("XDG_SESSION_COOKIE");
   if (cookie == NULL || cookie[0] == 0)
     {
@@ -232,11 +237,18 @@
       return;
     }
   g_object_unref (dm_proxy);
-
+  g_debug ("CREATING DM PROXIES WITH %s", seat);
   priv->display_manager_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
                                                            "org.freedesktop.DisplayManager",
                                                            seat,
                                                            "org.freedesktop.DisplayManager.Seat");
+
+  priv->display_manager_props_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
+                                                                 "org.freedesktop.DisplayManager",
+                                                                 seat,
+                                                                 "org.freedesktop.DBus.Properties");
+
+
   g_free (seat);
 
   if (!priv->display_manager_proxy)
@@ -244,6 +256,32 @@
       g_warning ("Failed to get DisplayManager seat proxy.");
       return;
     }
+  if (!priv->display_manager_props_proxy)
+    {
+      g_warning ("Failed to get DisplayManager Properties seat proxy.");
+      return;
+    }
+  
+  GValue has_guest_session = {0};
+  g_value_init (&has_guest_session, G_TYPE_BOOLEAN);
+  if (!dbus_g_proxy_call (priv->display_manager_props_proxy,
+                          "Get",
+                          &error,
+                          G_TYPE_STRING,
+                          "org.freedesktop.DisplayManager.Seat",
+                          G_TYPE_STRING,
+                          "HasGuestAccount",
+                          G_TYPE_INVALID,
+                          G_TYPE_VALUE,
+                          &has_guest_session,
+                          G_TYPE_INVALID))
+    {
+      g_warning ("Failed to get the HasGuestSession property from the DisplayManager Properties seat proxy. error: %s", error->message);
+      g_error_free (error);      
+      return;      
+    }
+    g_debug ("Does seat have a guest account = %i", g_value_get_boolean (&has_guest_session));
+    priv->guest_session_enabled = g_value_get_boolean (&has_guest_session);                                                        
 }
 
 static void
@@ -954,3 +992,12 @@
 
 	return;
 }
+
+gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self)
+{
+	g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE);
+	UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self);
+
+  return priv->guest_session_enabled;
+}                                                    
+

=== modified file 'src/users-service-dbus.h'
--- src/users-service-dbus.h	2011-08-25 17:52:42 +0000
+++ src/users-service-dbus.h	2011-09-07 20:06:55 +0000
@@ -85,6 +85,8 @@
 void      users_service_dbus_set_guest_item        (UsersServiceDbus * self,
                                                     DbusmenuMenuitem * mi);
 
+gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self);
+
 G_END_DECLS
 
 #endif


Follow ups