From f74a085accd8bbf3901f51b401b55745ae5486da Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 13 Jun 2012 13:30:46 +0200 Subject: [PATCH 1/2] Rename user_local_xxxx() to user_xxxx() * Since User* applies to remote users too, and the 'local' terminology can be confusing. https://bugs.freedesktop.org/show_bug.cgi?id=51037 --- src/daemon.c | 50 +++++++++++++++--------------- src/user.c | 99 ++++++++++++++++++++++++++++++------------------------------ src/user.h | 22 +++++++------- 3 files changed, 86 insertions(+), 85 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index b2587b6..a298a0b 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -375,7 +375,7 @@ entry_generator_cachedir (GHashTable *users, filename = g_build_filename (USERDIR, name, NULL); key_file = g_key_file_new (); if (g_key_file_load_from_file (key_file, filename, 0, NULL)) - user_local_update_from_keyfile (user, key_file); + user_update_from_keyfile (user, key_file); g_key_file_free (key_file); g_free (filename); } @@ -413,17 +413,17 @@ load_entries (Daemon *daemon, user = g_hash_table_lookup (daemon->priv->users, pwent->pw_name); if (user == NULL) { - user = user_local_new (daemon, pwent->pw_uid); + user = user_new (daemon, pwent->pw_uid); } else { g_object_ref (user); } /* freeze & update users not already in the new list */ g_object_freeze_notify (G_OBJECT (user)); - user_local_update_from_pwent (user, pwent); + user_update_from_pwent (user, pwent); - g_hash_table_insert (users, g_strdup (user_local_get_user_name (user)), user); - g_debug ("loaded user: %s", user_local_get_user_name (user)); + g_hash_table_insert (users, g_strdup (user_get_user_name (user)), user); + g_debug ("loaded user: %s", user_get_user_name (user)); } /* Generator should have cleaned up */ @@ -466,9 +466,9 @@ reload_users (Daemon *daemon) g_hash_table_iter_init (&iter, old_users); while (g_hash_table_iter_next (&iter, &name, (gpointer *)&user)) { if (!g_hash_table_lookup (users, name)) { - user_local_unregister (user); + user_unregister (user); accounts_accounts_emit_user_deleted (ACCOUNTS_ACCOUNTS (daemon), - user_local_get_object_path (user)); + user_get_object_path (user)); } } @@ -476,9 +476,9 @@ reload_users (Daemon *daemon) g_hash_table_iter_init (&iter, users); while (g_hash_table_iter_next (&iter, &name, (gpointer *)&user)) { if (!g_hash_table_lookup (old_users, name)) { - user_local_register (user); + user_register (user); accounts_accounts_emit_user_added (ACCOUNTS_ACCOUNTS (daemon), - user_local_get_object_path (user)); + user_get_object_path (user)); } g_object_thaw_notify (G_OBJECT (user)); } @@ -784,15 +784,15 @@ add_new_user_for_pwent (Daemon *daemon, { User *user; - user = user_local_new (daemon, pwent->pw_uid); - user_local_update_from_pwent (user, pwent); - user_local_register (user); + user = user_new (daemon, pwent->pw_uid); + user_update_from_pwent (user, pwent); + user_register (user); g_hash_table_insert (daemon->priv->users, - g_strdup (user_local_get_user_name (user)), + g_strdup (user_get_user_name (user)), user); - accounts_accounts_emit_user_added (ACCOUNTS_ACCOUNTS (daemon), user_local_get_object_path (user)); + accounts_accounts_emit_user_added (ACCOUNTS_ACCOUNTS (daemon), user_get_object_path (user)); return user; } @@ -850,7 +850,7 @@ daemon_find_user_by_id (AccountsAccounts *accounts, user = daemon_local_find_user_by_id (daemon, uid); if (user) { - accounts_accounts_complete_find_user_by_id (NULL, context, user_local_get_object_path (user)); + accounts_accounts_complete_find_user_by_id (NULL, context, user_get_object_path (user)); } else { throw_error (context, ERROR_FAILED, "Failed to look up user with uid %d.", (int)uid); @@ -870,7 +870,7 @@ daemon_find_user_by_name (AccountsAccounts *accounts, user = daemon_local_find_user_by_name (daemon, name); if (user) { - accounts_accounts_complete_find_user_by_name (NULL, context, user_local_get_object_path (user)); + accounts_accounts_complete_find_user_by_name (NULL, context, user_get_object_path (user)); } else { throw_error (context, ERROR_FAILED, "Failed to look up user with name %s.", name); @@ -921,10 +921,10 @@ finish_list_cached_users (gpointer user_data) g_hash_table_iter_init (&iter, data->daemon->priv->users); while (g_hash_table_iter_next (&iter, (gpointer *)&name, (gpointer *)&user)) { - uid = user_local_get_uid (user); - shell = user_local_get_shell (user); + uid = user_get_uid (user); + shell = user_get_shell (user); - if (user_local_get_system_account (user)) { + if (user_get_system_account (user)) { g_debug ("user %s %ld is system account, so excluded\n", name, (long) uid); continue; } @@ -935,7 +935,7 @@ finish_list_cached_users (gpointer user_data) } g_debug ("user %s %ld not excluded\n", name, (long) uid); - g_ptr_array_add (object_paths, (gpointer) user_local_get_object_path (user)); + g_ptr_array_add (object_paths, (gpointer) user_get_object_path (user)); } g_ptr_array_add (object_paths, NULL); @@ -1040,7 +1040,7 @@ daemon_create_user_authorized_cb (Daemon *daemon, user = daemon_local_find_user_by_name (daemon, cd->user_name); - accounts_accounts_complete_create_user (NULL, context, user_local_get_object_path (user)); + accounts_accounts_complete_create_user (NULL, context, user_get_object_path (user)); } static gboolean @@ -1092,7 +1092,7 @@ daemon_cache_user_authorized_cb (Daemon *daemon, } /* Always use the canonical user name looked up */ - user_name = user_local_get_user_name (user); + user_name = user_get_user_name (user); filename = g_build_filename (USERDIR, user_name, NULL); if (!g_file_test (filename, G_FILE_TEST_EXISTS)) { @@ -1109,7 +1109,7 @@ daemon_cache_user_authorized_cb (Daemon *daemon, g_free (filename); - accounts_accounts_complete_cache_user (NULL, context, user_local_get_object_path (user)); + accounts_accounts_complete_cache_user (NULL, context, user_get_object_path (user)); } static gboolean @@ -1159,7 +1159,7 @@ daemon_uncache_user_authorized_cb (Daemon *daemon, } /* Always use the canonical user name looked up */ - user_name = user_local_get_user_name (user); + user_name = user_get_user_name (user); filename = g_build_filename (USERDIR, user_name, NULL); g_remove (filename); @@ -1476,7 +1476,7 @@ daemon_local_set_automatic_login (Daemon *daemon, return TRUE; } - if (!save_autologin (daemon, user_local_get_user_name (user), enabled, error)) { + if (!save_autologin (daemon, user_get_user_name (user), enabled, error)) { return FALSE; } diff --git a/src/user.c b/src/user.c index 9713ecd..0910232 100644 --- a/src/user.c +++ b/src/user.c @@ -141,8 +141,8 @@ account_type_from_pwent (struct passwd *pwent) } void -user_local_update_from_pwent (User *user, - struct passwd *pwent) +user_update_from_pwent (User *user, + struct passwd *pwent) { #ifdef HAVE_SHADOW_H struct spwd *spent; @@ -290,8 +290,8 @@ user_local_update_from_pwent (User *user, } void -user_local_update_from_keyfile (User *user, - GKeyFile *keyfile) +user_update_from_keyfile (User *user, + GKeyFile *keyfile) { gchar *s; @@ -338,8 +338,8 @@ user_local_update_from_keyfile (User *user, } static void -user_local_save_to_keyfile (User *user, - GKeyFile *keyfile) +user_save_to_keyfile (User *user, + GKeyFile *keyfile) { if (user->email) g_key_file_set_string (keyfile, "User", "Email", user->email); @@ -369,7 +369,7 @@ save_extra_data (User *user) GError *error; keyfile = g_key_file_new (); - user_local_save_to_keyfile (user, keyfile); + user_save_to_keyfile (user, keyfile); error = NULL; data = g_key_file_to_data (keyfile, NULL, &error); @@ -418,7 +418,7 @@ compute_object_path (User *user) } void -user_local_register (User *user) +user_register (User *user) { GError *error = NULL; @@ -446,13 +446,14 @@ user_local_register (User *user) } void -user_local_unregister (User *user) +user_unregister (User *user) { g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (user)); } User * -user_local_new (Daemon *daemon, uid_t uid) +user_new (Daemon *daemon, + uid_t uid) { User *user; @@ -464,31 +465,31 @@ user_local_new (Daemon *daemon, uid_t uid) } const gchar * -user_local_get_user_name (User *user) +user_get_user_name (User *user) { return user->user_name; } gboolean -user_local_get_system_account (User *user) +user_get_system_account (User *user) { return user->system_account; } const gchar * -user_local_get_object_path (User *user) +user_get_object_path (User *user) { return user->object_path; } uid_t -user_local_get_uid (User *user) +user_get_uid (User *user) { return user->uid; } const gchar * -user_local_get_shell(User *user) +user_get_shell(User *user) { return user->shell; } @@ -1599,73 +1600,73 @@ user_set_automatic_login (AccountsUser *auser, } static guint64 -user_get_uid (AccountsUser *user) +user_real_get_uid (AccountsUser *user) { return (guint64) USER (user)->uid; } static const gchar * -user_get_user_name (AccountsUser *user) +user_real_get_user_name (AccountsUser *user) { return USER (user)->user_name; } static const gchar * -user_get_real_name (AccountsUser *user) +user_real_get_real_name (AccountsUser *user) { return USER (user)->real_name; } static gint -user_get_account_type (AccountsUser *user) +user_real_get_account_type (AccountsUser *user) { return (gint) USER (user)->account_type; } static const gchar * -user_get_home_directory (AccountsUser *user) +user_real_get_home_directory (AccountsUser *user) { return USER (user)->home_dir; } static const gchar * -user_get_shell (AccountsUser *user) +user_real_get_shell (AccountsUser *user) { return USER (user)->shell; } static const gchar * -user_get_email (AccountsUser *user) +user_real_get_email (AccountsUser *user) { return USER (user)->email; } static const gchar * -user_get_language (AccountsUser *user) +user_real_get_language (AccountsUser *user) { return USER (user)->language; } static const gchar * -user_get_xsession (AccountsUser *user) +user_real_get_xsession (AccountsUser *user) { return USER (user)->x_session; } static const gchar * -user_get_location (AccountsUser *user) +user_real_get_location (AccountsUser *user) { return USER (user)->location; } static guint64 -user_get_login_frequency (AccountsUser *user) +user_real_get_login_frequency (AccountsUser *user) { return USER (user)->login_frequency; } static const gchar * -user_get_icon_file (AccountsUser *user) +user_real_get_icon_file (AccountsUser *user) { if (USER (user)->icon_file) return USER (user)->icon_file; @@ -1674,31 +1675,31 @@ user_get_icon_file (AccountsUser *user) } static gboolean -user_get_locked (AccountsUser *user) +user_real_get_locked (AccountsUser *user) { return USER (user)->locked; } static gint -user_get_password_mode (AccountsUser *user) +user_real_get_password_mode (AccountsUser *user) { return USER (user)->password_mode; } static const gchar * -user_get_password_hint (AccountsUser *user) +user_real_get_password_hint (AccountsUser *user) { return USER (user)->password_hint; } static gboolean -user_get_automatic_login (AccountsUser *user) +user_real_get_automatic_login (AccountsUser *user) { return USER (user)->automatic_login; } static gboolean -user_get_system_account (AccountsUser *user) +user_real_get_system_account (AccountsUser *user) { return USER (user)->system_account; } @@ -1867,23 +1868,23 @@ user_accounts_user_iface_init (AccountsUserIface *iface) iface->handle_set_shell = user_set_shell; iface->handle_set_user_name = user_set_user_name; iface->handle_set_xsession = user_set_x_session; - iface->get_uid = user_get_uid; - iface->get_user_name = user_get_user_name; - iface->get_real_name = user_get_real_name; - iface->get_account_type = user_get_account_type; - iface->get_home_directory = user_get_home_directory; - iface->get_shell = user_get_shell; - iface->get_email = user_get_email; - iface->get_language = user_get_language; - iface->get_xsession = user_get_xsession; - iface->get_location = user_get_location; - iface->get_login_frequency = user_get_login_frequency; - iface->get_icon_file = user_get_icon_file; - iface->get_locked = user_get_locked; - iface->get_password_mode = user_get_password_mode; - iface->get_password_hint = user_get_password_hint; - iface->get_automatic_login = user_get_automatic_login; - iface->get_system_account = user_get_system_account; + iface->get_uid = user_real_get_uid; + iface->get_user_name = user_real_get_user_name; + iface->get_real_name = user_real_get_real_name; + iface->get_account_type = user_real_get_account_type; + iface->get_home_directory = user_real_get_home_directory; + iface->get_shell = user_real_get_shell; + iface->get_email = user_real_get_email; + iface->get_language = user_real_get_language; + iface->get_xsession = user_real_get_xsession; + iface->get_location = user_real_get_location; + iface->get_login_frequency = user_real_get_login_frequency; + iface->get_icon_file = user_real_get_icon_file; + iface->get_locked = user_real_get_locked; + iface->get_password_mode = user_real_get_password_mode; + iface->get_password_hint = user_real_get_password_hint; + iface->get_automatic_login = user_real_get_automatic_login; + iface->get_system_account = user_real_get_system_account; } static void diff --git a/src/user.h b/src/user.h index ffae648..f85c815 100644 --- a/src/user.h +++ b/src/user.h @@ -49,23 +49,23 @@ typedef enum { /* local methods */ -GType user_get_type (void) G_GNUC_CONST; -User *user_local_new (Daemon *daemon, +GType user_get_type (void) G_GNUC_CONST; +User * user_new (Daemon *daemon, uid_t uid); -void user_local_update_from_pwent (User *user, +void user_update_from_pwent (User *user, struct passwd *pwent); -void user_local_update_from_keyfile (User *user, +void user_update_from_keyfile (User *user, GKeyFile *keyfile); -void user_local_register (User *user); -void user_local_unregister (User *user); +void user_register (User *user); +void user_unregister (User *user); -const gchar *user_local_get_user_name (User *user); -gboolean user_local_get_system_account (User *user); -const gchar *user_local_get_object_path (User *user); -uid_t user_local_get_uid (User *user); -const gchar *user_local_get_shell (User *user); +const gchar * user_get_user_name (User *user); +gboolean user_get_system_account (User *user); +const gchar * user_get_object_path (User *user); +uid_t user_get_uid (User *user); +const gchar * user_get_shell (User *user); G_END_DECLS -- 1.7.11.4