diff options
-rw-r--r-- | mail/ChangeLog | 18 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in | 17 | ||||
-rw-r--r-- | mail/mail-component.c | 50 | ||||
-rw-r--r-- | mail/mail-config.c | 25 | ||||
-rw-r--r-- | mail/mail-config.h | 2 | ||||
-rw-r--r-- | mail/mail-ops.c | 5 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 2 |
7 files changed, 117 insertions, 2 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index b227cff207..2f1f3b0223 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,23 @@ 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. + +2008-05-26 Milan Crha <mcrha@redhat.com> + ** Fix for bug #322553 * mail-config.h: (mail_config_scripts_disabled): diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index 8d2e34d335..3565e01f1a 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -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> 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. */ diff --git a/mail/mail-config.c b/mail/mail-config.c index f966fff0f3..ec89953c05 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -679,6 +679,31 @@ mail_config_get_message_limit (void) 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 () { diff --git a/mail/mail-config.h b/mail/mail-config.h index eaf9b7bd87..01876b2cc8 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -154,6 +154,8 @@ char *mail_config_folder_to_safe_url (struct _CamelFolder *folder); 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); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 77bb37fa62..432e81539c 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1620,7 +1620,10 @@ refresh_folder_desc (struct _sync_folder_msg *m) 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 */ diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index 199a85baa7..7d1db25233 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -829,6 +829,8 @@ refresh_folders_exec (struct _refresh_folders_msg *m) 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); |