[evolution-data-server] Bug #678843 - May re-prompt password on account re-enable
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #678843 - May re-prompt password on account re-enable
- Date: Mon, 12 May 2014 17:44:31 +0000 (UTC)
commit 128bde8d84d99371fa29752a0571a05ff83fc96c
Author: Milan Crha <mcrha redhat com>
Date: Mon May 12 19:44:06 2014 +0200
Bug #678843 - May re-prompt password on account re-enable
libedataserver/e-source.c | 135 +++++++++++++++++++++++++++++++++++++++++++++
libedataserver/e-source.h | 11 ++++
2 files changed, 146 insertions(+), 0 deletions(-)
---
diff --git a/libedataserver/e-source.c b/libedataserver/e-source.c
index d2ae40d..ce2dbb1 100644
--- a/libedataserver/e-source.c
+++ b/libedataserver/e-source.c
@@ -3984,3 +3984,138 @@ e_source_delete_password_finish (ESource *source,
return g_task_propagate_boolean (G_TASK (result), error);
}
+/**
+ * e_source_allow_auth_prompt_sync:
+ * @source: an #ESource
+ * @cancellable: optional #GCancellable object, or %NULL
+ * @error: return location for a #GError, or %NULL
+ *
+ * Tells the source registry that it can ask for passwords, if necessary.
+ * Password prompts are disabled automatically when a user cancels
+ * the password prompt. This function is to reverse the effect. It does
+ * nothing, if the password prompt is not disabled.
+ *
+ * If an error occurs, the function sets @error and returns %FALSE.
+ *
+ * Returns: %TRUE on success, %FALSE on error
+ *
+ * Since: 3.14
+ **/
+gboolean
+e_source_allow_auth_prompt_sync (ESource *source,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GDBusObject *dbus_object;
+ EDBusSource *dbus_source = NULL;
+ GError *local_error = NULL;
+
+ g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
+
+ dbus_object = e_source_ref_dbus_object (source);
+ if (dbus_object != NULL) {
+ dbus_source = e_dbus_object_get_source (E_DBUS_OBJECT (dbus_object));
+ g_object_unref (dbus_object);
+ }
+
+ if (!dbus_source) {
+ g_warn_if_fail (dbus_source != NULL);
+ return FALSE;
+ }
+
+ e_dbus_source_call_allow_auth_prompt_sync (dbus_source, cancellable, &local_error);
+
+ g_object_unref (dbus_source);
+
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+source_allow_auth_prompt_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
+{
+ gboolean success;
+ GError *local_error = NULL;
+
+ success = e_source_allow_auth_prompt_sync (
+ E_SOURCE (source_object),
+ cancellable, &local_error);
+
+ if (local_error != NULL) {
+ g_task_return_error (task, local_error);
+ } else {
+ g_task_return_boolean (task, success);
+ }
+}
+
+/**
+ * e_source_allow_auth_prompt:
+ * @source: an #ESource
+ * @cancellable: optional #GCancellable object, or %NULL
+ * @callback: a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: data to pass to the callback function
+ *
+ * Asynchronously tells the source registry that it can ask for passwords,
+ * if necessary. Password prompts are disabled automatically when a user cancels
+ * the password prompt. This function is to reverse the effect. It does
+ * nothing, if the password prompt is not disabled.
+ *
+ * When the operation is finished, @callback will be called. You can then
+ * call e_source_allow_auth_prompt_finish() to get the result of the operation.
+ *
+ * Since: 3.14
+ **/
+void
+e_source_allow_auth_prompt (ESource *source,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GTask *task;
+
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ task = g_task_new (source, cancellable, callback, user_data);
+ g_task_set_source_tag (task, e_source_allow_auth_prompt);
+
+ g_task_run_in_thread (task, source_allow_auth_prompt_thread);
+
+ g_object_unref (task);
+}
+
+/**
+ * e_source_allow_auth_prompt_finish:
+ * @source: an #ESource
+ * @result: a #GAsyncResult
+ * @error: return location for a #GError, or %NULL
+ *
+ * Finishes the operation started with e_source_allow_auth_prompt().
+ *
+ * If an error occurs, the function sets @error and returns %FALSE.
+ *
+ * Returns: %TRUE on success, %FALSE on error
+ *
+ * Since: 3.14
+ **/
+gboolean
+e_source_allow_auth_prompt_finish (ESource *source,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
+ g_return_val_if_fail (g_task_is_valid (result, source), FALSE);
+
+ g_return_val_if_fail (
+ g_async_result_is_tagged (
+ result, e_source_allow_auth_prompt), FALSE);
+
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
diff --git a/libedataserver/e-source.h b/libedataserver/e-source.h
index 1f659e7..2d3c307 100644
--- a/libedataserver/e-source.h
+++ b/libedataserver/e-source.h
@@ -282,6 +282,17 @@ void e_source_delete_password (ESource *source,
gboolean e_source_delete_password_finish (ESource *source,
GAsyncResult *result,
GError **error);
+gboolean e_source_allow_auth_prompt_sync (ESource *source,
+ GCancellable *cancellable,
+ GError **error);
+void e_source_allow_auth_prompt (ESource *source,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean e_source_allow_auth_prompt_finish
+ (ESource *source,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]