aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-09-08 10:23:55 +0100
committerConor Curran <conor.curran@canonical.com>2011-09-08 10:23:55 +0100
commitdaa6295ce57baca8b3e4fc574e3b8dd29cf2598e (patch)
tree8b5e7de3138200a5433c46f4e5c76ad50da33121
parente889dd7e4d0f5f3eb84d4eff9c080b0f23883999 (diff)
parent9c24a238b2338b3a4af7629e8e4d4a6493499ac2 (diff)
downloadayatana-indicator-session-daa6295ce57baca8b3e4fc574e3b8dd29cf2598e.tar.gz
ayatana-indicator-session-daa6295ce57baca8b3e4fc574e3b8dd29cf2598e.tar.bz2
ayatana-indicator-session-daa6295ce57baca8b3e4fc574e3b8dd29cf2598e.zip
merge the display manager's has-guest-account work
-rw-r--r--src/user-menu-mgr.c41
-rw-r--r--src/users-service-dbus.c51
-rw-r--r--src/users-service-dbus.h2
3 files changed, 74 insertions, 20 deletions
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index 16c6e3b..efb3f7d 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -65,6 +65,7 @@ static gboolean is_this_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);
@@ -129,6 +130,25 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
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 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
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 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
_("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 @@ is_this_guest_session (void)
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. */
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c
index 0fa751d..0bab8c8 100644
--- a/src/users-service-dbus.c
+++ b/src/users-service-dbus.c
@@ -86,6 +86,7 @@ struct _UsersServiceDbusPrivate
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 @@ struct _UsersServiceDbusPrivate
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 @@ users_service_dbus_init (UsersServiceDbus *self)
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 @@ users_service_dbus_finalize (GObject *object)
G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object);
}
+
static void
create_display_manager_proxy (UsersServiceDbus *self)
{
@@ -202,7 +207,7 @@ create_display_manager_proxy (UsersServiceDbus *self)
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 @@ create_display_manager_proxy (UsersServiceDbus *self)
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 @@ create_display_manager_proxy (UsersServiceDbus *self)
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
@@ -956,3 +994,12 @@ users_service_dbus_set_guest_item (UsersServiceDbus * self, DbusmenuMenuitem * m
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;
+}
+
diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h
index 4dbf2a4..25942df 100644
--- a/src/users-service-dbus.h
+++ b/src/users-service-dbus.h
@@ -85,6 +85,8 @@ gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self);
void users_service_dbus_set_guest_item (UsersServiceDbus * self,
DbusmenuMenuitem * mi);
+gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self);
+
G_END_DECLS
#endif