aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-component.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-05-27 02:11:49 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-05-27 02:11:49 +0800
commitb67d6b02ca832f90e3e1b98bf85f98b68009f25d (patch)
tree2b8191b24a206b080efe2cfec445767a02b82072 /mail/mail-component.c
parentc9d8512b2e3a29263935bef58ae1c01469dee0c4 (diff)
downloadgsoc2013-evolution-b67d6b02ca832f90e3e1b98bf85f98b68009f25d.tar
gsoc2013-evolution-b67d6b02ca832f90e3e1b98bf85f98b68009f25d.tar.gz
gsoc2013-evolution-b67d6b02ca832f90e3e1b98bf85f98b68009f25d.tar.bz2
gsoc2013-evolution-b67d6b02ca832f90e3e1b98bf85f98b68009f25d.tar.lz
gsoc2013-evolution-b67d6b02ca832f90e3e1b98bf85f98b68009f25d.tar.xz
gsoc2013-evolution-b67d6b02ca832f90e3e1b98bf85f98b68009f25d.tar.zst
gsoc2013-evolution-b67d6b02ca832f90e3e1b98bf85f98b68009f25d.zip
** Fix for bug #317755
2008-05-26 Milan Crha <mcrha@redhat.com> ** Fix for bug #317755 * mail-send-recv.c: (refresh_folders_exec): * mail-ops.c: (refresh_folder_desc): Also sync with a server when refreshing folder. * evolution-mail.schemas.in: * mail-config.h: (mail_config_get_sync_timeout): * mail-config.c: (mail_config_get_sync_timeout): Use int value of /apps/evolution/mail/sync_interval where is set how often propagate local changes to server. * mail-component.c: (struct _MailComponentPrivate), (impl_dispose), (mc_sync_store_done), (mc_sync_store), (call_mail_sync), (mail_component_init): Upload local changes to server on some interval. * mail-component.c: (impl_quit): Do not quit until we are done with mail sync. svn path=/trunk/; revision=35552
Diffstat (limited to 'mail/mail-component.c')
-rw-r--r--mail/mail-component.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 7c83872314..850efe70e7 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -145,6 +145,9 @@ struct _MailComponentPrivate {
ELogger *logger;
EComponentView *component_view;
+
+ guint mail_sync_id; /* timeout id for sync call on the stores */
+ guint mail_sync_in_progress; /* is greater than 0 if still waiting to finish sync on some store */
};
/* indexed by _mail_component_folder_t */
@@ -452,6 +455,11 @@ impl_dispose (GObject *object)
{
MailComponentPrivate *priv = MAIL_COMPONENT (object)->priv;
+ if (priv->mail_sync_id) {
+ g_source_remove (priv->mail_sync_id);
+ priv->mail_sync_id = 0;
+ }
+
view_changed_timeout_remove ((EComponentView *)object);
if (priv->activity_handler != NULL) {
@@ -875,7 +883,7 @@ impl_quit(PortableServer_Servant servant, CORBA_Environment *ev)
}
/* Falls through */
case MC_QUIT_SYNC:
- if (mc->priv->quit_count > 0)
+ if (mc->priv->quit_count > 0 || mc->priv->mail_sync_in_progress > 0)
return FALSE;
mail_cancel_all();
@@ -1067,6 +1075,43 @@ impl_upgradeFromVersion (PortableServer_Servant servant, const short major, cons
camel_exception_clear (&ex);
}
+static void
+mc_sync_store_done (CamelStore *store, void *data)
+{
+ MailComponent *mc = (MailComponent *) data;
+
+ mc->priv->mail_sync_in_progress--;
+}
+
+static void
+mc_sync_store (gpointer key, gpointer value, gpointer user_data)
+{
+ extern int camel_application_is_exiting;
+ MailComponent *mc = (MailComponent *) user_data;
+
+ mc->priv->mail_sync_in_progress++;
+
+ if (!camel_application_is_exiting)
+ mail_sync_store (CAMEL_STORE (key), FALSE, mc_sync_store_done, mc);
+ else
+ mc_sync_store_done (CAMEL_STORE (key), mc);
+}
+
+static gboolean
+call_mail_sync (gpointer user_data)
+{
+ extern int camel_application_is_exiting;
+ MailComponent *mc = (MailComponent *)user_data;
+
+ if (camel_application_is_exiting)
+ return FALSE;
+
+ if (!mc->priv->mail_sync_in_progress && session && camel_session_is_online (session))
+ mail_component_stores_foreach (mc, mc_sync_store, mc);
+
+ return !camel_application_is_exiting;
+}
+
struct _setline_data {
GNOME_Evolution_Listener listener;
CORBA_boolean status;
@@ -1247,6 +1292,9 @@ mail_component_init (MailComponent *component)
(GDestroyNotify) store_hash_free);
mail_autoreceive_init();
+
+ priv->mail_sync_in_progress = 0;
+ priv->mail_sync_id = g_timeout_add_seconds (mail_config_get_sync_timeout (), call_mail_sync, component);
}
/* Public API. */