#include <modest-tny-account.h>
#include <modest-mime-part-view.h>
#include <modest-isearch-view.h>
+#include <modest-tny-mime-part.h>
#include <math.h>
#include <errno.h>
#include <glib/gstdio.h>
+#include <modest-debug.h>
#define DEFAULT_FOLDER "MyDocs/.documents"
/* 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;
/* 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));
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);
update_window_title (window);
modest_msg_view_window_update_priority (window);
+ gtk_widget_show_all (GTK_WIDGET (window));
+
return MODEST_WINDOW(window);
}
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));
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);
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));
}
}
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;
{
GList *pairs;
GtkWidget *banner;
- gboolean result;
+ GnomeVFSResult result;
} SaveMimePartInfo;
static void save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct);
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"));
}
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);
GList *files_to_save = NULL;
GtkWidget *save_dialog = NULL;
gchar *folder = NULL;
- gboolean canceled = FALSE;
const gchar *filename = NULL;
gchar *save_multiple_str = NULL;
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)) {
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 {
/* 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 */
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_get_filename (mime_part) != NULL)) {
SaveMimePartPair *pair;
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);