[evolution] Bug 781122 - Option to Download messages for offline on each Send/Receive
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 781122 - Option to Download messages for offline on each Send/Receive
- Date: Thu, 25 Oct 2018 12:01:40 +0000 (UTC)
commit 0d1aceebf5788af2e6efc8cae3dda96b2c75659a
Author: Milan Crha <mcrha redhat com>
Date: Thu Oct 25 14:02:00 2018 +0200
Bug 781122 - Option to Download messages for offline on each Send/Receive
Closes https://bugzilla.gnome.org/show_bug.cgi?id=781122
data/org.gnome.evolution.mail.gschema.xml.in | 5 ++
src/mail/mail-send-recv.c | 69 ++++++++++++++++++++++++++++
src/mail/mail.error.xml | 4 +-
src/modules/mail/e-mail-shell-view-actions.c | 1 +
4 files changed, 77 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 44c9ba7825..a9e0e2c852 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -803,6 +803,11 @@
<_summary>Where to lookup recipient S/MIME certificates or PGP keys when encrypting
messages.</_summary>
<_description>The “off” value completely disables certificate lookup; the “autocompleted” value
provides certificates only for auto-completed contacts; the “books” value uses certificates from
auto-completed contacts and searches in books marked for auto-completion.</_description>
</key>
+ <key name="send-receive-downloads-for-offline" type="b">
+ <default>false</default>
+ <_summary>Whether Send/Receive should also download of messages for offline.</_summary>
+ <_description>If enabled, whenever Send/Receive is run it also runs synchronization of messages for
offline use. The option is disabled by default.</_description>
+ </key>
<!-- The following keys are deprecated. -->
diff --git a/src/mail/mail-send-recv.c b/src/mail/mail-send-recv.c
index 3fe9595f18..402e8b4246 100644
--- a/src/mail/mail-send-recv.c
+++ b/src/mail/mail-send-recv.c
@@ -128,6 +128,7 @@ static gboolean send_done (gpointer data, const GError *error, const GPtrArray *
static struct _send_data *send_data = NULL;
static GtkWidget *send_recv_dialog = NULL;
+static GSList *glob_ongoing_downsyncs = NULL; /* CamelService *, those where downsync for offline is ongoing
*/
static void
free_folder_info (struct _folder_info *info)
@@ -1046,6 +1047,60 @@ receive_status (CamelFilterDriver *driver,
}
}
+static void
+free_downsync_for_store_data (gpointer ptr)
+{
+ CamelService *service = ptr;
+
+ if (!service)
+ return;
+
+ glob_ongoing_downsyncs = g_slist_remove (glob_ongoing_downsyncs, service);
+
+ g_clear_object (&service);
+}
+
+static void
+downsync_for_store_thread (EAlertSinkThreadJobData *job_data,
+ gpointer user_data,
+ GCancellable *cancellable,
+ GError **error)
+{
+ CamelOfflineStore *offline_store = user_data;
+
+ g_return_if_fail (CAMEL_IS_OFFLINE_STORE (offline_store));
+
+ camel_offline_store_prepare_for_offline_sync (offline_store, cancellable, error);
+}
+
+static void
+run_downsync_for_store (CamelService *service)
+{
+ EShellView *shell_view;
+ EActivity *activity;
+ gchar *description;
+
+ shell_view = mail_send_receive_get_mail_shell_view ();
+ if (!shell_view)
+ return;
+
+ glob_ongoing_downsyncs = g_slist_prepend (glob_ongoing_downsyncs, service);
+
+ description = g_strdup_printf (_("Preparing account “%s” for offline"),
camel_service_get_display_name (service));
+
+ activity = e_shell_view_submit_thread_job (shell_view, description,
+ "mail:prepare-for-offline",
+ camel_service_get_display_name (service),
+ downsync_for_store_thread, g_object_ref (service),
+ free_downsync_for_store_data);
+
+ if (!activity)
+ glob_ongoing_downsyncs = g_slist_remove (glob_ongoing_downsyncs, service);
+
+ g_clear_object (&activity);
+ g_free (description);
+}
+
/* when receive/send is complete */
static void
receive_done (gpointer data)
@@ -1126,6 +1181,20 @@ receive_done (gpointer data)
free_send_data ();
}
+ if (info->state != SEND_CANCELLED &&
+ CAMEL_IS_OFFLINE_STORE (info->service) &&
+ camel_offline_store_get_online (CAMEL_OFFLINE_STORE (info->service)) &&
+ !g_slist_find (glob_ongoing_downsyncs, info->service)) {
+ GSettings *settings;
+
+ settings = e_util_ref_settings ("org.gnome.evolution.mail");
+ if (g_settings_get_boolean (settings, "send-receive-downloads-for-offline") &&
+ camel_offline_store_requires_downsync (CAMEL_OFFLINE_STORE (info->service))) {
+ run_downsync_for_store (info->service);
+ }
+ g_object_unref (settings);
+ }
+
free_send_info (info);
}
diff --git a/src/mail/mail.error.xml b/src/mail/mail.error.xml
index 5f8b378b4b..f676d6ca6c 100644
--- a/src/mail/mail.error.xml
+++ b/src/mail/mail.error.xml
@@ -536,8 +536,8 @@ in the folder will be available in offline mode.</_secondary>
</error>
<error id="prepare-for-offline" type="warning">
- <_primary>Failed to download messages for offline viewing.</_primary>
- <_secondary>The reported error was “{0}”.</_secondary>
+ <_primary>Failed to download messages for offline viewing for account “{0}”.</_primary>
+ <_secondary>The reported error was “{1}”.</_secondary>
</error>
<error id="save-messages" type="error">
diff --git a/src/modules/mail/e-mail-shell-view-actions.c b/src/modules/mail/e-mail-shell-view-actions.c
index 0038f07b37..5642969fcb 100644
--- a/src/modules/mail/e-mail-shell-view-actions.c
+++ b/src/modules/mail/e-mail-shell-view-actions.c
@@ -309,6 +309,7 @@ action_mail_download_finished_cb (CamelStore *store,
} else if (error != NULL) {
e_alert_submit (
alert_sink, "mail:prepare-for-offline",
+ camel_service_get_display_name (CAMEL_SERVICE (store)),
error->message, NULL);
g_error_free (error);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]