Bug #697710 - Going offline doesn't disconnect remote stores

This commit is contained in:
Milan Crha
2013-04-11 13:53:22 +02:00
parent 5a389fa7bd
commit 765a50d3df
2 changed files with 51 additions and 13 deletions

View File

@ -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

View File

@ -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;