X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-view-window.c;h=593725f1ed250a129c07726136c669a00c12ec3a;hb=f02807b9ef9bdaa0291310798541fefadbb13227;hp=0bfcf6b4b0c6d58c7d6e837ad26b0f859d302044;hpb=c5e5c216be6773f1a37385084d067672db73edc3;p=modest diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 0bfcf6b..593725f 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -55,9 +55,11 @@ #include #include #include +#include #include #include #include +#include #define DEFAULT_FOLDER "MyDocs/.documents" @@ -724,8 +726,8 @@ select_next_valid_row (GtkTreeModel *model, /* TODO: This should be in _init(), with the parameters as properties. */ static void modest_msg_view_window_construct (ModestMsgViewWindow *self, - const gchar *modest_account_name, - const gchar *msg_uid) + const gchar *modest_account_name, + const gchar *msg_uid) { GObject *obj = NULL; ModestMsgViewWindowPrivate *priv = NULL; @@ -824,7 +826,6 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, /* Init the clipboard actions dim status */ modest_msg_view_grab_focus(MODEST_MSG_VIEW (priv->msg_view)); - gtk_widget_show_all (GTK_WIDGET (obj)); update_window_title (MODEST_MSG_VIEW_WINDOW (obj)); @@ -845,6 +846,10 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, ModestWindow *main_window = NULL; ModestWindowMgr *mgr = NULL; + MODEST_DEBUG_BLOCK ( + modest_tny_mime_part_to_string (TNY_MIME_PART (msg), 0); + ); + mgr = modest_runtime_get_window_mgr (); window = MODEST_MSG_VIEW_WINDOW (modest_window_mgr_get_msg_view_window (mgr)); g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL); @@ -865,11 +870,16 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, if (header_view != NULL){ header_folder = modest_header_view_get_folder(header_view); - priv->is_outbox = (modest_tny_folder_guess_folder_type (header_folder) == TNY_FOLDER_TYPE_OUTBOX); - g_assert(header_folder != NULL); - priv->header_folder_id = tny_folder_get_id(header_folder); - g_assert(priv->header_folder_id != NULL); - g_object_unref(header_folder); + /* This could happen if the header folder was + unseleted before opening this msg window (for + example if the user selects an account in the + folder view of the main window */ + if (header_folder) { + priv->is_outbox = (modest_tny_folder_guess_folder_type (header_folder) == TNY_FOLDER_TYPE_OUTBOX); + priv->header_folder_id = tny_folder_get_id(header_folder); + g_assert(priv->header_folder_id != NULL); + g_object_unref(header_folder); + } } priv->header_model = g_object_ref(model); @@ -942,6 +952,8 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg, update_window_title (window); modest_msg_view_window_update_priority (window); + gtk_widget_show_all (GTK_WIDGET (window)); + return MODEST_WINDOW(window); } @@ -965,6 +977,8 @@ modest_msg_view_window_new_for_attachment (TnyMsg *msg, tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); update_window_title (MODEST_MSG_VIEW_WINDOW (obj)); + gtk_widget_show_all (GTK_WIDGET (obj)); + /* Check dimming rules */ modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (obj)); modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (obj)); @@ -1094,10 +1108,10 @@ void modest_msg_view_window_on_row_reordered( * the new model. In this case the view will be detached from it's * header folder. From this point the next/prev buttons are dimmed. */ -void modest_msg_view_window_update_model_replaced( - ModestHeaderViewObserver *observer, - GtkTreeModel *model, - const gchar *tny_folder_id){ +void +modest_msg_view_window_update_model_replaced(ModestHeaderViewObserver *observer, + GtkTreeModel *model, + const gchar *tny_folder_id){ ModestMsgViewWindowPrivate *priv = NULL; ModestMsgViewWindow *window = NULL; @@ -1111,7 +1125,8 @@ void modest_msg_view_window_update_model_replaced( * not care about it's model (msg list). Else if the * header-view shows the folder the msg shown by us is in, we * shall replace our model reference and make some check. */ - if(tny_folder_id == NULL || !g_str_equal(tny_folder_id, priv->header_folder_id)) + if(tny_folder_id == NULL || + (priv->header_folder_id && !g_str_equal(tny_folder_id, priv->header_folder_id))) return; /* Model is changed(replaced), so we should forget the old @@ -1615,17 +1630,13 @@ message_reader_performer (gboolean canceled, /* New mail operation */ mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(parent_window), - modest_ui_actions_get_msgs_full_error_handler, + modest_ui_actions_disk_operations_error_handler, NULL, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); modest_mail_operation_get_msg (mail_op, info->header, view_msg_cb, info->row_reference); g_object_unref (mail_op); - /* Update dimming rules */ - modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (parent_window)); - modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (parent_window)); - frees: /* Frees. The row_reference will be freed by the view_msg_cb callback */ g_object_unref (info->header); @@ -2231,9 +2242,8 @@ on_mail_operation_finished (ModestMailOperation *mail_op, if (op_type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || op_type == MODEST_MAIL_OPERATION_TYPE_OPEN ) { while (tmp) { - modest_progress_object_remove_operation ( - MODEST_PROGRESS_OBJECT (tmp->data), - mail_op); + modest_progress_object_remove_operation (MODEST_PROGRESS_OBJECT (tmp->data), + mail_op); tmp = g_slist_next (tmp); } @@ -2241,6 +2251,14 @@ on_mail_operation_finished (ModestMailOperation *mail_op, if (observers_empty (self)) { set_toolbar_mode (self, TOOLBAR_MODE_NORMAL); } + + /* Update dimming rules. We have to do this right here + and not in view_msg_cb because at that point the + transfer mode is still enabled so the dimming rule + won't let the user delete the message that has been + readed for example */ + modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (self)); + modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self)); } } @@ -2342,7 +2360,7 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart return; } - if (!TNY_IS_MSG (mime_part)) { + if (!modest_tny_mime_part_is_msg (mime_part)) { gchar *filepath = NULL; const gchar *att_filename = tny_mime_part_get_filename (mime_part); const gchar *content_type; @@ -2431,7 +2449,7 @@ typedef struct { GList *pairs; GtkWidget *banner; - gboolean result; + GnomeVFSResult result; } SaveMimePartInfo; static void save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct); @@ -2464,16 +2482,16 @@ idle_save_mime_part_show_result (SaveMimePartInfo *info) if (info->pairs != NULL) { save_mime_part_to_file (info); } else { - gboolean result; - result = info->result; - /* This is a GDK lock because we are an idle callback and * hildon_banner_show_information is or does Gtk+ code */ gdk_threads_enter (); /* CHECKED */ save_mime_part_info_free (info, TRUE); - if (result) { + if (info->result == GNOME_VFS_OK) { hildon_banner_show_information (NULL, NULL, _CS("sfil_ib_saved")); + } else if (info->result == GNOME_VFS_ERROR_NO_SPACE) { + hildon_banner_show_information (NULL, NULL, dgettext("ke-recv", + "cerm_device_memory_full")); } else { hildon_banner_show_information (NULL, NULL, _("mail_ib_file_operation_failed")); } @@ -2486,26 +2504,22 @@ idle_save_mime_part_show_result (SaveMimePartInfo *info) static gpointer save_mime_part_to_file (SaveMimePartInfo *info) { - GnomeVFSResult result; GnomeVFSHandle *handle; TnyStream *stream; SaveMimePartPair *pair = (SaveMimePartPair *) info->pairs->data; - gboolean decode_result = TRUE; - result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0644); - if (result == GNOME_VFS_OK) { + info->result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0644); + if (info->result == GNOME_VFS_OK) { stream = tny_vfs_stream_new (handle); if (tny_mime_part_decode_to_stream (pair->part, stream, NULL) < 0) { - decode_result = FALSE; + info->result = GNOME_VFS_ERROR_IO; } g_object_unref (G_OBJECT (stream)); g_object_unref (pair->part); g_slice_free (SaveMimePartPair, pair); info->pairs = g_list_delete_link (info->pairs, info->pairs); - info->result = decode_result; } else { save_mime_part_info_free (info, FALSE); - info->result = FALSE; } g_idle_add ((GSourceFunc) idle_save_mime_part_show_result, info); @@ -2556,7 +2570,6 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *m GList *files_to_save = NULL; GtkWidget *save_dialog = NULL; gchar *folder = NULL; - gboolean canceled = FALSE; const gchar *filename = NULL; gchar *save_multiple_str = NULL; @@ -2578,11 +2591,15 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *m iter = tny_list_create_iterator (mime_parts); TnyMimePart *mime_part = (TnyMimePart *) tny_iterator_get_current (iter); g_object_unref (iter); - if (!TNY_IS_MSG (mime_part) && tny_mime_part_is_attachment (mime_part)) { + if (!modest_tny_mime_part_is_msg (mime_part) && + modest_tny_mime_part_is_attachment_for_modest (mime_part) && + !tny_mime_part_is_purged (mime_part)) { filename = tny_mime_part_get_filename (mime_part); } else { + /* TODO: show any error? */ g_warning ("Tried to save a non-file attachment"); - canceled = TRUE; + g_object_unref (mime_parts); + return; } g_object_unref (mime_part); } else { @@ -2606,6 +2623,7 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *m /* if multiple, set multiple string */ if (save_multiple_str) { g_object_set (G_OBJECT (save_dialog), "save-multiple", save_multiple_str, NULL); + gtk_window_set_title (GTK_WINDOW (save_dialog), _FM("sfil_ti_save_objects_files")); } /* show dialog */ @@ -2622,7 +2640,8 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *m while (!tny_iterator_is_done (iter)) { TnyMimePart *mime_part = (TnyMimePart *) tny_iterator_get_current (iter); - if ((tny_mime_part_is_attachment (mime_part)) && + if ((modest_tny_mime_part_is_attachment_for_modest (mime_part)) && + !tny_mime_part_is_purged (mime_part) && (tny_mime_part_get_filename (mime_part) != NULL)) { SaveMimePartPair *pair; @@ -2723,7 +2742,7 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean iter = tny_list_create_iterator (mime_parts); part = (TnyMimePart *) tny_iterator_get_current (iter); g_object_unref (iter); - if (TNY_IS_MSG (part)) { + if (modest_tny_mime_part_is_msg (part)) { TnyHeader *header; header = tny_msg_get_header (TNY_MSG (part)); filename = tny_header_get_subject (header);