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

Proposed by Conor Curran
Status: Merged
Approved by: Ted Gould
Approved revision: 207
Merged at revision: 208
Proposed branch: lp:~cjcurran/indicator-session/hasguestaccount-support
Merge into: lp:indicator-session/0.1
Diff against target: 206 lines (+74/-20)
3 files modified
src/user-menu-mgr.c (+23/-18)
src/users-service-dbus.c (+49/-2)
src/users-service-dbus.h (+2/-0)
To merge this branch: bzr merge lp:~cjcurran/indicator-session/hasguestaccount-support
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+74510@code.launchpad.net

Description of the change

Display manager's new property HasGuestAccount on the seat should now be supported

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

You technically should have a g_value_unset() after using the value. But since it's a boolean we know that it shouldn't have any memory so it's not a big deal.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/user-menu-mgr.c'
2--- src/user-menu-mgr.c 2011-09-06 15:52:08 +0000
3+++ src/user-menu-mgr.c 2011-09-07 20:06:55 +0000
4@@ -65,6 +65,7 @@
5 static void activate_guest_session (DbusmenuMenuitem * mi,
6 guint timestamp,
7 gpointer user_data);
8+
9
10 G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT);
11
12@@ -129,6 +130,25 @@
13 if (can_activate == TRUE)
14 {
15
16+ gboolean guest_enabled = users_service_dbus_guest_session_enabled (self->users_dbus_interface);
17+ GList * users = NULL;
18+ users = users_service_dbus_get_user_list (self->users_dbus_interface);
19+ self->user_count = g_list_length(users);
20+
21+ gboolean gsettings_user_menu_is_visible = should_show_user_menu();
22+
23+ if (gsettings_user_menu_is_visible == FALSE || greeter_mode == TRUE){
24+ session_dbus_set_user_menu_visibility (self->session_dbus_interface,
25+ FALSE);
26+ }
27+ else{
28+ // This needs to be updated once the ability to query guest session support is available
29+ session_dbus_set_user_menu_visibility (self->session_dbus_interface,
30+ guest_enabled || self->user_count > 1);
31+ }
32+
33+ // TODO we should really return here if the menu is not going to be shown.
34+
35 if (check_new_session ()){
36 switch_menuitem = dbusmenu_menuitem_new ();
37 dbusmenu_menuitem_property_set (switch_menuitem,
38@@ -144,7 +164,7 @@
39 self->users_dbus_interface);
40 }
41
42- if (is_this_guest_session ())
43+ if ( !is_this_guest_session () && guest_enabled)
44 {
45 guest_mi = dbusmenu_menuitem_new ();
46 dbusmenu_menuitem_property_set (guest_mi,
47@@ -169,21 +189,6 @@
48 _("Guest"));
49 }
50
51- GList * users = NULL;
52- users = users_service_dbus_get_user_list (self->users_dbus_interface);
53- self->user_count = g_list_length(users);
54-
55- gboolean user_menu_is_visible = should_show_user_menu();
56-
57- if (user_menu_is_visible == FALSE || greeter_mode == TRUE){
58- session_dbus_set_user_menu_visibility (self->session_dbus_interface,
59- FALSE);
60- }
61- else{
62- // This needs to be updated once the ability to query guest session support is available
63- session_dbus_set_user_menu_visibility (self->session_dbus_interface,
64- user_menu_is_visible);
65- }
66
67
68 if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) {
69@@ -420,10 +425,10 @@
70 if (geteuid() < 500) {
71 /* System users shouldn't have guest account shown. Mostly
72 this would be the case of the guest user itself. */
73- return FALSE;
74+ return TRUE;
75 }
76
77- return TRUE;
78+ return FALSE;
79 }
80
81 /* Called when someone clicks on the guest session item. */
82
83=== modified file 'src/users-service-dbus.c'
84--- src/users-service-dbus.c 2011-08-22 19:24:56 +0000
85+++ src/users-service-dbus.c 2011-09-07 20:06:55 +0000
86@@ -86,6 +86,7 @@
87
88 DBusGProxy *accounts_service_proxy;
89 DBusGProxy *display_manager_proxy;
90+ DBusGProxy *display_manager_props_proxy;
91 DBusGProxy *ck_proxy;
92 DBusGProxy *seat_proxy;
93 DBusGProxy *session_proxy;
94@@ -95,6 +96,7 @@
95
96 DbusmenuMenuitem * guest_item;
97 gchar * guest_session_id;
98+ gboolean guest_session_enabled;
99 };
100
101 #define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate))
102@@ -148,6 +150,8 @@
103 priv->count = 0;
104 priv->guest_item = NULL;
105 priv->guest_session_id = NULL;
106+
107+ priv->guest_session_enabled = FALSE;
108
109 /* Get the system bus */
110 priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
111@@ -194,6 +198,7 @@
112 G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object);
113 }
114
115+
116 static void
117 create_display_manager_proxy (UsersServiceDbus *self)
118 {
119@@ -202,7 +207,7 @@
120 GError *error = NULL;
121 const gchar *cookie = NULL;
122 gchar *seat = NULL;
123-
124+
125 cookie = g_getenv ("XDG_SESSION_COOKIE");
126 if (cookie == NULL || cookie[0] == 0)
127 {
128@@ -232,11 +237,18 @@
129 return;
130 }
131 g_object_unref (dm_proxy);
132-
133+ g_debug ("CREATING DM PROXIES WITH %s", seat);
134 priv->display_manager_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
135 "org.freedesktop.DisplayManager",
136 seat,
137 "org.freedesktop.DisplayManager.Seat");
138+
139+ priv->display_manager_props_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
140+ "org.freedesktop.DisplayManager",
141+ seat,
142+ "org.freedesktop.DBus.Properties");
143+
144+
145 g_free (seat);
146
147 if (!priv->display_manager_proxy)
148@@ -244,6 +256,32 @@
149 g_warning ("Failed to get DisplayManager seat proxy.");
150 return;
151 }
152+ if (!priv->display_manager_props_proxy)
153+ {
154+ g_warning ("Failed to get DisplayManager Properties seat proxy.");
155+ return;
156+ }
157+
158+ GValue has_guest_session = {0};
159+ g_value_init (&has_guest_session, G_TYPE_BOOLEAN);
160+ if (!dbus_g_proxy_call (priv->display_manager_props_proxy,
161+ "Get",
162+ &error,
163+ G_TYPE_STRING,
164+ "org.freedesktop.DisplayManager.Seat",
165+ G_TYPE_STRING,
166+ "HasGuestAccount",
167+ G_TYPE_INVALID,
168+ G_TYPE_VALUE,
169+ &has_guest_session,
170+ G_TYPE_INVALID))
171+ {
172+ g_warning ("Failed to get the HasGuestSession property from the DisplayManager Properties seat proxy. error: %s", error->message);
173+ g_error_free (error);
174+ return;
175+ }
176+ g_debug ("Does seat have a guest account = %i", g_value_get_boolean (&has_guest_session));
177+ priv->guest_session_enabled = g_value_get_boolean (&has_guest_session);
178 }
179
180 static void
181@@ -954,3 +992,12 @@
182
183 return;
184 }
185+
186+gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self)
187+{
188+ g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE);
189+ UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self);
190+
191+ return priv->guest_session_enabled;
192+}
193+
194
195=== modified file 'src/users-service-dbus.h'
196--- src/users-service-dbus.h 2011-08-25 17:52:42 +0000
197+++ src/users-service-dbus.h 2011-09-07 20:06:55 +0000
198@@ -85,6 +85,8 @@
199 void users_service_dbus_set_guest_item (UsersServiceDbus * self,
200 DbusmenuMenuitem * mi);
201
202+gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self);
203+
204 G_END_DECLS
205
206 #endif

Subscribers

People subscribed via source and target branches