[evolution-data-server/meego-eds] Upsync to servers only for remote accounts and that too sync only when there are changes.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/meego-eds] Upsync to servers only for remote accounts and that too sync only when there are changes.
- Date: Thu, 14 Jul 2011 17:01:20 +0000 (UTC)
commit c0a6af400416cad6062fa4e660fa1533fbde69aa
Author: Srinivasa Ragavan <srini linux intel com>
Date: Thu Jul 14 19:56:32 2011 +0300
Upsync to servers only for remote accounts and that too sync only when there are changes.
mail/daemon/mail-folder-cache.c | 34 ++++++++++++++++++++++++++++++++++
mail/daemon/main.c | 2 ++
2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/mail/daemon/mail-folder-cache.c b/mail/daemon/mail-folder-cache.c
index 8de42a8..14fe6fa 100644
--- a/mail/daemon/mail-folder-cache.c
+++ b/mail/daemon/mail-folder-cache.c
@@ -48,6 +48,7 @@
#include "mail-ops.h"
#include "mail-session.h"
#include "mail-tools.h"
+#include "mail-config.h"
#include "e-mail-local.h"
@@ -98,6 +99,7 @@ struct _folder_info {
gboolean has_children;
gpointer folder; /* if known (weak pointer) */
+ guint timeout;
};
/* pending list of updates */
@@ -305,6 +307,20 @@ update_1folder (MailFolderCache *self,
}
static void
+mail_sync_folder_done (CamelFolder *folder, gpointer data, GError *error)
+{
+ /* We don't have to do anything here as of now */
+}
+
+static gboolean
+mail_folder_sync (struct _folder_info *mfi)
+{
+ mail_sync_folder (mfi->folder, FALSE, mail_sync_folder_done, mfi);
+ mfi->timeout = 0;
+ return FALSE;
+}
+
+static void
folder_changed_cb (CamelFolder *folder,
CamelFolderChangeInfo *changes,
MailFolderCache *self)
@@ -323,6 +339,7 @@ folder_changed_cb (CamelFolder *folder,
gint i;
guint32 flags;
gchar *uid = NULL, *sender = NULL, *subject = NULL;
+ gboolean sync_changes = FALSE;
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
@@ -372,6 +389,13 @@ folder_changed_cb (CamelFolder *folder,
camel_folder_free_message_info (folder, info);
}
}
+ } else if (!CAMEL_IS_VEE_FOLDER(folder)
+ && folder != local_drafts
+ && folder != local_outbox
+ && folder != local_sent
+ && changes && changes->uid_changed && changes->uid_changed->len > 0) {
+ /* We must sync this back. */
+ sync_changes = TRUE;
}
if (new > 0)
@@ -385,6 +409,15 @@ folder_changed_cb (CamelFolder *folder,
&& (mfi = g_hash_table_lookup(si->folders, full_name)) != NULL
&& mfi->folder == folder) {
update_1folder (self, mfi, new, uid, sender, subject, NULL);
+ if (sync_changes == TRUE) {
+ if (mfi->timeout) {
+ g_source_remove (mfi->timeout);
+ }
+ mfi->timeout = g_timeout_add_seconds (mail_config_get_sync_timeout (),
+ (GSourceFunc)mail_folder_sync,
+ mfi);
+
+ }
}
g_mutex_unlock (self->priv->stores_mutex);
@@ -433,6 +466,7 @@ free_folder_info(struct _folder_info *mfi)
{
g_free(mfi->full_name);
g_free(mfi->uri);
+ g_source_remove (mfi->timeout);
g_free(mfi);
}
diff --git a/mail/daemon/main.c b/mail/daemon/main.c
index d84849e..01ae841 100644
--- a/mail/daemon/main.c
+++ b/mail/daemon/main.c
@@ -110,10 +110,12 @@ start_mail_engine ()
mail_autoreceive_init (session);
/* In regular intervals, sync to server. We donno how & when the daemon will die */
+#if 0
g_timeout_add_seconds (
mail_config_get_sync_timeout (),
(GSourceFunc) mail_auto_sync,
NULL);
+#endif
e_dbus_manager_new ();
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]