Fix a leak.
[claws.git] / src / messageview.c
index 2b2f743906360d5844baa640593b7444028be4cd..f4ff32419e936d4014a341beb923f9f9720cfd8f 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 #include "defs.h"
 #include "uri_opener.h"
 #include "inc.h"
 #include "log.h"
+#include "privacy.h"
 #include "combobox.h"
 #include "printing.h"
 #include "quoted-printable.h"
 #include "version.h"
 #include "statusbar.h"
-#ifndef USE_NEW_ADDRBOOK
+#include "folder_item_prefs.h"
+#include "avatars.h"
+#ifndef USE_ALT_ADDRBOOK
        #include "addressbook.h"
 #else
        #include "addressadd.h"
@@ -78,11 +80,9 @@ static gint messageview_delete_cb    (GtkWidget              *widget,
                                         MessageView            *messageview);
 static void messageview_size_allocate_cb(GtkWidget     *widget,
                                         GtkAllocation  *allocation);
-#ifndef MAEMO
 static gboolean key_pressed            (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         MessageView    *messageview);
-#endif
 static void return_receipt_show                (NoticeView     *noticeview, 
                                         MsgInfo        *msginfo);      
 static void return_receipt_send_clicked (NoticeView    *noticeview, 
@@ -185,6 +185,16 @@ static void messageview_update             (MessageView    *msgview,
                                         MsgInfo        *old_msginfo);
 static gboolean messageview_update_msg (gpointer source, gpointer data);
 
+static void save_part_as_cb(GtkAction *action, gpointer data);
+static void view_part_as_text_cb(GtkAction *action, gpointer data);
+static void open_part_cb(GtkAction *action, gpointer data);
+#ifndef G_OS_WIN32
+static void open_part_with_cb(GtkAction *action, gpointer data);
+#endif
+static void check_signature_cb(GtkAction *action, gpointer data);
+static void goto_next_part_cb(GtkAction *action, gpointer data);
+static void goto_prev_part_cb(GtkAction *action, gpointer data);
+
 static void messageview_nothing_cb        (GtkAction *action, gpointer data)
 {
 
@@ -204,7 +214,8 @@ static GtkActionEntry msgview_entries[] =
        {"PlaceHolder",                 NULL, "Placeholder", NULL, NULL, G_CALLBACK(messageview_nothing_cb) },
 
 /* File menu */
-       {"File/SaveAs",                 NULL, N_("_Save as..."), "<control>S", NULL, G_CALLBACK(save_as_cb) },
+       {"File/SaveAs",                 NULL, N_("_Save email as..."), "<control>S", NULL, G_CALLBACK(save_as_cb) },
+       {"File/SavePartAs",             NULL, N_("_Save part as..."), "Y", NULL, G_CALLBACK(save_part_as_cb) },
        {"File/PageSetup",              NULL, N_("Page setup..."), NULL, NULL, G_CALLBACK(page_setup_cb) },
        {"File/Print",                  NULL, N_("_Print..."), "<control>P", NULL, G_CALLBACK(print_cb) },
        {"File/---",                    NULL, "---", NULL, NULL, NULL },
@@ -239,8 +250,10 @@ static GtkActionEntry msgview_entries[] =
        {"View/Goto/ParentMessage",     NULL, N_("Parent message"), "<control>Up", NULL, G_CALLBACK(parent_cb) },
        /* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
        {"View/Goto/NextUnreadFolder",  NULL, N_("Next unread _folder"), "<shift>G", NULL, G_CALLBACK(goto_unread_folder_cb) },
-       {"View/Goto/OtherFolder",       NULL, N_("_Other folder..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
+       {"View/Goto/Folder",            NULL, N_("F_older..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
        /* {"View/Goto/---",            NULL, "---", NULL, NULL, NULL }, */
+       {"View/Goto/NextPart",          NULL, N_("Next part"), "A", NULL, G_CALLBACK(goto_next_part_cb) },
+       {"View/Goto/PrevPart",          NULL, N_("Previous part"), "Z", NULL, G_CALLBACK(goto_prev_part_cb) },
         {"View/Scroll",                 NULL, N_("Message scroll") },
         {"View/Scroll/PrevLine",        NULL, N_("Previous line"), NULL, NULL, G_CALLBACK(scroll_prev_line_cb) },
         {"View/Scroll/NextLine",        NULL, N_("Next line"), NULL, NULL, G_CALLBACK(scroll_next_line_cb) },
@@ -271,6 +284,12 @@ static GtkActionEntry msgview_entries[] =
 
        {"View/---",                    NULL, "---", NULL, NULL, NULL },
        {"View/MessageSource",          NULL, N_("Mess_age source"), "<control>U", NULL, G_CALLBACK(view_source_cb) },
+       {"View/Part",                   NULL, N_("Message part") },
+       {"View/Part/AsText",            NULL, N_("View as text"), "T", NULL, G_CALLBACK(view_part_as_text_cb) },
+       {"View/Part/Open",              NULL, N_("Open"), "L", NULL, G_CALLBACK(open_part_cb) },
+#ifndef G_OS_WIN32
+       {"View/Part/OpenWith",          NULL, N_("Open with..."), "O", NULL, G_CALLBACK(open_part_with_cb) },
+#endif
 
        {"View/Quotes",                 NULL, N_("Quotes") }, 
 
@@ -280,14 +299,15 @@ static GtkActionEntry msgview_entries[] =
 
        {"Message/Reply",               NULL, N_("_Reply"), "<control>R", NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REPLY */
        {"Message/ReplyTo",             NULL, N_("Repl_y to") }, 
-       {"Message/ReplyTo/All",         NULL, N_("_all"), "<control><shift>R", NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REPLY_TO_ALL */
-       {"Message/ReplyTo/Sender",      NULL, N_("_sender"), NULL, NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REPLY_TO_SENDER */
-       {"Message/ReplyTo/List",        NULL, N_("mailing _list"), "<control>L", NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REPLY_TO_LIST */
+       {"Message/ReplyTo/All",         NULL, N_("_All"), "<control><shift>R", NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REPLY_TO_ALL */
+       {"Message/ReplyTo/Sender",      NULL, N_("_Sender"), NULL, NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REPLY_TO_SENDER */
+       {"Message/ReplyTo/List",        NULL, N_("Mailing _list"), "<control>L", NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REPLY_TO_LIST */
        /* {"Message/---",                      NULL, "---", NULL, NULL, NULL }, */
 
        {"Message/Forward",             NULL, N_("_Forward"), "<control><alt>F", NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_FORWARD_INLINE */
        {"Message/ForwardAtt",          NULL, N_("For_ward as attachment"), NULL, NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_FORWARD_AS_ATTACH */
        {"Message/Redirect",            NULL, N_("Redirec_t"), NULL, NULL, G_CALLBACK(reply_cb) }, /* COMPOSE_REDIRECT */
+       {"Message/CheckSignature",              NULL, N_("Check signature"), "C", NULL, G_CALLBACK(check_signature_cb) },
 
 /* Tools menu */       
        {"Tools/AddressBook",           NULL, N_("_Address book"), "<control><shift>A", NULL, G_CALLBACK(addressbook_open_cb) }, 
@@ -345,6 +365,7 @@ static GtkRadioActionEntry msgview_radio_enc_entries[] =
        ENC_ACTION(CS_ISO_8859_9, C_ISO_8859_9, N_("Turkish (ISO-8859-_9)")), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_ISO_8859_5, C_ISO_8859_5, "ISO-8859-_5"), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_KOI8_R, C_KOI8_R, "KOI8-_R"), /* RADIO set_charset_cb */
+       ENC_ACTION("Cyrillic/"CS_MACCYR, C_MACCYR, "MAC_CYR"), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_KOI8_U, C_KOI8_U, "KOI8-_U"), /* RADIO set_charset_cb */
        ENC_ACTION("Cyrillic/"CS_WINDOWS_1251, C_WINDOWS_1251, "Windows-1251"), /* RADIO set_charset_cb */
        ENC_ACTION("Japanese/"CS_ISO_2022_JP, C_ISO_2022_JP, "ISO-2022-_JP"), /* RADIO set_charset_cb */
@@ -421,7 +442,7 @@ MessageView *messageview_create(MainWindow *mainwin)
        return messageview;
 }
 
-GList *messageview_get_msgview_list(void)
+const GList *messageview_get_msgview_list(void)
 {
        return msgview_list;
 }
@@ -459,12 +480,7 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        gtk_action_group_add_radio_actions(action_group, msgview_radio_dec_entries,
                        G_N_ELEMENTS(msgview_radio_dec_entries), C_AUTO, G_CALLBACK(set_decode_cb), (gpointer)msgview);
 
-#ifndef MAEMO
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_MENUBAR)
-#else
-       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_POPUP)
-#endif
-
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu", "File", "File", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu", "View", "View", GTK_UI_MANAGER_MENU)
@@ -474,9 +490,11 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
 
 /* File menu */
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "SavePartAs", "File/SavePartAs", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "Separator1", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "PageSetup", "File/PageSetup", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM)
-       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "Separator1", "File/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "Separator2", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/File", "Close", "File/Close", GTK_UI_MANAGER_MENUITEM)
 
 /* Edit menu */
@@ -508,7 +526,10 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Separator7", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM)
-       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "OtherFolder", "View/Goto/OtherFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Folder", "View/Goto/Folder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Separator8", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "NextPart", "View/Goto/NextPart", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "PrevPart", "View/Goto/PrevPart", GTK_UI_MANAGER_MENUITEM)
 
         MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View", "Scroll", "View/Scroll", GTK_UI_MANAGER_MENU)
         MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Scroll", "PrevLine", "View/Scroll/PrevLine", GTK_UI_MANAGER_MENUITEM)
@@ -551,6 +572,7 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Encoding", "Cyrillic", "View/Encoding/Cyrillic", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_ISO_8859_5, "View/Encoding/Cyrillic/"CS_ISO_8859_5, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_KOI8_R, "View/Encoding/Cyrillic/"CS_KOI8_R, GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_MACCYR, "View/Encoding/Cyrillic/"CS_MACCYR, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_KOI8_U, "View/Encoding/Cyrillic/"CS_KOI8_U, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Encoding/Cyrillic", CS_WINDOWS_1251, "View/Encoding/Cyrillic/"CS_WINDOWS_1251, GTK_UI_MANAGER_MENUITEM)
 
@@ -591,6 +613,12 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Quotes", "CollapseAll", "View/Quotes/CollapseAll", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Quotes", "Collapse2", "View/Quotes/Collapse2", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Quotes", "Collapse3", "View/Quotes/Collapse3", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View", "Part", "View/Part", GTK_UI_MANAGER_MENU)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Part", "AsText", "View/Part/AsText", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Part", "Open", "View/Part/Open", GTK_UI_MANAGER_MENUITEM)
+#ifndef G_OS_WIN32
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Part", "OpenWith", "View/Part/OpenWith", GTK_UI_MANAGER_MENUITEM)
+#endif
 
 /* Message menu */
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/Message", "Compose", "Message/Compose", GTK_UI_MANAGER_MENUITEM)
@@ -604,6 +632,7 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/Message", "Forward", "Message/Forward", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/Message", "ForwardAtt", "Message/ForwardAtt", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/Message", "Redirect", "Message/Redirect", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/Message", "CheckSignature", "Message/CheckSignature", GTK_UI_MANAGER_MENUITEM)
 
 /* Tools menu */
        MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/Tools", "AddressBook", "Tools/AddressBook", GTK_UI_MANAGER_MENUITEM)
@@ -636,11 +665,7 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        gtk_widget_show_all(menubar);
        gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(msgview->ui_manager));
 
-#ifndef MAEMO
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
-#else
-       hildon_window_set_menu(HILDON_WINDOW(window), GTK_MENU(menubar));
-#endif
 
        cm_toggle_menu_set_active_full(msgview->ui_manager, "Menu/View/AllHeaders",
                                        prefs_common.show_all_headers);
@@ -652,12 +677,6 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        }
        gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
        gtk_widget_realize(handlebox);
-#ifdef MAEMO
-       msgview->toolbar = toolbar_create(TOOLBAR_MSGVIEW, window,
-                                         (gpointer)msgview);
-       msgview->statusbar = NULL;
-       msgview->statusbar_cid = 0;
-#else
        msgview->toolbar = toolbar_create(TOOLBAR_MSGVIEW, handlebox,
                                          (gpointer)msgview);
 #ifndef GENERIC_UMPC
@@ -671,7 +690,6 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window)
        msgview->statusbar = NULL;
        msgview->statusbar_cid = 0;
 #endif
-#endif
 
 
        msgview->handlebox = handlebox;
@@ -715,16 +733,11 @@ static MessageView *messageview_create_with_new_window_visible(MainWindow *mainw
                         msgview);
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(messageview_delete_cb), msgview);
-#ifdef MAEMO
-       maemo_connect_key_press_to_mainwindow(GTK_WINDOW(window));
-#else
        g_signal_connect(G_OBJECT(window), "key_press_event",
                         G_CALLBACK(key_pressed), msgview);
-#endif
        messageview_add_toolbar(msgview, window);
 
        if (show) {
-               gtk_widget_grab_focus(msgview->mimeview->textview->text);
                gtk_widget_show(window);
        } else {
                gtk_widget_realize(window);
@@ -738,6 +751,11 @@ static MessageView *messageview_create_with_new_window_visible(MainWindow *mainw
                          prefs_common.toolbar_style);
        messageview_init(msgview);
 
+       if (show) {
+               GTK_EVENTS_FLUSH();
+               gtk_widget_grab_focus(msgview->mimeview->textview->text);
+       }
+
        return msgview;
 }
 
@@ -819,7 +837,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
                ok = strcasecmp(to_addr, buf);
                g_free(to_addr);
        } else {
-               strncpy(buf, _("<No Return-Path found>"), 
+               g_strlcpy(buf, _("<No Return-Path found>"), 
                                sizeof(buf));
        }
        
@@ -831,7 +849,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
                    "to be sent does not correspond to the return path:\n"
                    "Notification address: %s\n"
                    "Return path: %s\n"
-                   "It is advised to not to send the return receipt."),
+                   "It is advised to not send the return receipt."),
                  to, buf);
                val = alertpanel_full(_("Warning"), message,
                                _("_Don't Send"), _("_Send"), NULL, FALSE,
@@ -845,14 +863,21 @@ static gint disposition_notification_send(MsgInfo *msginfo)
        ac_list = account_find_all_from_address(ac_list, msginfo->cc);
 
        if (ac_list == NULL) {
-               AlertValue val = 
-               alertpanel_full(_("Warning"),
-                 _("This message is asking for a return receipt notification\n"
-                   "but according to its 'To:' and 'CC:' headers it was not\n"
+               AlertValue val;
+               gchar *text;
+               text = g_strdup_printf(
+                 C_("'%s' stands for 'To' then 'Cc'",
+                   "This message is asking for a return receipt notification\n"
+                   "but according to its '%s' and '%s' headers it was not\n"
                    "officially addressed to you.\n"
-                   "It is advised to not to send the return receipt."),
+                   "It is advised to not send the return receipt."),
+                 prefs_common_translated_header_name("To"),
+                 prefs_common_translated_header_name("Cc"));
+               val = alertpanel_full(_("Warning"),
+                 text,
                  _("_Don't Send"), _("_Send"), NULL, FALSE,
                  NULL, ALERT_WARNING, G_ALERTDEFAULT);
+               g_free(text);
                if (val != G_ALERTALTERNATE)
                        return -1;
        }
@@ -885,7 +910,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
        /* chmod for security */
        if (change_file_mode_rw(fp, tmp) < 0) {
                FILE_OP_ERROR(tmp, "chmod");
-               g_warning("can't change file mode\n");
+               g_warning("can't change file mode");
        }
        
        addr = g_strdup(to);
@@ -958,26 +983,13 @@ static gint disposition_notification_send(MsgInfo *msginfo)
                goto FILE_ERROR;
 
        /* Message ID */
-       if (account->set_domain && account->domain) {
-               g_snprintf(buf, sizeof(buf), "%s", account->domain); 
-       } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
-               g_snprintf(buf, sizeof(buf), "%s", 
-                       strchr(account->address, '@') ?
-                               strchr(account->address, '@')+1 :
-                               account->address);
-       } else {
-               g_snprintf(buf, sizeof(buf), "%s", "");
-       }
-       
        if (account->gen_msgid) {
-               gchar *addr = NULL;
-               if (account->msgid_with_addr) {
-                       addr = account->address;
-               }
-               generate_msgid(buf, sizeof(buf), addr);
-
-               if (fprintf(fp, "Message-ID: <%s>\n", buf) < 0)
+               gchar *addr = prefs_account_generate_msgid(account);
+               if (fprintf(fp, "Message-ID: <%s>\n", addr) < 0) {
+                       g_free(addr);
                        goto FILE_ERROR;
+               }
+               g_free(addr);
        }
 
        boundary = generate_mime_boundary("DN");
@@ -1018,6 +1030,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
                        "\n"
                        "--%s\n"
                        "Content-Type: application/octet-stream\n"
+                       "\n"
                        "Reporting-UA: %s\n"
                        "Original-Recipient: rfc822;%s\n"
                        "Final-Recipient: rfc822;%s\n"
@@ -1061,13 +1074,13 @@ static gint disposition_notification_send(MsgInfo *msginfo)
        queue = account_get_special_folder(account, F_QUEUE);
        if (!queue) queue = folder_get_default_queue();
        if (!queue) {
-               g_warning("can't find queue folder\n");
+               g_warning("can't find queue folder");
                claws_unlink(tmp);
                return -1;
        }
        folder_item_scan(queue);
        if ((num = folder_item_add_msg(queue, tmp, NULL, TRUE)) < 0) {
-               g_warning("can't queue the message\n");
+               g_warning("can't queue the message");
                claws_unlink(tmp);
                return -1;
        }
@@ -1190,11 +1203,12 @@ static void messageview_register_nav(MessageView *messageview)
 }
 
 gboolean messageview_nav_has_prev(MessageView *messageview) {
-       return messageview->trail != NULL &&  messageview->trail_pos > 0;
+       return messageview != NULL && messageview->trail != NULL
+               && messageview->trail_pos > 0;
 }
 
 gboolean messageview_nav_has_next(MessageView *messageview) {
-       if (!messageview->trail)
+       if (!messageview || !messageview->trail)
                return FALSE;
        
        return sc_g_list_bigger(messageview->trail, messageview->trail_pos + 1);
@@ -1252,12 +1266,66 @@ MsgInfo *messageview_nav_get_next(MessageView *messageview) {
        return info;
 }
 
+static gboolean messageview_try_select_mimeinfo(MessageView *messageview, MsgInfo *msginfo, MimeInfo *mimeinfo)
+{
+       if (mimeinfo->type == MIMETYPE_TEXT) {
+               if (!strcasecmp(mimeinfo->subtype, "calendar")
+                               && mimeview_has_viewer_for_content_type(messageview->mimeview, "text/calendar")) {
+                       mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
+                       return TRUE;
+               } else if (!strcasecmp(mimeinfo->subtype, "html")
+                               && mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT
+                               && (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS
+                                       || (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT
+                                               && prefs_common.promote_html_part))) {
+                       mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+static void messageview_find_part_depth_first(MimeInfoSearch *context, MimeMediaType type, const gchar *subtype)
+{
+       MimeInfo * mimeinfo = context->current;
+
+       if (!mimeinfo)
+               return;
+
+       debug_print("found part %d/%s\n", mimeinfo->type, mimeinfo->subtype);
+
+       if (mimeinfo->type == type
+                       && !strcasecmp(mimeinfo->subtype, subtype)) {
+               context->found = mimeinfo;
+       } else if (mimeinfo->type == MIMETYPE_MULTIPART) {
+               if (!strcasecmp(mimeinfo->subtype, "alternative")
+                               || !strcasecmp(mimeinfo->subtype, "related")) {
+                       context->found = procmime_mimeinfo_next(mimeinfo);
+                       while (context->found && context->found != context->parent) {
+                               if (context->found->type == type
+                                       && !strcasecmp(context->found->subtype, subtype))
+                                               break;
+                               context->found = procmime_mimeinfo_next(context->found);
+                       }
+                       if (context->found == context->parent)
+                               context->found = NULL;
+               }
+               if (!context->found
+                       && (!strcasecmp(mimeinfo->subtype, "related")
+                               || !strcasecmp(mimeinfo->subtype, "mixed"))) {
+                       context->parent = mimeinfo;
+                       context->current = procmime_mimeinfo_next(mimeinfo);
+                       messageview_find_part_depth_first(context, type, subtype);
+               }
+       }
+}
+
 gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
                      gboolean all_headers)
 {
        gchar *text = NULL;
        gchar *file;
-       MimeInfo *mimeinfo, *encinfo, *brokeninfo, *root;
+       MimeInfo *mimeinfo, *encinfo, *root;
        gchar *subject = NULL;
        cm_return_val_if_fail(msginfo != NULL, -1);
 
@@ -1308,7 +1376,7 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
                statuswindow_pop_all();
 
        if (!file) {
-               g_warning("can't get message file path.\n");
+               g_warning("can't get message file path.");
                textview_show_error(messageview->mimeview->textview);
                return -1;
        }
@@ -1349,7 +1417,7 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
        }
                        
        if (messageview->msginfo != msginfo) {
-               procmsg_msginfo_free(messageview->msginfo);
+               procmsg_msginfo_free(&(messageview->msginfo));
                messageview->msginfo = NULL;
                messageview_set_menu_sensitive(messageview);
                messageview->msginfo = 
@@ -1361,14 +1429,12 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
                messageview_set_menu_sensitive(messageview);
                messageview->msginfo = msginfo;
        }
-       headerview_show(messageview->headerview, messageview->msginfo);
+       if (prefs_common.display_header_pane)
+               headerview_show(messageview->headerview, messageview->msginfo);
 
        messageview_register_nav(messageview);
        messageview_set_position(messageview, 0);
 
-#ifdef MAEMO
-       maemo_window_full_screen_if_needed(GTK_WINDOW(messageview->window));
-#endif
        if (messageview->window) {
                gtk_window_set_title(GTK_WINDOW(messageview->window), 
                                _("Claws Mail - Message View"));
@@ -1414,7 +1480,7 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
                return_receipt_show(messageview->noticeview, 
                                    messageview->msginfo);
 
-       if ((brokeninfo = find_broken_part(mimeinfo)) != NULL) {
+       if (find_broken_part(mimeinfo) != NULL) {
                noticeview_set_icon(messageview->noticeview,
                                    STOCK_PIXMAP_NOTICE_WARN);
                if (!noticeview_is_visible(messageview->noticeview)) {
@@ -1436,75 +1502,36 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
                        
        root = mimeinfo;
        mimeinfo = procmime_mimeinfo_next(mimeinfo);
-       if (!all_headers && mimeinfo 
-                       && (mimeinfo->type != MIMETYPE_TEXT || 
-           strcasecmp(mimeinfo->subtype, "plain")) 
-                       && (mimeinfo->type != MIMETYPE_MULTIPART || 
-           strcasecmp(mimeinfo->subtype, "signed"))) {
-               if (strcasecmp(mimeinfo->subtype, "html")) {
-                       MimeInfo *saved_mimeinfo = mimeinfo;
-                       MimeInfo *alt_parent = mimeinfo;
-
-                       /* if multipart/{related,mixed} part, look inside for a multipart/alternative child */
-                       if (mimeinfo->type == MIMETYPE_MULTIPART &&
-                           (!strcasecmp(mimeinfo->subtype, "related") ||
-                            !strcasecmp(mimeinfo->subtype, "mixed"))) {
-                               for (; mimeinfo; mimeinfo = procmime_mimeinfo_next(mimeinfo)) {
-                                       if (mimeinfo->node->parent != saved_mimeinfo->node) {
-                                               /* only consider children of the 
-                                                * multipart/{related,mixed} part */
-                                               continue;
-                                       }
-                                       if (mimeinfo->type == MIMETYPE_MULTIPART && 
-                                           !strcasecmp(mimeinfo->subtype, "alternative")) {
-                                               /* we got an alternative part */
-                                               alt_parent = mimeinfo;
-                                               break;
-                                       }
-                                       if (mimeinfo->type == MIMETYPE_TEXT && 
-                                           !strcasecmp(mimeinfo->subtype, "calendar") &&
-                                           mimeview_has_viewer_for_content_type(messageview->mimeview,
-                                                                                "text/calendar")) {
-                                               mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
-                                               goto done;
-                                       } else if (mimeinfo->type == MIMETYPE_TEXT && 
-                                           !strcasecmp(mimeinfo->subtype, "html") &&
-                                           prefs_common.promote_html_part) {
-                                               mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
-                                               goto done;
-                                       }
-                               }
-                       }
-
-                       /* if we now have a multipart/alternative part (possibly inside a
-                        * multipart/{related,mixed} part, look for an HTML part inside */
-                       if (mimeinfo && mimeinfo->type == MIMETYPE_MULTIPART &&
-                           !strcasecmp(mimeinfo->subtype, "alternative")) {
-                               for (; mimeinfo; mimeinfo = procmime_mimeinfo_next(mimeinfo)) {
-                                       if (mimeinfo->node->parent != alt_parent->node) {
-                                               /* only consider children of the 
-                                                * multipart/alternative part, so as
-                                                * not to show html attachments */
-                                               continue;
-                                       }
-                                       if (mimeinfo->type == MIMETYPE_TEXT && 
-                                           !strcasecmp(mimeinfo->subtype, "calendar") &&
-                                           mimeview_has_viewer_for_content_type(messageview->mimeview,
-                                                                                "text/calendar")) {
-                                               mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
+       if (!all_headers && mimeinfo
+                       && (mimeinfo->type != MIMETYPE_TEXT
+                               || strcasecmp(mimeinfo->subtype, "plain"))
+                       && (mimeinfo->type != MIMETYPE_MULTIPART
+                               || strcasecmp(mimeinfo->subtype, "signed"))) {
+               if (strcasecmp(mimeinfo->subtype, "html")) {
+                       MimeInfoSearch context = {
+                               .parent = root,
+                               .current = mimeinfo,
+                               .found = NULL
+                       };
+                       if (mimeview_has_viewer_for_content_type(messageview->mimeview, "text/calendar")) {
+                               MimeInfoSearch cal_context = context;
+                               messageview_find_part_depth_first(&cal_context, MIMETYPE_TEXT, "calendar");
+                               if (cal_context.found) { /* calendar found */
+                                       mimeinfo = cal_context.found;
+                                       if (messageview_try_select_mimeinfo(messageview, msginfo, mimeinfo))
                                                goto done;
-                                       } else if (mimeinfo->type == MIMETYPE_TEXT && 
-                                           !strcasecmp(mimeinfo->subtype, "html") &&
-                                           prefs_common.promote_html_part) {
-                                               mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
-                                               goto done;
-                                       }
                                }
                        }
-                       
-                       /* if we didn't find anything, go back to start */
-                       if (!mimeinfo) 
-                               mimeinfo = saved_mimeinfo;
+                       messageview_find_part_depth_first(&context, MIMETYPE_TEXT, "html");
+                       if (context.found &&
+                           (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS ||
+                            (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT &&
+                             prefs_common.promote_html_part))) { /* html found */
+                               mimeinfo = context.found;
+                               if (messageview_try_select_mimeinfo(messageview, msginfo, mimeinfo))
+                                       goto done;
+                       } else
+                               mimeinfo = root; /* nothing found */
 
                        if (!mimeview_show_part(messageview->mimeview, mimeinfo))
                                mimeview_select_mimepart_icon(messageview->mimeview, root);
@@ -1530,6 +1557,7 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
 
        mimeview_select_mimepart_icon(messageview->mimeview, root);
 done:
+       messageview_set_menu_sensitive(messageview);
        /* plugins may hook in here to work with the message view */
        hooks_invoke(MESSAGE_VIEW_SHOW_DONE_HOOKLIST, messageview);
 
@@ -1554,7 +1582,7 @@ void messageview_clear(MessageView *messageview)
 {
        if (!messageview)
                return;
-       procmsg_msginfo_free(messageview->msginfo);
+       procmsg_msginfo_free(&(messageview->msginfo));
        messageview->msginfo = NULL;
        messageview->filtered = FALSE;
 
@@ -1606,7 +1634,7 @@ void messageview_destroy(MessageView *messageview)
        mimeview_destroy(messageview->mimeview);
        noticeview_destroy(messageview->noticeview);
 
-       procmsg_msginfo_free(messageview->msginfo);
+       procmsg_msginfo_free(&(messageview->msginfo));
        toolbar_clear_list(TOOLBAR_MSGVIEW);
        if (messageview->toolbar) {
                toolbar_destroy(messageview->toolbar);
@@ -1849,7 +1877,7 @@ static void messageview_size_allocate_cb(GtkWidget *widget,
        prefs_common.msgwin_width  = allocation->width;
        prefs_common.msgwin_height = allocation->height;
 }
-#ifndef MAEMO
+
 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
                        MessageView *messageview)
 {
@@ -1865,7 +1893,6 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
 
        return mimeview_pass_key_press_event(messageview->mimeview, event);
 }
-#endif
 
 static void messageview_show_partial_display_cb(NoticeView *noticeview, MessageView *messageview)
 {
@@ -1914,7 +1941,7 @@ static void return_receipt_show(NoticeView *noticeview, MsgInfo *msginfo)
        if (from_me) {
                noticeview_set_icon(noticeview, STOCK_PIXMAP_NOTICE_WARN);
                if (MSG_IS_RETRCPT_GOT(msginfo->flags)) {
-                       noticeview_set_text(noticeview, _("You got a return receipt for this message : "
+                       noticeview_set_text(noticeview, _("You got a return receipt for this message: "
                                                          "it has been displayed by the recipient."));
                } else {
                        noticeview_set_text(noticeview, _("You asked for a return receipt in this message."));
@@ -1939,7 +1966,7 @@ static void return_receipt_send_clicked(NoticeView *noticeview, MsgInfo *msginfo
 
        file = procmsg_get_message_file_path(msginfo);
        if (!file) {
-               g_warning("can't get message file path.\n");
+               g_warning("can't get message file path.");
                return;
        }
 
@@ -1952,7 +1979,7 @@ static void return_receipt_send_clicked(NoticeView *noticeview, MsgInfo *msginfo
                noticeview_hide(noticeview);
        }               
 
-       procmsg_msginfo_free(tmpmsginfo);
+       procmsg_msginfo_free(&tmpmsginfo);
        g_free(file);
 }
 
@@ -2068,9 +2095,9 @@ static PrefsAccount *select_account_from_list(GList *ac_list)
        account_id = ((PrefsAccount *) ac_list->data)->account_id;
        if (alertpanel_with_widget(
                                _("Return Receipt Notification"),
-                               _("The message was sent to several of your "
-                                 "accounts.\n"
-                                 "Please choose which account do you want to "
+                               _("More than one of your accounts uses the "
+                                 "address that this message was sent to.\n"
+                                 "Please choose which account you want to "
                                  "use for sending the receipt notification:"),
                                _("_Cancel"), _("_Send Notification"), NULL,
                                FALSE, G_ALERTDEFAULT, optmenu) != G_ALERTALTERNATE)
@@ -2093,6 +2120,8 @@ gchar *messageview_get_selection(MessageView *msgview)
        GtkTextView *edit = NULL;
        GtkTextBuffer *textbuf;
        gint body_pos = 0;
+       GtkTextIter start_iter, end_iter;
+       GtkTextMark *body_start, *body_end;
        
        cm_return_val_if_fail(msgview != NULL, NULL);
 
@@ -2114,15 +2143,35 @@ gchar *messageview_get_selection(MessageView *msgview)
 
        textbuf = gtk_text_view_get_buffer(edit);
 
-       if (gtk_text_buffer_get_selection_bounds(textbuf, NULL, NULL))
+       if (gtk_text_buffer_get_selection_bounds(textbuf, NULL, NULL)) {
                return gtkut_text_view_get_selection(edit);
-       else if (msgview->filtered) {
-               GtkTextIter start_iter, end_iter;
-               gtk_text_buffer_get_iter_at_offset(textbuf, &start_iter, body_pos);
-               gtk_text_buffer_get_end_iter(textbuf, &end_iter);
-               gtk_text_buffer_get_text(textbuf, &start_iter, &end_iter, FALSE);
-       } else
-               text = NULL;
+       } else {
+               if (msgview->filtered) {
+                       gtk_text_buffer_get_iter_at_offset(textbuf, &start_iter, body_pos);
+                       gtk_text_buffer_get_end_iter(textbuf, &end_iter);
+               } else {
+                       body_start = gtk_text_buffer_get_mark(textbuf, "body_start");
+
+                       /* If there is no body_start mark, an attachment is likely
+                        * selected, and we're looking at instructions on what to do
+                        * with it. No point in quoting that, so we'll just return NULL,
+                        * so that original message body is quoted instead down the line.
+                        */
+                       if (body_start == NULL) {
+                               return NULL;
+                       }
+
+                       gtk_text_buffer_get_iter_at_mark(textbuf, &start_iter, body_start);
+
+                       body_end = gtk_text_buffer_get_mark(textbuf, "body_end");
+                       if (body_end != NULL) /* Just in case */
+                               gtk_text_buffer_get_iter_at_mark(textbuf, &end_iter, body_end);
+                       else
+                               gtk_text_buffer_get_end_iter(textbuf, &end_iter);
+               }
+
+               return gtk_text_buffer_get_text(textbuf, &start_iter, &end_iter, FALSE);
+       }
 
        return text;
 }
@@ -2166,7 +2215,10 @@ static void print_mimeview(MimeView *mimeview, gint sel_start, gint sel_end, gin
                mainwin = mainwindow_get_mainwindow();
                printing_print(GTK_TEXT_VIEW(mimeview->textview->text),
                               mainwin ? GTK_WINDOW(mainwin->window) : NULL,
-                               sel_start, sel_end);
+                               sel_start, sel_end,
+                               (mimeview->textview->image 
+                                       ? GTK_IMAGE(mimeview->textview->image)
+                                       : NULL));
        }
 }
 
@@ -2248,7 +2300,7 @@ static void prev_cb(GtkAction *action, gpointer data)
 {
        MessageView *messageview = (MessageView *)data;
        messageview->updating = TRUE;
-       summary_step(messageview->mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
+       summary_select_prev(messageview->mainwin->summaryview);
        messageview->updating = FALSE;
 
        if (messageview->deferred_destroy) {
@@ -2273,7 +2325,7 @@ static void next_cb(GtkAction *action, gpointer data)
 {
        MessageView *messageview = (MessageView *)data;
        messageview->updating = TRUE;
-       summary_step(messageview->mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
+       summary_select_next(messageview->mainwin->summaryview);
        messageview->updating = FALSE;
 
        if (messageview->deferred_destroy) {
@@ -2503,7 +2555,7 @@ static void prev_history_cb(GtkAction *action, gpointer data)
                messageview_show(messageview, info, 
                                         messageview->all_headers);
                messageview->updating = FALSE;
-               procmsg_msginfo_free(info);
+               procmsg_msginfo_free(&info);
                if (messageview->deferred_destroy) {
                        debug_print("messageview got away!\n");
                        messageview_destroy(messageview);
@@ -2521,7 +2573,7 @@ static void next_history_cb(GtkAction *action, gpointer data)
                messageview_show(messageview, info, 
                                         messageview->all_headers);
                messageview->updating = FALSE;
-               procmsg_msginfo_free(info);
+               procmsg_msginfo_free(&info);
                if (messageview->deferred_destroy) {
                        debug_print("messageview got away!\n");
                        messageview_destroy(messageview);
@@ -2558,8 +2610,9 @@ static void parent_cb(GtkAction *action, gpointer data)
 static void goto_unread_folder_cb(GtkAction *action, gpointer data)
 {
        MessageView *messageview = (MessageView *)data;
+
        messageview->updating = TRUE;
-       folderview_select_next_unread(messageview->mainwin->folderview, FALSE);
+       folderview_select_next_with_flag(messageview->mainwin->folderview, MSG_UNREAD);
        messageview->updating = FALSE;
 
        if (messageview->deferred_destroy) {
@@ -2583,9 +2636,7 @@ static void goto_unread_folder_cb(GtkAction *action, gpointer data)
 static void goto_folder_cb(GtkAction *action, gpointer data)
 {
        MessageView *messageview = (MessageView *)data;
-       messageview->updating = TRUE;
        FolderItem *to_folder;
-       messageview->updating = FALSE;
 
        to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL, FALSE);
 
@@ -2696,7 +2747,7 @@ static void show_all_header_cb(GtkToggleAction *action, gpointer data)
        if (!msginfo) return;
        messageview->msginfo = NULL;
        messageview_show(messageview, msginfo, messageview->all_headers);
-       procmsg_msginfo_free(msginfo);
+       procmsg_msginfo_free(&msginfo);
        main_window_set_menu_sensitive(messageview->mainwin);
        summary_redisplay_msg(messageview->mainwin->summaryview);
 }
@@ -2728,7 +2779,7 @@ static void msg_hide_quotes_cb(GtkToggleAction *action, gpointer data)
        messageview->msginfo = NULL;
        messageview_show(messageview, msginfo,
                         messageview->all_headers);
-       procmsg_msginfo_free(msginfo);
+       procmsg_msginfo_free(&msginfo);
        
        /* update main window */
        main_window_set_menu_sensitive(messageview->mainwin);
@@ -2783,15 +2834,14 @@ static void reply_cb(GtkAction *gaction, gpointer data)
 
 static void addressbook_open_cb(GtkAction *action, gpointer data)
 {
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
        addressbook_open(NULL);
 #else
        GError* error = NULL;
        
        addressbook_dbus_open(FALSE, &error);
        if (error) {
-               g_warning("Failed to open address book");
-               g_warning("%s", error->message);
+               g_warning("Failed to open address book: %s", error->message);
                g_error_free(error);
        }
 #endif
@@ -2802,8 +2852,8 @@ static void add_address_cb(GtkAction *action, gpointer data)
        MessageView *messageview = (MessageView *)data;
        MsgInfo *msginfo, *full_msginfo;
        gchar *from;
-       GtkWidget *image = NULL;
        GdkPixbuf *picture = NULL;
+       AvatarRender *avatarr;
 
        if (!messageview->msginfo || !messageview->msginfo->from) 
                return;
@@ -2814,33 +2864,23 @@ static void add_address_cb(GtkAction *action, gpointer data)
        extract_address(from);
        
        full_msginfo = procmsg_msginfo_get_full_info(msginfo);
-       if (full_msginfo &&
-           full_msginfo->extradata &&
-           full_msginfo->extradata->face) {
-               image = face_get_from_header(full_msginfo->extradata->face);
-       } 
-#if HAVE_LIBCOMPFACE
-       else if (full_msginfo &&
-                full_msginfo->extradata &&
-                full_msginfo->extradata->xface) {
-               image = xface_get_from_header(full_msginfo->extradata->xface,
-                               &(gtk_widget_get_style(messageview->mainwin->summaryview->ctree)->white),
-                               gtk_widget_get_window(messageview->window));
-       }
-#endif
-       procmsg_msginfo_free(full_msginfo);
-       if (image)
-               picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
 
-#ifndef USE_NEW_ADDRBOOK
+       avatarr = avatars_avatarrender_new(full_msginfo);
+       hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
+
+       procmsg_msginfo_free(&full_msginfo);
+
+       if (avatarr->image != NULL)
+               picture = gtk_image_get_pixbuf(GTK_IMAGE(avatarr->image));
+
+#ifndef USE_ALT_ADDRBOOK
        addressbook_add_contact(msginfo->fromname, from, NULL, picture);
 #else
        if (addressadd_selection(msginfo->fromname, from, NULL, picture)) {
                debug_print( "addressbook_add_contact - added\n" );
        }
 #endif
-       if (image)
-               gtk_widget_destroy(image);
+       avatars_avatarrender_free(avatarr);
 }
 
 static void create_filter_cb(GtkAction *gaction, gpointer data)
@@ -2917,7 +2957,7 @@ static gboolean messageview_update_msg(gpointer source, gpointer data)
                                textview_show_info(messageview->mimeview->textview,
                                        MSG_IS_DELETED(old_msginfo->flags) ?
                                        _("\n  Message has been deleted") :
-                                       _("\n  Message has been moved to trash"));
+                                       _("\n  Message has been deleted or moved to another folder"));
                        } else
                                messageview->update_needed = TRUE;
 
@@ -2932,16 +2972,16 @@ static gboolean messageview_update_msg(gpointer source, gpointer data)
 
 void messageview_set_menu_sensitive(MessageView *messageview)
 {
-       if (!messageview || !messageview->new_window) 
+       if (!messageview || !messageview->ui_manager)
                return;
-       /* do some smart things */
-       if (!messageview->menubar) return;
 
        cm_toggle_menu_set_active_full(messageview->ui_manager, "Menu/View/Quotes/CollapseAll", (prefs_common.hide_quotes == 1));
        cm_toggle_menu_set_active_full(messageview->ui_manager, "Menu/View/Quotes/Collapse2", (prefs_common.hide_quotes == 2));
        cm_toggle_menu_set_active_full(messageview->ui_manager, "Menu/View/Quotes/Collapse3", (prefs_common.hide_quotes == 3));
        cm_menu_set_sensitive_full(messageview->ui_manager, "Menu/View/Goto/PrevHistory", messageview_nav_has_prev(messageview));
        cm_menu_set_sensitive_full(messageview->ui_manager, "Menu/View/Goto/NextHistory", messageview_nav_has_next(messageview));
+
+       cm_menu_set_sensitive_full(messageview->ui_manager, "Menu/Message/CheckSignature", messageview->mimeview->signed_part);
 }
 
 void messageview_learn (MessageView *msgview, gboolean is_spam)
@@ -3004,3 +3044,60 @@ void messageview_list_urls (MessageView  *msgview)
        g_slist_free(newlist);
        g_hash_table_destroy(uri_hashtable);
 }
+
+static void save_part_as_cb(GtkAction *action, gpointer data)
+{
+       MessageView *messageview = (MessageView *)data;
+
+       if (messageview->mimeview)
+               mimeview_save_as(messageview->mimeview);
+}
+
+static void view_part_as_text_cb(GtkAction *action, gpointer data)
+{
+       MessageView *messageview = (MessageView *)data;
+
+       if (messageview->mimeview)
+               mimeview_display_as_text(messageview->mimeview);
+}
+
+static void open_part_cb(GtkAction *action, gpointer data)
+{
+       MessageView *messageview = (MessageView *)data;
+
+       if (messageview->mimeview)
+               mimeview_launch(messageview->mimeview, NULL);
+}
+#ifndef G_OS_WIN32
+static void open_part_with_cb(GtkAction *action, gpointer data)
+{
+       MessageView *messageview = (MessageView *)data;
+
+       if (messageview->mimeview)
+               mimeview_open_with(messageview->mimeview);
+}
+#endif
+static void check_signature_cb(GtkAction *action, gpointer data)
+{
+       MessageView *messageview = (MessageView *)data;
+
+       if (messageview->mimeview)
+               mimeview_check_signature(messageview->mimeview);
+}
+
+static void goto_next_part_cb(GtkAction *action, gpointer data)
+{
+       MessageView *messageview = (MessageView *)data;
+
+       if (messageview->mimeview)
+               mimeview_select_next_part(messageview->mimeview);
+}
+
+static void goto_prev_part_cb(GtkAction *action, gpointer data)
+{
+       MessageView *messageview = (MessageView *)data;
+
+       if (messageview->mimeview)
+               mimeview_select_prev_part(messageview->mimeview);
+}
+