aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/addressbook.error.xml5
-rw-r--r--addressbook/gui/widgets/e-addressbook-selector.c2
-rw-r--r--calendar/calendar.error.xml18
-rw-r--r--calendar/gui/e-calendar-selector.c4
-rw-r--r--calendar/gui/e-memo-list-selector.c4
-rw-r--r--calendar/gui/e-task-list-selector.c4
-rw-r--r--e-util/e-client-cache.c20
-rw-r--r--e-util/e-client-selector.c94
-rw-r--r--e-util/e-client-selector.h2
-rw-r--r--e-util/e-misc-utils.c66
-rw-r--r--e-util/e-misc-utils.h14
-rw-r--r--mail/e-mail-account-store.c37
-rw-r--r--modules/addressbook/e-book-shell-sidebar.c3
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c129
-rw-r--r--modules/addressbook/e-book-shell-view-private.c2
-rw-r--r--modules/calendar/e-cal-shell-sidebar.c4
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c12
-rw-r--r--modules/calendar/e-cal-shell-view.c83
-rw-r--r--modules/calendar/e-cal-shell-view.h5
-rw-r--r--modules/calendar/e-memo-shell-sidebar.c4
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c12
-rw-r--r--modules/calendar/e-task-shell-sidebar.c4
-rw-r--r--modules/calendar/e-task-shell-view-actions.c12
-rw-r--r--modules/mail/e-mail-shell-view-actions.c69
24 files changed, 533 insertions, 76 deletions
diff --git a/addressbook/addressbook.error.xml b/addressbook/addressbook.error.xml
index 18e00d8a75..1e078575cb 100644
--- a/addressbook/addressbook.error.xml
+++ b/addressbook/addressbook.error.xml
@@ -65,6 +65,11 @@
<secondary>{0}</secondary>
</error>
+ <error id="refresh-error" type="error">
+ <_primary>Failed to refresh address book '{0}'</_primary>
+ <secondary>{1}</secondary>
+ </error>
+
<error id="prompt-save" type="question" default="GTK_RESPONSE_YES">
<_primary>Would you like to save your changes?</_primary>
<_secondary>You have made modifications to this contact. Do you want to save these changes?</_secondary>
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index 4b044867c9..f90f167890 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.c
+++ b/addressbook/gui/widgets/e-addressbook-selector.c
@@ -327,7 +327,7 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
merge_context->pending_adds = TRUE;
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), destination, NULL,
+ E_CLIENT_SELECTOR (selector), destination, FALSE, NULL,
target_client_connect_cb, merge_context);
return TRUE;
diff --git a/calendar/calendar.error.xml b/calendar/calendar.error.xml
index 9affa1c4d3..0fecc1c7b1 100644
--- a/calendar/calendar.error.xml
+++ b/calendar/calendar.error.xml
@@ -373,4 +373,22 @@
<_primary>Moving a memo into the memo list '{0}'</_primary>
</error>
+ <error id="refresh-error-events" type="error">
+ <!-- Translators: {0} is the name of the calendar. -->
+ <_primary>Failed to refresh calendar '{0}'</_primary>
+ <secondary>{1}</secondary>
+ </error>
+
+ <error id="refresh-error-tasks" type="error">
+ <!-- Translators: {0} is the name of the task list. -->
+ <_primary>Failed to refresh task list '{0}'</_primary>
+ <secondary>{1}</secondary>
+ </error>
+
+ <error id="refresh-error-memos" type="error">
+ <!-- Translators: {0} is the name of the memo list. -->
+ <_primary>Failed to refresh memo list '{0}'</_primary>
+ <secondary>{1}</secondary>
+ </error>
+
</error-list>
diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c
index cb3bac9e39..87d4a5d40c 100644
--- a/calendar/gui/e-calendar-selector.c
+++ b/calendar/gui/e-calendar-selector.c
@@ -214,7 +214,7 @@ source_client_connect_cb (GObject *source_object,
titd->src_client = client;
e_client_selector_get_client (
- E_CLIENT_SELECTOR (titd->selector), titd->destination, cancellable,
+ E_CLIENT_SELECTOR (titd->selector), titd->destination, FALSE, cancellable,
destination_client_connect_cb, titd);
return;
@@ -376,7 +376,7 @@ calendar_selector_data_dropped (ESourceSelector *selector,
titd->do_copy = do_copy;
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source, cancellable,
+ E_CLIENT_SELECTOR (selector), source, FALSE, cancellable,
source_client_connect_cb, titd);
exit:
diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c
index b83d383ec1..4246c6b7ab 100644
--- a/calendar/gui/e-memo-list-selector.c
+++ b/calendar/gui/e-memo-list-selector.c
@@ -220,7 +220,7 @@ memo_list_selector_process_data (ESourceSelector *selector,
if (source != NULL) {
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source, NULL,
+ E_CLIENT_SELECTOR (selector), source, FALSE, NULL,
client_connect_cb, g_strdup (old_uid));
g_object_unref (source);
}
@@ -388,7 +388,7 @@ memo_list_selector_data_dropped (ESourceSelector *selector,
dd->list = cal_comp_selection_get_string_list (selection_data);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), destination, NULL,
+ E_CLIENT_SELECTOR (selector), destination, FALSE, NULL,
client_connect_for_drop_cb, dd);
return TRUE;
diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c
index f6198f47d9..23b82e642f 100644
--- a/calendar/gui/e-task-list-selector.c
+++ b/calendar/gui/e-task-list-selector.c
@@ -217,7 +217,7 @@ task_list_selector_process_data (ESourceSelector *selector,
if (source != NULL) {
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source, NULL,
+ E_CLIENT_SELECTOR (selector), source, FALSE, NULL,
client_connect_cb, g_strdup (old_uid));
g_object_unref (source);
}
@@ -372,7 +372,7 @@ task_list_selector_data_dropped (ESourceSelector *selector,
dd->list = cal_comp_selection_get_string_list (selection_data);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), destination, NULL,
+ E_CLIENT_SELECTOR (selector), destination, FALSE, NULL,
client_connect_for_drop_cb, dd);
return TRUE;
diff --git a/e-util/e-client-cache.c b/e-util/e-client-cache.c
index 215c470a88..19bfa8efd6 100644
--- a/e-util/e-client-cache.c
+++ b/e-util/e-client-cache.c
@@ -656,6 +656,21 @@ client_cache_cal_connect_cb (GObject *source_object,
}
static void
+client_cache_source_allow_auth_prompt_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *local_error = NULL;
+
+ e_source_allow_auth_prompt_finish (E_SOURCE (source_object), result, &local_error);
+
+ if (local_error) {
+ g_debug ("%s: Failed with: %s", G_STRFUNC, local_error->message);
+ g_clear_error (&local_error);
+ }
+}
+
+static void
client_cache_source_removed_cb (ESourceRegistry *registry,
ESource *source,
GWeakRef *weak_ref)
@@ -680,6 +695,11 @@ client_cache_source_disabled_cb (ESourceRegistry *registry,
client_cache = g_weak_ref_get (weak_ref);
if (client_cache != NULL) {
+ /* There is not much interest in the result, it just
+ makes sure a password prompt will be shown the next
+ time it is needed. */
+ e_source_allow_auth_prompt (source, NULL, client_cache_source_allow_auth_prompt_done_cb, NULL);
+
client_ht_remove (client_cache, source);
g_object_unref (client_cache);
}
diff --git a/e-util/e-client-selector.c b/e-util/e-client-selector.c
index 74e875cb5f..01ff2d432d 100644
--- a/e-util/e-client-selector.c
+++ b/e-util/e-client-selector.c
@@ -515,6 +515,7 @@ e_client_selector_ref_client_cache (EClientSelector *selector)
* e_client_selector_get_client_sync:
* @selector: an #ESourceSelector
* @source: an #ESource
+ * @call_allow_auth_prompt: whether call allow-auth-prompt on the source first
* @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL
*
@@ -539,6 +540,7 @@ e_client_selector_ref_client_cache (EClientSelector *selector)
EClient *
e_client_selector_get_client_sync (EClientSelector *selector,
ESource *source,
+ gboolean call_allow_auth_prompt,
GCancellable *cancellable,
GError **error)
{
@@ -552,7 +554,7 @@ e_client_selector_get_client_sync (EClientSelector *selector,
closure = e_async_closure_new ();
e_client_selector_get_client (
- selector, source, cancellable,
+ selector, source, call_allow_auth_prompt, cancellable,
e_async_closure_callback, closure);
result = e_async_closure_wait (closure);
@@ -600,10 +602,64 @@ client_selector_get_client_done_cb (GObject *source_object,
g_object_unref (simple);
}
+typedef struct _AllowAuthPromptData
+{
+ EClientSelector *selector;
+ GSimpleAsyncResult *simple;
+ GCancellable *cancellable;
+} AllowAuthPromptData;
+
+static void
+client_selector_allow_auth_prompt_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ AllowAuthPromptData *data;
+ ESource *source;
+ GError *local_error = NULL;
+
+ g_return_if_fail (E_IS_SOURCE (source_object));
+ g_return_if_fail (user_data != NULL);
+
+ data = user_data;
+ source = E_SOURCE (source_object);
+
+ e_source_allow_auth_prompt_finish (source, result, &local_error);
+
+ if (local_error) {
+ g_simple_async_result_take_error (data->simple, local_error);
+ g_simple_async_result_complete (data->simple);
+
+ g_clear_error (&local_error);
+ } else {
+ EClientCache *client_cache;
+ const gchar *extension_name;
+
+ extension_name = e_source_selector_get_extension_name (
+ E_SOURCE_SELECTOR (data->selector));
+
+ client_cache = e_client_selector_ref_client_cache (data->selector);
+
+ e_client_cache_get_client (
+ client_cache, source,
+ extension_name, data->cancellable,
+ client_selector_get_client_done_cb,
+ g_object_ref (data->simple));
+
+ g_object_unref (client_cache);
+ }
+
+ g_clear_object (&data->selector);
+ g_clear_object (&data->simple);
+ g_clear_object (&data->cancellable);
+ g_free (data);
+}
+
/**
* e_client_selector_get_client:
* @selector: an #ESourceSelector
* @source: an #ESource
+ * @call_allow_auth_prompt: whether call allow-auth-prompt on the source first
* @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
@@ -627,13 +683,12 @@ client_selector_get_client_done_cb (GObject *source_object,
void
e_client_selector_get_client (EClientSelector *selector,
ESource *source,
+ gboolean call_allow_auth_prompt,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- EClientCache *client_cache;
GSimpleAsyncResult *simple;
- const gchar *extension_name;
g_return_if_fail (E_IS_CLIENT_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
@@ -644,18 +699,33 @@ e_client_selector_get_client (EClientSelector *selector,
g_simple_async_result_set_check_cancellable (simple, cancellable);
- extension_name = e_source_selector_get_extension_name (
- E_SOURCE_SELECTOR (selector));
+ if (call_allow_auth_prompt) {
+ AllowAuthPromptData *data;
- client_cache = e_client_selector_ref_client_cache (selector);
+ data = g_new0 (AllowAuthPromptData, 1);
+ data->selector = g_object_ref (selector);
+ data->simple = g_object_ref (simple);
+ data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
- e_client_cache_get_client (
- client_cache, source,
- extension_name, cancellable,
- client_selector_get_client_done_cb,
- g_object_ref (simple));
+ e_source_allow_auth_prompt (source, cancellable,
+ client_selector_allow_auth_prompt_done_cb, data);
+ } else {
+ EClientCache *client_cache;
+ const gchar *extension_name;
- g_object_unref (client_cache);
+ extension_name = e_source_selector_get_extension_name (
+ E_SOURCE_SELECTOR (selector));
+
+ client_cache = e_client_selector_ref_client_cache (selector);
+
+ e_client_cache_get_client (
+ client_cache, source,
+ extension_name, cancellable,
+ client_selector_get_client_done_cb,
+ g_object_ref (simple));
+
+ g_object_unref (client_cache);
+ }
g_object_unref (simple);
}
diff --git a/e-util/e-client-selector.h b/e-util/e-client-selector.h
index baf1753acc..c8d3e7108e 100644
--- a/e-util/e-client-selector.h
+++ b/e-util/e-client-selector.h
@@ -67,10 +67,12 @@ EClientCache * e_client_selector_ref_client_cache
EClient * e_client_selector_get_client_sync
(EClientSelector *selector,
ESource *source,
+ gboolean call_allow_auth_prompt,
GCancellable *cancellable,
GError **error);
void e_client_selector_get_client (EClientSelector *selector,
ESource *source,
+ gboolean call_allow_auth_prompt,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c
index 0f935d49af..3a52292af4 100644
--- a/e-util/e-misc-utils.c
+++ b/e-util/e-misc-utils.c
@@ -1964,6 +1964,72 @@ e_util_dup_searchable_categories (void)
return g_list_reverse (res);
}
+gboolean
+e_util_allow_auth_prompt_and_refresh_client_sync (EClient *client,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
+
+ if (!e_source_allow_auth_prompt_sync (e_client_get_source (client), cancellable, error))
+ return FALSE;
+
+ return e_client_refresh_sync (client, cancellable, error);
+}
+
+static void
+util_allow_auth_prompt_and_refresh_client_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
+{
+ gboolean success;
+ GError *local_error = NULL;
+
+ success = e_util_allow_auth_prompt_and_refresh_client_sync (
+ E_CLIENT (source_object),
+ cancellable, &local_error);
+
+ if (local_error != NULL) {
+ g_task_return_error (task, local_error);
+ } else {
+ g_task_return_boolean (task, success);
+ }
+}
+
+void
+e_util_allow_auth_prompt_and_refresh_client (EClient *client,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GTask *task;
+
+ g_return_if_fail (E_IS_CLIENT (client));
+
+ task = g_task_new (client, cancellable, callback, user_data);
+ g_task_set_source_tag (task, e_util_allow_auth_prompt_and_refresh_client);
+
+ g_task_run_in_thread (task, util_allow_auth_prompt_and_refresh_client_thread);
+
+ g_object_unref (task);
+}
+
+gboolean
+e_util_allow_auth_prompt_and_refresh_client_finish (EClient *client,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (g_task_is_valid (result, client), FALSE);
+
+ g_return_val_if_fail (
+ g_async_result_is_tagged (
+ result, e_util_allow_auth_prompt_and_refresh_client), FALSE);
+
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
+
/**
* e_binding_transform_color_to_string:
* @binding: a #GBinding
diff --git a/e-util/e-misc-utils.h b/e-util/e-misc-utils.h
index f5b6c29bcd..33d8978a31 100644
--- a/e-util/e-misc-utils.h
+++ b/e-util/e-misc-utils.h
@@ -162,6 +162,20 @@ GSList * e_util_get_category_filter_options
(void);
GList * e_util_dup_searchable_categories (void);
+gboolean e_util_allow_auth_prompt_and_refresh_client_sync
+ (EClient *client,
+ GCancellable *cancellable,
+ GError **error);
+void e_util_allow_auth_prompt_and_refresh_client
+ (EClient *client,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean e_util_allow_auth_prompt_and_refresh_client_finish
+ (EClient *client,
+ GAsyncResult *result,
+ GError **error);
+
/* Useful GBinding transform functions */
gboolean e_binding_transform_color_to_string
(GBinding *binding,
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index cfcbbc9caa..2a6439c1b1 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -481,6 +481,35 @@ mail_account_store_constructed (GObject *object)
}
static void
+mail_account_store_allow_auth_prompt_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *local_error = NULL;
+
+ e_source_allow_auth_prompt_finish (E_SOURCE (source_object), result, &local_error);
+
+ if (local_error) {
+ g_debug ("%s: Failed with: %s", G_STRFUNC, local_error->message);
+ g_clear_error (&local_error);
+ }
+}
+
+static void
+call_allow_auth_prompt (ESource *source)
+{
+ if (!source)
+ return;
+
+ g_return_if_fail (E_IS_SOURCE (source));
+
+ /* There is not much interest in the result, it just
+ makes sure a password prompt will be shown the next
+ time it is needed. */
+ e_source_allow_auth_prompt (source, NULL, mail_account_store_allow_auth_prompt_done_cb, NULL);
+}
+
+static void
mail_account_store_service_added (EMailAccountStore *store,
CamelService *service)
{
@@ -643,12 +672,16 @@ mail_account_store_service_disabled (EMailAccountStore *store,
ESourceMailAccount *extension;
const gchar *extension_name;
+ call_allow_auth_prompt (source);
+
extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
extension = e_source_get_extension (source, extension_name);
uid = e_source_mail_account_get_identity_uid (extension);
- if (uid != NULL)
+ if (uid != NULL) {
identity = e_source_registry_ref_source (registry, uid);
+ call_allow_auth_prompt (identity);
+ }
if (identity != NULL && e_source_get_writable (identity)) {
e_source_set_enabled (identity, FALSE);
@@ -675,6 +708,8 @@ mail_account_store_service_disabled (EMailAccountStore *store,
collection = e_source_registry_find_extension (
registry, source, E_SOURCE_EXTENSION_COLLECTION);
if (collection != NULL) {
+ call_allow_auth_prompt (collection);
+
g_object_unref (source);
source = collection;
}
diff --git a/modules/addressbook/e-book-shell-sidebar.c b/modules/addressbook/e-book-shell-sidebar.c
index 1138ce3a6c..393ddc6148 100644
--- a/modules/addressbook/e-book-shell-sidebar.c
+++ b/modules/addressbook/e-book-shell-sidebar.c
@@ -225,6 +225,9 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
refresh_supported =
e_client_check_refresh_supported (client);
g_object_unref (client);
+ } else {
+ /* It's also used to allow-auth-prompt for the source */
+ refresh_supported = TRUE;
}
g_object_unref (source);
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index ba935c3966..57fd7e9df9 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -200,34 +200,96 @@ action_address_book_properties_cb (GtkAction *action,
}
static void
+address_book_handle_refresh_done (ESource *source,
+ EActivity *activity,
+ const GError *error)
+{
+ EAlertSink *alert_sink;
+ const gchar *display_name;
+
+ alert_sink = e_activity_get_alert_sink (activity);
+ display_name = e_source_get_display_name (source);
+
+ if (e_activity_handle_cancellation (activity, error)) {
+ /* nothing to do */
+
+ } else if (error != NULL) {
+ e_alert_submit (
+ alert_sink,
+ "addressbook:refresh-error",
+ display_name, error->message, NULL);
+
+ } else {
+ e_activity_set_state (activity, E_ACTIVITY_COMPLETED);
+ }
+}
+
+static void
address_book_refresh_done_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
EClient *client;
- GError *error = NULL;
+ ESource *source;
+ EActivity *activity;
+ GError *local_error = NULL;
g_return_if_fail (E_IS_CLIENT (source_object));
client = E_CLIENT (source_object);
+ source = e_client_get_source (client);
+ activity = user_data;
- e_client_refresh_finish (client, result, &error);
+ e_util_allow_auth_prompt_and_refresh_client_finish (client, result, &local_error);
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_error_free (error);
+ address_book_handle_refresh_done (source, activity, local_error);
- } else if (error != NULL) {
- ESource *source;
+ g_clear_object (&activity);
+ g_clear_error (&local_error);
+}
- source = e_client_get_source (client);
+typedef struct _AllowAuthPromptData {
+ EActivity *activity;
+ ESourceSelector *selector;
+} AllowAuthPromptData;
- g_warning (
- "%s: Failed to refresh '%s', %s",
- G_STRFUNC, e_source_get_display_name (source),
- error ? error->message : "Unknown error");
+static void
+address_book_allow_auth_prompt_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ ESource *source;
+ ESourceSelector *selector;
+ EActivity *activity;
+ AllowAuthPromptData *data = user_data;
+ GError *local_error = NULL;
- g_error_free (error);
+ g_return_if_fail (E_IS_SOURCE (source_object));
+ g_return_if_fail (user_data != NULL);
+
+ source = E_SOURCE (source_object);
+ activity = data->activity;
+ selector = data->selector;
+
+ g_free (data);
+
+ e_source_allow_auth_prompt_finish (source, result, &local_error);
+
+ address_book_handle_refresh_done (source, activity, local_error);
+
+ if (!local_error) {
+ ESource *primary;
+
+ primary = e_source_selector_ref_primary_selection (selector);
+ if (primary == source)
+ e_source_selector_set_primary_selection (selector, source);
+
+ g_clear_object (&primary);
}
+
+ g_clear_object (&activity);
+ g_clear_object (&selector);
+ g_clear_error (&local_error);
}
static void
@@ -238,15 +300,46 @@ action_address_book_refresh_cb (GtkAction *action,
ESourceSelector *selector;
EClient *client = NULL;
ESource *source;
+ EActivity *activity;
+ EAlertSink *alert_sink;
+ EShellBackend *shell_backend;
+ EShellContent *shell_content;
+ EShellView *shell_view;
+ GCancellable *cancellable;
book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
source = e_source_selector_ref_primary_selection (selector);
if (source != NULL) {
client = e_client_selector_ref_cached_client (
E_CLIENT_SELECTOR (selector), source);
+ if (!client) {
+ AllowAuthPromptData *data;
+
+ alert_sink = E_ALERT_SINK (shell_content);
+ activity = e_activity_new ();
+ cancellable = g_cancellable_new ();
+
+ e_activity_set_alert_sink (activity, alert_sink);
+ e_activity_set_cancellable (activity, cancellable);
+
+ data = g_new0 (AllowAuthPromptData, 1);
+ data->activity = activity;
+ data->selector = g_object_ref (selector);
+
+ e_source_allow_auth_prompt (source, cancellable, address_book_allow_auth_prompt_done_cb, data);
+
+ e_shell_backend_add_activity (shell_backend, activity);
+
+ g_object_unref (cancellable);
+ }
+
g_object_unref (source);
}
@@ -255,8 +348,18 @@ action_address_book_refresh_cb (GtkAction *action,
g_return_if_fail (e_client_check_refresh_supported (client));
- e_client_refresh (client, NULL, address_book_refresh_done_cb, book_shell_view);
+ alert_sink = E_ALERT_SINK (shell_content);
+ activity = e_activity_new ();
+ cancellable = g_cancellable_new ();
+
+ e_activity_set_alert_sink (activity, alert_sink);
+ e_activity_set_cancellable (activity, cancellable);
+
+ e_util_allow_auth_prompt_and_refresh_client (client, cancellable, address_book_refresh_done_cb, activity);
+
+ e_shell_backend_add_activity (shell_backend, activity);
+ g_object_unref (cancellable);
g_object_unref (client);
}
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index b931c16576..3703318c9b 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -339,7 +339,7 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
/* XXX No way to cancel this? */
e_client_selector_get_client (
E_CLIENT_SELECTOR (selector),
- source, NULL,
+ source, TRUE, NULL,
book_shell_view_client_connect_cb,
g_object_ref (view));
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index 28b8d46d4c..dbecf6d989 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -351,7 +351,7 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar,
priv->connecting_default_client = g_object_ref (closure->activity);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source,
+ E_CLIENT_SELECTOR (selector), source, TRUE,
e_activity_get_cancellable (closure->activity),
cal_shell_sidebar_default_connect_cb, closure);
}
@@ -853,7 +853,7 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
closure = connect_closure_new (cal_shell_sidebar, source);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source,
+ E_CLIENT_SELECTOR (selector), source, TRUE,
e_activity_get_cancellable (closure->activity),
cal_shell_sidebar_client_connect_cb, closure);
}
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index 660be9c267..93e61aae41 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -23,6 +23,7 @@
#endif
#include "e-cal-shell-view-private.h"
+#include "e-cal-shell-view.h"
/* This is for radio action groups whose value is persistent. We
* initialize it to a bogus value to ensure a "changed" signal is
@@ -374,7 +375,6 @@ action_calendar_refresh_cb (GtkAction *action,
ESourceSelector *selector;
EClient *client = NULL;
ESource *source;
- GError *error = NULL;
cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
@@ -392,15 +392,7 @@ action_calendar_refresh_cb (GtkAction *action,
g_return_if_fail (e_client_check_refresh_supported (client));
- e_client_refresh_sync (client, NULL, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to refresh '%s', %s",
- G_STRFUNC, e_source_get_display_name (source),
- error->message);
- g_error_free (error);
- }
+ e_cal_shell_view_allow_auth_prompt_and_refresh (E_SHELL_VIEW (cal_shell_view), client);
g_object_unref (client);
}
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index a703cbc076..41d6d54a43 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -629,3 +629,86 @@ e_cal_shell_view_type_register (GTypeModule *type_module)
e_cal_shell_view_register_type (type_module);
}
+static void
+cal_shell_view_allow_auth_prompt_and_refresh_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ EClient *client;
+ EActivity *activity;
+ EAlertSink *alert_sink;
+ ESource *source;
+ const gchar *display_name;
+ GError *local_error = NULL;
+
+ g_return_if_fail (E_IS_CAL_CLIENT (source_object));
+
+ client = E_CLIENT (source_object);
+ source = e_client_get_source (client);
+ activity = user_data;
+ alert_sink = e_activity_get_alert_sink (activity);
+ display_name = e_source_get_display_name (source);
+
+ e_util_allow_auth_prompt_and_refresh_client_finish (client, result, &local_error);
+
+ if (e_activity_handle_cancellation (activity, local_error)) {
+ g_error_free (local_error);
+
+ } else if (local_error != NULL) {
+ const gchar *error_message;
+
+ switch (e_cal_client_get_source_type (E_CAL_CLIENT (client))) {
+ default:
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
+ error_message = "calendar:refresh-error-events";
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
+ error_message = "calendar:refresh-error-tasks";
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
+ error_message = "calendar:refresh-error-memos";
+ break;
+ }
+ e_alert_submit (
+ alert_sink,
+ error_message,
+ display_name, local_error->message, NULL);
+ g_error_free (local_error);
+
+ } else {
+ e_activity_set_state (activity, E_ACTIVITY_COMPLETED);
+ }
+
+ g_clear_object (&activity);
+}
+
+void
+e_cal_shell_view_allow_auth_prompt_and_refresh (EShellView *shell_view,
+ EClient *client)
+{
+ EShellBackend *shell_backend;
+ EShellContent *shell_content;
+ EActivity *activity;
+ EAlertSink *alert_sink;
+ GCancellable *cancellable;
+
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (E_IS_CLIENT (client));
+
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ alert_sink = E_ALERT_SINK (shell_content);
+ activity = e_activity_new ();
+ cancellable = g_cancellable_new ();
+
+ e_activity_set_alert_sink (activity, alert_sink);
+ e_activity_set_cancellable (activity, cancellable);
+
+ e_util_allow_auth_prompt_and_refresh_client (client, cancellable,
+ cal_shell_view_allow_auth_prompt_and_refresh_done_cb, activity);
+
+ e_shell_backend_add_activity (shell_backend, activity);
+
+ g_object_unref (cancellable);
+}
diff --git a/modules/calendar/e-cal-shell-view.h b/modules/calendar/e-cal-shell-view.h
index 9057faf9d9..d01a77e731 100644
--- a/modules/calendar/e-cal-shell-view.h
+++ b/modules/calendar/e-cal-shell-view.h
@@ -21,6 +21,7 @@
#ifndef E_CAL_SHELL_VIEW_H
#define E_CAL_SHELL_VIEW_H
+#include <e-util/e-util.h>
#include <shell/e-shell-view.h>
/* Standard GObject macros */
@@ -60,6 +61,10 @@ struct _ECalShellViewClass {
GType e_cal_shell_view_get_type (void);
void e_cal_shell_view_type_register (GTypeModule *type_module);
+void e_cal_shell_view_allow_auth_prompt_and_refresh
+ (EShellView *shell_view,
+ EClient *client);
+
G_END_DECLS
#endif /* E_CAL_SHELL_VIEW_H */
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c
index 8575da2745..72408dc497 100644
--- a/modules/calendar/e-memo-shell-sidebar.c
+++ b/modules/calendar/e-memo-shell-sidebar.c
@@ -349,7 +349,7 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar,
priv->connecting_default_client = g_object_ref (closure->activity);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source,
+ E_CLIENT_SELECTOR (selector), source, TRUE,
e_activity_get_cancellable (closure->activity),
memo_shell_sidebar_default_connect_cb, closure);
}
@@ -780,7 +780,7 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
closure = connect_closure_new (memo_shell_sidebar, source);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source,
+ E_CLIENT_SELECTOR (selector), source, TRUE,
e_activity_get_cancellable (closure->activity),
memo_shell_sidebar_client_connect_cb, closure);
}
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index cea084e293..35ab8cc879 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -23,6 +23,7 @@
#endif
#include "e-memo-shell-view-private.h"
+#include "e-cal-shell-view.h"
static void
action_memo_delete_cb (GtkAction *action,
@@ -277,7 +278,6 @@ action_memo_list_refresh_cb (GtkAction *action,
ESourceSelector *selector;
EClient *client = NULL;
ESource *source;
- GError *error = NULL;
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
@@ -295,15 +295,7 @@ action_memo_list_refresh_cb (GtkAction *action,
g_return_if_fail (e_client_check_refresh_supported (client));
- e_client_refresh_sync (client, NULL, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to refresh '%s', %s",
- G_STRFUNC, e_source_get_display_name (source),
- error->message);
- g_error_free (error);
- }
+ e_cal_shell_view_allow_auth_prompt_and_refresh (E_SHELL_VIEW (memo_shell_view), client);
g_object_unref (client);
}
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c
index d858a9f94a..10d8bdcc2c 100644
--- a/modules/calendar/e-task-shell-sidebar.c
+++ b/modules/calendar/e-task-shell-sidebar.c
@@ -349,7 +349,7 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar,
priv->connecting_default_client = g_object_ref (closure->activity);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source,
+ E_CLIENT_SELECTOR (selector), source, TRUE,
e_activity_get_cancellable (closure->activity),
task_shell_sidebar_default_connect_cb, closure);
}
@@ -780,7 +780,7 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
closure = connect_closure_new (task_shell_sidebar, source);
e_client_selector_get_client (
- E_CLIENT_SELECTOR (selector), source,
+ E_CLIENT_SELECTOR (selector), source, TRUE,
e_activity_get_cancellable (closure->activity),
task_shell_sidebar_client_connect_cb, closure);
}
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 99754570aa..39c7032492 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -23,6 +23,7 @@
#endif
#include "e-task-shell-view-private.h"
+#include "e-cal-shell-view.h"
static void
action_task_assign_cb (GtkAction *action,
@@ -300,7 +301,6 @@ action_task_list_refresh_cb (GtkAction *action,
ESourceSelector *selector;
EClient *client = NULL;
ESource *source;
- GError *error = NULL;
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
@@ -318,15 +318,7 @@ action_task_list_refresh_cb (GtkAction *action,
g_return_if_fail (e_client_check_refresh_supported (client));
- e_client_refresh_sync (client, NULL, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to refresh '%s', %s",
- G_STRFUNC, e_source_get_display_name (source),
- error->message);
- g_error_free (error);
- }
+ e_cal_shell_view_allow_auth_prompt_and_refresh (E_SHELL_VIEW (task_shell_view), client);
g_object_unref (client);
}
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 76159950a5..292aa96c48 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -156,6 +156,54 @@ account_refresh_folder_info_received_cb (GObject *source,
g_clear_object (&activity);
}
+typedef struct _RefreshData
+{
+ EActivity *activity;
+ CamelStore *store;
+} RefreshData;
+
+static void
+account_refresh_allow_auth_prompt_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ RefreshData *data = user_data;
+ EActivity *activity;
+ CamelStore *store;
+ GError *local_error = NULL;
+
+ g_return_if_fail (data != NULL);
+
+ activity = data->activity;
+ store = data->store;
+
+ g_free (data);
+
+ e_source_allow_auth_prompt_finish (E_SOURCE (source_object), result, &local_error);
+
+ if (e_activity_handle_cancellation (activity, local_error)) {
+ g_error_free (local_error);
+ g_clear_object (&activity);
+ } else {
+ GCancellable *cancellable;
+
+ if (local_error) {
+ g_debug ("%s: Failed with: %s", G_STRFUNC, local_error->message);
+ g_clear_error (&local_error);
+ }
+
+ cancellable = e_activity_get_cancellable (activity);
+
+ camel_store_get_folder_info (
+ store, NULL,
+ CAMEL_STORE_FOLDER_INFO_RECURSIVE,
+ G_PRIORITY_DEFAULT, cancellable,
+ account_refresh_folder_info_received_cb, activity);
+ }
+
+ g_object_unref (store);
+}
+
static void
action_mail_account_refresh_cb (GtkAction *action,
EMailShellView *mail_shell_view)
@@ -165,8 +213,12 @@ action_mail_account_refresh_cb (GtkAction *action,
EMFolderTree *folder_tree;
EMailView *mail_view;
EActivity *activity;
+ ESourceRegistry *registry;
+ ESource *source;
+ EShell *shell;
CamelStore *store;
GCancellable *cancellable;
+ RefreshData *data;
mail_shell_content = mail_shell_view->priv->mail_shell_content;
mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
@@ -179,13 +231,18 @@ action_mail_account_refresh_cb (GtkAction *action,
activity = e_mail_reader_new_activity (E_MAIL_READER (mail_view));
cancellable = e_activity_get_cancellable (activity);
- camel_store_get_folder_info (
- store, NULL,
- CAMEL_STORE_FOLDER_INFO_RECURSIVE,
- G_PRIORITY_DEFAULT, cancellable,
- account_refresh_folder_info_received_cb, activity);
+ data = g_new0 (RefreshData, 1);
+ data->activity = activity;
+ data->store = store;
- g_object_unref (store);
+ shell = e_shell_backend_get_shell (e_shell_view_get_shell_backend (E_SHELL_VIEW (mail_shell_view)));
+ registry = e_shell_get_registry (shell);
+ source = e_source_registry_ref_source (registry, camel_service_get_uid (CAMEL_SERVICE (store)));
+ g_return_if_fail (source != NULL);
+
+ e_source_allow_auth_prompt (source, cancellable, account_refresh_allow_auth_prompt_done_cb, data);
+
+ g_clear_object (&source);
}
static void