aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-18 00:08:07 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-18 07:51:11 +0800
commitb3b917365ff2e813df0503e94267f2cb3bab4255 (patch)
tree30fc79ded6cfd43eed38d09c20ed8884c1a9a739 /mail
parent8520334bc8a1745f5954f0b69252418e12d4c3a2 (diff)
downloadgsoc2013-evolution-b3b917365ff2e813df0503e94267f2cb3bab4255.tar.gz
gsoc2013-evolution-b3b917365ff2e813df0503e94267f2cb3bab4255.tar.zst
gsoc2013-evolution-b3b917365ff2e813df0503e94267f2cb3bab4255.zip
Remove mail_store_prepare_offline().
Use e_mail_store_prepare_for_offline() instead.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-store-utils.c74
-rw-r--r--mail/e-mail-store-utils.h10
-rw-r--r--mail/mail-ops.c81
-rw-r--r--mail/mail-ops.h4
-rw-r--r--mail/mail.error.xml5
5 files changed, 89 insertions, 85 deletions
diff --git a/mail/e-mail-store-utils.c b/mail/e-mail-store-utils.c
index 57304f926d..47c9970c25 100644
--- a/mail/e-mail-store-utils.c
+++ b/mail/e-mail-store-utils.c
@@ -188,3 +188,77 @@ e_mail_store_go_online_finish (CamelStore *store,
/* Assume success unless a GError is set. */
return !g_simple_async_result_propagate_error (simple, error);
}
+
+static void
+mail_store_prepare_for_offline_thread (GSimpleAsyncResult *simple,
+ CamelStore *store,
+ GCancellable *cancellable)
+{
+ CamelService *service;
+ gchar *service_name;
+ GError *error = NULL;
+
+ service = CAMEL_SERVICE (store);
+
+ service_name = camel_service_get_name (service, TRUE);
+ camel_operation_push_message (
+ cancellable, _("Preparing account '%s' for offline"),
+ service_name);
+ g_free (service_name);
+
+ if (CAMEL_IS_DISCO_STORE (store))
+ camel_disco_store_prepare_for_offline (
+ CAMEL_DISCO_STORE (store), cancellable, &error);
+
+ else if (CAMEL_IS_OFFLINE_STORE (store))
+ camel_offline_store_prepare_for_offline_sync (
+ CAMEL_OFFLINE_STORE (store), cancellable, &error);
+
+ if (error != NULL) {
+ g_simple_async_result_set_from_error (simple, error);
+ g_error_free (error);
+ }
+
+ camel_operation_pop_message (cancellable);
+}
+
+void
+e_mail_store_prepare_for_offline (CamelStore *store,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *simple;
+
+ g_return_if_fail (CAMEL_IS_STORE (store));
+
+ simple = g_simple_async_result_new (
+ G_OBJECT (store), callback, user_data,
+ e_mail_store_prepare_for_offline);
+
+ g_simple_async_result_run_in_thread (
+ simple, (GSimpleAsyncThreadFunc)
+ mail_store_prepare_for_offline_thread,
+ io_priority, cancellable);
+
+ g_object_unref (simple);
+}
+
+gboolean
+e_mail_store_prepare_for_offline_finish (CamelStore *store,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple;
+
+ g_return_val_if_fail (
+ g_simple_async_result_is_valid (
+ result, G_OBJECT (store),
+ e_mail_store_prepare_for_offline), FALSE);
+
+ simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ /* Assume success unless a GError is set. */
+ return !g_simple_async_result_propagate_error (simple, error);
+}
diff --git a/mail/e-mail-store-utils.h b/mail/e-mail-store-utils.h
index daf7a98412..7610b82f54 100644
--- a/mail/e-mail-store-utils.h
+++ b/mail/e-mail-store-utils.h
@@ -41,6 +41,16 @@ void e_mail_store_go_online (CamelStore *store,
gboolean e_mail_store_go_online_finish (CamelStore *store,
GAsyncResult *result,
GError **error);
+void e_mail_store_prepare_for_offline
+ (CamelStore *store,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean e_mail_store_prepare_for_offline_finish
+ (CamelStore *store,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 0678370b49..1438805321 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1894,87 +1894,6 @@ mail_save_messages (CamelFolder *folder, GPtrArray *uids, const gchar *path,
return id;
}
-/* ** Prepare OFFLINE ***************************************************** */
-
-struct _set_offline_msg {
- MailMsg base;
-
- CamelStore *store;
- gboolean offline;
- void (*done)(CamelStore *store, gpointer data);
- gpointer data;
-};
-
-static gchar *
-prepare_offline_desc (struct _set_offline_msg *m)
-{
- gchar *service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE);
- gchar *msg;
-
- msg = g_strdup_printf (_("Preparing account '%s' for offline"), service_name);
- g_free (service_name);
-
- return msg;
-}
-
-static void
-prepare_offline_exec (struct _set_offline_msg *m,
- GCancellable *cancellable,
- GError **error)
-{
- if (CAMEL_IS_DISCO_STORE (m->store)) {
- camel_disco_store_prepare_for_offline (
- CAMEL_DISCO_STORE (m->store),
- cancellable, error);
- } else if (CAMEL_IS_OFFLINE_STORE (m->store)) {
- camel_offline_store_prepare_for_offline_sync (
- CAMEL_OFFLINE_STORE (m->store),
- cancellable, error);
- }
-}
-
-static void
-prepare_offline_done (struct _set_offline_msg *m)
-{
- if (m->done)
- m->done (m->store, m->data);
-}
-
-static void
-prepare_offline_free (struct _set_offline_msg *m)
-{
- g_object_unref (m->store);
-}
-
-static MailMsgInfo prepare_offline_info = {
- sizeof (struct _set_offline_msg),
- (MailMsgDescFunc) prepare_offline_desc,
- (MailMsgExecFunc) prepare_offline_exec,
- (MailMsgDoneFunc) prepare_offline_done,
- (MailMsgFreeFunc) prepare_offline_free
-};
-
-gint
-mail_store_prepare_offline (CamelStore *store)
-{
- struct _set_offline_msg *m;
- gint id;
-
- /* Cancel any pending connect first so the set_offline_op
- * thread won't get queued behind a hung connect op.
- */
-
- m = mail_msg_new (&prepare_offline_info);
- m->store = store;
- g_object_ref (store);
- m->data = NULL;
- m->done = NULL;
-
- id = m->base.seq;
- mail_msg_unordered_push (m);
-
- return id;
-}
/* ** Execute Shell Command ***************************************************** */
void
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 58dd8dff3d..2d18b1a24f 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -112,14 +112,10 @@ void mail_filter_folder (EMailSession *session,
const gchar *type,
gboolean notify);
-/* Work Offline */
-gint mail_store_prepare_offline (CamelStore *store);
-
/* filter driver execute shell command async callback */
void mail_execute_shell_command (CamelFilterDriver *driver, gint argc, gchar **argv, gpointer data);
gint mail_disconnect_store (CamelStore *store);
-gint mail_remove_attachments (CamelFolder *folder, GPtrArray *uids);
G_END_DECLS
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index 8eab30e396..82767fca18 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -525,5 +525,10 @@ An mbox account will be created to preserve the old mbox folders. You can delete
<_secondary>The reported error was &quot;{0}&quot;.</_secondary>
</error>
+ <error id="prepare-for-offline" type="warning">
+ <_primary>Failed to download messages for offline viewing.</_primary>
+ <_secondary>The reported error was &quot;{0}&quot;.</_secondary>
+ </error>
+
</error-list>