aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-ops.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-05-15 20:39:17 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-05-15 20:39:17 +0800
commitbe2d7023bf9f5af1202e674e17978c75c08a6e7d (patch)
tree750e520d0dedbad45960eea63e79c8abb44007cb /mail/mail-ops.c
parentc1e8c1cf3a367d721973bd93d99be8279ab204de (diff)
downloadgsoc2013-evolution-be2d7023bf9f5af1202e674e17978c75c08a6e7d.tar
gsoc2013-evolution-be2d7023bf9f5af1202e674e17978c75c08a6e7d.tar.gz
gsoc2013-evolution-be2d7023bf9f5af1202e674e17978c75c08a6e7d.tar.bz2
gsoc2013-evolution-be2d7023bf9f5af1202e674e17978c75c08a6e7d.tar.lz
gsoc2013-evolution-be2d7023bf9f5af1202e674e17978c75c08a6e7d.tar.xz
gsoc2013-evolution-be2d7023bf9f5af1202e674e17978c75c08a6e7d.tar.zst
gsoc2013-evolution-be2d7023bf9f5af1202e674e17978c75c08a6e7d.zip
Implement prep_offline for an individual folder. (set_offline_do): Only
2002-05-15 Not Zed <NotZed@Ximian.com> * mail-ops.c (prep_offline_do): (prep_offline_done): (prep_offline_free): (mail_prep_offline): Implement prep_offline for an individual folder. (set_offline_do): Only call disco_store_set_status or disconnect for the store, dont do any offline prep stuff. * mail-offline-handler.c: Applied patch from Ettore to hook in extra offline interfaces. (impl_destroy): Dont free listener here anymore, its removed, but free sync table. (mail_offline_handler_init): Same for setup. (impl_syncFolder): Implement. (sync_done): handles finalising synchronisation of 1 folder. (sync_status): progress reporting, camel side. (sync_timeout): progress reporting, gmainloop side. (impl_cancelSyncFolder): Implement. (impl_goOffline, storage_go_offline, went_offline): Dont copy the listener to our struct - its an argument, not a member, so give each thread its own copy. svn path=/trunk/; revision=16799
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r--mail/mail-ops.c112
1 files changed, 86 insertions, 26 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index c86c5f2208..ed7a876585 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -2085,6 +2085,85 @@ mail_save_part (CamelMimePart *part, const char *path,
}
+/* ** PREPARE OFFLINE ***************************************************** */
+
+struct _prep_offline_msg {
+ struct _mail_msg msg;
+
+ CamelOperation *cancel;
+ char *uri;
+ void (*done)(const char *uri, void *data);
+ void *data;
+};
+
+static void prep_offline_do(struct _mail_msg *mm)
+{
+ struct _prep_offline_msg *m = (struct _prep_offline_msg *)mm;
+ CamelFolder *folder;
+
+ if (m->cancel)
+ camel_operation_register(m->cancel);
+
+ folder = mail_tool_uri_to_folder(m->uri, 0, &mm->ex);
+ if (folder) {
+ if (CAMEL_IS_DISCO_FOLDER(folder)) {
+ camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder,
+ "(match-all (not (system-flag \"Seen\")))",
+ &mm->ex);
+ }
+ /* prepare_for_offline should do this? */
+ /* of course it should all be atomic, but ... */
+ camel_folder_sync(folder, FALSE, NULL);
+ camel_object_unref((CamelObject *)folder);
+ }
+
+ if (m->cancel)
+ camel_operation_unregister(m->cancel);
+}
+
+static void prep_offline_done(struct _mail_msg *mm)
+{
+ struct _prep_offline_msg *m = (struct _prep_offline_msg *)mm;
+
+ if (m->done)
+ m->done(m->uri, m->data);
+}
+
+static void prep_offline_free(struct _mail_msg *mm)
+{
+ struct _prep_offline_msg *m = (struct _prep_offline_msg *)mm;
+
+ if (m->cancel)
+ camel_operation_unref(m->cancel);
+ g_free(m->uri);
+}
+
+static struct _mail_msg_op prep_offline_op = {
+ NULL, /* DO NOT CHANGE THIS, IT MUST BE NULL FOR CANCELLATION TO WORK */
+ prep_offline_do,
+ prep_offline_done,
+ prep_offline_free,
+};
+
+void
+mail_prep_offline(const char *uri,
+ CamelOperation *cancel,
+ void (*done)(const char *, void *data),
+ void *data)
+{
+ struct _prep_offline_msg *m;
+
+ m = mail_msg_new(&prep_offline_op, NULL, sizeof(*m));
+ m->cancel = cancel;
+ if (cancel)
+ camel_operation_ref(cancel);
+ m->uri = g_strdup(uri);
+ m->data = data;
+ m->done = done;
+
+ e_thread_put(mail_thread_queued, (EMsg *)m);
+}
+
/* ** GO OFFLINE ***************************************************** */
struct _set_offline_msg {
@@ -2102,9 +2181,9 @@ static char *set_offline_desc(struct _mail_msg *mm, int done)
char *service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE);
char *msg;
- msg = g_strdup_printf (m->offline ? _("Disconnecting from %s") :
- _("Reconnecting to %s"), service_name);
- g_free (service_name);
+ msg = g_strdup_printf(m->offline?_("Disconnecting from %s"):_("Reconnecting to %s"),
+ service_name);
+ g_free(service_name);
return msg;
}
@@ -2118,29 +2197,11 @@ static void set_offline_do(struct _mail_msg *mm)
camel_service_disconnect (CAMEL_SERVICE (m->store),
TRUE, &mm->ex);
}
- return;
- }
-
- if (m->offline && camel_disco_store_status (CAMEL_DISCO_STORE (m->store)) == CAMEL_DISCO_STORE_ONLINE) {
- CamelFolder *inbox;
-
- /* FIXME. Something more generic here... (bug 10755) */
- inbox = camel_store_get_inbox (m->store, NULL);
- if (inbox) {
- camel_disco_folder_prepare_for_offline (
- CAMEL_DISCO_FOLDER (inbox),
- "(match-all (not (system-flag \"Seen\")))",
- &mm->ex);
- camel_folder_sync (inbox, FALSE, NULL);
- camel_object_unref (CAMEL_OBJECT (inbox));
- if (camel_exception_is_set (&mm->ex))
- return;
- }
+ } else {
+ camel_disco_store_set_status (CAMEL_DISCO_STORE (m->store),
+ m->offline ? CAMEL_DISCO_STORE_OFFLINE : CAMEL_DISCO_STORE_ONLINE,
+ &mm->ex);
}
-
- camel_disco_store_set_status (CAMEL_DISCO_STORE (m->store),
- m->offline ? CAMEL_DISCO_STORE_OFFLINE :
- CAMEL_DISCO_STORE_ONLINE, &mm->ex);
}
static void set_offline_done(struct _mail_msg *mm)
@@ -2188,7 +2249,6 @@ mail_store_set_offline (CamelStore *store, gboolean offline,
e_thread_put(mail_thread_queued, (EMsg *)m);
}
-
/* ** Execute Shell Command ***************************************************** */
struct _execute_shell_command_msg {