[evolution] Bug #697710 - Going offline doesn't disconnect remote stores
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #697710 - Going offline doesn't disconnect remote stores
- Date: Thu, 11 Apr 2013 11:53:50 +0000 (UTC)
commit 765a50d3df2d53b73b149fc2646f46722add7635
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 11 13:53:22 2013 +0200
Bug #697710 - Going offline doesn't disconnect remote stores
mail/e-mail-account-store.c | 42 +++++++++++++++++++++++++++++++++++++++---
mail/e-mail-backend.c | 22 ++++++++++++----------
2 files changed, 51 insertions(+), 13 deletions(-)
---
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index e79943c..7b4605b 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -185,15 +185,51 @@ mail_account_store_update_row (EMailAccountStore *store,
-1);
}
+struct ServiceNotifyCbData
+{
+ EMailAccountStore *store;
+ CamelService *service;
+};
+
+static void
+service_notify_cb_data_free (gpointer ptr)
+{
+ struct ServiceNotifyCbData *data = ptr;
+
+ g_clear_object (&data->store);
+ g_clear_object (&data->service);
+ g_slice_free (struct ServiceNotifyCbData, data);
+}
+
+static gboolean
+mail_account_store_service_notify_idle_cb (gpointer user_data)
+{
+ struct ServiceNotifyCbData *data = user_data;
+ GtkTreeIter iter;
+
+ g_return_val_if_fail (data != NULL, FALSE);
+
+ if (mail_account_store_get_iter (data->store, data->service, &iter))
+ mail_account_store_update_row (data->store, data->service, &iter);
+
+ return FALSE;
+}
+
static void
mail_account_store_service_notify_cb (CamelService *service,
GParamSpec *pspec,
EMailAccountStore *store)
{
- GtkTreeIter iter;
+ struct ServiceNotifyCbData *data;
- if (mail_account_store_get_iter (store, service, &iter))
- mail_account_store_update_row (store, service, &iter);
+ data = g_slice_new0 (struct ServiceNotifyCbData);
+ data->store = g_object_ref (store);
+ data->service = g_object_ref (service);
+
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ mail_account_store_service_notify_idle_cb,
+ data,
+ service_notify_cb_data_free);
}
static void
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 610e891..efb3521 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -138,17 +138,8 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
GQueue queue = G_QUEUE_INIT;
gboolean synchronize = FALSE;
- if (e_shell_backend_is_started (E_SHELL_BACKEND (backend))) {
- if (!e_activity_get_cancellable (activity)) {
- GCancellable *cancellable;
-
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (activity, cancellable);
- g_object_unref (cancellable);
- }
-
+ if (e_shell_backend_is_started (E_SHELL_BACKEND (backend)))
e_shell_backend_add_activity (E_SHELL_BACKEND (backend), activity);
- }
window = e_shell_get_active_window (shell);
session = e_mail_backend_get_session (backend);
@@ -165,6 +156,17 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
CAMEL_SESSION (session), FALSE);
}
+ /* Set the cancellable only here, because mail_cancel_all() would
+ cancel the just added CamelOperation as well. */
+ if (e_shell_backend_is_started (E_SHELL_BACKEND (backend)) &&
+ !e_activity_get_cancellable (activity)) {
+ GCancellable *cancellable;
+
+ cancellable = camel_operation_new ();
+ e_activity_set_cancellable (activity, cancellable);
+ g_object_unref (cancellable);
+ }
+
e_mail_account_store_queue_enabled_services (account_store, &queue);
while (!g_queue_is_empty (&queue)) {
CamelService *service;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]