diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-06-03 15:30:28 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-06-03 15:30:28 -0500 |
commit | 3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136 (patch) | |
tree | c4dc4622c7c762bb32612e36cd0e1c8bfccbb4bd /src/users-service-dbus.c | |
parent | 4823f27147e1a7a604d511acde9750d65190c865 (diff) | |
download | ayatana-indicator-session-3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136.tar.gz ayatana-indicator-session-3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136.tar.bz2 ayatana-indicator-session-3d6809119b9bdc0d144b7e4a3c23bca7ec2c3136.zip |
Remove the seemingly-pointless MINIMUM_USERS constant
Diffstat (limited to 'src/users-service-dbus.c')
-rw-r--r-- | src/users-service-dbus.c | 145 |
1 files changed, 71 insertions, 74 deletions
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 09f916d..e6d094c 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -718,91 +718,88 @@ sync_users (UsersServiceDbus *self) g_return_if_fail(IS_USERS_SERVICE_DBUS(self)); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - if (priv->count > MINIMUM_USERS) + GPtrArray *users = NULL; + GError *error = NULL; + gint i; + + users = g_ptr_array_new (); + + if (!org_freedesktop_Accounts_list_cached_users (priv->accounts_service_proxy, + &users, + &error)) + { + g_warning ("failed to retrieve user list: %s", error->message); + g_error_free (error); + + return; + } + + for (i = 0; i < users->len; i++) { - GPtrArray *users = NULL; + gchar *id; + DBusGProxy *proxy; + UserData *user; GError *error = NULL; - gint i; - users = g_ptr_array_new (); + id = g_ptr_array_index (users, i); + + proxy = dbus_g_proxy_new_for_name (priv->system_bus, + "org.freedesktop.Accounts", + id, + "org.freedesktop.DBus.Properties"); - if (!org_freedesktop_Accounts_list_cached_users (priv->accounts_service_proxy, - &users, - &error)) + GHashTable *properties; + if (!dbus_g_proxy_call (proxy, "GetAll", &error, + G_TYPE_STRING, "org.freedesktop.Accounts.User", G_TYPE_INVALID, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &properties, G_TYPE_INVALID)) { - g_warning ("failed to retrieve user list: %s", error->message); + g_warning ("unable to retrieve user info: %s", error->message); g_error_free (error); - return; + continue; } - - for (i = 0; i < users->len; i++) + + user = g_hash_table_lookup (priv->users, id); + // Double check we havent processed this user already + if (user != NULL) { - gchar *id; - DBusGProxy *proxy; - UserData *user; - GError *error = NULL; - - id = g_ptr_array_index (users, i); - - proxy = dbus_g_proxy_new_for_name (priv->system_bus, - "org.freedesktop.Accounts", - id, - "org.freedesktop.DBus.Properties"); - - GHashTable *properties; - if (!dbus_g_proxy_call (proxy, "GetAll", &error, - G_TYPE_STRING, "org.freedesktop.Accounts.User", G_TYPE_INVALID, - dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &properties, G_TYPE_INVALID)) - { - g_warning ("unable to retrieve user info: %s", error->message); - g_error_free (error); - - continue; - } - - user = g_hash_table_lookup (priv->users, id); - // Double check we havent processed this user already - if (user != NULL) - { - g_free(user->user_name); - g_free(user->real_name); - g_free(user->icon_file); - user->real_name_conflict = FALSE; - //continue; - } - else - { - user = g_new0 (UserData, 1); - } - // Can't subscribe to the Changed signal on each individual user path - // for some reason. - dbus_g_proxy_add_signal (proxy, - "Changed", - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal (proxy, "Changed", - G_CALLBACK(user_changed), - self, - NULL); - user->uid = g_value_get_uint64 (g_hash_table_lookup (properties, "Uid")); - user->user_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "UserName"))); - user->real_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "RealName"))); - user->icon_file = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "IconFile"))); - user->real_name_conflict = FALSE; - user->menuitem = NULL; - - g_hash_table_unref (properties); - - g_hash_table_insert (priv->users, - g_strdup (id), - user); - - add_sessions_for_user (self, user); + g_free(user->user_name); + g_free(user->real_name); + g_free(user->icon_file); + user->real_name_conflict = FALSE; + //continue; } - - g_ptr_array_free (users, TRUE); + else + { + user = g_new0 (UserData, 1); + } + // Can't subscribe to the Changed signal on each individual user path + // for some reason. + dbus_g_proxy_add_signal (proxy, + "Changed", + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (proxy, "Changed", + G_CALLBACK(user_changed), + self, + NULL); + user->uid = g_value_get_uint64 (g_hash_table_lookup (properties, "Uid")); + user->user_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "UserName"))); + user->real_name = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "RealName"))); + user->icon_file = g_strdup (g_value_get_string (g_hash_table_lookup (properties, "IconFile"))); + user->real_name_conflict = FALSE; + user->menuitem = NULL; + + g_hash_table_unref (properties); + + g_hash_table_insert (priv->users, + g_strdup (id), + user); + + add_sessions_for_user (self, user); } + + g_ptr_array_free (users, TRUE); } static void |