aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-02-08 16:44:37 -0600
committerTed Gould <ted@gould.cx>2010-02-08 16:44:37 -0600
commitd0febf8d25e2cc35fcb2baaa445ce939e51d2173 (patch)
tree3698fbe73fb87fa5eb43f18c2ffe78084dcbd8e6 /src
parente9698bb4739ec4894736037234e93d4ce0e06623 (diff)
parent40be2d62a4014ed8238b5a64952bcb148eeba500 (diff)
downloadayatana-indicator-session-d0febf8d25e2cc35fcb2baaa445ce939e51d2173.tar.gz
ayatana-indicator-session-d0febf8d25e2cc35fcb2baaa445ce939e51d2173.tar.bz2
ayatana-indicator-session-d0febf8d25e2cc35fcb2baaa445ce939e51d2173.zip
* Upstream Merge
* Check the user_switching lockdown key to disable user_switching * Only create the screensaver proxy when needed.
Diffstat (limited to 'src')
-rw-r--r--src/lock-helper.c34
-rw-r--r--src/session-service.c72
2 files changed, 89 insertions, 17 deletions
diff --git a/src/lock-helper.c b/src/lock-helper.c
index f9c46cc..94a86ef 100644
--- a/src/lock-helper.c
+++ b/src/lock-helper.c
@@ -35,6 +35,8 @@ static gboolean is_guest = FALSE;
static gdm_autologin_cb_t gdm_autologin_cb = NULL;
+void build_gss_proxy (void);
+
/* Checks to see if there is an error and reports
it. Not much else we can do. */
static void
@@ -56,6 +58,9 @@ screensaver_unthrottle (void)
{
g_return_if_fail(cookie != 0);
+ build_gss_proxy();
+ g_return_if_fail(gss_proxy != NULL);
+
dbus_g_proxy_begin_call(gss_proxy, "UnThrottle",
unthrottle_return, NULL,
NULL,
@@ -103,6 +108,9 @@ screensaver_throttle (gchar * reason)
screensaver_unthrottle();
}
+ build_gss_proxy();
+ g_return_if_fail(gss_proxy != NULL);
+
cookie_call = dbus_g_proxy_begin_call(gss_proxy, "Throttle",
throttle_return, NULL,
NULL,
@@ -247,17 +255,19 @@ gss_active_changed (DBusGProxy * proxy, gboolean active, gpointer data)
void
build_gss_proxy (void)
{
- DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- g_return_if_fail(session_bus != NULL);
-
- gss_proxy = dbus_g_proxy_new_for_name(session_bus,
- "org.gnome.ScreenSaver",
- "/",
- "org.gnome.ScreenSaver");
- g_return_if_fail(gss_proxy != NULL);
-
- dbus_g_proxy_add_signal(gss_proxy, "ActiveChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(gss_proxy, "ActiveChanged", G_CALLBACK(gss_active_changed), NULL, NULL);
+ if (gss_proxy == NULL) {
+ DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+ g_return_if_fail(session_bus != NULL);
+
+ gss_proxy = dbus_g_proxy_new_for_name(session_bus,
+ "org.gnome.ScreenSaver",
+ "/",
+ "org.gnome.ScreenSaver");
+ g_return_if_fail(gss_proxy != NULL);
+
+ dbus_g_proxy_add_signal(gss_proxy, "ActiveChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(gss_proxy, "ActiveChanged", G_CALLBACK(gss_active_changed), NULL, NULL);
+ }
return;
}
@@ -288,6 +298,7 @@ lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data)
return;
}
+ build_gss_proxy();
g_return_if_fail(gss_proxy != NULL);
dbus_g_proxy_call_no_reply(gss_proxy,
@@ -320,7 +331,6 @@ lock_screen_setup (gpointer data)
}
build_gdm_proxy();
- build_gss_proxy();
return FALSE;
}
diff --git a/src/session-service.c b/src/session-service.c
index 8306d02..791611e 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -50,6 +50,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch"
+#define LOCKDOWN_DIR "/desktop/gnome/lockdown"
+#define LOCKDOWN_KEY LOCKDOWN_DIR "/disable_user_switching"
+
typedef struct _ActivateData ActivateData;
struct _ActivateData
{
@@ -62,6 +65,7 @@ static DBusGProxy *gdm_proxy = NULL;
static UsersServiceDbus *dbus_interface = NULL;
static DbusmenuMenuitem *lock_menuitem = NULL;
+static DbusmenuMenuitem *switch_menuitem = NULL;
static gint count;
static GList *users;
@@ -80,6 +84,53 @@ static DbusmenuMenuitem * logout_mi = NULL;
static DbusmenuMenuitem * restart_mi = NULL;
static DbusmenuMenuitem * shutdown_mi = NULL;
+static GConfClient * gconf_client = NULL;
+static guint notify_lockdown_id = 0;
+
+static void
+lockdown_changed (GConfClient *client,
+ guint cnxd_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ GConfValue *value = gconf_entry_get_value (entry);
+ const gchar *key = gconf_entry_get_key (entry);
+
+ if (!value || !key)
+ return;
+
+ if (g_strcmp0 (key, LOCKDOWN_KEY) == 0)
+ {
+ if (switch_menuitem)
+ {
+ if (gconf_value_get_bool (value))
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+ else
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ }
+ }
+ }
+}
+
+static void
+ensure_gconf_client (void)
+{
+ if (!gconf_client)
+ {
+ gconf_client = gconf_client_get_default ();
+
+ notify_lockdown_id = gconf_client_notify_add (gconf_client,
+ LOCKDOWN_KEY,
+ lockdown_changed,
+ NULL,
+ NULL,
+ NULL);
+ }
+}
+
/* A return from the command to sleep the system. Make sure
that we unthrottle the screensaver. */
static void
@@ -441,13 +492,24 @@ rebuild_items (DbusmenuMenuitem *root,
if (check_new_session ())
{
- mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User..."));
- dbusmenu_menuitem_child_append (root, mi);
- g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL);
+ ensure_gconf_client ();
+
+ switch_menuitem = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User..."));
+ dbusmenu_menuitem_child_append (root, switch_menuitem);
+ g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL);
+
+ if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL))
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ }
+ else
+ {
+ dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ }
}
}
-
+
DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
dbusmenu_menuitem_child_append(root, separator);