From a4828845f0defcb856c4be2a1c24757b8765afd8 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Tue, 15 May 2007 17:58:09 +0000 Subject: Improved offline support options svn path=/trunk/; revision=33548 --- mail/ChangeLog | 14 +++++++++ mail/em-folder-view.c | 20 +++++++++++- mail/evolution-mail.schemas.in.in | 15 ++++++++- mail/mail-component.c | 3 +- mail/mail-ops.c | 65 +++++++++++++++++++++++++++++++++++++++ mail/mail.error.xml | 7 +++++ 6 files changed, 121 insertions(+), 3 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 93b68cad34..163c80da53 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,17 @@ +2007-05-15 Srinivasa Ragavan + + ** Improved options for offline support. + + * em-folder-view.c: (prepare_offline), (emfv_prepare_offline): Adds + option for downloading for offline. + * evolution-mail.schemas.in.in: + * mail-component.c: (status_check): Adds a option for non-sync while + going offline. + * mail-ops.c: (prepare_offline_desc), (prepare_offline_do), + (prepare_offline_done), (prepare_offline_free), + (mail_store_prepare_offline): + * mail.error.xml: + 2007-05-13 Srinivasa Ragavan ** Fix for bug #334966 diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index 30a736d49b..0ebb079e49 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include #include @@ -1322,6 +1324,22 @@ emfv_empty_trash(BonoboUIComponent *uid, void *data, const char *path) em_utils_empty_trash (gtk_widget_get_toplevel ((GtkWidget *) emfv)); } +static void +prepare_offline(void *key, void *value, void *data) +{ + CamelService *service = key; + + if (CAMEL_IS_DISCO_STORE(service) + || CAMEL_IS_OFFLINE_STORE(service)) { + mail_store_prepare_offline((CamelStore *)service); + } +} + +static void +emfv_prepare_offline(BonoboUIComponent *uid, void *data, const char *path) +{ + mail_component_stores_foreach(mail_component_peek(), prepare_offline, NULL); +} static void emfv_edit_cut(BonoboUIComponent *uid, void *data, const char *path) @@ -1737,7 +1755,7 @@ EMFV_MAP_CALLBACK(emfv_tools_vfolder_mlist, emfv_popup_vfolder_mlist) static BonoboUIVerb emfv_message_verbs[] = { BONOBO_UI_UNSAFE_VERB ("EmptyTrash", emfv_empty_trash), - + BONOBO_UI_UNSAFE_VERB ("PrepareForOffline", emfv_prepare_offline), BONOBO_UI_UNSAFE_VERB ("EditCut", emfv_edit_cut), BONOBO_UI_UNSAFE_VERB ("EditCopy", emfv_edit_copy), BONOBO_UI_UNSAFE_VERB ("EditPaste", emfv_edit_paste), diff --git a/mail/evolution-mail.schemas.in.in b/mail/evolution-mail.schemas.in.in index e2f7d41abb..1276d96ac0 100644 --- a/mail/evolution-mail.schemas.in.in +++ b/mail/evolution-mail.schemas.in.in @@ -790,7 +790,20 @@ - + + /schemas/apps/evolution/mail/prompts/quick_offline + /apps/evolution/mail/prompts/quick_offline + evolution-mail + bool + true + + Prompt to check if the user wants to go offline immediately + + It disables the feature where repeated prompts to ask if offline sync is required. + + + + /schemas/apps/evolution/mail/trash/empty_on_exit diff --git a/mail/mail-component.c b/mail/mail-component.c index 9bd59e06c2..804788912f 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -1099,7 +1099,8 @@ status_check (GNOME_Evolution_ShellState shell_state) { case GNOME_Evolution_USER_OFFLINE: status = OFFLINE; - break; + if (em_utils_prompt_user (NULL, "/apps/evolution/mail/prompts/quick_offline", "mail:ask-quick-offline", NULL)) + break; case GNOME_Evolution_FORCED_OFFLINE: /*Network is down so change network state on the camel session*/ status = OFFLINE; diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 2c09c26833..777639fc50 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -2350,6 +2350,71 @@ mail_store_set_offline (CamelStore *store, gboolean offline, return id; } +/* ** Prepare OFFLINE ***************************************************** */ + +static char *prepare_offline_desc(struct _mail_msg *mm, int done) +{ + struct _set_offline_msg *m = (struct _set_offline_msg *)mm; + char *service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE); + char *msg; + + msg = g_strdup_printf(_("Preparing account '%s' for offline"), service_name); + g_free(service_name); + + return msg; +} + +static void prepare_offline_do(struct _mail_msg *mm) +{ + struct _set_offline_msg *m = (struct _set_offline_msg *)mm; + + camel_disco_store_prepare_for_offline (CAMEL_DISCO_STORE (m->store), + &mm->ex); +} + +static void prepare_offline_done(struct _mail_msg *mm) +{ + struct _set_offline_msg *m = (struct _set_offline_msg *)mm; + + if (m->done) + m->done(m->store, m->data); +} + +static void prepare_offline_free(struct _mail_msg *mm) +{ + struct _set_offline_msg *m = (struct _set_offline_msg *)mm; + + camel_object_unref(m->store); +} + +static struct _mail_msg_op prepare_offline_op = { + prepare_offline_desc, + prepare_offline_do, + prepare_offline_done, + prepare_offline_free, +}; + +int +mail_store_prepare_offline (CamelStore *store) +{ + struct _set_offline_msg *m; + int id; + + /* Cancel any pending connect first so the set_offline_op + * thread won't get queued behind a hung connect op. + */ + + m = mail_msg_new(&prepare_offline_op, NULL, sizeof(*m)); + m->store = store; + camel_object_ref(store); + m->data = NULL; + m->done = NULL; + + id = m->msg.seq; + e_thread_put(mail_thread_new, (EMsg *)m); + + return id; +} /* ** Execute Shell Command ***************************************************** */ void diff --git a/mail/mail.error.xml b/mail/mail.error.xml index 936bcf9748..87a1ea5f8d 100644 --- a/mail/mail.error.xml +++ b/mail/mail.error.xml @@ -368,6 +368,13 @@ You can choose to ignore this folder, overwrite or append its contents, or quit.