X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-msg-view-window.c;h=cf2f3f38166b42f53231c4b55cab0faca2135d21;hp=0fff509a95823c0e8bdf0d6f4045c45477312880;hb=f7b838795d57791e623ea279d8971d07864bcbf9;hpb=7f9bb17c7d224f37ff14a4a686791ad704eb6b28 diff --git a/src/hildon2/modest-msg-view-window.c b/src/hildon2/modest-msg-view-window.c index 0fff509..cf2f3f3 100644 --- a/src/hildon2/modest-msg-view-window.c +++ b/src/hildon2/modest-msg-view-window.c @@ -71,6 +71,10 @@ #include #include #include +#include +#include +#include +#include #define MYDOCS_ENV "MYDOCSDIR" #define DOCS_FOLDER ".documents" @@ -236,6 +240,11 @@ static gboolean _modest_msg_view_window_map_event (GtkWidget *widget, gpointer userdata); static void update_branding (ModestMsgViewWindow *self); static void sync_flags (ModestMsgViewWindow *self); +static gboolean on_handle_calendar (ModestMsgView *msgview, TnyMimePart *calendar_part, + GtkContainer *container, ModestMsgViewWindow *self); + +static gboolean on_realize (GtkWidget *widget, + gpointer userdata); /* list my signals */ enum { @@ -483,15 +492,20 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj) priv->remove_attachment_banner = NULL; priv->msg_uid = NULL; priv->other_body = NULL; - + priv->sighandlers = NULL; - + /* Init window */ init_window (MODEST_MSG_VIEW_WINDOW(obj)); - + hildon_program_add_window (hildon_program_get_instance(), HILDON_WINDOW(obj)); + /* Grab the zoom keys, it will be used for Zoom and not for + changing volume */ + g_signal_connect (G_OBJECT (obj), "realize", + G_CALLBACK (on_realize), + NULL); } static void @@ -807,6 +821,8 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, G_CALLBACK (modest_ui_actions_on_msg_link_contextual), obj); g_signal_connect (G_OBJECT(priv->msg_view), "limit_error", G_CALLBACK (modest_ui_actions_on_limit_error), obj); + g_signal_connect (G_OBJECT(priv->msg_view), "handle_calendar", + G_CALLBACK (on_handle_calendar), obj); g_signal_connect (G_OBJECT (priv->msg_view), "fetch_image", G_CALLBACK (on_fetch_image), obj); @@ -2193,10 +2209,10 @@ view_msg_cb (ModestMailOperation *mail_op, modest_window_mgr_unregister_header (modest_runtime_get_window_mgr (), header); row_reference = (GtkTreeRowReference *) user_data; - if (canceled) { + self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op); + if (canceled || !self || MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self)->msg_view == NULL ) { if (row_reference) gtk_tree_row_reference_free (row_reference); - self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op); if (self) { /* Restore window title */ update_window_title (self); @@ -2210,7 +2226,6 @@ view_msg_cb (ModestMailOperation *mail_op, if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg)) { if (row_reference) gtk_tree_row_reference_free (row_reference); - self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op); if (self) { priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); /* First we check if the parent is a folder window */ @@ -2274,7 +2289,6 @@ view_msg_cb (ModestMailOperation *mail_op, } /* Get the window */ - self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op); g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self)); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); @@ -2294,8 +2308,14 @@ view_msg_cb (ModestMailOperation *mail_op, } /* Mark header as read */ - if (!(tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN)) + if (!(tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN)) { + gchar *uid; + tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN); + uid = modest_tny_folder_get_header_unique_id (header); + modest_platform_emit_msg_read_changed_signal (uid, TRUE); + g_free (uid); + } /* Set new message */ if (priv->msg_view != NULL && TNY_IS_MSG_VIEW (priv->msg_view)) { @@ -3081,6 +3101,7 @@ idle_save_mime_part_show_result (SaveMimePartInfo *info) } else { hildon_banner_show_information (NULL, NULL, _("mail_ib_file_operation_failed")); } + set_progress_hint (info->window, FALSE); save_mime_part_info_free (info, FALSE); gdk_threads_leave (); /* CHECKED */ @@ -3204,7 +3225,7 @@ save_mime_part_to_file (SaveMimePartInfo *info) if (written < 0) { g_warning ("modest: could not save attachment %s: %d (%s)\n", pair->filename, error?error->code:-1, error?error->message:"Unknown error"); - if ((error->domain == TNY_ERROR_DOMAIN) && + if (error && (error->domain == TNY_ERROR_DOMAIN) && (error->code == TNY_IO_ERROR_WRITE) && (errno == ENOSPC)) { info->result = GNOME_VFS_ERROR_NO_SPACE; @@ -3275,6 +3296,8 @@ save_mime_parts_to_file_with_checks (GtkWindow *parent, if (!is_ok) { save_mime_part_info_free (info, TRUE); } else { + /* Start progress and launch thread */ + set_progress_hint (info->window, TRUE); g_thread_create ((GThreadFunc)save_mime_part_to_file, info, FALSE, NULL); } @@ -3375,6 +3398,28 @@ save_attachments_response (GtkDialog *dialog, gtk_widget_destroy (GTK_WIDGET (dialog)); } +static gboolean +msg_is_attachment (TnyList *mime_parts) +{ + TnyIterator *iter; + gboolean retval = FALSE; + + if (tny_list_get_length (mime_parts) > 1) + return FALSE; + + iter = tny_list_create_iterator (mime_parts); + if (iter) { + TnyMimePart *part = TNY_MIME_PART (tny_iterator_get_current (iter)); + if (part) { + if (TNY_IS_MSG (part)) + retval = TRUE; + g_object_unref (part); + } + g_object_unref (iter); + } + return retval; +} + void modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, TnyList *mime_parts) @@ -3390,10 +3435,31 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); if (mime_parts == NULL) { + gboolean allow_msgs = FALSE; + /* In Hildon 2.2 save and delete operate over all the attachments as there's no * selection available */ mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view)); - if (mime_parts && !modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, FALSE)) { + + /* Check if the message is composed by an unique MIME + part whose content disposition is attachment. There + could be messages like this: + + Date: Tue, 12 Jan 2010 20:40:59 +0000 + From: + To: + Subject: no body + Content-Type: image/jpeg + Content-Disposition: attachment; filename="bug7718.jpeg" + + whose unique MIME part is the message itself whose + content disposition is attachment + */ + if (mime_parts && msg_is_attachment (mime_parts)) + allow_msgs = TRUE; + + if (mime_parts && + !modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, allow_msgs)) { g_object_unref (mime_parts); return; } @@ -4046,3 +4112,45 @@ sync_flags (ModestMsgViewWindow *self) g_object_unref (header); } } + +static gboolean +on_realize (GtkWidget *widget, + gpointer userdata) +{ + GdkDisplay *display; + Atom atom; + unsigned long val = 1; + + display = gdk_drawable_get_display (widget->window); + atom = gdk_x11_get_xatom_by_name_for_display (display, "_HILDON_ZOOM_KEY_ATOM"); + XChangeProperty (GDK_DISPLAY_XDISPLAY (display), + GDK_WINDOW_XID (widget->window), atom, + XA_INTEGER, 32, PropModeReplace, + (unsigned char *) &val, 1); + + return FALSE; +} + +static gboolean +on_handle_calendar (ModestMsgView *msgview, TnyMimePart *calendar_part, GtkContainer *container, ModestMsgViewWindow *self) +{ + const gchar *account_name; + ModestProtocolType proto_type; + ModestProtocol *protocol; + gboolean retval = FALSE; + + account_name = modest_window_get_active_account (MODEST_WINDOW (self)); + + /* Get proto */ + proto_type = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (), + account_name); + protocol = + modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (), + proto_type); + + if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) { + retval = modest_account_protocol_handle_calendar (MODEST_ACCOUNT_PROTOCOL (protocol), MODEST_WINDOW (self), + calendar_part, container); + } + return retval; +}