From 10135c887c0c30ddefa85716b06d3e5795a17651 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Wed, 12 Mar 2008 11:57:23 +0000 Subject: [PATCH] Work to fix bug NB#81989: * src/modest-ui-actions.[ch]: * Now send receive operations get an interactive parameter. This is used to know if the action was scheduled pressing any UI send receive action. * If a send queue operation has errors, and last operation done on it was an interactive send receive, we show the errors. If not, errors do not show feedback. * src/dbus_api/modest-dbus-callback.c: * Set as non interactive send receive operations requested from dbus. * src/maemo/modest-main-window.c: * Set as interactive send receive mail operations requested from toolbar button. * src/modest-mail-operation.[ch]: * Set "send mail" operations as non interactive to disable error feedback. * Propagate and set properly the interactive values for send receive operations. * src/modest-tny-send-queue.[ch]: * Add an internal attribute to set if last request to send queue was an interactive send receive. * src/modest-tny-account-store.c: * Send receive scheduled by a connection status change is a non interactive send receive. pmo-trunk-r4299 --- src/dbus_api/modest-dbus-callbacks.c | 2 +- src/maemo/modest-main-window.c | 4 ++-- src/modest-mail-operation.c | 6 ++++++ src/modest-mail-operation.h | 2 ++ src/modest-tny-account-store.c | 2 +- src/modest-tny-send-queue.c | 27 +++++++++++++++++++++++++++ src/modest-tny-send-queue.h | 22 ++++++++++++++++++++++ src/modest-ui-actions.c | 19 +++++++++++++------ src/modest-ui-actions.h | 6 +++++- 9 files changed, 79 insertions(+), 11 deletions(-) diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index fa4b30a..b0c4f04 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -794,7 +794,7 @@ on_idle_send_receive(gpointer user_data) if (auto_update) /* Do send receive */ - modest_ui_actions_do_send_receive_all (main_win, FALSE, FALSE); + modest_ui_actions_do_send_receive_all (main_win, FALSE, FALSE, FALSE); else /* Disable auto update */ modest_platform_set_update_interval (0); diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 70c4cad..88cc77e 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -2547,9 +2547,9 @@ refresh_account (const gchar *account_name) /* If account_name == NULL, we must update all (option All) */ if (!account_name) - modest_ui_actions_do_send_receive_all (win, TRUE, TRUE); + modest_ui_actions_do_send_receive_all (win, TRUE, TRUE, TRUE); else - modest_ui_actions_do_send_receive (account_name, TRUE, TRUE, win); + modest_ui_actions_do_send_receive (account_name, TRUE, TRUE, TRUE, win); } diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 1f49f12..7c522bc 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -626,6 +626,7 @@ modest_mail_operation_send_mail (ModestMailOperation *self, modest_mail_operation_notify_start (self); tny_send_queue_add_async (send_queue, msg, NULL, NULL, NULL); + modest_tny_send_queue_set_requested_send_receive (MODEST_TNY_SEND_QUEUE (send_queue), FALSE); priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS; modest_mail_operation_notify_end (self); @@ -1180,6 +1181,7 @@ typedef struct gboolean poke_all; TnyFolderObserver *inbox_observer; RetrieveAllCallback retrieve_all_cb; + gboolean interactive; } UpdateAccountInfo; @@ -1372,6 +1374,8 @@ inbox_refreshed_cb (TnyFolder *inbox, /* Try to send */ tny_camel_send_queue_flush (TNY_CAMEL_SEND_QUEUE (send_queue)); + modest_tny_send_queue_set_requested_send_receive (MODEST_TNY_SEND_QUEUE (send_queue), + info->interactive); } } @@ -1491,6 +1495,7 @@ void modest_mail_operation_update_account (ModestMailOperation *self, const gchar *account_name, gboolean poke_all, + gboolean interactive, RetrieveAllCallback retrieve_all_cb, UpdateAccountCallback callback, gpointer user_data) @@ -1539,6 +1544,7 @@ modest_mail_operation_update_account (ModestMailOperation *self, info->folders = tny_simple_list_new (); info->mail_op = g_object_ref (self); info->poke_all = poke_all; + info->interactive = interactive; info->account_name = g_strdup (account_name); info->callback = callback; info->user_data = user_data; diff --git a/src/modest-mail-operation.h b/src/modest-mail-operation.h index c721541..f646929 100644 --- a/src/modest-mail-operation.h +++ b/src/modest-mail-operation.h @@ -424,6 +424,7 @@ void modest_mail_operation_save_to_drafts (ModestMailOperation *self, * @self: a #ModestMailOperation * @account_name: the id of a Modest account * @poke_all: if TRUE it will also do a poke_status over all folders of the account + * @interactive: if TRUE the update account was scheduled by an interactive send receive * * Asynchronously refreshes the root folders of the given store * account. The caller should add the #ModestMailOperation to a @@ -448,6 +449,7 @@ void modest_mail_operation_save_to_drafts (ModestMailOperation *self, void modest_mail_operation_update_account (ModestMailOperation *self, const gchar *account_name, gboolean poke_all, + gboolean interactive, RetrieveAllCallback retrieve_all_cb, UpdateAccountCallback callback, gpointer user_data); diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index a9459cd..05f8fc2 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -1500,7 +1500,7 @@ connection_status_changed (TnyAccount *account, /* Perform a send receive */ account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account); main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE); - modest_ui_actions_do_send_receive (account_name, FALSE, FALSE, main_window); + modest_ui_actions_do_send_receive (account_name, FALSE, FALSE, FALSE, main_window); } } diff --git a/src/modest-tny-send-queue.c b/src/modest-tny-send-queue.c index 37e26f9..fbeb4c7 100644 --- a/src/modest-tny-send-queue.c +++ b/src/modest-tny-send-queue.c @@ -105,6 +105,9 @@ struct _ModestTnySendQueuePrivate { /* Special folders */ TnyFolder *outbox; TnyFolder *sentbox; + + /* last was send receive operation?*/ + gboolean requested_send_receive; }; #define MODEST_TNY_SEND_QUEUE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ @@ -424,6 +427,8 @@ modest_tny_send_queue_new (TnyCamelTransportAccount *account) priv->sentbox = modest_tny_account_get_special_folder (TNY_ACCOUNT(account), TNY_FOLDER_TYPE_SENT); + priv->requested_send_receive = FALSE; + headers = tny_simple_list_new (); tny_folder_get_headers (priv->outbox, headers, TRUE, NULL); @@ -761,3 +766,25 @@ modest_tny_send_queue_wakeup (ModestTnySendQueue *self) g_object_unref (iter); g_object_unref (G_OBJECT (headers)); } + +gboolean +modest_tny_send_queue_get_requested_send_receive (ModestTnySendQueue *self) +{ + ModestTnySendQueuePrivate *priv; + + g_return_val_if_fail (MODEST_IS_TNY_SEND_QUEUE (self), FALSE); + priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self); + + return priv->requested_send_receive; +} + +void +modest_tny_send_queue_set_requested_send_receive (ModestTnySendQueue *self, gboolean requested_send_receive) +{ + ModestTnySendQueuePrivate *priv; + + g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE (self)); + priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self); + + priv->requested_send_receive = requested_send_receive; +} diff --git a/src/modest-tny-send-queue.h b/src/modest-tny-send-queue.h index 826b778..a1cfedd 100644 --- a/src/modest-tny-send-queue.h +++ b/src/modest-tny-send-queue.h @@ -155,6 +155,28 @@ gchar* modest_tny_send_queue_to_string (ModestTnySendQueue *self); */ void modest_tny_send_queue_wakeup (ModestTnySendQueue *self); +/** + * modest_tny_send_queue_get_requested_send_receive: + * @self: a #ModestTnySendQueue + * + * gets if the last request to send queue was an interactive send + * receive or not. + * + * Returns: %TRUE if last request was an interactive send receive, + * %FALSE otherwise. + */ +gboolean modest_tny_send_queue_get_requested_send_receive (ModestTnySendQueue *self); + +/** + * modest_tny_send_queue_set_requested_send_receive: + * @self: a #ModestTnySendQueue + * @requested_send_receive: mode. + * + * this should be called on each call to process the queue, to distinguish if the + * action was an interactive send receive. + */ +void modest_tny_send_queue_set_requested_send_receive (ModestTnySendQueue *self, gboolean requested_send_receive); + G_END_DECLS diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index e361b67..d7d3d7a 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -1801,6 +1801,7 @@ typedef struct { ModestWindow *win; gchar *account_name; gboolean poke_status; + gboolean interactive; } SendReceiveInfo; static void @@ -1835,7 +1836,7 @@ do_send_receive_performer (gboolean canceled, /* Send & receive. */ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); - modest_mail_operation_update_account (mail_op, info->account_name, info->poke_status, + modest_mail_operation_update_account (mail_op, info->account_name, info->poke_status, info->interactive, (info->win) ? retrieve_all_messages_cb : NULL, new_messages_arrived, info->win); g_object_unref (G_OBJECT (mail_op)); @@ -1861,6 +1862,7 @@ void modest_ui_actions_do_send_receive (const gchar *account_name, gboolean force_connection, gboolean poke_status, + gboolean interactive, ModestWindow *win) { gchar *acc_name = NULL; @@ -1889,6 +1891,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name, info->account_name = acc_name; info->win = (win) ? g_object_ref (win) : NULL; info->poke_status = poke_status; + info->interactive = interactive; info->account = modest_tny_account_store_get_server_account (acc_store, acc_name, TNY_ACCOUNT_TYPE_STORE); @@ -1978,7 +1981,8 @@ modest_ui_actions_cancel_send (GtkAction *action, ModestWindow *win) void modest_ui_actions_do_send_receive_all (ModestWindow *win, gboolean force_connection, - gboolean poke_status) + gboolean poke_status, + gboolean interactive) { GSList *account_names, *iter; @@ -1989,7 +1993,7 @@ modest_ui_actions_do_send_receive_all (ModestWindow *win, while (iter) { modest_ui_actions_do_send_receive ((const char*) iter->data, force_connection, - poke_status, win); + poke_status, interactive, win); iter = g_slist_next (iter); } @@ -2032,7 +2036,7 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win) /* Refresh the active account. Force the connection if needed and poke the status of all folders */ - modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, win); + modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, TRUE, win); } @@ -5511,10 +5515,13 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, TnyTransportAccount *server_account; gchar *message = NULL; - /* Don't show anything if the user cancelled something */ - if (err->code == TNY_SYSTEM_ERROR_CANCEL) + /* Don't show anything if the user cancelled something or the send receive request is not + * interactive */ + if (err->code == TNY_SYSTEM_ERROR_CANCEL || + !modest_tny_send_queue_get_requested_send_receive (MODEST_TNY_SEND_QUEUE (self))) return; + /* Get the server name: */ server_account = TNY_TRANSPORT_ACCOUNT (tny_camel_send_queue_get_transport_account (TNY_CAMEL_SEND_QUEUE (self))); diff --git a/src/modest-ui-actions.h b/src/modest-ui-actions.h index c09626a..c746512 100644 --- a/src/modest-ui-actions.h +++ b/src/modest-ui-actions.h @@ -200,18 +200,21 @@ void modest_ui_actions_cancel_send (GtkAction *action, ModestWindow *win); * @win: the window that will be used as source of the refresh mail operation * @force_connection: whether or not the code should try to force a new connection if we're offline * @poke_status: wheter ot not we want to poke the status of all mail folders + * @interactive: is coming from an interactive send receive. * * Refreshes all the accounts **/ void modest_ui_actions_do_send_receive_all (ModestWindow *win, gboolean force_connection, - gboolean poke_status); + gboolean poke_status, + gboolean interactive); /** * modest_ui_actions_do_send_receive: * @account_name: the name of the Modest account or NULL * @force_connection: whether or not the code should try to force a new connection if we're offline * @poke_status: wheter ot not we want to poke the status of all mail folders + * @interactive: is coming from an interactive send receive * @win: the window that will be used as source of the refresh mail operation * * Refreshes the Modest account whose name is passed as argument. If @@ -222,6 +225,7 @@ void modest_ui_actions_do_send_receive_all (ModestWindow *win, void modest_ui_actions_do_send_receive (const gchar *account_name, gboolean force_connection, gboolean poke_status, + gboolean interactive, ModestWindow *win); /** -- 1.7.9.5