aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog9
-rw-r--r--src/lock-helper.c142
-rw-r--r--src/lock-helper.h3
-rw-r--r--src/session-service.c87
4 files changed, 95 insertions, 146 deletions
diff --git a/debian/changelog b/debian/changelog
index 345770c..3dd9fc6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+indicator-session (0.2.1-0ubuntu1~ppa2) lucid; urgency=low
+
+ * Upstream Merge
+ * Check the user_switching lockdown key to disable user_switching
+ * Only create the screensaver proxy when needed.
+ * Removing unneeded GPM proxy
+
+ -- Ted Gould <ted@ubuntu.com> Mon, 08 Feb 2010 16:49:20 -0600
+
indicator-session (0.2.1-0ubuntu1) lucid; urgency=low
* Upstream release 0.2.1
diff --git a/src/lock-helper.c b/src/lock-helper.c
index f9c46cc..b38be65 100644
--- a/src/lock-helper.c
+++ b/src/lock-helper.c
@@ -27,13 +27,9 @@ static GMainLoop * gss_mainloop = NULL;
static guint cookie = 0;
static DBusGProxyCall * cookie_call = NULL;
-static DBusGProxy * gdm_settings_proxy = NULL;
-static gboolean gdm_auto_login = FALSE;
-static const gchar * gdm_auto_login_string = "daemon/AutomaticLoginEnable";
-
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. */
@@ -56,6 +52,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 +102,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,
@@ -113,28 +115,11 @@ screensaver_throttle (gchar * reason)
return;
}
-/* Setting up a call back */
-void
-lock_screen_gdm_cb_set (gdm_autologin_cb_t cb)
-{
- if (gdm_autologin_cb) {
- g_warning("Already had a callback, setting up a new one...");
- }
-
- gdm_autologin_cb = cb;
- return;
-}
-
/* This is our logic on whether the screen should be locked
or not. It effects everything else. */
gboolean
will_lock_screen (void)
{
-/*
- if (gdm_auto_login) {
- return FALSE;
- }
-*/
if (is_guest) {
return FALSE;
}
@@ -142,95 +127,6 @@ will_lock_screen (void)
return TRUE;
}
-/* Respond to the signal of autologin changing to see if the
- setting for timed login changes. */
-static void
-gdm_settings_change (DBusGProxy * proxy, const gchar * value, const gchar * old, const gchar * new, gpointer data)
-{
- if (g_strcmp0(value, gdm_auto_login_string)) {
- /* This is not a setting that we care about,
- there is only one. */
- return;
- }
- g_debug("GDM Settings change: %s", new);
-
- if (g_strcmp0(new, "true") == 0) {
- gdm_auto_login = TRUE;
- } else {
- gdm_auto_login = FALSE;
- }
-
- if (gdm_autologin_cb != NULL) {
- gdm_autologin_cb();
- }
-
- return;
-}
-
-/* Get back the data from querying to see if there is auto
- login enabled in GDM */
-static void
-gdm_get_autologin (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data)
-{
- GError * error = NULL;
- gchar * value = NULL;
-
- if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_STRING, &value, G_TYPE_INVALID)) {
- g_warning("Unable to get autologin setting: %s", error != NULL ? error->message : "null");
- g_error_free(error);
- return;
- }
-
- g_return_if_fail(value != NULL);
- gdm_settings_change(proxy, gdm_auto_login_string, NULL, value, NULL);
-
- return;
-}
-
-/* Sets up the proxy and queries for the setting to know
- whether we're doing an autologin. */
-static void
-build_gdm_proxy (void)
-{
- g_return_if_fail(gdm_settings_proxy == NULL);
-
- /* Grab the system bus */
- DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
- g_return_if_fail(bus != NULL);
-
- /* Get the settings proxy */
- gdm_settings_proxy = dbus_g_proxy_new_for_name_owner(bus,
- "org.gnome.DisplayManager",
- "/org/gnome/DisplayManager/Settings",
- "org.gnome.DisplayManager.Settings", NULL);
- g_return_if_fail(gdm_settings_proxy != NULL);
-
- /* Signal for value changed */
- dbus_g_proxy_add_signal(gdm_settings_proxy,
- "ValueChanged",
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(gdm_settings_proxy,
- "ValueChanged",
- G_CALLBACK(gdm_settings_change),
- NULL,
- NULL);
-
- /* Start to get the initial value */
- dbus_g_proxy_begin_call(gdm_settings_proxy,
- "GetValue",
- gdm_get_autologin,
- NULL,
- NULL,
- G_TYPE_STRING,
- gdm_auto_login_string,
- G_TYPE_INVALID);
-
- return;
-}
-
/* When the screensave go active, if we've got a mainloop
running we should quit it. */
static void
@@ -247,17 +143,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);
+ 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);
+ 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);
+ 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 +186,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,
@@ -319,9 +218,6 @@ lock_screen_setup (gpointer data)
is_guest = TRUE;
}
- build_gdm_proxy();
- build_gss_proxy();
-
return FALSE;
}
diff --git a/src/lock-helper.h b/src/lock-helper.h
index ebcd635..37f1448 100644
--- a/src/lock-helper.h
+++ b/src/lock-helper.h
@@ -24,14 +24,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libdbusmenu-glib/menuitem.h>
-typedef void (*gdm_autologin_cb_t) (void);
-
void screensaver_throttle (gchar * reason);
void screensaver_unthrottle (void);
gboolean will_lock_screen (void);
void lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data);
gboolean lock_screen_setup (gpointer data);
-void lock_screen_gdm_cb_set (gdm_autologin_cb_t cb);
#endif /* LOCK_HELPER_H__ */
diff --git a/src/session-service.c b/src/session-service.c
index 8306d02..e89a9a0 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
@@ -264,20 +315,6 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type)
return;
}
-/* Respond to the signal of autologin changing to see if the
- setting for timed login changes. */
-static void
-gdm_settings_change (void)
-{
- if (!will_lock_screen()) {
- dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
- } else {
- dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
- }
-
- return;
-}
-
/* Checks to see if we should show the guest suession item */
static gboolean
check_guest_session (void)
@@ -441,13 +478,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);
@@ -574,7 +622,6 @@ main (int argc, char ** argv)
G_CALLBACK(service_shutdown), NULL);
g_idle_add(lock_screen_setup, NULL);
- lock_screen_gdm_cb_set(gdm_settings_change);
root_menuitem = dbusmenu_menuitem_new();
g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem));