diff options
-rw-r--r-- | composer/e-composer-actions.c | 18 | ||||
-rw-r--r-- | composer/mail-composer.error.xml | 2 | ||||
-rw-r--r-- | libemail-engine/e-mail-session-utils.c | 10 | ||||
-rw-r--r-- | libemail-engine/mail-ops.c | 14 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 14 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 23 | ||||
-rw-r--r-- | modules/mail-config/e-mail-config-sendmail-backend.c | 11 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 20 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.c | 20 |
9 files changed, 82 insertions, 50 deletions
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c index 8388888234..f16fbdf2f1 100644 --- a/composer/e-composer-actions.c +++ b/composer/e-composer-actions.c @@ -239,23 +239,7 @@ static void action_send_cb (GtkAction *action, EMsgComposer *composer) { - CamelSession *session; - - session = e_msg_composer_ref_session (composer); - - /* If we're online, send the message now. - * Otherwise write the message to Outbox. */ - if (camel_session_get_online (session)) - e_msg_composer_send (composer); - else { - /* Inform the user. */ - e_alert_run_dialog_for_args ( - GTK_WINDOW (composer), - "mail-composer:saving-to-outbox", NULL); - e_msg_composer_save_to_outbox (composer); - } - - g_object_unref (session); + e_msg_composer_send (composer); } static void diff --git a/composer/mail-composer.error.xml b/composer/mail-composer.error.xml index 0f6f11d429..65379e1284 100644 --- a/composer/mail-composer.error.xml +++ b/composer/mail-composer.error.xml @@ -84,7 +84,7 @@ <error id="saving-to-outbox" type="info"> <_primary>Saving message to Outbox.</_primary> - <_secondary>Because you are working offline, the message will be saved to your local Outbox folder. When you are back online you can send the message by clicking the Send/Receive button in Evolution's toolbar.</_secondary> + <_secondary>The message will be saved to your local Outbox folder, because the destination service is currently unavailable. You can send the message by clicking the Send/Receive button in Evolution's toolbar.</_secondary> </error> </error-list> diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c index ce400c4d10..da54b7640d 100644 --- a/libemail-engine/e-mail-session-utils.c +++ b/libemail-engine/e-mail-session-utils.c @@ -552,6 +552,14 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, return; } + provider = camel_service_get_provider (service); + if ((provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0 && + !camel_session_get_online (CAMEL_SESSION (session))) { + /* silently ignore */ + g_object_unref (service); + return; + } + status = camel_service_get_connection_status (service); if (status != CAMEL_SERVICE_CONNECTED) { did_connect = TRUE; @@ -566,8 +574,6 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, } } - provider = camel_service_get_provider (service); - if (provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER) copy_to_sent = FALSE; diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c index 2084aa1e01..b54ac06e23 100644 --- a/libemail-engine/mail-ops.c +++ b/libemail-engine/mail-ops.c @@ -242,6 +242,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m, struct _filter_mail_msg *fm = (struct _filter_mail_msg *) m; GObjectClass *class; CamelFolder *folder = NULL; + CamelProvider *provider; CamelService *service; CamelSession *session; CamelSettings *settings; @@ -258,6 +259,11 @@ fetch_mail_exec (struct _fetch_mail_msg *m, service = CAMEL_SERVICE (m->store); session = camel_service_ref_session (service); + provider = camel_service_get_provider (service); + + if (provider && (provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0 && + !camel_session_get_online (session)) + goto exit; fm->destination = e_mail_session_get_local_folder ( E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_LOCAL_INBOX); @@ -265,9 +271,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m, goto exit; g_object_ref (fm->destination); - service = CAMEL_SERVICE (m->store); uid = camel_service_get_uid (service); - settings = camel_service_ref_settings (service); /* XXX This is a POP3-specific setting. */ @@ -703,6 +707,12 @@ mail_send_message (struct _send_queue_msg *m, } if (camel_address_length (recipients) > 0) { + if (provider && (provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0 && + !camel_session_get_online (CAMEL_SESSION (m->session))) { + /* silently ignore */ + goto exit; + } + if (!camel_service_connect_sync ( service, cancellable, error)) goto exit; diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index c9bdaabe79..64e1e2deed 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -520,7 +520,6 @@ composer_send_completed (EMailSession *session, e_mail_session_send_to_finish (session, result, &error); if (e_activity_handle_cancellation (context->activity, error)) { - g_error_free (error); set_changed = TRUE; goto exit; } @@ -538,6 +537,16 @@ composer_send_completed (EMailSession *session, e_shell_submit_alert (shell, alert); g_object_unref (alert); + /* The destination store is offline => save to Outbox and try again later */ + } else if (g_error_matches (error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE)) { + /* Inform the user. */ + e_alert_run_dialog_for_args ( + GTK_WINDOW (context->composer), + "mail-composer:saving-to-outbox", NULL); + e_msg_composer_save_to_outbox (context->composer); + + goto exit; + /* All other errors are shown in the composer window. */ } else if (error != NULL) { gint response; @@ -555,7 +564,6 @@ composer_send_completed (EMailSession *session, e_msg_composer_send (context->composer); if (response == GTK_RESPONSE_ACCEPT) /* Save to Outbox */ e_msg_composer_save_to_outbox (context->composer); - g_error_free (error); set_changed = TRUE; goto exit; } @@ -569,6 +577,8 @@ composer_send_completed (EMailSession *session, gtk_widget_destroy, context->composer); exit: + g_clear_error (&error); + if (set_changed) { gtkhtml_editor_set_changed (GTKHTML_EDITOR (context->composer), TRUE); gtk_window_present (GTK_WINDOW (context->composer)); diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index a11b10662d..c9334bdf59 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -1154,6 +1154,16 @@ receive_update_got_store (CamelStore *store, E_MAIL_SESSION (info->session)); if (store != NULL) { + CamelProvider *provider; + + /* do not update remote stores in offline */ + provider = camel_service_get_provider (CAMEL_SERVICE (store)); + if (provider && (provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0 && + !camel_session_get_online (info->session)) + store = NULL; + } + + if (store != NULL) { mail_folder_cache_note_store ( folder_cache, store, info->cancellable, receive_update_got_folderinfo, info); @@ -1213,7 +1223,7 @@ send_receive (GtkWindow *parent, CamelFolder *local_outbox; CamelService *transport; struct _send_data *data; - GList *scan; + GList *scan, *siter; if (send_recv_dialog != NULL) { if (parent != NULL && gtk_widget_get_realized (send_recv_dialog)) { @@ -1222,9 +1232,6 @@ send_receive (GtkWindow *parent, return send_recv_dialog; } - if (!camel_session_get_online (CAMEL_SESSION (session))) - return send_recv_dialog; - transport = ref_default_transport (session); local_outbox = @@ -1237,8 +1244,10 @@ send_receive (GtkWindow *parent, if (transport != NULL) g_object_unref (transport); - for (scan = data->infos; scan != NULL; scan = scan->next) { - struct _send_info *info = scan->data; + scan = g_list_copy (data->infos); + + for (siter = scan; siter != NULL; siter = siter->next) { + struct _send_info *info = siter->data; if (!CAMEL_IS_SERVICE (info->service)) continue; @@ -1275,6 +1284,8 @@ send_receive (GtkWindow *parent, } } + g_list_free (scan); + return send_recv_dialog; } diff --git a/modules/mail-config/e-mail-config-sendmail-backend.c b/modules/mail-config/e-mail-config-sendmail-backend.c index f656caa6ee..1d92f2f43b 100644 --- a/modules/mail-config/e-mail-config-sendmail-backend.c +++ b/modules/mail-config/e-mail-config-sendmail-backend.c @@ -44,6 +44,7 @@ mail_config_sendmail_backend_insert_widgets (EMailConfigServiceBackend *backend, GtkWidget *custom_binary_entry; GtkWidget *use_custom_args_check; GtkWidget *custom_args_entry; + GtkWidget *send_in_offline; gchar *markup; PangoAttribute *attr; PangoAttrList *attr_list; @@ -124,6 +125,10 @@ mail_config_sendmail_backend_insert_widgets (EMailConfigServiceBackend *backend, gtk_label_set_attributes (GTK_LABEL (widget), attr_list); pango_attr_list_unref (attr_list); + widget = gtk_check_button_new_with_mnemonic (_("Send mail also when in offline _mode")); + gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 2, 1); + send_in_offline = widget; + g_object_bind_property ( use_custom_binary_check, "active", custom_binary_entry, "sensitive", @@ -158,6 +163,12 @@ mail_config_sendmail_backend_insert_widgets (EMailConfigServiceBackend *backend, G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property ( + settings, "send-in-offline", + send_in_offline, "active", + G_BINDING_BIDIRECTIONAL | + G_BINDING_SYNC_CREATE); + gtk_widget_show_all (container); } diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index ed5b30702c..16ad279629 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -1951,26 +1951,6 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) ACTION (MAIL_STOP), "sensitive", G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell, "online", - ACTION (MAIL_SEND_RECEIVE), "sensitive", - G_BINDING_SYNC_CREATE); - - g_object_bind_property ( - shell, "online", - ACTION (MAIL_SEND_RECEIVE_RECEIVE_ALL), "sensitive", - G_BINDING_SYNC_CREATE); - - g_object_bind_property ( - shell, "online", - ACTION (MAIL_SEND_RECEIVE_SEND_ALL), "sensitive", - G_BINDING_SYNC_CREATE); - - g_object_bind_property ( - shell, "online", - ACTION (MAIL_SEND_RECEIVE_SUBMENU), "sensitive", - G_BINDING_SYNC_CREATE); - /* Keep the sensitivity of "Create Search Folder from Search" * in sync with "Save Search" so that its only selectable when * showing search results. */ diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 6373e571a2..54f4d581e4 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -1215,10 +1215,13 @@ send_receive_add_to_menu (SendReceiveData *data, gint position) { GtkWidget *menu_item; + CamelProvider *provider; if (send_receive_find_menu_item (data, service) != NULL) return; + provider = camel_service_get_provider (service); + menu_item = gtk_menu_item_new (); gtk_widget_show (menu_item); @@ -1227,6 +1230,23 @@ send_receive_add_to_menu (SendReceiveData *data, menu_item, "label", G_BINDING_SYNC_CREATE); + if (provider && (provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0) { + gpointer object; + + if (CAMEL_IS_OFFLINE_STORE (service) || + CAMEL_IS_DISCO_STORE (service)) + object = g_object_ref (service); + else + object = camel_service_ref_session (service); + + g_object_bind_property ( + object, "online", + menu_item, "sensitive", + G_BINDING_SYNC_CREATE); + + g_object_unref (object); + } + g_hash_table_insert ( data->menu_items, menu_item, g_object_ref (service)); |