diff options
author | Milan Crha <mcrha@redhat.com> | 2014-02-13 19:30:15 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2014-02-13 19:30:15 +0800 |
commit | a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c (patch) | |
tree | 38bb08ba880a2a0ab936fae76998d1b4ea20eadf /mail | |
parent | 55557b13d2111c5728078e4866da77140ace960b (diff) | |
download | gsoc2013-evolution-a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c.tar gsoc2013-evolution-a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c.tar.gz gsoc2013-evolution-a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c.tar.bz2 gsoc2013-evolution-a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c.tar.lz gsoc2013-evolution-a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c.tar.xz gsoc2013-evolution-a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c.tar.zst gsoc2013-evolution-a431ed4c3ae99de13e5bd9ff63c380f8b8dac61c.zip |
Bug #685381 - POP3's "delete-expunged" ignored when Empty trash on exit
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-backend.c | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index 3ea4db862b..83ee93d45e 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -147,6 +147,24 @@ mail_backend_store_operation_done_cb (CamelStore *store, } static void +mail_backend_local_trash_expunge_done_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) +{ + CamelFolder *folder = CAMEL_FOLDER (source_object); + EActivity *activity = user_data; + GError *error = NULL; + + if (!e_mail_folder_expunge_finish (folder, result, &error)) { + g_warning ("%s: Failed to expunge local trash: %s", G_STRFUNC, error ? error->message : "Unknown error"); + } + + g_clear_error (&error); + + g_object_unref (activity); +} + +static void mail_backend_set_session_offline_cb (gpointer user_data, GObject *object) { @@ -374,14 +392,33 @@ mail_backend_prepare_for_quit_cb (EShell *shell, !mail_backend_service_is_enabled (registry, service)) continue; - /* FIXME Not passing a GCancellable. */ - /* FIXME This operation should be queued. */ - camel_store_synchronize ( - CAMEL_STORE (service), - empty_trash, G_PRIORITY_DEFAULT, - NULL, (GAsyncReadyCallback) - mail_backend_store_operation_done_cb, - g_object_ref (activity)); + if (empty_trash && g_strcmp0 (camel_service_get_uid (service), E_MAIL_SESSION_LOCAL_UID) == 0) { + /* local trash requires special handling, + due to POP3's "delete-expunged" option */ + CamelFolder *local_trash; + GCancellable *cancellable = e_activity_get_cancellable (activity); + + /* This should be lightning-fast, it's a local trash folder */ + local_trash = camel_store_get_trash_folder_sync (CAMEL_STORE (service), cancellable, NULL); + + if (local_trash) { + e_mail_folder_expunge (local_trash, + G_PRIORITY_DEFAULT, cancellable, + mail_backend_local_trash_expunge_done_cb, + g_object_ref (activity)); + + g_object_unref (local_trash); + } + } else { + /* FIXME Not passing a GCancellable. */ + /* FIXME This operation should be queued. */ + camel_store_synchronize ( + CAMEL_STORE (service), + empty_trash, G_PRIORITY_DEFAULT, + NULL, (GAsyncReadyCallback) + mail_backend_store_operation_done_cb, + g_object_ref (activity)); + } } g_list_free_full (list, (GDestroyNotify) g_object_unref); |