From 564dc2f4a923c6e2c45a9920776ae93a97bebede Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Thu, 18 Sep 2014 18:55:36 +0200 Subject: [PATCH] Add asynchronous api for user uncaching It is needed for deleting enterprise accounts in gnome-control-center. See https://bugzilla.gnome.org/show_bug.cgi?id=727871 for details. --- src/libaccountsservice/act-user-manager.c | 83 +++++++++++++++++++++++++++++++ src/libaccountsservice/act-user-manager.h | 8 +++ 2 files changed, 91 insertions(+) diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c index c1c6f5a..e7c3305 100644 --- a/src/libaccountsservice/act-user-manager.c +++ b/src/libaccountsservice/act-user-manager.c @@ -3353,6 +3353,89 @@ act_user_manager_uncache_user (ActUserManager *manager, return TRUE; } +/* + * act_user_manager_uncache_user_async: + * @manager: a #ActUserManager + * @username: a unix user name + * @cancellable: (allow-none): optional #GCancellable object, + * %NULL to ignore + * @callback: (scope async): a #GAsyncReadyCallback to call + * when the request is satisfied + * @user_data: (closure): the data to pass to @callback + * + * Asynchronously uncaches a user account. + * + * For more details, see act_user_manager_uncache_user(), which + * is the synchronous version of this call. + * + * Since: 0.6.39 + */ +void +act_user_manager_uncache_user_async (ActUserManager *manager, + const char *username, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *res; + + g_return_if_fail (ACT_IS_USER_MANAGER (manager)); + g_return_if_fail (manager->priv->accounts_proxy != NULL); + + g_debug ("ActUserManager: Uncaching user (async) '%s'", username); + + res = g_simple_async_result_new (G_OBJECT (manager), + callback, user_data, + act_user_manager_uncache_user_async); + g_simple_async_result_set_check_cancellable (res, cancellable); + + accounts_accounts_call_uncache_user (manager->priv->accounts_proxy, + username, + cancellable, + act_user_manager_async_complete_handler, res); +} + +/** + * act_user_manager_uncache_user_finish: + * @manager: a #ActUserManager + * @result: a #GAsyncResult + * @error: a #GError + * + * Finishes an asynchronous user uncaching. + * + * See act_user_manager_uncache_user_async(). + * + * Returns: %TRUE if the user account was successfully uncached + * + * Since: 0.6.39 + */ +gboolean +act_user_manager_uncache_user_finish (ActUserManager *manager, + GAsyncResult *result, + GError **error) +{ + GAsyncResult *inner_result; + gboolean success; + GSimpleAsyncResult *res; + GError *remote_error = NULL; + + g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (manager), act_user_manager_uncache_user_async), FALSE); + + res = G_SIMPLE_ASYNC_RESULT (result); + inner_result = g_simple_async_result_get_op_res_gpointer (res); + g_assert (inner_result); + + success = accounts_accounts_call_uncache_user_finish (manager->priv->accounts_proxy, + inner_result, &remote_error); + + if (remote_error) { + g_dbus_error_strip_remote_error (remote_error); + g_propagate_error (error, remote_error); + } + + return success; +} + /** * act_user_manager_delete_user: * @manager: a #ActUserManager diff --git a/src/libaccountsservice/act-user-manager.h b/src/libaccountsservice/act-user-manager.h index 3d91f83..ae5fd2e 100644 --- a/src/libaccountsservice/act-user-manager.h +++ b/src/libaccountsservice/act-user-manager.h @@ -122,6 +122,14 @@ ActUser * act_user_manager_cache_user_finish (ActUserManager * gboolean act_user_manager_uncache_user (ActUserManager *manager, const char *username, GError **error); +void act_user_manager_uncache_user_async (ActUserManager *manager, + const gchar *username, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean act_user_manager_uncache_user_finish (ActUserManager *manager, + GAsyncResult *result, + GError **error); gboolean act_user_manager_delete_user (ActUserManager *manager, ActUser *user, -- 1.9.3