aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2013-04-11 19:53:22 +0800
committerMilan Crha <mcrha@redhat.com>2013-04-11 19:53:22 +0800
commit765a50d3df2d53b73b149fc2646f46722add7635 (patch)
tree8e540bebd24d80af919c04825ed7247ae0866e46
parent5a389fa7bd73671410ce4a47c225d580ad87bd2a (diff)
downloadgsoc2013-evolution-765a50d3df2d53b73b149fc2646f46722add7635.tar
gsoc2013-evolution-765a50d3df2d53b73b149fc2646f46722add7635.tar.gz
gsoc2013-evolution-765a50d3df2d53b73b149fc2646f46722add7635.tar.bz2
gsoc2013-evolution-765a50d3df2d53b73b149fc2646f46722add7635.tar.lz
gsoc2013-evolution-765a50d3df2d53b73b149fc2646f46722add7635.tar.xz
gsoc2013-evolution-765a50d3df2d53b73b149fc2646f46722add7635.tar.zst
gsoc2013-evolution-765a50d3df2d53b73b149fc2646f46722add7635.zip
Bug #697710 - Going offline doesn't disconnect remote stores
-rw-r--r--mail/e-mail-account-store.c42
-rw-r--r--mail/e-mail-backend.c22
2 files changed, 51 insertions, 13 deletions
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index e79943c32e..7b4605b64d 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 610e8913fa..efb3521b06 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;