diff options
| author | Robert Ancell <robert.ancell@canonical.com> | 2017-12-20 17:08:27 +1300 |
|---|---|---|
| committer | Robert Ancell <robert.ancell@canonical.com> | 2017-12-20 17:08:27 +1300 |
| commit | 6015bce25f241e7580c03594d846769f8236232f (patch) | |
| tree | 6a0ae48b6c43c6a2e2e5e3eaef4246fc45aae562 /common | |
| parent | ee9f36a21ed661f52758a6d3badfdcac3716119c (diff) | |
Use AccountsService extension system for extended greeter information (background, messages etc)
The support for this never landed upstream in AccountsService and the extension system was added later. This allows OSs to make use of these features without a patched AccountsService.
Diffstat (limited to 'common')
| -rw-r--r-- | common/user-list.c | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/common/user-list.c b/common/user-list.c index ee4063dd..b8e32826 100644 --- a/common/user-list.c +++ b/common/user-list.c @@ -494,6 +494,7 @@ load_accounts_user (CommonUser *user) { CommonUserPrivate *priv = GET_USER_PRIVATE (user); g_autoptr(GVariant) result = NULL; + g_autoptr(GVariant) extra_result = NULL; GVariant *value; GVariantIter *iter; gchar *name; @@ -572,29 +573,50 @@ load_accounts_user (CommonUser *user) 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_clear_pointer (&priv->background, g_free); - } - else if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) + 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); + + extra_result = g_dbus_connection_call_sync (priv->bus, + "org.freedesktop.Accounts", + priv->path, + "org.freedesktop.DBus.Properties", + "GetAll", + g_variant_new ("(s)", "org.freedesktop.DisplayManager.AccountsService"), + G_VARIANT_TYPE ("(a{sv})"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (error) + g_warning ("Error updating user %s: %s", priv->path, error->message); + if (extra_result) { + g_variant_get (extra_result, "(a{sv})", &iter); + while (g_variant_iter_loop (iter, "{&sv}", &name, &value)) { - g_strfreev (priv->layouts); - priv->layouts = g_variant_dup_strv (value, NULL); - if (!priv->layouts) + 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_clear_pointer (&priv->background, g_free); + } + else if (strcmp (name, "HasMessages") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + priv->has_messages = g_variant_get_boolean (value); + else if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY)) { - priv->layouts = g_malloc (sizeof (gchar *) * 1); - priv->layouts[0] = NULL; + 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_iter_free (iter); return !system_account; } |
