[gdm/accounts-service-split: 21/22] Get users from account service, fallback to old way
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/accounts-service-split: 21/22] Get users from account service, fallback to old way
- Date: Mon, 7 Jun 2010 22:26:18 +0000 (UTC)
commit 19210562f5845caa2e54db45bece8d018d768427
Author: Ray Strode <rstrode redhat com>
Date: Tue Mar 16 03:07:19 2010 -0400
Get users from account service, fallback to old way
gui/simple-greeter/gdm-user-manager.c | 310 +++++++++++++++++++++++++++------
gui/simple-greeter/gdm-user.c | 278 ++++++++++++++++++++++-------
gui/simple-greeter/gdm-user.h | 4 +
gui/user-switch-applet/applet.c | 7 +-
4 files changed, 477 insertions(+), 122 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index 13533ca..3eaf231 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -63,9 +63,9 @@
/* Prefs Defaults */
#ifdef __sun
-#define DEFAULT_MINIMAL_UID 100
+#define FALLBACK_MINIMAL_UID 100
#else
-#define DEFAULT_MINIMAL_UID 500
+#define FALLBACK_MINIMAL_UID 500
#endif
#ifndef _PATH_SHELLS
@@ -76,13 +76,19 @@
#define DEFAULT_GLOBAL_FACE_DIR DATADIR "/faces"
#define DEFAULT_USER_ICON "stock_person"
+#define ACCOUNTS_NAME "org.freedesktop.Accounts"
+#define ACCOUNTS_PATH "/org/freedesktop/Accounts"
+#define ACCOUNTS_INTERFACE "org.freedesktop.Accounts"
+
struct GdmUserManagerPrivate
{
GHashTable *users_by_name;
+ GHashTable *users_by_object_path;
GHashTable *sessions;
GHashTable *shells;
DBusGConnection *connection;
DBusGProxy *seat_proxy;
+ DBusGProxy *accounts_proxy;
char *seat_id;
GFileMonitor *passwd_monitor;
@@ -92,7 +98,6 @@ struct GdmUserManagerPrivate
GSList *include;
gboolean include_all;
- guint reload_id;
guint ck_history_id;
};
@@ -114,6 +119,8 @@ static void gdm_user_manager_finalize (GObject *object);
static gboolean match_real_name_hrfunc (gpointer key,
gpointer value,
gpointer user);
+static void get_users_manually (GdmUserManager *manager);
+static void add_included_users (GdmUserManager *manager);
static gpointer user_manager_object = NULL;
@@ -739,6 +746,7 @@ add_user (GdmUserManager *manager,
GdmUser *user)
{
GdmUser *dup;
+ const char *object_path;
add_sessions_for_user (manager, user);
dup = g_hash_table_find (manager->priv->users_by_name,
@@ -752,6 +760,10 @@ add_user (GdmUserManager *manager,
g_strdup (gdm_user_get_user_name (user)),
g_object_ref (user));
+ object_path = gdm_user_get_object_path (user);
+ if (object_path != NULL) {
+ g_hash_table_insert (manager->priv->users_by_object_path, (gpointer) object_path, g_object_ref (user));
+ }
g_signal_emit (manager, signals[USER_ADDED], 0, user);
}
@@ -761,16 +773,78 @@ add_new_user_for_pwent (GdmUserManager *manager,
{
GdmUser *user;
- g_debug ("Creating new user");
+ g_debug ("Creating new user from password entry");
user = create_user (manager);
_gdm_user_update_from_pwent (user, pwent);
add_user (manager, user);
+ g_object_unref (user);
+
+ user = g_hash_table_lookup (manager->priv->users_by_name, pwent->pw_name);
return user;
}
+static void
+add_new_user_for_object_path (const char *object_path,
+ GdmUserManager *manager)
+{
+ GdmUser *user;
+ const char *username;
+
+ if (g_hash_table_lookup (manager->priv->users_by_object_path, object_path)) {
+ return;
+ }
+ user = gdm_user_new_from_object_path (object_path);
+
+ if (user == NULL) {
+ return;
+ }
+
+ username = gdm_user_get_user_name (user);
+ if (user_in_exclude_list (manager, username)) {
+ g_debug ("GdmUserManager: excluding user '%s'", username);
+ g_object_unref (user);
+ return;
+ }
+
+ g_signal_connect (user, "sessions-changed",
+ G_CALLBACK (on_user_sessions_changed), manager);
+ g_signal_connect (user, "changed",
+ G_CALLBACK (on_user_changed), manager);
+
+ add_user (manager, user);
+ g_object_unref (user);
+}
+
+static void
+on_new_user_in_accounts_service (DBusGProxy *proxy,
+ const char *object_path,
+ gpointer user_data)
+{
+ GdmUserManager *manager = GDM_USER_MANAGER (user_data);
+
+ add_new_user_for_object_path (object_path, manager);
+}
+
+static void
+on_user_removed_in_accounts_service (DBusGProxy *proxy,
+ const char *object_path,
+ gpointer user_data)
+{
+ GdmUserManager *manager = GDM_USER_MANAGER (user_data);
+ GdmUser *user;
+
+ user = g_hash_table_lookup (manager->priv->users_by_object_path, object_path);
+ g_object_ref (user);
+ g_signal_handlers_disconnect_by_func (user, on_user_changed, manager);
+ g_hash_table_remove (manager->priv->users_by_object_path, gdm_user_get_object_path (user));
+ g_hash_table_remove (manager->priv->users_by_name, gdm_user_get_user_name (user));
+ g_signal_emit (manager, signals[USER_REMOVED], 0, user);
+ g_object_unref (user);
+}
+
static char *
get_current_seat_id (DBusGConnection *connection)
{
@@ -867,6 +941,82 @@ get_uid_from_session_id (GdmUserManager *manager,
return TRUE;
}
+static char *
+get_user_object_path_from_accounts_service (GdmUserManager *manager,
+ const char *name)
+{
+ GError *error;
+ char *object_path;
+ gboolean res;
+
+ error = NULL;
+ object_path = NULL;
+ res = dbus_g_proxy_call (manager->priv->accounts_proxy,
+ "FindUserByName",
+ &error,
+ G_TYPE_STRING,
+ name,
+ G_TYPE_INVALID,
+ DBUS_TYPE_G_OBJECT_PATH,
+ &object_path,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_debug ("Failed to find user %s: %s", name, error->message);
+ g_error_free (error);
+ } else {
+ g_debug ("Failed to find user %s", name);
+ }
+ return NULL;
+ }
+ return object_path;
+}
+
+static void
+on_list_cached_users_finished (DBusGProxy *proxy,
+ DBusGProxyCall *call_id,
+ gpointer data)
+{
+ GdmUserManager *manager = data;
+ GError *error = NULL;
+ GPtrArray *paths;
+
+ if (!dbus_g_proxy_end_call (proxy,
+ call_id,
+ &error,
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), &paths,
+ G_TYPE_INVALID)) {
+ g_debug ("ListCachedUsers failed: %s", error->message);
+ g_error_free (error);
+
+ g_object_unref (manager->priv->accounts_proxy);
+ manager->priv->accounts_proxy = NULL;
+
+ return get_users_manually (manager);
+ }
+
+ g_ptr_array_foreach (paths, (GFunc)add_new_user_for_object_path, manager);
+
+ g_ptr_array_foreach (paths, (GFunc)g_free, NULL);
+ g_ptr_array_free (paths, TRUE);
+
+ add_included_users (manager);
+
+ g_signal_emit (G_OBJECT (manager), signals[USERS_LOADED], 0);
+}
+
+static void
+get_users (GdmUserManager *manager)
+{
+ g_debug ("calling 'ListCachedUsers'");
+ dbus_g_proxy_begin_call (manager->priv->accounts_proxy,
+ "ListCachedUsers",
+ on_list_cached_users_finished,
+ manager,
+ NULL,
+ G_TYPE_INVALID);
+}
+
static void
seat_session_added (DBusGProxy *seat_proxy,
const char *session_id,
@@ -901,11 +1051,20 @@ seat_session_added (DBusGProxy *seat_proxy,
user = g_hash_table_lookup (manager->priv->users_by_name, pwent->pw_name);
if (user == NULL) {
+ char *object_path;
+
g_debug ("Creating new user");
- user = create_user (manager);
- _gdm_user_update_from_pwent (user, pwent);
is_new = TRUE;
+
+ object_path = get_user_object_path_from_accounts_service (manager, pwent->pw_name);
+ if (object_path == NULL) {
+ return;
+ }
+
+ user = gdm_user_new_from_object_path (object_path);
+ g_free (object_path);
+
} else {
is_new = FALSE;
}
@@ -915,10 +1074,14 @@ seat_session_added (DBusGProxy *seat_proxy,
/* only add the user if we added a session */
if (is_new) {
if (res) {
+ g_signal_connect (user, "sessions-changed",
+ G_CALLBACK (on_user_sessions_changed),
+ manager);
+ g_signal_connect (user, "changed",
+ G_CALLBACK (on_user_changed), manager);
add_user (manager, user);
- } else {
- g_object_unref (user);
}
+ g_object_unref (user);
}
}
@@ -1016,6 +1179,47 @@ get_seat_proxy (GdmUserManager *manager)
}
+static void
+on_accounts_proxy_destroy (DBusGProxy *proxy,
+ GdmUserManager *manager)
+{
+ g_debug ("GdmUserManager: accounts proxy destroyed");
+
+ manager->priv->accounts_proxy = NULL;
+}
+
+static void
+get_accounts_proxy (GdmUserManager *manager)
+{
+ DBusGProxy *proxy;
+ GError *error;
+
+ g_assert (manager->priv->accounts_proxy == NULL);
+
+ error = NULL;
+
+ proxy = dbus_g_proxy_new_for_name (manager->priv->connection,
+ ACCOUNTS_NAME,
+ ACCOUNTS_PATH,
+ ACCOUNTS_INTERFACE);
+
+ g_signal_connect (proxy, "destroy",
+ G_CALLBACK (on_accounts_proxy_destroy), manager);
+
+ dbus_g_proxy_add_signal (proxy, "UserAdded",
+ DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (proxy, "UserDeleted",
+ DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (proxy, "UserAdded",
+ G_CALLBACK (on_new_user_in_accounts_service),
+ manager, NULL);
+ dbus_g_proxy_connect_signal (proxy, "UserDeleted",
+ G_CALLBACK (on_user_removed_in_accounts_service),
+ manager, NULL);
+ manager->priv->accounts_proxy = proxy;
+}
+
/**
* gdm_manager_get_user:
* @manager: the manager to query.
@@ -1038,12 +1242,28 @@ gdm_user_manager_get_user (GdmUserManager *manager,
user = g_hash_table_lookup (manager->priv->users_by_name, username);
if (user == NULL) {
- struct passwd *pwent;
+ if (manager->priv->accounts_proxy != NULL) {
+ char *object_path;
- pwent = getpwnam (username);
+ object_path = get_user_object_path_from_accounts_service (manager, username);
- if (pwent != NULL) {
- user = add_new_user_for_pwent (manager, pwent);
+ if (object_path != NULL) {
+ add_new_user_for_object_path (object_path, manager);
+ g_free (object_path);
+ } else {
+ g_object_unref (manager->priv->accounts_proxy);
+ manager->priv->accounts_proxy = NULL;
+ }
+
+ user = g_hash_table_lookup (manager->priv->users_by_name, username);
+ }
+
+ if (manager->priv->accounts_proxy == NULL) {
+ struct passwd *pwent;
+ pwent = getpwnam (username);
+ if (pwent != NULL) {
+ user = add_new_user_for_pwent (manager, pwent);
+ }
}
}
@@ -1054,7 +1274,6 @@ GdmUser *
gdm_user_manager_get_user_by_uid (GdmUserManager *manager,
uid_t uid)
{
- GdmUser *user;
struct passwd *pwent;
g_return_val_if_fail (GDM_IS_USER_MANAGER (manager), NULL);
@@ -1065,13 +1284,7 @@ gdm_user_manager_get_user_by_uid (GdmUserManager *manager,
return NULL;
}
- user = g_hash_table_lookup (manager->priv->users_by_name, pwent->pw_name);
-
- if (user == NULL) {
- user = add_new_user_for_pwent (manager, pwent);
- }
-
- return user;
+ return gdm_user_manager_get_user (manager, pwent->pw_name);
}
static void
@@ -1407,7 +1620,7 @@ reload_passwd (GdmUserManager *manager)
user = NULL;
/* Skip users below MinimalUID... */
- if (pwent->pw_uid < DEFAULT_MINIMAL_UID) {
+ if (pwent->pw_uid < FALLBACK_MINIMAL_UID) {
continue;
}
@@ -1488,32 +1701,6 @@ reload_passwd (GdmUserManager *manager)
}
static void
-reload_users (GdmUserManager *manager)
-{
- reload_ck_history (manager);
- reload_passwd (manager);
-}
-
-static gboolean
-reload_users_timeout (GdmUserManager *manager)
-{
- reload_users (manager);
- manager->priv->reload_id = 0;
-
- return FALSE;
-}
-
-static void
-queue_reload_users (GdmUserManager *manager)
-{
- if (manager->priv->reload_id > 0) {
- return;
- }
-
- manager->priv->reload_id = g_idle_add ((GSourceFunc)reload_users_timeout, manager);
-}
-
-static void
reload_shells (GdmUserManager *manager)
{
char *shell;
@@ -1618,6 +1805,20 @@ monitor_local_users (GdmUserManager *manager)
}
static void
+get_users_manually (GdmUserManager *manager)
+{
+ g_debug ("Getting users manually");
+
+ if (manager->priv->include_all == TRUE) {
+ monitor_local_users (manager);
+ }
+
+ reload_ck_history (manager);
+ reload_passwd (manager);
+ add_included_users (manager);
+}
+
+static void
gdm_user_manager_class_init (GdmUserManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -1692,7 +1893,6 @@ gdm_set_string_list (char *value, GSList **retval)
g_strfreev (temp_array);
}
-
static void
gdm_user_manager_init (GdmUserManager *manager)
{
@@ -1728,6 +1928,11 @@ gdm_user_manager_init (GdmUserManager *manager)
g_free,
(GDestroyNotify) g_object_run_dispose);
+ manager->priv->users_by_object_path = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ NULL,
+ (GDestroyNotify) g_object_unref);
+
if (manager->priv->include_all == TRUE) {
monitor_local_users (manager);
}
@@ -1748,8 +1953,9 @@ gdm_user_manager_init (GdmUserManager *manager)
}
get_seat_proxy (manager);
+ get_accounts_proxy (manager);
- queue_reload_users (manager);
+ get_users (manager);
}
static void
@@ -1781,15 +1987,11 @@ gdm_user_manager_finalize (GObject *object)
manager->priv->ck_history_id = 0;
}
- if (manager->priv->reload_id > 0) {
- g_source_remove (manager->priv->reload_id);
- manager->priv->reload_id = 0;
- }
-
g_hash_table_destroy (manager->priv->sessions);
g_file_monitor_cancel (manager->priv->passwd_monitor);
g_hash_table_destroy (manager->priv->users_by_name);
+ g_hash_table_destroy (manager->priv->users_by_object_path);
g_file_monitor_cancel (manager->priv->shells_monitor);
g_hash_table_destroy (manager->priv->shells);
diff --git a/gui/simple-greeter/gdm-user.c b/gui/simple-greeter/gdm-user.c
index 7901fb0..ec60851 100644
--- a/gui/simple-greeter/gdm-user.c
+++ b/gui/simple-greeter/gdm-user.c
@@ -26,6 +26,9 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <dbus/dbus-glib.h>
+
+#include <glib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
@@ -41,6 +44,9 @@
#define MAX_FILE_SIZE 65536
#define MINIMAL_UID 100
+#define USER_ACCOUNTS_NAME "org.freedesktop.Accounts"
+#define USER_ACCOUNTS_INTERFACE "org.freedesktop.Accounts.User"
+
enum {
CHANGED,
SESSIONS_CHANGED,
@@ -50,12 +56,15 @@ enum {
struct _GdmUser {
GObject parent;
+ DBusGConnection *connection;
+ DBusGProxy *accounts_proxy;
+ gchar *object_path;
+
uid_t uid;
char *user_name;
char *real_name;
char *display_name;
- char *home_dir;
- char *shell;
+ gchar *icon_file;
GList *sessions;
gulong login_frequency;
};
@@ -66,6 +75,8 @@ typedef struct _GdmUserClass
} GdmUserClass;
static void gdm_user_finalize (GObject *object);
+static gboolean check_user_file (const char *filename,
+ gssize max_file_size);
static guint signals[LAST_SIGNAL] = { 0 };
@@ -159,10 +170,18 @@ gdm_user_class_init (GdmUserClass *class)
static void
gdm_user_init (GdmUser *user)
{
+ GError *error;
+
user->user_name = NULL;
user->real_name = NULL;
user->display_name = NULL;
user->sessions = NULL;
+
+ error = NULL;
+ user->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (user->connection == NULL) {
+ g_warning ("Couldn't connect to system bus: %s", error->message);
+ }
}
static void
@@ -175,6 +194,15 @@ gdm_user_finalize (GObject *object)
g_free (user->user_name);
g_free (user->real_name);
g_free (user->display_name);
+ g_free (user->icon_file);
+
+ if (user->accounts_proxy != NULL) {
+ g_object_unref (user->accounts_proxy);
+ }
+
+ if (user->connection != NULL) {
+ dbus_g_connection_unref (user->connection);
+ }
if (G_OBJECT_CLASS (gdm_user_parent_class)->finalize)
(*G_OBJECT_CLASS (gdm_user_parent_class)->finalize) (object);
@@ -198,6 +226,7 @@ _gdm_user_update_from_pwent (GdmUser *user,
g_return_if_fail (GDM_IS_USER (user));
g_return_if_fail (pwent != NULL);
+ g_return_if_fail (user->object_path == NULL);
changed = FALSE;
@@ -266,6 +295,23 @@ _gdm_user_update_from_pwent (GdmUser *user,
(pwent->pw_name &&
user->user_name &&
strcmp (user->user_name, pwent->pw_name) != 0)) {
+
+ g_free (user->icon_file);
+ user->icon_file = NULL;
+ if (pwent->pw_name != NULL) {
+ gboolean res;
+
+ user->icon_file = g_build_filename (GDM_CACHE_DIR, pwent->pw_name, "face", NULL);
+
+ res = check_user_file (user->icon_file,
+ MAX_FILE_SIZE);
+
+ if (!res) {
+ g_free (user->icon_file);
+ user->icon_file = g_build_filename (GLOBAL_FACEDIR, pwent->pw_name, NULL);
+ }
+ }
+
g_free (user->user_name);
user->user_name = g_strdup (pwent->pw_name);
changed = TRUE;
@@ -523,33 +569,6 @@ check_user_file (const char *filename,
return TRUE;
}
-static GdkPixbuf *
-render_icon_from_cache (GdmUser *user,
- int icon_size)
-{
- GdkPixbuf *retval;
- char *path;
- gboolean is_autofs;
- gboolean res;
- char *filesystem_type;
-
- path = g_build_filename (GDM_CACHE_DIR, user->user_name, "face", NULL);
- res = check_user_file (path,
- MAX_FILE_SIZE);
- if (res) {
- retval = gdk_pixbuf_new_from_file_at_size (path,
- icon_size,
- icon_size,
- NULL);
- } else {
- g_debug ("Could not access face icon %s", path);
- retval = NULL;
- }
- g_free (path);
-
- return retval;
-}
-
static void
rounded_rectangle (cairo_t *cr,
gdouble aspect,
@@ -783,55 +802,41 @@ gdm_user_render_icon (GdmUser *user,
{
GdkPixbuf *pixbuf;
GdkPixbuf *framed;
- char *path;
- char *tmp;
gboolean res;
+ GError *error;
g_return_val_if_fail (GDM_IS_USER (user), NULL);
g_return_val_if_fail (icon_size > 12, NULL);
- path = NULL;
-
- pixbuf = render_icon_from_cache (user, icon_size);
- if (pixbuf != NULL) {
- goto out;
- }
-
- /* Try ${GlobalFaceDir}/${username} */
- path = g_build_filename (GLOBAL_FACEDIR, user->user_name, NULL);
- res = check_user_file (path,
- MAX_FILE_SIZE);
- if (res) {
- pixbuf = gdk_pixbuf_new_from_file_at_size (path,
- icon_size,
- icon_size,
- NULL);
- } else {
- g_debug ("Could not access global face icon %s", path);
- pixbuf = NULL;
+ pixbuf = NULL;
+ if (user->icon_file) {
+ res = check_user_file (user->icon_file,
+ MAX_FILE_SIZE);
+ if (res) {
+ pixbuf = gdk_pixbuf_new_from_file_at_size (user->icon_file,
+ icon_size,
+ icon_size,
+ NULL);
+ } else {
+ pixbuf = NULL;
+ }
}
- g_free (path);
if (pixbuf != NULL) {
goto out;
}
- /* Finally, ${GlobalFaceDir}/${username}.png */
- tmp = g_strconcat (user->user_name, ".png", NULL);
- path = g_build_filename (GLOBAL_FACEDIR, tmp, NULL);
- g_free (tmp);
- res = check_user_file (path,
- MAX_FILE_SIZE);
- if (res) {
- pixbuf = gdk_pixbuf_new_from_file_at_size (path,
- icon_size,
- icon_size,
- NULL);
- } else {
- g_debug ("Could not access global face icon %s", path);
- pixbuf = NULL;
+ error = NULL;
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+
+ "stock_person",
+ icon_size,
+ GTK_ICON_LOOKUP_FORCE_SIZE,
+ &error);
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
- g_free (path);
out:
if (pixbuf != NULL) {
@@ -845,6 +850,22 @@ gdm_user_render_icon (GdmUser *user,
return pixbuf;
}
+G_CONST_RETURN gchar *
+gdm_user_get_icon_file (GdmUser *user)
+{
+ g_return_val_if_fail (GDM_IS_USER (user), NULL);
+
+ return user->icon_file;
+}
+
+G_CONST_RETURN gchar *
+gdm_user_get_object_path (GdmUser *user)
+{
+ g_return_val_if_fail (GDM_IS_USER (user), NULL);
+
+ return user->object_path;
+}
+
G_CONST_RETURN char *
gdm_user_get_primary_session_id (GdmUser *user)
{
@@ -874,3 +895,128 @@ out:
return primary_ssid;
}
+static void
+collect_props (const gchar *key,
+ const GValue *value,
+ GdmUser *user)
+{
+ gboolean handled = TRUE;
+
+ if (strcmp (key, "Uid") == 0) {
+ user->uid = g_value_get_uint64 (value);
+ } else if (strcmp (key, "UserName") == 0) {
+ g_free (user->user_name);
+ user->user_name = g_value_dup_string (value);
+ } else if (strcmp (key, "RealName") == 0) {
+ g_free (user->real_name);
+ user->real_name = g_value_dup_string (value);
+ } else if (strcmp (key, "AccountType") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "Email") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "Language") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "Location") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "LoginFrequency") == 0) {
+ user->login_frequency = g_value_get_uint64 (value);
+ } else if (strcmp (key, "IconFile") == 0) {
+ g_free (user->icon_file);
+ user->icon_file = g_value_dup_string (value);
+ } else if (strcmp (key, "Locked") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "AutomaticLogin") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "PasswordMode") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "PasswordHint") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "HomeDirectory") == 0) {
+ /* ignore */
+ } else if (strcmp (key, "Shell") == 0) {
+ /* ignore */
+ } else {
+ handled = FALSE;
+ }
+
+ if (!handled) {
+ g_debug ("unhandled property %s", key);
+ }
+}
+
+static gboolean
+update_info (GdmUser *user)
+{
+ GError *error;
+ DBusGProxy *proxy;
+ GHashTable *hash_table;
+ gboolean retval;
+
+ proxy = dbus_g_proxy_new_for_name (user->connection,
+ USER_ACCOUNTS_NAME,
+ user->object_path,
+ DBUS_INTERFACE_PROPERTIES);
+
+ error = NULL;
+ if (!dbus_g_proxy_call (proxy,
+ "GetAll",
+ &error,
+ G_TYPE_STRING,
+ USER_ACCOUNTS_INTERFACE,
+ G_TYPE_INVALID,
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+ &hash_table,
+ G_TYPE_INVALID)) {
+ g_debug ("Error calling GetAll() when retrieving properties for %s: %s", user->object_path, error->message);
+ g_error_free (error);
+ retval = FALSE;
+ goto out;
+ }
+ g_hash_table_foreach (hash_table, (GHFunc) collect_props, user);
+ g_hash_table_unref (hash_table);
+
+ retval = TRUE;
+ out:
+ g_object_unref (proxy);
+ return retval;
+}
+
+static void
+changed_handler (DBusGProxy *proxy,
+ gpointer *data)
+{
+ GdmUser *user = GDM_USER (data);
+
+ if (update_info (user)) {
+ g_signal_emit (user, signals[CHANGED], 0);
+ }
+}
+
+GdmUser *
+gdm_user_new_from_object_path (const gchar *object_path)
+{
+ GdmUser *user;
+
+ user = (GdmUser *)g_object_new (GDM_TYPE_USER, NULL);
+ user->object_path = g_strdup (object_path);
+
+ user->accounts_proxy = dbus_g_proxy_new_for_name (user->connection,
+ USER_ACCOUNTS_NAME,
+ user->object_path,
+ USER_ACCOUNTS_INTERFACE);
+ dbus_g_proxy_set_default_timeout (user->accounts_proxy, INT_MAX);
+ dbus_g_proxy_add_signal (user->accounts_proxy, "Changed", G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (user->accounts_proxy, "Changed",
+ G_CALLBACK (changed_handler), user, NULL);
+
+ if (!update_info (user)) {
+ goto error;
+ }
+
+ return user;
+
+ error:
+ g_object_unref (user);
+ return NULL;
+}
diff --git a/gui/simple-greeter/gdm-user.h b/gui/simple-greeter/gdm-user.h
index 6b51ffb..8514f2f 100644
--- a/gui/simple-greeter/gdm-user.h
+++ b/gui/simple-greeter/gdm-user.h
@@ -39,6 +39,9 @@ typedef struct _GdmUser GdmUser;
GType gdm_user_get_type (void) G_GNUC_CONST;
+GdmUser *gdm_user_new_from_object_path (const gchar *path);
+const char *gdm_user_get_object_path (GdmUser *user);
+
uid_t gdm_user_get_uid (GdmUser *user);
G_CONST_RETURN char *gdm_user_get_user_name (GdmUser *user);
G_CONST_RETURN char *gdm_user_get_real_name (GdmUser *user);
@@ -46,6 +49,7 @@ G_CONST_RETURN char *gdm_user_get_display_name (GdmUser *user);
guint gdm_user_get_num_sessions (GdmUser *user);
gboolean gdm_user_is_logged_in (GdmUser *user);
gulong gdm_user_get_login_frequency (GdmUser *user);
+G_CONST_RETURN char *gdm_user_get_icon_file (GdmUser *user);
G_CONST_RETURN char *gdm_user_get_primary_session_id (GdmUser *user);
GdkPixbuf *gdm_user_render_icon (GdmUser *user,
diff --git a/gui/user-switch-applet/applet.c b/gui/user-switch-applet/applet.c
index 89c2b69..436207d 100644
--- a/gui/user-switch-applet/applet.c
+++ b/gui/user-switch-applet/applet.c
@@ -800,9 +800,12 @@ on_account_activate (GtkMenuItem *item,
GdkScreen *screen;
gboolean res;
- args[0] = g_find_program_in_path ("gnome-about-me");
+ args[0] = g_find_program_in_path ("accounts-dialog");
if (args[0] == NULL) {
- return;
+ args[0] = g_find_program_in_path ("gnome-about-me");
+ if (args[0] == NULL) {
+ return;
+ }
}
args[1] = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]