aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-disco-folder.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-09-23 02:48:34 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-09-23 02:48:34 +0800
commit6abd6e01b3f220a127c780ffdf2ea9a80f028238 (patch)
treece0575d5ed607aaf29739724859318649cf8860c /camel/camel-disco-folder.c
parent5d47e3740be4786532d412529a1d53f32ef4faf5 (diff)
downloadgsoc2013-evolution-6abd6e01b3f220a127c780ffdf2ea9a80f028238.tar
gsoc2013-evolution-6abd6e01b3f220a127c780ffdf2ea9a80f028238.tar.gz
gsoc2013-evolution-6abd6e01b3f220a127c780ffdf2ea9a80f028238.tar.bz2
gsoc2013-evolution-6abd6e01b3f220a127c780ffdf2ea9a80f028238.tar.lz
gsoc2013-evolution-6abd6e01b3f220a127c780ffdf2ea9a80f028238.tar.xz
gsoc2013-evolution-6abd6e01b3f220a127c780ffdf2ea9a80f028238.tar.zst
gsoc2013-evolution-6abd6e01b3f220a127c780ffdf2ea9a80f028238.zip
Added "offline_sync" option, which lets you synchronise all mail to local
2003-09-22 Not Zed <NotZed@Ximian.com> * providers/imap/camel-imap-provider.c: Added "offline_sync" option, which lets you synchronise all mail to local storage automagically. * camel-disco-folder.c (cdf_folder_changed): hook onto the folder changed single, for all new messages, check that they are online using another thread, if the offline_sync option has been enabled for this store. 2003-09-21 Not Zed <NotZed@Ximian.com> * camel-session.c (session_thread_destroy): call proper entry point for freeing the message. 2003-09-18 Not Zed <NotZed@Ximian.com> * camel-folder.c (filter_filter): register the filtering process for progress, and do progress of the filtering process. 2003-09-17 Not Zed <NotZed@Ximian.com> * camel.c (camel_init): init camel operation. * camel-operation.c (camel_operation_reset): removed, not used, not worth it. (camel_operation_mute): new method to stop all status updates permanently. (*): Changed to use thread specific data and a list rather than a hashtable. (cancel_thread): removed. (camel_operation_register): return the previously registered op. svn path=/trunk/; revision=22648
Diffstat (limited to 'camel/camel-disco-folder.c')
-rw-r--r--camel/camel-disco-folder.c77
1 files changed, 75 insertions, 2 deletions
diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c
index 3d3d9212bd..61e825020c 100644
--- a/camel/camel-disco-folder.c
+++ b/camel/camel-disco-folder.c
@@ -29,6 +29,8 @@
#include "camel-disco-store.h"
#include "camel-exception.h"
+#include "camel-session.h"
+
#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (o)))
#define CDF_CLASS(o) (CAMEL_DISCO_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (o)))
@@ -72,6 +74,77 @@ camel_disco_folder_class_init (CamelDiscoFolderClass *camel_disco_folder_class)
camel_folder_class->transfer_messages_to = disco_transfer_messages_to;
}
+struct _cdf_sync_msg {
+ CamelSessionThreadMsg msg;
+
+ CamelFolder *folder;
+ CamelFolderChangeInfo *changes;
+};
+
+static void
+cdf_sync_offline(CamelSession *session, CamelSessionThreadMsg *mm)
+{
+ struct _cdf_sync_msg *m = (struct _cdf_sync_msg *)mm;
+ int i;
+
+ camel_operation_start(NULL, _("Downloading new messages for offline mode"));
+
+ if (m->changes) {
+ for (i=0;i<m->changes->uid_added->len;i++) {
+ int pc = i * 100 / m->changes->uid_added->len;
+
+ camel_operation_progress(NULL, pc);
+ camel_disco_folder_cache_message((CamelDiscoFolder *)m->folder,
+ m->changes->uid_added->pdata[i],
+ &mm->ex);
+ }
+ } else {
+ camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)m->folder,
+ "(match-all)",
+ &mm->ex);
+ }
+
+ camel_operation_end(NULL);
+}
+
+static void
+cdf_sync_free(CamelSession *session, CamelSessionThreadMsg *mm)
+{
+ struct _cdf_sync_msg *m = (struct _cdf_sync_msg *)mm;
+
+ if (m->changes)
+ camel_folder_change_info_free(m->changes);
+ camel_object_unref(m->folder);
+}
+
+static CamelSessionThreadOps cdf_sync_ops = {
+ cdf_sync_offline,
+ cdf_sync_free,
+};
+
+static void
+cdf_folder_changed(CamelFolder *folder, CamelFolderChangeInfo *changes, void *dummy)
+{
+ if (changes->uid_added->len > 0
+ && camel_url_get_param(((CamelService *)folder->parent_store)->url, "offline_sync")) {
+ CamelSession *session = ((CamelService *)folder->parent_store)->session;
+ struct _cdf_sync_msg *m;
+
+ m = camel_session_thread_msg_new(session, &cdf_sync_ops, sizeof(*m));
+ m->changes = camel_folder_change_info_new();
+ camel_folder_change_info_cat(m->changes, changes);
+ m->folder = folder;
+ camel_object_ref(folder);
+ camel_session_thread_queue(session, &m->msg, 0);
+ }
+}
+
+static void
+camel_disco_folder_init(CamelDiscoFolder *folder)
+{
+ camel_object_hook_event(folder, "folder_changed", (CamelObjectEventHookFunc)cdf_folder_changed, NULL);
+}
+
CamelType
camel_disco_folder_get_type (void)
{
@@ -82,8 +155,8 @@ camel_disco_folder_get_type (void)
CAMEL_FOLDER_TYPE, "CamelDiscoFolder",
sizeof (CamelDiscoFolder),
sizeof (CamelDiscoFolderClass),
- (CamelObjectClassInitFunc) camel_disco_folder_class_init,
- NULL, NULL, NULL);
+ (CamelObjectClassInitFunc)camel_disco_folder_class_init, NULL,
+ (CamelObjectInitFunc)camel_disco_folder_init, NULL);
}
return camel_disco_folder_type;