evolution r35552 - trunk/mail
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r35552 - trunk/mail
- Date: Mon, 26 May 2008 18:11:49 +0000 (UTC)
Author: mcrha
Date: Mon May 26 18:11:49 2008
New Revision: 35552
URL: http://svn.gnome.org/viewvc/evolution?rev=35552&view=rev
Log:
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.
Modified:
trunk/mail/ChangeLog
trunk/mail/evolution-mail.schemas.in
trunk/mail/mail-component.c
trunk/mail/mail-config.c
trunk/mail/mail-config.h
trunk/mail/mail-ops.c
trunk/mail/mail-send-recv.c
Modified: trunk/mail/evolution-mail.schemas.in
==============================================================================
--- trunk/mail/evolution-mail.schemas.in (original)
+++ trunk/mail/evolution-mail.schemas.in Mon May 26 18:11:49 2008
@@ -1332,5 +1332,22 @@
</locale>
</schema>
+ <!-- Others -->
+
+ <schema>
+ <key>/schemas/apps/evolution/mail/sync_interval</key>
+ <applyto>/apps/evolution/mail/sync_interval</applyto>
+ <owner>evolution-mail</owner>
+ <type>int</type>
+ <default>60</default>
+ <locale name="C">
+ <short>Time interval, in seconds, how often upload store changes to server.</short>
+ <long>
+ Time interval, in seconds, how often upload store changes to server.
+ The actual value cannot be less than 30 seconds.
+ </long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
Modified: trunk/mail/mail-component.c
==============================================================================
--- trunk/mail/mail-component.c (original)
+++ trunk/mail/mail-component.c Mon May 26 18:11:49 2008
@@ -145,6 +145,9 @@
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 @@
{
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 @@
}
/* 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 @@
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 @@
(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. */
Modified: trunk/mail/mail-config.c
==============================================================================
--- trunk/mail/mail-config.c (original)
+++ trunk/mail/mail-config.c Mon May 26 18:11:49 2008
@@ -679,6 +679,31 @@
return config->mlimit_size;
}
+/* timeout interval, in seconds, when to call server update */
+gint
+mail_config_get_sync_timeout (void)
+{
+ GConfClient *gconf = mail_config_get_gconf_client ();
+ gint res = 60;
+
+ if (gconf) {
+ GError *error = NULL;
+
+ res = gconf_client_get_int (gconf, "/apps/evolution/mail/sync_interval", &error);
+
+ /* do not allow recheck sooner than every 30 seconds */
+ if (error || res == 0)
+ res = 60;
+ else if (res < 30)
+ res = 30;
+
+ if (error)
+ g_error_free (error);
+ }
+
+ return res;
+}
+
gboolean
mail_config_get_enable_magic_spacebar ()
{
Modified: trunk/mail/mail-config.h
==============================================================================
--- trunk/mail/mail-config.h (original)
+++ trunk/mail/mail-config.h Mon May 26 18:11:49 2008
@@ -154,6 +154,8 @@
guint mail_config_get_error_timeout (void);
guint mail_config_get_error_level (void);
+gint mail_config_get_sync_timeout (void);
+
void mail_config_reload_junk_headers (void);
gboolean mail_config_get_lookup_book (void);
gboolean mail_config_get_lookup_book_local_only (void);
Modified: trunk/mail/mail-ops.c
==============================================================================
--- trunk/mail/mail-ops.c (original)
+++ trunk/mail/mail-ops.c Mon May 26 18:11:49 2008
@@ -1620,7 +1620,10 @@
static void
refresh_folder_exec (struct _sync_folder_msg *m)
{
- camel_folder_refresh_info(m->folder, &m->base.ex);
+ camel_folder_sync (m->folder, FALSE, &m->base.ex);
+
+ if (!camel_exception_is_set (&m->base.ex))
+ camel_folder_refresh_info(m->folder, &m->base.ex);
}
/* we just use the sync stuff where we can, since it would be the same */
Modified: trunk/mail/mail-send-recv.c
==============================================================================
--- trunk/mail/mail-send-recv.c (original)
+++ trunk/mail/mail-send-recv.c Mon May 26 18:11:49 2008
@@ -829,6 +829,8 @@
for (i=0;i<m->folders->len;i++) {
folder = mail_tool_uri_to_folder(m->folders->pdata[i], 0, &ex);
if (folder) {
+ camel_folder_sync (folder, FALSE, &ex);
+ camel_exception_clear(&ex);
camel_folder_refresh_info(folder, &ex);
camel_exception_clear(&ex);
camel_object_unref(folder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]