X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=46fb8e31c9a64f59250a32894e424e6130aeb717;hp=f5ecd14efca2e797afa980f0f5b0b9d94095f11d;hb=c7d97f3f8158d317bd5fa78fbb91277a1c3b7555;hpb=85a57f911013b1ac70cd2f07c1f230e772b18183 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index f5ecd14..46fb8e3 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -703,7 +703,8 @@ modest_ui_actions_compose_msg(ModestWindow *win, const gchar *bcc_str, const gchar *subject_str, const gchar *body_str, - GSList *attachments) + GSList *attachments, + gboolean set_as_modified) { gchar *account_name = NULL; TnyMsg *msg = NULL; @@ -758,6 +759,8 @@ modest_ui_actions_compose_msg(ModestWindow *win, attachments = g_slist_next(attachments); } modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win); + modest_msg_edit_window_set_modified (MODEST_MSG_EDIT_WINDOW (msg_win), set_as_modified); + gtk_widget_show_all (GTK_WIDGET (msg_win)); cleanup: @@ -779,7 +782,7 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) if (!modest_ui_actions_run_account_setup_wizard (win)) return; - modest_ui_actions_compose_msg(win, NULL, NULL, NULL, NULL, NULL, NULL); + modest_ui_actions_compose_msg(win, NULL, NULL, NULL, NULL, NULL, NULL, FALSE); } @@ -804,6 +807,28 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op, return TRUE; } +typedef struct { + guint idle_handler; + gchar *message; + GtkWidget *banner; +} OpenMsgBannerInfo; + +gboolean +open_msg_banner_idle (gpointer userdata) +{ + OpenMsgBannerInfo *banner_info = (OpenMsgBannerInfo *) userdata; + + gdk_threads_enter (); + banner_info->idle_handler = 0; + banner_info->banner = modest_platform_animation_banner (NULL, NULL, banner_info->message); + g_object_ref (banner_info->banner); + + gdk_threads_leave (); + + return FALSE; + +} + static void open_msg_cb (ModestMailOperation *mail_op, TnyHeader *header, @@ -819,12 +844,13 @@ open_msg_cb (ModestMailOperation *mail_op, gchar *account = NULL; TnyFolder *folder; gboolean open_in_editor = FALSE; + OpenMsgBannerInfo *banner_info = (OpenMsgBannerInfo *) user_data; /* Do nothing if there was any problem with the mail operation. The error will be shown by the error_handler of the mail operation */ if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg)) - return; + goto banner_cleanup; parent_win = (ModestWindow *) modest_mail_operation_get_source (mail_op); folder = tny_header_get_folder (header); @@ -905,9 +931,6 @@ open_msg_cb (ModestMailOperation *mail_op, win = modest_msg_edit_window_new (msg, account, TRUE); - /* Show banner */ - modest_platform_information_banner_with_timeout - (NULL, NULL, _("mail_ib_opening_draft_message"), 1200); } else { gchar *uid = modest_tny_folder_get_header_unique_id (header); @@ -962,6 +985,20 @@ cleanup: g_free(account); g_object_unref (parent_win); g_object_unref (folder); +banner_cleanup: + if (banner_info) { + g_free (banner_info->message); + if (banner_info->idle_handler > 0) { + g_source_remove (banner_info->idle_handler); + banner_info->idle_handler = 0; + } + if (banner_info->banner != NULL) { + gtk_widget_destroy (banner_info->banner); + g_object_unref (banner_info->banner); + banner_info->banner = NULL; + } + g_slice_free (OpenMsgBannerInfo, banner_info); + } } void @@ -978,9 +1015,13 @@ modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op, if (error->code == TNY_SYSTEM_ERROR_MEMORY || error->code == TNY_IO_ERROR_WRITE || error->code == TNY_IO_ERROR_READ) { - modest_platform_information_banner ((GtkWidget *) win, - NULL, dgettext("ke-recv", - "cerm_device_memory_full")); + ModestMailOperationStatus st = modest_mail_operation_get_status (mail_op); + /* If the mail op has been cancelled then it's not an error: don't show any message */ + if (st != MODEST_MAIL_OPERATION_STATUS_CANCELED) { + modest_platform_information_banner ((GtkWidget *) win, + NULL, dgettext("ke-recv", + "cerm_device_memory_full")); + } } else if (user_data) { modest_platform_information_banner ((GtkWidget *) win, NULL, user_data); @@ -1034,6 +1075,8 @@ open_msgs_performer(gboolean canceled, ModestTransportStoreProtocol proto; TnyList *not_opened_headers; TnyConnectionStatus status; + gboolean show_open_draft = FALSE; + OpenMsgBannerInfo *banner_info = NULL; not_opened_headers = TNY_LIST (user_data); @@ -1065,6 +1108,19 @@ open_msgs_performer(gboolean canceled, g_object_unref (header); g_object_unref (iter); } else { + TnyHeader *header; + TnyFolder *folder; + TnyIterator *iter; + TnyFolderType folder_type; + + iter = tny_list_create_iterator (not_opened_headers); + header = TNY_HEADER (tny_iterator_get_current (iter)); + folder = tny_header_get_folder (header); + folder_type = modest_tny_folder_get_local_or_mmc_folder_type (folder); + show_open_draft = (folder_type == TNY_FOLDER_TYPE_DRAFTS); + g_object_unref (folder); + g_object_unref (header); + g_object_unref (iter); error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error")); } } else { @@ -1078,11 +1134,18 @@ open_msgs_performer(gboolean canceled, error_msg, g_free); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); - + + if (show_open_draft) { + banner_info = g_slice_new (OpenMsgBannerInfo); + banner_info->message = g_strdup (_("mail_ib_opening_draft_message")); + banner_info->banner = NULL; + banner_info->idle_handler = g_timeout_add (500, open_msg_banner_idle, banner_info); + } + modest_mail_operation_get_msgs_full (mail_op, not_opened_headers, open_msg_cb, - NULL, + banner_info, NULL); /* Frees */ @@ -2259,6 +2322,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi guint64 available_disk, expected_size; gint parts_count; guint64 parts_size; + ModestMainWindow *win; g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), FALSE); @@ -2328,9 +2392,18 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi on_save_to_drafts_cb, g_object_ref(edit_window)); -/* info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts")); */ - modest_platform_information_banner (NULL, NULL, _CS("sfil_ib_saving")); - modest_msg_edit_window_reset_modified (edit_window); + /* Use the main window as the parent of the banner, if the + main window does not exist it won't be shown, if the parent + window exists then it's properly shown. We don't use the + editor window because it could be closed (save to drafts + could happen after closing the window */ + win = (ModestMainWindow *) + modest_window_mgr_get_main_window( modest_runtime_get_window_mgr(), FALSE); + if (win) { + modest_platform_information_banner (GTK_WIDGET (win), + NULL, _CS("sfil_ib_saving")); + } + modest_msg_edit_window_set_modified (edit_window, FALSE); /* Frees */ g_free (from); @@ -2355,8 +2428,6 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi * we find a better solution it should be removed * See NB#65125 (commend #18) for details. */ - ModestMainWindow *win = MODEST_MAIN_WINDOW(modest_window_mgr_get_main_window( - modest_runtime_get_window_mgr(), FALSE)); if (!had_error && win != NULL) { ModestFolderView *view = MODEST_FOLDER_VIEW(modest_main_window_get_child_widget( win, MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW)); @@ -3034,6 +3105,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, ModestMainWindow *main_window) { g_return_if_fail(server_account_name); + gboolean completed = FALSE; /* Initalize output parameters: */ if (cancel) @@ -3151,49 +3223,58 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store, */ gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); + + while (!completed) { - if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - if (username) { - *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username))); - - modest_account_mgr_set_server_account_username ( - modest_runtime_get_account_mgr(), server_account_name, - *username); - - const gboolean username_was_changed = - (strcmp (*username, initial_username) != 0); - if (username_was_changed) { - g_warning ("%s: tinymail does not yet support changing the " - "username in the get_password() callback.\n", __FUNCTION__); + if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { + if (username) { + *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username))); + + /* Note that an empty field becomes the "" string */ + if (*username && strlen (*username) > 0) { + modest_account_mgr_set_server_account_username (modest_runtime_get_account_mgr(), + server_account_name, + *username); + completed = TRUE; + + const gboolean username_was_changed = + (strcmp (*username, initial_username) != 0); + if (username_was_changed) { + g_warning ("%s: tinymail does not yet support changing the " + "username in the get_password() callback.\n", __FUNCTION__); + } + } else { + /* Show error */ + modest_platform_information_banner (GTK_WIDGET (dialog), NULL, + _("mcen_ib_username_pw_incorrect")); + completed = FALSE; + } } - } - if (password) { - *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password))); + if (password) { + *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password))); - /* We do not save the password in the configuration, - * because this function is only called for passwords that should - * not be remembered: - modest_server_account_set_password ( + /* We do not save the password in the configuration, + * because this function is only called for passwords that should + * not be remembered: + modest_server_account_set_password ( modest_runtime_get_account_mgr(), server_account_name, *password); - */ + */ + } + if (cancel) + *cancel = FALSE; + } else { + modest_platform_information_banner(GTK_WIDGET (dialog), + NULL, _("mail_ib_login_cancelled")); + completed = TRUE; + if (username) + *username = NULL; + if (password) + *password = NULL; + if (cancel) + *cancel = TRUE; } - - if (cancel) - *cancel = FALSE; - - } else { - modest_platform_information_banner(GTK_WIDGET (main_window), NULL, _("mail_ib_login_cancelled")); - - if (username) - *username = NULL; - - if (password) - *password = NULL; - - if (cancel) - *cancel = TRUE; } /* This is not in the Maemo UI spec: @@ -5369,6 +5450,9 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, case TNY_SERVICE_ERROR_SEND: message = g_strdup (_("emev_ib_ui_smtp_send_error")); break; + case TNY_SERVICE_ERROR_UNAVAILABLE: + message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"), server_name); + break; default: g_warning ("%s: unexpected ERROR %d", __FUNCTION__, err->code);