aboutsummaryrefslogtreecommitdiff
path: root/src/users-service-dbus.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-09-07 21:02:44 +0100
committerConor Curran <conor.curran@canonical.com>2011-09-07 21:02:44 +0100
commit0bef37124f305aef894fa19f01911bc3553df3c5 (patch)
tree2db1ab978170cb7c473e19f56166d1b5fd54c53a /src/users-service-dbus.c
parent433512c195ed7faac8d834bd648f32aaff380827 (diff)
downloadayatana-indicator-session-0bef37124f305aef894fa19f01911bc3553df3c5.tar.gz
ayatana-indicator-session-0bef37124f305aef894fa19f01911bc3553df3c5.tar.bz2
ayatana-indicator-session-0bef37124f305aef894fa19f01911bc3553df3c5.zip
display manager HasGuestAccount now supported
Diffstat (limited to 'src/users-service-dbus.c')
-rw-r--r--src/users-service-dbus.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c
index 4b41f4b..7054a22 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 ("HAS 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 @@ 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;
+}
+