summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2014-10-03 16:41:36 +1300
committerRobert Ancell <robert.ancell@canonical.com>2014-10-03 16:41:36 +1300
commitc68853aa93380e7410f25785bfef8b21395ae8dd (patch)
tree1430240803ccde73fc4b53d16554c77ef5378ed9 /common
parent6ed3da1444a90d85f5f0df9ff4bad92bedfd89f7 (diff)
downloadlightdm-git-c68853aa93380e7410f25785bfef8b21395ae8dd.tar.gz
Revert changes to AccountsService properties watching - it appears it's not using org.freedesktop.DBus.Properties
Diffstat (limited to 'common')
-rw-r--r--common/user-list.c239
1 files changed, 78 insertions, 161 deletions
diff --git a/common/user-list.c b/common/user-list.c
index 636ac778..f501c368 100644
--- a/common/user-list.c
+++ b/common/user-list.c
@@ -117,9 +117,6 @@ typedef struct
/* Shell for user */
gchar *shell;
- /* TRUE if a system account */
- gboolean system_account;
-
/* Image for user */
gchar *image;
@@ -454,110 +451,7 @@ passwd_changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileM
}
}
-static gboolean
-update_user_property (CommonUser *user, const gchar *name, GVariant *value)
-{
- CommonUserPrivate *priv = GET_USER_PRIVATE (user);
-
- if (strcmp (name, "UserName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- g_free (priv->name);
- priv->name = g_variant_dup_string (value, NULL);
- return TRUE;
- }
-
- if (strcmp (name, "RealName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- g_free (priv->real_name);
- priv->real_name = g_variant_dup_string (value, NULL);
- return TRUE;
- }
-
- if (strcmp (name, "HomeDirectory") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- g_free (priv->home_directory);
- priv->home_directory = g_variant_dup_string (value, NULL);
- return TRUE;
- }
-
- if (strcmp (name, "Shell") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- g_free (priv->shell);
- priv->shell = g_variant_dup_string (value, NULL);
- return TRUE;
- }
-
- if (strcmp (name, "SystemAccount") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
- {
- priv->system_account = g_variant_get_boolean (value);
- return TRUE;
- }
-
- if (strcmp (name, "Language") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- if (priv->language)
- g_free (priv->language);
- priv->language = g_variant_dup_string (value, NULL);
- return TRUE;
- }
-
- if (strcmp (name, "IconFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- g_free (priv->image);
- priv->image = g_variant_dup_string (value, NULL);
- if (strcmp (priv->image, "") == 0)
- {
- g_free (priv->image);
- priv->image = NULL;
- }
- return TRUE;
- }
-
- if (strcmp (name, "XSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- g_free (priv->session);
- priv->session = g_variant_dup_string (value, NULL);
- return TRUE;
- }
-
- if (strcmp (name, "BackgroundFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
- {
- g_free (priv->background);
- priv->background = g_variant_dup_string (value, NULL);
- if (strcmp (priv->background, "") == 0)
- {
- g_free (priv->background);
- priv->background = NULL;
- }
- return TRUE;
- }
-
- if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY))
- {
- g_strfreev (priv->layouts);
- priv->layouts = g_variant_dup_strv (value, NULL);
- if (!priv->layouts)
- {
- priv->layouts = g_malloc (sizeof (gchar *) * 1);
- priv->layouts[0] = NULL;
- }
- return TRUE;
- }
-
- if (strcmp (name, "XHasMessages") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
- {
- priv->has_messages = g_variant_get_boolean (value);
- return TRUE;
- }
-
- if (strcmp (name, "Uid") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64))
- {
- priv->uid = g_variant_get_uint64 (value);
- return TRUE;
- }
-
- return FALSE;
-}
+static gboolean load_accounts_user (CommonUser *user);
static void
accounts_user_changed_cb (GDBusConnection *connection,
@@ -569,57 +463,11 @@ accounts_user_changed_cb (GDBusConnection *connection,
gpointer data)
{
CommonUser *user = data;
- CommonUserPrivate *priv = GET_USER_PRIVATE (user);
- gboolean changed = FALSE;
- GVariantIter *iter;
- GVariantIter *invalidated_properties;
- gchar *name;
- GVariant *value;
-
- g_variant_get (parameters, "(sa{sv}as)", NULL, &iter, &invalidated_properties);
- while (g_variant_iter_loop (iter, "{&sv}", &name, &value))
- {
- if (update_user_property (user, name, value))
- changed = TRUE;
- }
- g_variant_iter_free (iter);
- while (g_variant_iter_loop (invalidated_properties, "&s", &name))
- {
- GVariant *result;
- GError *error = NULL;
-
- result = g_dbus_connection_call_sync (connection,
- "org.freedesktop.Accounts",
- priv->path,
- "org.freedesktop.DBus.Properties",
- "Get",
- g_variant_new ("(ss)", "org.freedesktop.Accounts.User", name),
- G_VARIANT_TYPE ("(v)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
- if (error)
- g_warning ("Error updating user property %s: %s", name, error->message);
- g_clear_error (&error);
-
- if (result)
- {
- GVariant *value;
+ CommonUserPrivate *priv = GET_USER_PRIVATE (user);
- g_variant_get (result, "(v)", &value);
- if (update_user_property (user, name, value))
- changed = TRUE;
- g_variant_unref (value);
- g_variant_unref (result);
- }
- }
-
- if (changed)
- {
- g_debug ("User %s changed", priv->path);
+ g_debug ("User %s changed", priv->path);
+ if (load_accounts_user (user))
g_signal_emit (user, user_signals[CHANGED], 0);
- }
}
static gboolean
@@ -629,16 +477,17 @@ load_accounts_user (CommonUser *user)
GVariant *result, *value;
GVariantIter *iter;
gchar *name;
+ gboolean system_account = FALSE;
GError *error = NULL;
/* Get the properties for this user */
if (!priv->changed_signal)
priv->changed_signal = g_dbus_connection_signal_subscribe (GET_LIST_PRIVATE (priv->user_list)->bus,
"org.freedesktop.Accounts",
- "org.freedesktop.DBus.Properties",
- "PropertiesChanged",
- priv->path,
"org.freedesktop.Accounts.User",
+ "Changed",
+ priv->path,
+ NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
accounts_user_changed_cb,
user,
@@ -663,12 +512,80 @@ load_accounts_user (CommonUser *user)
/* Store the properties we need */
g_variant_get (result, "(a{sv})", &iter);
while (g_variant_iter_loop (iter, "{&sv}", &name, &value))
- update_user_property (user, name, value);
+ {
+ if (strcmp (name, "UserName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ g_free (priv->name);
+ priv->name = g_variant_dup_string (value, NULL);
+ }
+ else if (strcmp (name, "RealName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ g_free (priv->real_name);
+ priv->real_name = g_variant_dup_string (value, NULL);
+ }
+ else if (strcmp (name, "HomeDirectory") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ g_free (priv->home_directory);
+ priv->home_directory = g_variant_dup_string (value, NULL);
+ }
+ else if (strcmp (name, "Shell") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ g_free (priv->shell);
+ priv->shell = g_variant_dup_string (value, NULL);
+ }
+ else if (strcmp (name, "SystemAccount") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
+ system_account = g_variant_get_boolean (value);
+ else if (strcmp (name, "Language") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ if (priv->language)
+ g_free (priv->language);
+ priv->language = g_variant_dup_string (value, NULL);
+ }
+ else if (strcmp (name, "IconFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ g_free (priv->image);
+ priv->image = g_variant_dup_string (value, NULL);
+ if (strcmp (priv->image, "") == 0)
+ {
+ g_free (priv->image);
+ priv->image = NULL;
+ }
+ }
+ else if (strcmp (name, "XSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ g_free (priv->session);
+ priv->session = g_variant_dup_string (value, NULL);
+ }
+ else if (strcmp (name, "BackgroundFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ {
+ g_free (priv->background);
+ priv->background = g_variant_dup_string (value, NULL);
+ if (strcmp (priv->background, "") == 0)
+ {
+ g_free (priv->background);
+ priv->background = NULL;
+ }
+ }
+ else if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY))
+ {
+ g_strfreev (priv->layouts);
+ priv->layouts = g_variant_dup_strv (value, NULL);
+ if (!priv->layouts)
+ {
+ priv->layouts = g_malloc (sizeof (gchar *) * 1);
+ priv->layouts[0] = NULL;
+ }
+ }
+ else if (strcmp (name, "XHasMessages") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
+ priv->has_messages = g_variant_get_boolean (value);
+ else if (strcmp (name, "Uid") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64))
+ priv->uid = g_variant_get_uint64 (value);
+ }
g_variant_iter_free (iter);
g_variant_unref (result);
- return !priv->system_account;
+ return !system_account;
}
static void