Clean-up in comments (The Commit Of The Year).
[claws.git] / src / compose.c
index ae848836433ea7cd53c590bd265fbb8434238d14..a49d6addfaa187b4f98067a34c6382856ae981d7 100644 (file)
 #include "timing.h"
 #include "autofaces.h"
 #include "spell_entry.h"
+#include "headers.h"
+#ifdef USE_LDAP
+#include "password.h"
+#include "ldapserver.h"
+#endif
 
 enum
 {
@@ -122,7 +127,8 @@ enum
 
 typedef enum
 {
-       COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE,
+       COMPOSE_CALL_ADVANCED_ACTION_UNDEFINED = -1,
+       COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE = 0,
        COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_CHARACTER,
        COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_CHARACTER,
        COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_WORD,
@@ -308,11 +314,11 @@ static gint compose_write_body_to_file            (Compose        *compose,
 static gint compose_remove_reedit_target       (Compose        *compose,
                                                 gboolean        force);
 static void compose_remove_draft                       (Compose        *compose);
-static gint compose_queue_sub                  (Compose        *compose,
+static ComposeQueueResult compose_queue_sub                    (Compose        *compose,
                                                 gint           *msgnum,
                                                 FolderItem     **item,
                                                 gchar          **msgpath,
-                                                gboolean       check_subject,
+                                                gboolean       perform_checks,
                                                 gboolean       remove_reedit_target);
 static int compose_add_attachments             (Compose        *compose,
                                                 MimeInfo       *parent);
@@ -488,8 +494,6 @@ static void compose_update_privacy_system_menu_item(Compose * compose, gboolean
 static void activate_privacy_system     (Compose *compose, 
                                          PrefsAccount *account,
                                         gboolean warn);
-static void compose_use_signing(Compose *compose, gboolean use_signing);
-static void compose_use_encryption(Compose *compose, gboolean use_encryption);
 static void compose_toggle_return_receipt_cb(GtkToggleAction *action,
                                         gpointer        data);
 static void compose_toggle_remove_refs_cb(GtkToggleAction *action,
@@ -585,156 +589,154 @@ static void from_name_activate_cb(GtkWidget *widget, gpointer data);
 
 static GtkActionEntry compose_popup_entries[] =
 {
-       {"Compose",                     NULL, "Compose" },
-       {"Compose/Add",                 NULL, N_("_Add..."), NULL, NULL, G_CALLBACK(compose_attach_cb) },
-       {"Compose/Remove",                      NULL, N_("_Remove"), NULL, NULL, G_CALLBACK(compose_attach_remove_selected) },
-       {"Compose/---",                 NULL, "---", NULL, NULL, NULL },
-       {"Compose/Properties",          NULL, N_("_Properties..."), NULL, NULL, G_CALLBACK(compose_attach_property) },
+       {"Compose",            NULL, "Compose", NULL, NULL, NULL },
+       {"Compose/Add",        NULL, N_("_Add..."), NULL, NULL, G_CALLBACK(compose_attach_cb) },
+       {"Compose/Remove",     NULL, N_("_Remove"), NULL, NULL, G_CALLBACK(compose_attach_remove_selected) },
+       {"Compose/---",        NULL, "---", NULL, NULL, NULL },
+       {"Compose/Properties", NULL, N_("_Properties..."), NULL, NULL, G_CALLBACK(compose_attach_property) },
 };
 
 static GtkActionEntry compose_entries[] =
 {
-       {"Menu",                                NULL, "Menu" },
+       {"Menu",                          NULL, "Menu", NULL, NULL, NULL },
 /* menus */
-       {"Message",                     NULL, N_("_Message") },
-       {"Edit",                        NULL, N_("_Edit") },
+       {"Message",                       NULL, N_("_Message"), NULL, NULL, NULL },
+       {"Edit",                          NULL, N_("_Edit"), NULL, NULL, NULL },
 #if USE_ENCHANT
-       {"Spelling",                    NULL, N_("_Spelling") },
+       {"Spelling",                      NULL, N_("_Spelling"), NULL, NULL, NULL },
 #endif
-       {"Options",                     NULL, N_("_Options") },
-       {"Tools",                       NULL, N_("_Tools") },
-       {"Help",                        NULL, N_("_Help") },
+       {"Options",                       NULL, N_("_Options"), NULL, NULL, NULL },
+       {"Tools",                         NULL, N_("_Tools"), NULL, NULL, NULL },
+       {"Help",                          NULL, N_("_Help"), NULL, NULL, NULL },
 /* Message menu */
-       {"Message/Send",                NULL, N_("S_end"), "<control>Return", NULL, G_CALLBACK(compose_send_cb) },
-       {"Message/SendLater",           NULL, N_("Send _later"), "<shift><control>S", NULL, G_CALLBACK(compose_send_later_cb) },
-       {"Message/---",                 NULL, "---" },
-
-       {"Message/AttachFile",          NULL, N_("_Attach file"), "<control>M", NULL, G_CALLBACK(compose_attach_cb) },
-       {"Message/InsertFile",          NULL, N_("_Insert file"), "<control>I", NULL, G_CALLBACK(compose_insert_file_cb) },
-       {"Message/InsertSig",           NULL, N_("Insert si_gnature"), "<control>G", NULL, G_CALLBACK(compose_insert_sig_cb) },
-       {"Message/ReplaceSig",          NULL, N_("_Replace signature"), NULL, NULL, G_CALLBACK(compose_replace_sig_cb) },
-       /* {"Message/---",              NULL, "---" }, */
-       {"Message/Save",                NULL, N_("_Save"), "<control>S", NULL, G_CALLBACK(compose_save_cb) }, /*COMPOSE_KEEP_EDITING*/
-       /* {"Message/---",              NULL, "---" }, */
-       {"Message/Print",               NULL, N_("_Print"), NULL, NULL, G_CALLBACK(compose_print_cb) },
-       /* {"Message/---",              NULL, "---" }, */
-       {"Message/Close",               NULL, N_("_Close"), "<control>W", NULL, G_CALLBACK(compose_close_cb) },
+       {"Message/Send",                  NULL, N_("S_end"), "<control>Return", NULL, G_CALLBACK(compose_send_cb) },
+       {"Message/SendLater",             NULL, N_("Send _later"), "<shift><control>S", NULL, G_CALLBACK(compose_send_later_cb) },
+       {"Message/---",                   NULL, "---", NULL, NULL, NULL },
+
+       {"Message/AttachFile",            NULL, N_("_Attach file"), "<control>M", NULL, G_CALLBACK(compose_attach_cb) },
+       {"Message/InsertFile",            NULL, N_("_Insert file"), "<control>I", NULL, G_CALLBACK(compose_insert_file_cb) },
+       {"Message/InsertSig",             NULL, N_("Insert si_gnature"), "<control>G", NULL, G_CALLBACK(compose_insert_sig_cb) },
+       {"Message/ReplaceSig",            NULL, N_("_Replace signature"), NULL, NULL, G_CALLBACK(compose_replace_sig_cb) },
+       /* {"Message/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Message/Save",                  NULL, N_("_Save"), "<control>S", NULL, G_CALLBACK(compose_save_cb) }, /*COMPOSE_KEEP_EDITING*/
+       /* {"Message/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Message/Print",                 NULL, N_("_Print"), NULL, NULL, G_CALLBACK(compose_print_cb) },
+       /* {"Message/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Message/Close",                 NULL, N_("_Close"), "<control>W", NULL, G_CALLBACK(compose_close_cb) },
 
 /* Edit menu */
-       {"Edit/Undo",                   NULL, N_("_Undo"), "<control>Z", NULL, G_CALLBACK(compose_undo_cb) },
-       {"Edit/Redo",                   NULL, N_("_Redo"), "<control>Y", NULL, G_CALLBACK(compose_redo_cb) },
-       {"Edit/---",                    NULL, "---" },
-
-       {"Edit/Cut",                    NULL, N_("Cu_t"), "<control>X", NULL, G_CALLBACK(compose_cut_cb) },
-       {"Edit/Copy",                   NULL, N_("_Copy"), "<control>C", NULL, G_CALLBACK(compose_copy_cb) },
-       {"Edit/Paste",                  NULL, N_("_Paste"), "<control>V", NULL, G_CALLBACK(compose_paste_cb) },
-
-       {"Edit/SpecialPaste",           NULL, N_("_Special paste") },
-       {"Edit/SpecialPaste/AsQuotation",       NULL, N_("As _quotation"), NULL, NULL, G_CALLBACK(compose_paste_as_quote_cb) },
-       {"Edit/SpecialPaste/Wrapped",   NULL, N_("_Wrapped"), NULL, NULL, G_CALLBACK(compose_paste_wrap_cb) },
-       {"Edit/SpecialPaste/Unwrapped", NULL, N_("_Unwrapped"), NULL, NULL, G_CALLBACK(compose_paste_no_wrap_cb) },
-
-       {"Edit/SelectAll",              NULL, N_("Select _all"), "<control>A", NULL, G_CALLBACK(compose_allsel_cb) },
-
-       {"Edit/Advanced",               NULL, N_("A_dvanced") },
-       {"Edit/Advanced/BackChar",      NULL, N_("Move a character backward"), "<shift><control>B", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_CHARACTER*/
-       {"Edit/Advanced/ForwChar",      NULL, N_("Move a character forward"), "<shift><control>F", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_CHARACTER*/
-       {"Edit/Advanced/BackWord",      NULL, N_("Move a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_WORD*/
-       {"Edit/Advanced/ForwWord",      NULL, N_("Move a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_WORD*/
-       {"Edit/Advanced/BegLine",       NULL, N_("Move to beginning of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE*/
-       {"Edit/Advanced/EndLine",       NULL, N_("Move to end of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_END_OF_LINE*/
-       {"Edit/Advanced/PrevLine",      NULL, N_("Move to previous line"), "<control>P", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_PREVIOUS_LINE*/
-       {"Edit/Advanced/NextLine",      NULL, N_("Move to next line"), "<control>N", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_NEXT_LINE*/
-       {"Edit/Advanced/DelBackChar",   NULL, N_("Delete a character backward"), "<control>H", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_CHARACTER*/
-       {"Edit/Advanced/DelForwChar",   NULL, N_("Delete a character forward"), "<control>D", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_CHARACTER*/
-       {"Edit/Advanced/DelBackWord",   NULL, N_("Delete a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD*/
-       {"Edit/Advanced/DelForwWord",   NULL, N_("Delete a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD*/
-       {"Edit/Advanced/DelLine",       NULL, N_("Delete line"), "<control>U", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE*/
-       {"Edit/Advanced/DelEndLine",    NULL, N_("Delete to end of line"), "<control>K", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END*/
-
-       /* {"Edit/---",                 NULL, "---" }, */
-       {"Edit/Find",           NULL, N_("_Find"), "<control>F", NULL, G_CALLBACK(compose_find_cb) },
-
-       /* {"Edit/---",                 NULL, "---" }, */
-       {"Edit/WrapPara",               NULL, N_("_Wrap current paragraph"), "<control>L", NULL, G_CALLBACK(compose_wrap_cb) }, /* 0 */
-       {"Edit/WrapAllLines",           NULL, N_("Wrap all long _lines"), "<control><alt>L", NULL, G_CALLBACK(compose_wrap_all_cb) }, /* 1 */
-       /* {"Edit/---",                 NULL, "---" }, */
-       {"Edit/ExtEditor",              NULL, N_("Edit with e_xternal editor"), "<shift><control>X", NULL, G_CALLBACK(compose_ext_editor_cb) },
+       {"Edit/Undo",                     NULL, N_("_Undo"), "<control>Z", NULL, G_CALLBACK(compose_undo_cb) },
+       {"Edit/Redo",                     NULL, N_("_Redo"), "<control>Y", NULL, G_CALLBACK(compose_redo_cb) },
+       {"Edit/---",                      NULL, "---", NULL, NULL, NULL },
+
+       {"Edit/Cut",                      NULL, N_("Cu_t"), "<control>X", NULL, G_CALLBACK(compose_cut_cb) },
+       {"Edit/Copy",                     NULL, N_("_Copy"), "<control>C", NULL, G_CALLBACK(compose_copy_cb) },
+       {"Edit/Paste",                    NULL, N_("_Paste"), "<control>V", NULL, G_CALLBACK(compose_paste_cb) },
+
+       {"Edit/SpecialPaste",             NULL, N_("_Special paste"), NULL, NULL, NULL },
+       {"Edit/SpecialPaste/AsQuotation", NULL, N_("As _quotation"), NULL, NULL, G_CALLBACK(compose_paste_as_quote_cb) },
+       {"Edit/SpecialPaste/Wrapped",     NULL, N_("_Wrapped"), NULL, NULL, G_CALLBACK(compose_paste_wrap_cb) },
+       {"Edit/SpecialPaste/Unwrapped",   NULL, N_("_Unwrapped"), NULL, NULL, G_CALLBACK(compose_paste_no_wrap_cb) },
+
+       {"Edit/SelectAll",                NULL, N_("Select _all"), "<control>A", NULL, G_CALLBACK(compose_allsel_cb) },
+
+       {"Edit/Advanced",                 NULL, N_("A_dvanced"), NULL, NULL, NULL },
+       {"Edit/Advanced/BackChar",        NULL, N_("Move a character backward"), "<shift><control>B", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_CHARACTER*/
+       {"Edit/Advanced/ForwChar",        NULL, N_("Move a character forward"), "<shift><control>F", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_CHARACTER*/
+       {"Edit/Advanced/BackWord",        NULL, N_("Move a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BACKWARD_WORD*/
+       {"Edit/Advanced/ForwWord",        NULL, N_("Move a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_FORWARD_WORD*/
+       {"Edit/Advanced/BegLine",         NULL, N_("Move to beginning of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_BEGINNING_OF_LINE*/
+       {"Edit/Advanced/EndLine",         NULL, N_("Move to end of line"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_END_OF_LINE*/
+       {"Edit/Advanced/PrevLine",        NULL, N_("Move to previous line"), "<control>P", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_PREVIOUS_LINE*/
+       {"Edit/Advanced/NextLine",        NULL, N_("Move to next line"), "<control>N", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_MOVE_NEXT_LINE*/
+       {"Edit/Advanced/DelBackChar",     NULL, N_("Delete a character backward"), "<control>H", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_CHARACTER*/
+       {"Edit/Advanced/DelForwChar",     NULL, N_("Delete a character forward"), "<control>D", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_CHARACTER*/
+       {"Edit/Advanced/DelBackWord",     NULL, N_("Delete a word backward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD*/
+       {"Edit/Advanced/DelForwWord",     NULL, N_("Delete a word forward"), NULL, NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD*/
+       {"Edit/Advanced/DelLine",         NULL, N_("Delete line"), "<control>U", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE*/
+       {"Edit/Advanced/DelEndLine",      NULL, N_("Delete to end of line"), "<control>K", NULL, G_CALLBACK(compose_advanced_action_cb) }, /*COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END*/
+
+       /* {"Edit/---",                   NULL, "---", NULL, NULL, NULL }, */
+       {"Edit/Find",                     NULL, N_("_Find"), "<control>F", NULL, G_CALLBACK(compose_find_cb) },
+
+       /* {"Edit/---",                   NULL, "---", NULL, NULL, NULL }, */
+       {"Edit/WrapPara",                 NULL, N_("_Wrap current paragraph"), "<control>L", NULL, G_CALLBACK(compose_wrap_cb) }, /* 0 */
+       {"Edit/WrapAllLines",             NULL, N_("Wrap all long _lines"), "<control><alt>L", NULL, G_CALLBACK(compose_wrap_all_cb) }, /* 1 */
+       /* {"Edit/---",                   NULL, "---", NULL, NULL, NULL }, */
+       {"Edit/ExtEditor",                NULL, N_("Edit with e_xternal editor"), "<shift><control>X", NULL, G_CALLBACK(compose_ext_editor_cb) },
 #if USE_ENCHANT
 /* Spelling menu */
-       {"Spelling/CheckAllSel",        NULL, N_("_Check all or check selection"), NULL, NULL, G_CALLBACK(compose_check_all) },
-       {"Spelling/HighlightAll",       NULL, N_("_Highlight all misspelled words"), NULL, NULL, G_CALLBACK(compose_highlight_all) },
-       {"Spelling/CheckBackwards",     NULL, N_("Check _backwards misspelled word"), NULL, NULL, G_CALLBACK(compose_check_backwards) },
-       {"Spelling/ForwardNext",        NULL, N_("_Forward to next misspelled word"), NULL, NULL, G_CALLBACK(compose_check_forwards_go) },
+       {"Spelling/CheckAllSel",          NULL, N_("_Check all or check selection"), NULL, NULL, G_CALLBACK(compose_check_all) },
+       {"Spelling/HighlightAll",         NULL, N_("_Highlight all misspelled words"), NULL, NULL, G_CALLBACK(compose_highlight_all) },
+       {"Spelling/CheckBackwards",       NULL, N_("Check _backwards misspelled word"), NULL, NULL, G_CALLBACK(compose_check_backwards) },
+       {"Spelling/ForwardNext",          NULL, N_("_Forward to next misspelled word"), NULL, NULL, G_CALLBACK(compose_check_forwards_go) },
 
-       {"Spelling/---",                NULL, "---" },
-       {"Spelling/Options",            NULL, N_("_Options") },
+       {"Spelling/---",                  NULL, "---", NULL, NULL, NULL },
+       {"Spelling/Options",              NULL, N_("_Options"), NULL, NULL, NULL },
 #endif
 
 /* Options menu */
+       {"Options/ReplyMode",                 NULL, N_("Reply _mode"), NULL, NULL, NULL },
+       {"Options/---",                       NULL, "---", NULL, NULL, NULL },
+       {"Options/PrivacySystem",             NULL, N_("Privacy _System"), NULL, NULL, NULL },
+       {"Options/PrivacySystem/PlaceHolder", NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
 
-       {"Options/ReplyMode",           NULL, N_("Reply _mode") },
-       {"Options/---",                 NULL, "---" },
-       {"Options/PrivacySystem",       NULL, N_("Privacy _System") },
-       {"Options/PrivacySystem/PlaceHolder",   NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
-
-       /* {"Options/---",              NULL, "---" }, */
-
-       {"Options/Priority",            NULL, N_("_Priority") },
+       /* {"Options/---",                NULL, "---", NULL, NULL, NULL }, */
+       {"Options/Priority",              NULL, N_("_Priority"), NULL, NULL, NULL },
 
-       {"Options/Encoding",            NULL, N_("Character _encoding") },
-       {"Options/Encoding/---",        NULL, "---" },
+       {"Options/Encoding",              NULL, N_("Character _encoding"), NULL, NULL, NULL },
+       {"Options/Encoding/---",          NULL, "---", NULL, NULL, NULL },
 #define ENC_ACTION(cs_char,c_char,string) \
-       { "Options/Encoding/" cs_char, NULL, N_(string), NULL, NULL, c_char }
-
-       {"Options/Encoding/Western",    NULL, N_("Western European") },
-       {"Options/Encoding/Baltic",     NULL, N_("Baltic") },
-       {"Options/Encoding/Hebrew",     NULL, N_("Hebrew") },
-       {"Options/Encoding/Arabic",     NULL, N_("Arabic") },
-       {"Options/Encoding/Cyrillic",   NULL, N_("Cyrillic") },
-       {"Options/Encoding/Japanese",   NULL, N_("Japanese") },
-       {"Options/Encoding/Chinese",    NULL, N_("Chinese") },
-       {"Options/Encoding/Korean",     NULL, N_("Korean") },
-       {"Options/Encoding/Thai",       NULL, N_("Thai") },
+       {"Options/Encoding/" cs_char, NULL, N_(string), NULL, NULL, c_char }
+
+       {"Options/Encoding/Western",      NULL, N_("Western European"), NULL, NULL, NULL },
+       {"Options/Encoding/Baltic",       NULL, N_("Baltic"), NULL, NULL, NULL },
+       {"Options/Encoding/Hebrew",       NULL, N_("Hebrew"), NULL, NULL, NULL },
+       {"Options/Encoding/Arabic",       NULL, N_("Arabic"), NULL, NULL, NULL },
+       {"Options/Encoding/Cyrillic",     NULL, N_("Cyrillic"), NULL, NULL, NULL },
+       {"Options/Encoding/Japanese",     NULL, N_("Japanese"), NULL, NULL, NULL },
+       {"Options/Encoding/Chinese",      NULL, N_("Chinese"), NULL, NULL, NULL },
+       {"Options/Encoding/Korean",       NULL, N_("Korean"), NULL, NULL, NULL },
+       {"Options/Encoding/Thai",         NULL, N_("Thai"), NULL, NULL, NULL },
 
 /* Tools menu */
-       {"Tools/AddressBook",           NULL, N_("_Address book"), NULL, NULL, G_CALLBACK(compose_address_cb) }, 
+       {"Tools/AddressBook",             NULL, N_("_Address book"), NULL, NULL, G_CALLBACK(compose_address_cb) }, 
 
-       {"Tools/Template",      NULL, N_("_Template") },
-       {"Tools/Template/PlaceHolder",  NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
-       {"Tools/Actions",       NULL, N_("Actio_ns") },
-       {"Tools/Actions/PlaceHolder",   NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
+       {"Tools/Template",                NULL, N_("_Template"), NULL, NULL, NULL },
+       {"Tools/Template/PlaceHolder",    NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
+       {"Tools/Actions",                 NULL, N_("Actio_ns"), NULL, NULL, NULL },
+       {"Tools/Actions/PlaceHolder",     NULL, "Placeholder", NULL, NULL, G_CALLBACK(compose_nothing_cb) },
 
 /* Help menu */
-       {"Help/About",          NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_show_cb) }, 
+       {"Help/About",                    NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_show_cb) }, 
 };
 
 static GtkToggleActionEntry compose_toggle_entries[] =
 {
-       {"Edit/AutoWrap",               NULL, N_("Aut_o wrapping"), "<shift><control>L", NULL, G_CALLBACK(compose_toggle_autowrap_cb) }, /* TOGGLE */
-       {"Edit/AutoIndent",             NULL, N_("Auto _indent"), NULL, NULL, G_CALLBACK(compose_toggle_autoindent_cb) }, /* TOGGLE */
-       {"Options/Sign",                NULL, N_("Si_gn"), NULL, NULL, G_CALLBACK(compose_toggle_sign_cb) }, /* Toggle */
-       {"Options/Encrypt",             NULL, N_("_Encrypt"), NULL, NULL, G_CALLBACK(compose_toggle_encrypt_cb) }, /* Toggle */
-       {"Options/RequestRetRcpt",      NULL, N_("_Request Return Receipt"), NULL, NULL, G_CALLBACK(compose_toggle_return_receipt_cb) }, /* TOGGLE */
-       {"Options/RemoveReferences",    NULL, N_("Remo_ve references"), NULL, NULL, G_CALLBACK(compose_toggle_remove_refs_cb) }, /* TOGGLE */
-       {"Tools/ShowRuler",             NULL, N_("Show _ruler"), NULL, NULL, G_CALLBACK(compose_toggle_ruler_cb) }, /* Toggle */
+       {"Edit/AutoWrap",            NULL, N_("Aut_o wrapping"), "<shift><control>L", NULL, G_CALLBACK(compose_toggle_autowrap_cb), FALSE }, /* Toggle */
+       {"Edit/AutoIndent",          NULL, N_("Auto _indent"), NULL, NULL, G_CALLBACK(compose_toggle_autoindent_cb), FALSE }, /* Toggle */
+       {"Options/Sign",             NULL, N_("Si_gn"), NULL, NULL, G_CALLBACK(compose_toggle_sign_cb), FALSE }, /* Toggle */
+       {"Options/Encrypt",          NULL, N_("_Encrypt"), NULL, NULL, G_CALLBACK(compose_toggle_encrypt_cb), FALSE }, /* Toggle */
+       {"Options/RequestRetRcpt",   NULL, N_("_Request Return Receipt"), NULL, NULL, G_CALLBACK(compose_toggle_return_receipt_cb), FALSE }, /* Toggle */
+       {"Options/RemoveReferences", NULL, N_("Remo_ve references"), NULL, NULL, G_CALLBACK(compose_toggle_remove_refs_cb), FALSE }, /* Toggle */
+       {"Tools/ShowRuler",          NULL, N_("Show _ruler"), NULL, NULL, G_CALLBACK(compose_toggle_ruler_cb), FALSE }, /* Toggle */
 };
 
 static GtkRadioActionEntry compose_radio_rm_entries[] =
 {
-       {"Options/ReplyMode/Normal",    NULL, N_("_Normal"), NULL, NULL, COMPOSE_REPLY }, /* RADIO compose_reply_change_mode_cb */
-       {"Options/ReplyMode/All",       NULL, N_("_All"), NULL, NULL, COMPOSE_REPLY_TO_ALL }, /* RADIO compose_reply_change_mode_cb */
-       {"Options/ReplyMode/Sender",    NULL, N_("_Sender"), NULL, NULL, COMPOSE_REPLY_TO_SENDER }, /* RADIO compose_reply_change_mode_cb */
-       {"Options/ReplyMode/List",      NULL, N_("_Mailing-list"), NULL, NULL, COMPOSE_REPLY_TO_LIST }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/Normal", NULL, N_("_Normal"), NULL, NULL, COMPOSE_REPLY }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/All",    NULL, N_("_All"), NULL, NULL, COMPOSE_REPLY_TO_ALL }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/Sender", NULL, N_("_Sender"), NULL, NULL, COMPOSE_REPLY_TO_SENDER }, /* RADIO compose_reply_change_mode_cb */
+       {"Options/ReplyMode/List",   NULL, N_("_Mailing-list"), NULL, NULL, COMPOSE_REPLY_TO_LIST }, /* RADIO compose_reply_change_mode_cb */
 };
 
 static GtkRadioActionEntry compose_radio_prio_entries[] =
 {
-       {"Options/Priority/Highest",    NULL, N_("_Highest"), NULL, NULL, PRIORITY_HIGHEST }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/High",       NULL, N_("Hi_gh"), NULL, NULL, PRIORITY_HIGH }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/Normal",     NULL, N_("_Normal"), NULL, NULL, PRIORITY_NORMAL }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/Low",        NULL, N_("Lo_w"), NULL, NULL, PRIORITY_LOW }, /* RADIO compose_set_priority_cb */
-       {"Options/Priority/Lowest",     NULL, N_("_Lowest"), NULL, NULL, PRIORITY_LOWEST }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Highest", NULL, N_("_Highest"), NULL, NULL, PRIORITY_HIGHEST }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/High",    NULL, N_("Hi_gh"), NULL, NULL, PRIORITY_HIGH }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Normal",  NULL, N_("_Normal"), NULL, NULL, PRIORITY_NORMAL }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Low",     NULL, N_("Lo_w"), NULL, NULL, PRIORITY_LOW }, /* RADIO compose_set_priority_cb */
+       {"Options/Priority/Lowest",  NULL, N_("_Lowest"), NULL, NULL, PRIORITY_LOWEST }, /* RADIO compose_set_priority_cb */
 };
 
 static GtkRadioActionEntry compose_radio_enc_entries[] =
@@ -836,32 +838,26 @@ static void compose_create_tags(GtkTextView *text, Compose *compose)
 {
        GtkTextBuffer *buffer;
        GdkColor black = {(gulong)0, (gushort)0, (gushort)0, (gushort)0};
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       GdkColormap *cmap;
-       gboolean success[8];
-       int i;
-       GdkColor color[8];
-#endif
 
        buffer = gtk_text_view_get_buffer(text);
 
        if (prefs_common.enable_color) {
                /* grab the quote colors, converting from an int to a GdkColor */
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level1_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL1],
                                               &quote_color1);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level2_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL2],
                                               &quote_color2);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level3_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL3],
                                               &quote_color3);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level1_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL1_BG],
                                               &quote_bgcolor1);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level2_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL2_BG],
                                               &quote_bgcolor2);
-               gtkut_convert_int_to_gdk_color(prefs_common.quote_level3_bgcol,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_QUOTE_LEVEL3_BG],
                                               &quote_bgcolor3);
-               gtkut_convert_int_to_gdk_color(prefs_common.signature_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_SIGNATURE],
                                               &signature_color);
-               gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+               gtkut_convert_int_to_gdk_color(prefs_common.color[COL_URI],
                                               &uri_color);
        } else {
                signature_color = quote_color1 = quote_color2 = quote_color3 = 
@@ -902,29 +898,6 @@ static void compose_create_tags(GtkTextView *text, Compose *compose)
                                         NULL);
        compose->no_wrap_tag = gtk_text_buffer_create_tag(buffer, "no_wrap", NULL);
        compose->no_join_tag = gtk_text_buffer_create_tag(buffer, "no_join", NULL);
-
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       color[0] = quote_color1;
-       color[1] = quote_color2;
-       color[2] = quote_color3;
-       color[3] = quote_bgcolor1;
-       color[4] = quote_bgcolor2;
-       color[5] = quote_bgcolor3;
-       color[6] = signature_color;
-       color[7] = uri_color;
-
-       cmap = gdk_drawable_get_colormap(gtk_widget_get_window(compose->window));
-       gdk_colormap_alloc_colors(cmap, color, 8, FALSE, TRUE, success);
-
-       for (i = 0; i < 8; i++) {
-               if (success[i] == FALSE) {
-                       g_warning("Compose: color allocation failed.");
-                       quote_color1 = quote_color2 = quote_color3 = 
-                               quote_bgcolor1 = quote_bgcolor2 = quote_bgcolor3 = 
-                               signature_color = uri_color = black;
-               }
-       }
-#endif
 }
 
 Compose *compose_new(PrefsAccount *account, const gchar *mailto,
@@ -956,20 +929,11 @@ static void compose_set_save_to(Compose *compose, const gchar *folderidentifier)
 {
        GtkEditable *entry;
        if (folderidentifier) {
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_unset_popdown_strings(GTK_COMBO_BOX(compose->savemsg_combo));
-#else
                combobox_unset_popdown_strings(GTK_COMBO_BOX_TEXT(compose->savemsg_combo));
-#endif
                prefs_common.compose_save_to_history = add_history(
                                prefs_common.compose_save_to_history, folderidentifier);
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(compose->savemsg_combo),
-                               prefs_common.compose_save_to_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(compose->savemsg_combo),
                                prefs_common.compose_save_to_history);
-#endif
        }
 
        entry = GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(compose->savemsg_combo)));
@@ -987,20 +951,11 @@ static gchar *compose_get_save_to(Compose *compose)
        result = gtk_editable_get_chars(entry, 0, -1);
        
        if (result) {
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_unset_popdown_strings(GTK_COMBO_BOX(compose->savemsg_combo));
-#else
                combobox_unset_popdown_strings(GTK_COMBO_BOX_TEXT(compose->savemsg_combo));
-#endif
                prefs_common.compose_save_to_history = add_history(
                                prefs_common.compose_save_to_history, result);
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(compose->savemsg_combo),
-                               prefs_common.compose_save_to_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(compose->savemsg_combo),
                                prefs_common.compose_save_to_history);
-#endif
        }
        return result;
 }
@@ -1086,6 +1041,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        else
                                gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
                        quote_fmt_reset_vartable();
+                       quote_fmtlex_destroy();
 
                        g_free(tmp);
                }
@@ -1179,6 +1135,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                                gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
                        compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
                        quote_fmt_reset_vartable();
+                       quote_fmtlex_destroy();
 
                        g_free(subject);
                        g_free(tmp);
@@ -1226,7 +1183,10 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
                for (curr = attach_files ; curr != NULL ; curr = curr->next) {
                        ainfo = (AttachInfo *) curr->data;
-                       compose_attach_append(compose, ainfo->file, ainfo->file,
+                       if (ainfo->insert)
+                               compose_insert_file(compose, ainfo->file);
+                       else
+                               compose_attach_append(compose, ainfo->file, ainfo->file,
                                        ainfo->content_type, ainfo->charset);
                }
        }
@@ -1321,6 +1281,7 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
                if (privacy_avail && g_slist_length(privacy_avail)) {
                        privacy = (gchar *)(privacy_avail->data);
                }
+               g_slist_free_full(privacy_avail, g_free);
        }
        if (privacy != NULL) {
                if (system) {
@@ -1653,6 +1614,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                else
                        gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
                quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
 
                g_free(tmp);
        }
@@ -1835,6 +1797,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                else
                        gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
                quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
 
                g_free(tmp);
                procmsg_msginfo_free(&full_msginfo);
@@ -2026,6 +1989,7 @@ static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_
                        else
                                gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
                        quote_fmt_reset_vartable();
+                       quote_fmtlex_destroy();
 
                        g_free(tmp);
                }
@@ -2225,7 +2189,6 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
        GtkTextMark *mark;
        GtkTextIter iter;
        FILE *fp;
-       gchar buf[BUFFSIZE];
        gboolean use_signing = FALSE;
        gboolean use_encryption = FALSE;
        gchar *privacy_system = NULL;
@@ -2245,124 +2208,141 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
         if (folder_has_parent_of_type(msginfo->folder, F_QUEUE) ||
            folder_has_parent_of_type(msginfo->folder, F_DRAFT) ||
            folder_has_parent_of_type(msginfo->folder, F_OUTBOX)) {
-               gchar queueheader_buf[BUFFSIZE];
+               gchar *queueheader_buf = NULL;
                gint id, param;
 
                /* Select Account from queue headers */
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Claws-Account-Id:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                                       "X-Claws-Account-Id:")) {
                        id = atoi(&queueheader_buf[strlen("X-Claws-Account-Id:")]);
                        account = account_find_from_id(id);
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Sylpheed-Account-Id:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                                       "X-Sylpheed-Account-Id:")) {
                        id = atoi(&queueheader_buf[strlen("X-Sylpheed-Account-Id:")]);
                        account = account_find_from_id(id);
+                       g_free(queueheader_buf);
                }
-               if (!account && !procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "NAID:")) {
+               if (!account && !procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                                       "NAID:")) {
                        id = atoi(&queueheader_buf[strlen("NAID:")]);
                        account = account_find_from_id(id);
+                       g_free(queueheader_buf);
                }
-               if (!account && !procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                                   sizeof(queueheader_buf), "MAID:")) {
+               if (!account && !procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                                       "MAID:")) {
                        id = atoi(&queueheader_buf[strlen("MAID:")]);
                        account = account_find_from_id(id);
+                       g_free(queueheader_buf);
                }
-               if (!account && !procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                                               sizeof(queueheader_buf), "S:")) {
+               if (!account && !procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                                       "S:")) {
                        account = account_find_from_address(queueheader_buf, FALSE);
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Claws-Sign:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "X-Claws-Sign:")) {
                        param = atoi(&queueheader_buf[strlen("X-Claws-Sign:")]);
                        use_signing = param;
-                       
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Sylpheed-Sign:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "X-Sylpheed-Sign:")) {
                        param = atoi(&queueheader_buf[strlen("X-Sylpheed-Sign:")]);
                        use_signing = param;
-                       
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Claws-Encrypt:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "X-Claws-Encrypt:")) {
                        param = atoi(&queueheader_buf[strlen("X-Claws-Encrypt:")]);
                        use_encryption = param;
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Sylpheed-Encrypt:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "X-Sylpheed-Encrypt:")) {
                        param = atoi(&queueheader_buf[strlen("X-Sylpheed-Encrypt:")]);
                        use_encryption = param;
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Claws-Auto-Wrapping:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "X-Claws-Auto-Wrapping:")) {
                        param = atoi(&queueheader_buf[strlen("X-Claws-Auto-Wrapping:")]);
                        autowrap = param;
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Claws-Auto-Indent:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "X-Claws-Auto-Indent:")) {
                        param = atoi(&queueheader_buf[strlen("X-Claws-Auto-Indent:")]);
                        autoindent = param;
+                       g_free(queueheader_buf);
+               }
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                       "X-Claws-Privacy-System:")) {
+                       privacy_system = g_strdup(&queueheader_buf[strlen("X-Claws-Privacy-System:")]);
+                       g_free(queueheader_buf);
+               }
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                       "X-Sylpheed-Privacy-System:")) {
+                       privacy_system = g_strdup(&queueheader_buf[strlen("X-Sylpheed-Privacy-System:")]);
+                       g_free(queueheader_buf);
                }
-                if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Claws-Privacy-System:")) {
-                        privacy_system = g_strdup(&queueheader_buf[strlen("X-Claws-Privacy-System:")]);
-                }
-                if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Sylpheed-Privacy-System:")) {
-                        privacy_system = g_strdup(&queueheader_buf[strlen("X-Sylpheed-Privacy-System:")]);
-                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "X-Priority: ")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "X-Priority: ")) {
                        param = atoi(&queueheader_buf[strlen("X-Priority: ")]); /* mind the space */
                        priority = param;
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "RMID:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf,
+                                                                                       "RMID:")) {
                        gchar **tokens = g_strsplit(&queueheader_buf[strlen("RMID:")], "\t", 0);
-                       if (tokens[0] && tokens[1] && tokens[2]) {
+                       if (tokens && tokens[0] && tokens[1] && tokens[2]) {
                                FolderItem *orig_item = folder_find_item_from_identifier(tokens[0]);
                                if (orig_item != NULL) {
                                        replyinfo = folder_item_get_msginfo_by_msgid(orig_item, tokens[2]);
                                }
+                               g_strfreev(tokens);
                        }
-                       g_strfreev(tokens);
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
-                                            sizeof(queueheader_buf), "FMID:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, 
+                                                                               "FMID:")) {
                        gchar **tokens = g_strsplit(&queueheader_buf[strlen("FMID:")], "\t", 0);
-                       if (tokens[0] && tokens[1] && tokens[2]) {
+                       if (tokens && tokens[0] && tokens[1] && tokens[2]) {
                                FolderItem *orig_item = folder_find_item_from_identifier(tokens[0]);
                                if (orig_item != NULL) {
                                        fwdinfo = folder_item_get_msginfo_by_msgid(orig_item, tokens[2]);
                                }
+                               g_strfreev(tokens);
                        }
-                       g_strfreev(tokens);
+                       g_free(queueheader_buf);
                }
                /* Get manual headers */
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, sizeof(queueheader_buf), "X-Claws-Manual-Headers:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf,
+                                                                                       "X-Claws-Manual-Headers:")) {
                        gchar *listmh = g_strdup(&queueheader_buf[strlen("X-Claws-Manual-Headers:")]);
-                       if (*listmh != '\0') {
+                       if (listmh && *listmh != '\0') {
                                debug_print("Got manual headers: %s\n", listmh);
                                manual_headers = procheader_entries_from_str(listmh);
+                               g_free(listmh);
                        }
-                       g_free(listmh);
+                       g_free(queueheader_buf);
                }
        } else {
                account = msginfo->folder->folder->account;
        }
 
        if (!account && prefs_common.reedit_account_autosel) {
-                       gchar from[BUFFSIZE];
-               if (!procheader_get_header_from_msginfo(msginfo, from, sizeof(from), "FROM:")) {
-                       extract_address(from);
-                       account = account_find_from_address(from, FALSE);
-                }
-       }
-        if (!account) {
-               account = cur_account;
-        }
+               gchar *from = NULL;
+               if (!procheader_get_header_from_msginfo(msginfo, &from, "FROM:")) {
+                       extract_address(from);
+                       account = account_find_from_address(from, FALSE);
+                       g_free(from);
+               }
+       }
+       if (!account) {
+               account = cur_account;
+       }
        cm_return_val_if_fail(account != NULL, NULL);
 
        compose = compose_create(account, msginfo->folder, COMPOSE_REEDIT, batch);
@@ -2389,21 +2369,23 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
 
        compose_extract_original_charset(compose);
 
-        if (folder_has_parent_of_type(msginfo->folder, F_QUEUE) ||
+       if (folder_has_parent_of_type(msginfo->folder, F_QUEUE) ||
            folder_has_parent_of_type(msginfo->folder, F_DRAFT) ||
            folder_has_parent_of_type(msginfo->folder, F_OUTBOX)) {
-               gchar queueheader_buf[BUFFSIZE];
+               gchar *queueheader_buf = NULL;
 
                /* Set message save folder */
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, sizeof(queueheader_buf), "SCF:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, "SCF:")) {
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
                        compose_set_save_to(compose, &queueheader_buf[4]);
+                       g_free(queueheader_buf);
                }
-               if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, sizeof(queueheader_buf), "RRCPT:")) {
+               if (!procheader_get_header_from_msginfo(msginfo, &queueheader_buf, "RRCPT:")) {
                        gint active = atoi(&queueheader_buf[strlen("RRCPT:")]);
                        if (active) {
                                cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/RequestRetRcpt", TRUE);
                        }
+                       g_free(queueheader_buf);
                }
        }
        
@@ -2438,6 +2420,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
        }
 
        if (fp != NULL) {
+               gchar buf[BUFFSIZE];
                gboolean prev_autowrap;
                GtkTextBuffer *buffer;
                BLOCK_WRAP();
@@ -2737,6 +2720,10 @@ void compose_toolbar_cb(gint action, gpointer data)
                compose_check_all(NULL, compose);
                break;
 #endif
+       case A_PRIVACY_SIGN:
+               break;
+       case A_PRIVACY_ENCRYPT:
+               break;
        default:
                break;
        }
@@ -2846,26 +2833,28 @@ static MailField compose_entries_set(Compose *compose, const gchar *mailto, Comp
 
 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
 {
-       static HeaderEntry hentry[] = {{"Reply-To:",    NULL, TRUE},
-                                      {"Cc:",          NULL, TRUE},
-                                      {"References:",  NULL, FALSE},
-                                      {"Bcc:",         NULL, TRUE},
-                                      {"Newsgroups:",  NULL, TRUE},
-                                      {"Followup-To:", NULL, TRUE},
-                                      {"List-Post:",   NULL, FALSE},
-                                      {"X-Priority:",  NULL, FALSE},
-                                      {NULL,           NULL, FALSE}};
+       static HeaderEntry hentry[] = {
+                                      {"Reply-To:",    NULL, TRUE },
+                                      {"Cc:",          NULL, TRUE },
+                                      {"References:",  NULL, FALSE },
+                                      {"Bcc:",         NULL, TRUE },
+                                      {"Newsgroups:",  NULL, TRUE },
+                                      {"Followup-To:", NULL, TRUE },
+                                      {"List-Post:",   NULL, FALSE },
+                                      {"X-Priority:",  NULL, FALSE },
+                                      {NULL,           NULL, FALSE }
+       };
 
        enum
        {
-               H_REPLY_TO      = 0,
-               H_CC            = 1,
-               H_REFERENCES    = 2,
-               H_BCC           = 3,
-               H_NEWSGROUPS    = 4,
-               H_FOLLOWUP_TO   = 5,
-               H_LIST_POST     = 6,
-               H_X_PRIORITY    = 7
+               H_REPLY_TO    = 0,
+               H_CC          = 1,
+               H_REFERENCES  = 2,
+               H_BCC         = 3,
+               H_NEWSGROUPS  = 4,
+               H_FOLLOWUP_TO = 5,
+               H_LIST_POST   = 6,
+               H_X_PRIORITY  = 7
        };
 
        FILE *fp;
@@ -2960,7 +2949,9 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
                if (msginfo->inreplyto && *msginfo->inreplyto)
                        compose->inreplyto = g_strdup(msginfo->inreplyto);
 
-               if (msginfo->msgid && *msginfo->msgid)
+               if (msginfo->msgid && *msginfo->msgid &&
+                               compose->folder != NULL &&
+                               compose->folder->stype ==  F_DRAFT)
                        compose->msgid = g_strdup(msginfo->msgid);
        } else {
                if (msginfo->msgid && *msginfo->msgid)
@@ -3099,6 +3090,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
                quote_fmt_parse();
 
                buf = quote_fmt_get_buffer();
+
                if (buf == NULL)
                        alertpanel_error(_("The \"Quotation mark\" of the template is invalid."));
                else
@@ -3132,11 +3124,14 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
                }
 
                buf = quote_fmt_get_buffer();
+
                if (buf == NULL) {
                        gint line = quote_fmt_get_line();
                        alertpanel_error(err_msg, line);
+
                        goto error;
                }
+
        } else
                buf = "";
 
@@ -3595,33 +3590,61 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
        gint len;
        FILE *fp;
        gboolean prev_autowrap;
+#ifdef G_OS_WIN32
+       GFile *f;
+       GFileInfo *fi;
+       GError *error = NULL;
+#else
        GStatBuf file_stat;
+#endif
        int ret;
+       goffset size;
        GString *file_contents = NULL;
        ComposeInsertResult result = COMPOSE_INSERT_SUCCESS;
 
        cm_return_val_if_fail(file != NULL, COMPOSE_INSERT_NO_FILE);
 
        /* get the size of the file we are about to insert */
+#ifdef G_OS_WIN32
+       f = g_file_new_for_path(file);
+       fi = g_file_query_info(f, "standard::size",
+                       G_FILE_QUERY_INFO_NONE, NULL, &error);
+       ret = 0;
+       if (error != NULL) {
+               g_warning(error->message);
+               ret = 1;
+               g_error_free(error);
+               g_object_unref(f);
+       }
+#else
        ret = g_stat(file, &file_stat);
+#endif
        if (ret != 0) {
                gchar *shortfile = g_path_get_basename(file);
                alertpanel_error(_("Could not get size of file '%s'."), shortfile);
                g_free(shortfile);
                return COMPOSE_INSERT_NO_FILE;
        } else if (prefs_common.warn_large_insert == TRUE) {
+#ifdef G_OS_WIN32
+               size = g_file_info_get_size(fi);
+               g_object_unref(fi);
+               g_object_unref(f);
+#else
+               size = file_stat.st_size;
+#endif
 
                /* ask user for confirmation if the file is large */
                if (prefs_common.warn_large_insert_size < 0 ||
-                   file_stat.st_size > (prefs_common.warn_large_insert_size * 1024)) {
+                   size > ((goffset) prefs_common.warn_large_insert_size * 1024)) {
                        AlertValue aval;
                        gchar *msg;
 
                        msg = g_strdup_printf(_("You are about to insert a file of %s "
                                                "in the message body. Are you sure you want to do that?"),
-                                               to_human_readable(file_stat.st_size));
+                                               to_human_readable(size));
                        aval = alertpanel_full(_("Are you sure?"), msg, GTK_STOCK_CANCEL,
-                                       g_strconcat("+", _("_Insert"), NULL), NULL, TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
+                                       _("_Insert"), NULL, ALERTFOCUS_SECOND, TRUE,
+                                       NULL, ALERT_QUESTION);
                        g_free(msg);
 
                        /* do we ask for confirmation next time? */
@@ -3735,7 +3758,7 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
                g_free(file_from_uri);
                if (result)
                        return TRUE;
-               alertpanel_error("File %s doesn't exist\n", filename);
+               alertpanel_error("File %s doesn't exist or permission denied\n", filename);
                return FALSE;
        }
        if ((size = get_file_size(file)) < 0) {
@@ -3747,8 +3770,8 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
        if (size == 0 && !compose->batch) {
                gchar * msg = g_strdup_printf(_("File %s is empty."), filename);
                AlertValue aval = alertpanel_full(_("Empty file"), msg, 
-                               GTK_STOCK_CANCEL,  g_strconcat("+", _("_Attach anyway"), NULL), NULL, FALSE,
-                               NULL, ALERT_WARNING, G_ALERTDEFAULT);
+                               GTK_STOCK_CANCEL,  _("_Attach anyway"), NULL,
+                               ALERTFOCUS_SECOND, FALSE, NULL, ALERT_WARNING);
                g_free(msg);
 
                if (aval != G_ALERTALTERNATE) {
@@ -3847,13 +3870,13 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
        return TRUE;
 }
 
-static void compose_use_signing(Compose *compose, gboolean use_signing)
+void compose_use_signing(Compose *compose, gboolean use_signing)
 {
        compose->use_signing = use_signing;
        cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Sign", use_signing);
 }
 
-static void compose_use_encryption(Compose *compose, gboolean use_encryption)
+void compose_use_encryption(Compose *compose, gboolean use_encryption)
 {
        compose->use_encryption = use_encryption;
        cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Encrypt", use_encryption);
@@ -4061,10 +4084,22 @@ static int compose_itemized_length(GtkTextBuffer *buffer,
        }
 
        clen = g_unichar_to_utf8(wc, ch);
-       if (clen != 1)
-               return 0;
-
-       if (!strchr("*-+", ch[0]))
+       if (!((clen == 1 && strchr("*-+", ch[0])) ||
+           (clen == 3 && (
+               wc == 0x2022 || /* BULLET */
+               wc == 0x2023 || /* TRIANGULAR BULLET */
+               wc == 0x2043 || /* HYPHEN BULLET */
+               wc == 0x204c || /* BLACK LEFTWARDS BULLET */
+               wc == 0x204d || /* BLACK RIGHTWARDS BULLET */
+               wc == 0x2219 || /* BULLET OPERATOR */
+               wc == 0x25d8 || /* INVERSE BULLET */
+               wc == 0x25e6 || /* WHITE BULLET */
+               wc == 0x2619 || /* REVERSED ROTATED FLORAL HEART BULLET */
+               wc == 0x2765 || /* ROTATED HEAVY BLACK HEART BULLET */
+               wc == 0x2767 || /* ROTATED FLORAL HEART BULLET */
+               wc == 0x29be || /* CIRCLED WHITE BULLET */
+               wc == 0x29bf    /* CIRCLED BULLET */
+               ))))
                return 0;
 
        gtk_text_iter_forward_char(&iter);
@@ -4232,7 +4267,7 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                can_break = TRUE;
        }
 
-//     debug_print("compose_get_line_break_pos(): do_break = %d, pos = %d, col = %d\n", do_break, pos, col);
+/*     debug_print("compose_get_line_break_pos(): do_break = %d, pos = %d, col = %d\n", do_break, pos, col); */
 
        g_free(attrs);
        g_free(str);
@@ -4478,7 +4513,7 @@ static gboolean compose_beautify_paragraph(Compose *compose, GtkTextIter *par_it
                quote_str = compose_get_quote_str(buffer, &iter, &quote_len);
 
                if (quote_str) {
-//                     debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str);
+/*                     debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str); */
                        if (startq_offset == -1) 
                                startq_offset = gtk_text_iter_get_offset(&iter);
                        quotelevel = get_quote_level(quote_str, prefs_common.quote_chars);
@@ -4724,11 +4759,11 @@ colorize:
                        }
                }
                if (!modified) {
-//                     debug_print("not modified, out after %d lines\n", lines);
+/*                     debug_print("not modified, out after %d lines\n", lines); */
                        goto end;
                }
        }
-//     debug_print("modified, out after %d lines\n", lines);
+/*     debug_print("modified, out after %d lines\n", lines); */
 end:
        g_free(itemized_chars);
        if (par_iter)
@@ -4882,9 +4917,7 @@ static void compose_select_account(Compose *compose, PrefsAccount *account,
 {
        gchar *from = NULL, *header = NULL;
        ComposeHeaderEntry *header_entry;
-#if GTK_CHECK_VERSION(2, 24, 0)
        GtkTreeIter iter;
-#endif
 
        cm_return_if_fail(account != NULL);
 
@@ -4926,13 +4959,9 @@ static void compose_select_account(Compose *compose, PrefsAccount *account,
        }
        
        header_entry = (ComposeHeaderEntry *) compose->header_list->data;
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       header = gtk_combo_box_get_active_text(GTK_COMBO_BOX(header_entry->combo));
-#else
        if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(header_entry->combo), &iter))
                gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(
                        header_entry->combo)), &iter, COMBOBOX_TEXT, &header, -1);
-#endif
        
        if (header && !strlen(gtk_entry_get_text(GTK_ENTRY(header_entry->entry)))) {
                if (account->protocol == A_NNTP) {
@@ -5032,12 +5061,16 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                }
                if (!found_other) {
                        AlertValue aval;
+                       gchar *text;
                        if (compose->batch) {
                                gtk_widget_show_all(compose->window);
                        }
+                       text = g_strdup_printf(_("The only recipient is the default '%s' address. Send anyway?"),
+                                          prefs_common_translated_header_name("Cc"));
                        aval = alertpanel(_("Send"),
-                                         _("The only recipient is the default CC address. Send anyway?"),
-                                         GTK_STOCK_CANCEL, g_strconcat("+", _("_Send"), NULL), NULL);
+                                         text,
+                                         GTK_STOCK_CANCEL, _("_Send"), NULL, ALERTFOCUS_SECOND);
+                       g_free(text);
                        if (aval != G_ALERTALTERNATE)
                                return FALSE;
                }
@@ -5057,6 +5090,7 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                        ||  strcmp(header, prefs_common_translated_header_name("Bcc:"))) {
                                found_other = TRUE;
                                g_free(entry);
+                               g_free(header);
                                break;
                        }
                        g_free(entry);
@@ -5064,12 +5098,16 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                }
                if (!found_other) {
                        AlertValue aval;
+                       gchar *text;
                        if (compose->batch) {
                                gtk_widget_show_all(compose->window);
                        }
+                       text = g_strdup_printf(_("The only recipient is the default '%s' address. Send anyway?"),
+                                          prefs_common_translated_header_name("Bcc"));
                        aval = alertpanel(_("Send"),
-                                         _("The only recipient is the default BCC address. Send anyway?"),
-                                         GTK_STOCK_CANCEL, g_strconcat("+", _("_Send"), NULL), NULL);
+                                         text,
+                                         GTK_STOCK_CANCEL, _("_Send"), NULL, ALERTFOCUS_SECOND);
+                       g_free(text);
                        if (aval != G_ALERTALTERNATE)
                                return FALSE;
                }
@@ -5098,20 +5136,15 @@ static gboolean compose_check_entries(Compose *compose, gboolean check_everythin
                if (*str == '\0' && check_everything == TRUE &&
                    compose->mode != COMPOSE_REDIRECT) {
                        AlertValue aval;
-                       gchar *button_label;
                        gchar *message;
 
-                       if (compose->sending)
-                               button_label = g_strconcat("+", _("_Send"), NULL);
-                       else
-                               button_label = g_strconcat("+", _("_Queue"), NULL);
                        message = g_strdup_printf(_("Subject is empty. %s"),
                                        compose->sending?_("Send it anyway?"):
                                        _("Queue it anyway?"));
 
                        aval = alertpanel_full(compose->sending?_("Send"):_("Send later"), message,
-                                              GTK_STOCK_CANCEL, button_label, NULL, TRUE, NULL,
-                                              ALERT_QUESTION, G_ALERTDEFAULT);
+                                              GTK_STOCK_CANCEL, compose->sending?_("_Send"):_("_Queue"), NULL,
+                                              ALERTFOCUS_FIRST, TRUE, NULL, ALERT_QUESTION);
                        g_free(message);
                        if (aval & G_ALERTDISABLE) {
                                aval &= ~G_ALERTDISABLE;
@@ -5122,17 +5155,98 @@ static gboolean compose_check_entries(Compose *compose, gboolean check_everythin
                }
        }
 
+       if (!compose->batch && prefs_common.warn_sending_many_recipients_num > 0
+                       && check_everything == TRUE) {
+               GSList *list;
+               gint cnt = 0;
+
+               /* count To and Cc recipients */
+               for (list = compose->header_list; list; list = list->next) {
+                       gchar *header;
+                       gchar *entry;
+
+                       header = gtk_editable_get_chars(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN((((ComposeHeaderEntry *)list->data)->combo)))), 0, -1);
+                       entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
+                       g_strstrip(header);
+                       g_strstrip(entry);
+                       if ((entry[0] != '\0') &&
+                           (!strcmp(header, prefs_common_translated_header_name("To:")) ||
+                            !strcmp(header, prefs_common_translated_header_name("Cc:")))) {
+                               cnt++;
+                       }
+                       g_free(header);
+                       g_free(entry);
+               }
+               if (cnt > prefs_common.warn_sending_many_recipients_num) {
+                       AlertValue aval;
+                       gchar *message;
+
+                       message = g_strdup_printf(_("Sending to %d recipients. %s"), cnt,
+                                       compose->sending?_("Send it anyway?"):
+                                       _("Queue it anyway?"));
+
+                       aval = alertpanel_full(compose->sending?_("Send"):_("Send later"), message,
+                                              GTK_STOCK_CANCEL, compose->sending?_("_Send"):_("_Queue"), NULL,
+                                              ALERTFOCUS_FIRST, TRUE, NULL, ALERT_QUESTION);
+                       g_free(message);
+                       if (aval & G_ALERTDISABLE) {
+                               aval &= ~G_ALERTDISABLE;
+                               prefs_common.warn_sending_many_recipients_num = 0;
+                       }
+                       if (aval != G_ALERTALTERNATE)
+                               return FALSE;
+               }
+       }
+
        if (check_everything && hooks_invoke(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, compose))
                return FALSE;
 
        return TRUE;
 }
 
+static void _display_queue_error(ComposeQueueResult val)
+{
+       switch (val) {
+               case COMPOSE_QUEUE_SUCCESS:
+                       break;
+               case COMPOSE_QUEUE_ERROR_NO_MSG:
+                       alertpanel_error(_("Could not queue message."));
+                       break;
+               case COMPOSE_QUEUE_ERROR_WITH_ERRNO:
+                       alertpanel_error(_("Could not queue message:\n\n%s."),
+                                       g_strerror(errno));
+                       break;
+               case COMPOSE_QUEUE_ERROR_SIGNING_FAILED:
+                       alertpanel_error(_("Could not queue message for sending:\n\n"
+                                               "Signature failed: %s"),
+                                       privacy_peek_error() ? privacy_get_error() : _("Unknown error"));
+                       break;
+               case COMPOSE_QUEUE_ERROR_ENCRYPT_FAILED:
+                       alertpanel_error(_("Could not queue message for sending:\n\n"
+                                               "Encryption failed: %s"),
+                                       privacy_peek_error() ? privacy_get_error() : _("Unknown error"));
+                       break;
+               case COMPOSE_QUEUE_ERROR_CHAR_CONVERSION:
+                       alertpanel_error(_("Could not queue message for sending:\n\n"
+                                               "Charset conversion failed."));
+                       break;
+               case COMPOSE_QUEUE_ERROR_NO_ENCRYPTION_KEY:
+                       alertpanel_error(_("Could not queue message for sending:\n\n"
+                                               "Couldn't get recipient encryption key."));
+                       break;
+               default:
+                       /* unhandled error */
+                       debug_print("oops, unhandled compose_queue() return value %d\n",
+                                       val);
+                       break;
+       }
+}
+
 gint compose_send(Compose *compose)
 {
        gint msgnum;
        FolderItem *folder = NULL;
-       gint val = -1;
+       ComposeQueueResult val = COMPOSE_QUEUE_ERROR_NO_MSG;
        gchar *msgpath = NULL;
        gboolean discard_window = FALSE;
        gchar *errstr = NULL;
@@ -5157,27 +5271,13 @@ gint compose_send(Compose *compose)
        inc_lock();
        val = compose_queue(compose, &msgnum, &folder, &msgpath, TRUE);
 
-       if (val) {
+       if (val != COMPOSE_QUEUE_SUCCESS) {
                if (compose->batch) {
                        gtk_widget_show_all(compose->window);
                }
-               if (val == -4) {
-                       alertpanel_error(_("Could not queue message for sending:\n\n"
-                                          "Charset conversion failed."));
-               } else if (val == -5) {
-                       alertpanel_error(_("Could not queue message for sending:\n\n"
-                                          "Couldn't get recipient encryption key."));
-               } else if (val == -6) {
-                       /* silent error */
-               } else if (val == -3) {
-                       if (privacy_peek_error())
-                       alertpanel_error(_("Could not queue message for sending:\n\n"
-                                          "Signature failed: %s"), privacy_get_error());
-               } else if (val == -2 && errno != 0) {
-                       alertpanel_error(_("Could not queue message for sending:\n\n%s."), g_strerror(errno));
-               } else {
-                       alertpanel_error(_("Could not queue message for sending."));
-               }
+
+               _display_queue_error(val);
+
                goto bail;
        }
 
@@ -5367,6 +5467,7 @@ static gint compose_redirect_write_headers_from_headerlist(Compose *compose,
 
 static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
 {
+       gchar date[RFC822_DATE_BUFFSIZE];
        gchar buf[BUFFSIZE];
        gchar *str;
        const gchar *entstr;
@@ -5379,10 +5480,10 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
 
        /* Resent-Date */
        if (prefs_common.hide_timezone)
-               get_rfc822_date_hide_tz(buf, sizeof(buf));
+               get_rfc822_date_hide_tz(date, sizeof(date));
        else
-               get_rfc822_date(buf, sizeof(buf));
-       err |= (fprintf(fp, "Resent-Date: %s\n", buf) < 0);
+               get_rfc822_date(date, sizeof(date));
+       err |= (fprintf(fp, "Resent-Date: %s\n", date) < 0);
 
        /* Resent-From */
        if (compose->account->name && *compose->account->name) {
@@ -5430,7 +5531,8 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
 {
        FILE *fp;
        size_t len;
-       gchar buf[BUFFSIZE];
+       gchar *buf = NULL;
+       gchar rewrite_buf[BUFFSIZE];
        int i = 0;
        gboolean skip = FALSE;
        gboolean err = FALSE;
@@ -5451,12 +5553,14 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
                "X-Claws-Auto-Wrapping:", "X-Claws-Auto-Indent:",
                NULL
                };
+       gint ret = 0;
+
        if ((fp = g_fopen(compose->redirect_filename, "rb")) == NULL) {
                FILE_OP_ERROR(compose->redirect_filename, "fopen");
                return -1;
        }
 
-       while (procheader_get_one_field_asis(buf, sizeof(buf), fp) != -1) {
+       while ((ret = procheader_get_one_field_asis(&buf, fp)) != -1) {
                skip = FALSE;
                for (i = 0; not_included[i] != NULL; i++) {
                        if (g_ascii_strncasecmp(buf, not_included[i],
@@ -5465,10 +5569,16 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
                                break;
                        }
                }
-               if (skip)
+               if (skip) {
+                       g_free(buf);
+                       buf = NULL;
                        continue;
-               if (fputs(buf, fdest) == -1)
+               }
+               if (fputs(buf, fdest) == -1) {
+                       g_free(buf);
+                       buf = NULL;
                        goto error;
+               }
 
                if (!prefs_common.redirect_keep_from) {
                        if (g_ascii_strncasecmp(buf, "From:",
@@ -5476,13 +5586,15 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
                                err |= (fputs(" (by way of ", fdest) == EOF);
                                if (compose->account->name
                                    && *compose->account->name) {
+                                       gchar buffer[BUFFSIZE];
+
                                        compose_convert_header
-                                               (compose, buf, sizeof(buf),
+                                               (compose, buffer, sizeof(buffer),
                                                 compose->account->name,
                                                 strlen("From: "),
                                                 FALSE);
                                        err |= (fprintf(fdest, "%s <%s>",
-                                               buf,
+                                               buffer,
                                                compose->account->address) < 0);
                                } else
                                        err |= (fprintf(fdest, "%s",
@@ -5491,6 +5603,8 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
                        }
                }
 
+               g_free(buf);
+               buf = NULL;
                if (fputs("\n", fdest) == -1)
                        goto error;
        }
@@ -5501,14 +5615,15 @@ static gint compose_redirect_write_to_file(Compose *compose, FILE *fdest)
        if (compose_redirect_write_headers(compose, fdest))
                goto error;
 
-       while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
-               if (fwrite(buf, sizeof(gchar), len, fdest) != len)
+       while ((len = fread(rewrite_buf, sizeof(gchar), sizeof(rewrite_buf), fp)) > 0) {
+               if (fwrite(rewrite_buf, sizeof(gchar), len, fdest) != len)
                        goto error;
        }
 
        fclose(fp);
 
        return 0;
+
 error:
        fclose(fp);
 
@@ -5518,7 +5633,7 @@ error:
 static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gboolean attach_parts)
 {
        GtkTextBuffer *buffer;
-       GtkTextIter start, end;
+       GtkTextIter start, end, tmp;
        gchar *chars, *tmp_enc_file, *content;
        gchar *buf, *msg;
        const gchar *out_codeset;
@@ -5550,10 +5665,21 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        mimemsg->data.mem = compose_get_header(compose);
 
        /* Create text part MimeInfo */
-       /* get all composed text */
        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(compose->text));
-       gtk_text_buffer_get_start_iter(buffer, &start);
        gtk_text_buffer_get_end_iter(buffer, &end);
+       tmp = end;
+
+       /* We make sure that there is a newline at the end. */
+       if (action == COMPOSE_WRITE_FOR_SEND && gtk_text_iter_backward_char(&tmp)) {
+               chars = gtk_text_buffer_get_text(buffer, &tmp, &end, FALSE);
+               if (*chars != '\n') {
+                       gtk_text_buffer_insert(buffer, &end, "\n", 1);
+               }
+               g_free(chars);
+       }
+
+       /* get all composed text */
+       gtk_text_buffer_get_start_iter(buffer, &start);
        chars = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 
        out_codeset = conv_get_charset_str(compose->out_encoding);
@@ -5622,13 +5748,13 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
                                                "to the specified %s charset.\n"
                                                "Send it as %s?"), out_codeset, src_codeset);
                        aval = alertpanel_full(_("Error"), msg, GTK_STOCK_CANCEL,
-                                              g_strconcat("+", _("_Send"), NULL), NULL, FALSE,
-                                             NULL, ALERT_ERROR, G_ALERTDEFAULT);
+                                              _("_Send"), NULL, ALERTFOCUS_SECOND, FALSE,
+                                             NULL, ALERT_ERROR);
                        g_free(msg);
 
                        if (aval != G_ALERTALTERNATE) {
                                g_free(chars);
-                               return -3;
+                               return COMPOSE_QUEUE_ERROR_CHAR_CONVERSION;
                        } else {
                                buf = chars;
                                out_codeset = src_codeset;
@@ -5684,11 +5810,12 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
                           "The contents of the message might be broken on the way to the delivery.\n"
                           "\n"
                           "Send it anyway?"), line + 1);
-               aval = alertpanel(_("Warning"), msg, GTK_STOCK_CANCEL, GTK_STOCK_OK, NULL);
+               aval = alertpanel(_("Warning"), msg, GTK_STOCK_CANCEL, GTK_STOCK_OK, NULL,
+                               ALERTFOCUS_FIRST);
                g_free(msg);
                if (aval != G_ALERTALTERNATE) {
                        g_free(buf);
-                       return -1;
+                       return COMPOSE_QUEUE_ERROR_NO_MSG;
                }
        }
        
@@ -5718,7 +5845,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
                g_node_append(mimemsg->node, mimempart->node);
 
                if (compose_add_attachments(compose, mimempart) < 0)
-                       return -1;
+                       return COMPOSE_QUEUE_ERROR_NO_MSG;
        } else
                g_node_append(mimemsg->node, mimetext->node);
 
@@ -5745,7 +5872,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
                        compose->account, from_addr)) {
                        g_free(from_name);
                        g_free(from_addr);
-                       return -2;
+                       return COMPOSE_QUEUE_ERROR_SIGNING_FAILED;
        }
        g_free(from_name);
        g_free(from_addr);
@@ -5791,8 +5918,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
                        if (!privacy_encrypt(compose->privacy_system, mimemsg, compose->encdata)) {
                                debug_print("Couldn't encrypt mime structure: %s.\n",
                                                privacy_get_error());
-                               alertpanel_error(_("Couldn't encrypt the email: %s"),
-                                               privacy_get_error());
+                               return COMPOSE_QUEUE_ERROR_ENCRYPT_FAILED;
                        }
                }
        }
@@ -5898,7 +6024,7 @@ static void compose_remove_draft(Compose *compose)
 
 }
 
-gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item, gchar **msgpath,
+ComposeQueueResult compose_queue(Compose *compose, gint *msgnum, FolderItem **item, gchar **msgpath,
                   gboolean remove_reedit_target)
 {
        return compose_queue_sub (compose, msgnum, item, msgpath, FALSE, remove_reedit_target);
@@ -5913,8 +6039,8 @@ static gboolean compose_warn_encryption(Compose *compose)
                return TRUE;
 
        val = alertpanel_full(_("Encryption warning"), warning,
-                 GTK_STOCK_CANCEL, g_strconcat("+", _("C_ontinue"), NULL), NULL,
-                 TRUE, NULL, ALERT_WARNING, G_ALERTALTERNATE);
+                 GTK_STOCK_CANCEL, _("C_ontinue"), NULL, ALERTFOCUS_SECOND,
+                 TRUE, NULL, ALERT_WARNING);
        if (val & G_ALERTDISABLE) {
                val &= ~G_ALERTDISABLE;
                if (val == G_ALERTALTERNATE)
@@ -5929,8 +6055,8 @@ static gboolean compose_warn_encryption(Compose *compose)
        } 
 }
 
-static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item, 
-                             gchar **msgpath, gboolean check_subject,
+static ComposeQueueResult compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item, 
+                             gchar **msgpath, gboolean perform_checks,
                              gboolean remove_reedit_target)
 {
        FolderItem *queue;
@@ -5944,16 +6070,16 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        debug_print("queueing message...\n");
        cm_return_val_if_fail(compose->account != NULL, -1);
 
-       if (compose_check_entries(compose, check_subject) == FALSE) {
+       if (compose_check_entries(compose, perform_checks) == FALSE) {
                if (compose->batch) {
                        gtk_widget_show_all(compose->window);
                }
-                return -1;
+                return COMPOSE_QUEUE_ERROR_NO_MSG;
        }
 
        if (!compose->to_list && !compose->newsgroup_list) {
                g_warning("can't get recipient list.");
-                return -1;
+                return COMPOSE_QUEUE_ERROR_NO_MSG;
         }
 
        if (compose->to_list) {
@@ -5963,7 +6089,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                        mailac = cur_account;
                else if (!(mailac = compose_current_mail_account())) {
                        alertpanel_error(_("No account for sending mails available!"));
-                       return -1;
+                       return COMPOSE_QUEUE_ERROR_NO_MSG;
                }
        }
 
@@ -5972,7 +6098,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                         newsac = compose->account;
                 else {
                        alertpanel_error(_("Selected account isn't NNTP: Posting is impossible."));
-                       return -1;
+                       return COMPOSE_QUEUE_ERROR_NO_MSG;
                }                       
        }
 
@@ -5983,7 +6109,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        if ((fp = g_fopen(tmp, "w+b")) == NULL) {
                FILE_OP_ERROR(tmp, "fopen");
                g_free(tmp);
-               return -2;
+               return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
        }
 
        if (change_file_mode_rw(fp, tmp) < 0) {
@@ -6015,7 +6141,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        else
                err |= (fprintf(fp, "NSV:\n") < 0);
        err |= (fprintf(fp, "SSH:\n") < 0);
-       /* write recepient list */
+       /* write recipient list */
        if (compose->to_list) {
                err |= (fprintf(fp, "R:<%s>", (gchar *)compose->to_list->data) < 0);
                for (cur = compose->to_list->next; cur != NULL;
@@ -6031,7 +6157,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                        err |= (fprintf(fp, ",%s", (gchar *)cur->data) < 0);
                err |= (fprintf(fp, "\n") < 0);
        }
-       /* Sylpheed account IDs */
+       /* account IDs */
        if (mailac)
                err |= (fprintf(fp, "MAID:%d\n", mailac->account_id) < 0);
        if (newsac)
@@ -6046,7 +6172,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                                fclose(fp);
                                claws_unlink(tmp);
                                g_free(tmp);
-                               return -6;
+                               return COMPOSE_QUEUE_ERROR_NO_MSG;
                        }
                        if (mailac && mailac->encrypt_to_self) {
                                GSList *tmp_list = g_slist_copy(compose->to_list);
@@ -6071,7 +6197,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                                fclose(fp);
                                claws_unlink(tmp);
                                g_free(tmp);
-                               return -5;
+                               return COMPOSE_QUEUE_ERROR_NO_ENCRYPTION_KEY;
                        }
                }
        }
@@ -6124,7 +6250,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                        fclose(fp);
                        claws_unlink(tmp);
                        g_free(tmp);
-                       return -2;
+                       return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
                }
        } else {
                gint result = 0;
@@ -6132,7 +6258,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                        fclose(fp);
                        claws_unlink(tmp);
                        g_free(tmp);
-                       return result - 1; /* -2 for a generic error, -3 for signing error, -4 for encoding */
+                       return result;
                }
        }
        if (err == TRUE) {
@@ -6140,13 +6266,13 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                fclose(fp);
                claws_unlink(tmp);
                g_free(tmp);
-               return -2;
+               return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
        }
        if (fclose(fp) == EOF) {
                FILE_OP_ERROR(tmp, "fclose");
                claws_unlink(tmp);
                g_free(tmp);
-               return -2;
+               return COMPOSE_QUEUE_ERROR_WITH_ERRNO;
        }
 
        if (item && *item) {
@@ -6158,14 +6284,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                g_warning("can't find queue folder");
                claws_unlink(tmp);
                g_free(tmp);
-               return -1;
+               return COMPOSE_QUEUE_ERROR_NO_MSG;
        }
        folder_item_scan(queue);
        if ((num = folder_item_add_msg(queue, tmp, NULL, FALSE)) < 0) {
                g_warning("can't queue the message");
                claws_unlink(tmp);
                g_free(tmp);
-               return -1;
+               return COMPOSE_QUEUE_ERROR_NO_MSG;
        }
        
        if (msgpath == NULL) {
@@ -6183,7 +6309,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                *item = queue;
        }
 
-       return 0;
+       return COMPOSE_QUEUE_SUCCESS;
 }
 
 static int compose_add_attachments(Compose *compose, MimeInfo *parent)
@@ -6191,7 +6317,14 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
        AttachInfo *ainfo;
        GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist);
        MimeInfo *mimepart;
+#ifdef G_OS_WIN32
+       GFile *f;
+       GFileInfo *fi;
+       GError *error = NULL;
+#else
        GStatBuf statbuf;
+#endif
+       goffset size;
        gchar *type, *subtype;
        GtkTreeModel *model;
        GtkTreeIter iter;
@@ -6201,29 +6334,44 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
        if (!gtk_tree_model_get_iter_first(model, &iter))
                return 0;
        do {
-               gtk_tree_model_get(model, &iter,
-                                  COL_DATA, &ainfo,
-                                  -1);
+               gtk_tree_model_get(model, &iter, COL_DATA, &ainfo, -1);
                
                if (!is_file_exist(ainfo->file)) {
                        gchar *msg = g_strdup_printf(_("Attachment %s doesn't exist anymore. Ignore?"), ainfo->file);
-                       AlertValue val = alertpanel_full(_("Warning"), msg, _("Cancel sending"), _("Ignore attachment"),
-                                     NULL, FALSE, NULL, ALERT_WARNING, G_ALERTDEFAULT);
+                       AlertValue val = alertpanel_full(_("Warning"), msg,
+                                       _("Cancel sending"), _("Ignore attachment"), NULL,
+                                       ALERTFOCUS_FIRST, FALSE, NULL, ALERT_WARNING);
                        g_free(msg);
                        if (val == G_ALERTDEFAULT) {
                                return -1;
                        }
                        continue;
                }
+#ifdef G_OS_WIN32
+               f = g_file_new_for_path(ainfo->file);
+               fi = g_file_query_info(f, "standard::size",
+                               G_FILE_QUERY_INFO_NONE, NULL, &error);
+               if (error != NULL) {
+                       g_warning(error->message);
+                       g_error_free(error);
+                       g_object_unref(f);
+                       return -1;
+               }
+               size = g_file_info_get_size(fi);
+               g_object_unref(fi);
+               g_object_unref(f);
+#else
                if (g_stat(ainfo->file, &statbuf) < 0)
                        return -1;
+               size = statbuf.st_size;
+#endif
 
                mimepart = procmime_mimeinfo_new();
                mimepart->content = MIMECONTENT_FILE;
                mimepart->data.filename = g_strdup(ainfo->file);
                mimepart->tmp = FALSE; /* or we destroy our attachment */
                mimepart->offset = 0;
-               mimepart->length = statbuf.st_size;
+               mimepart->length = size;
 
                type = g_strdup(ainfo->content_type);
 
@@ -6232,11 +6380,11 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
                        type = g_strdup("application/octet-stream");
                }
 
-               subtype = strchr(type, '/') + 1;
-               *(subtype - 1) = '\0';
-               mimepart->type = procmime_get_media_type(type);
-               mimepart->subtype = g_strdup(subtype);
-               g_free(type);
+               subtype = strchr(type, '/') + 1;
+               *(subtype - 1) = '\0';
+               mimepart->type = procmime_get_media_type(type);
+               mimepart->subtype = g_strdup(subtype);
+               g_free(type);
 
                if (mimepart->type == MIMETYPE_MESSAGE && 
                    !g_ascii_strcasecmp(mimepart->subtype, "rfc822")) {
@@ -6274,8 +6422,6 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
                                ainfo->encoding = ENC_BASE64;
                }
 
-               
-               
                procmime_encode_content(mimepart, ainfo->encoding);
 
                g_node_append(parent->node, mimepart->node);
@@ -6330,6 +6476,40 @@ static gchar *compose_quote_list_of_addresses(gchar *str)
        (compose->account->add_customhdr && \
         custom_header_find(compose->account->customhdr_list, header) != NULL)
 
+static const gchar *compose_untranslated_header_name(gchar *header_name)
+{
+       /* return the untranslated header name, if header_name is a known
+          header name, in either its translated or untranslated form, with
+          or without trailing colon. otherwise, returns header_name. */
+       gchar *translated_header_name;
+       gchar *translated_header_name_wcolon;
+       const gchar *untranslated_header_name;
+       const gchar *untranslated_header_name_wcolon;
+       gint i;
+
+       cm_return_val_if_fail(header_name != NULL, NULL);
+
+       for (i = 0; HEADERS[i].header_name != NULL; i++) {
+               untranslated_header_name = HEADERS[i].header_name;
+               untranslated_header_name_wcolon = HEADERS[i].header_name_w_colon;
+
+               translated_header_name = gettext(untranslated_header_name);
+               translated_header_name_wcolon = gettext(untranslated_header_name_wcolon);
+
+               if (!strcmp(header_name, untranslated_header_name) ||
+                       !strcmp(header_name, translated_header_name)) {
+                       return untranslated_header_name;
+               } else {
+                       if (!strcmp(header_name, untranslated_header_name_wcolon) ||
+                               !strcmp(header_name, translated_header_name_wcolon)) {
+                               return untranslated_header_name_wcolon;
+                       }
+               }
+       }
+       debug_print("compose_untranslated_header_name: unknown header '%s'\n", header_name);
+       return header_name;
+}
+
 static void compose_add_headerfield_from_headerlist(Compose *compose, 
                                                    GString *header, 
                                                    const gchar *fieldname,
@@ -6439,6 +6619,7 @@ static gchar *compose_get_manual_headers_info(Compose *compose)
 
 static gchar *compose_get_header(Compose *compose)
 {
+       gchar date[RFC822_DATE_BUFFSIZE];
        gchar buf[BUFFSIZE];
        const gchar *entry_str;
        gchar *str;
@@ -6456,10 +6637,10 @@ static gchar *compose_get_header(Compose *compose)
 
        /* Date */
        if (prefs_common.hide_timezone)
-               get_rfc822_date_hide_tz(buf, sizeof(buf));
+               get_rfc822_date_hide_tz(date, sizeof(date));
        else
-               get_rfc822_date(buf, sizeof(buf));
-       g_string_append_printf(header, "Date: %s\n", buf);
+               get_rfc822_date(date, sizeof(date));
+       g_string_append_printf(header, "Date: %s\n", date);
 
        /* From */
        
@@ -6688,16 +6869,22 @@ static gchar *compose_get_header(Compose *compose)
                Xstrdup_a(headervalue, entry_str, return NULL);
                subst_char(headervalue, '\r', ' ');
                subst_char(headervalue, '\n', ' ');
-               string = std_headers;
-               while (*string != NULL) {
-                       headername_trans = prefs_common_translated_header_name(*string);
-                       if (!strcmp(headername_trans, headername_wcolon))
-                               standard_header = TRUE;
-                       string++;
-               }
-               if (!standard_header && !IS_IN_CUSTOM_HEADER(headername))
-                       g_string_append_printf(header, "%s %s\n", headername_wcolon, headervalue);
-                               
+               g_strstrip(headervalue);
+               if (*headervalue != '\0') {
+                       string = std_headers;
+                       while (*string != NULL && !standard_header) {
+                               headername_trans = prefs_common_translated_header_name(*string);
+                               /* support mixed translated and untranslated headers */
+                               if (!strcmp(headername_trans, headername_wcolon) || !strcmp(*string, headername_wcolon))
+                                       standard_header = TRUE;
+                               string++;
+                       }
+                       if (!standard_header && !IS_IN_CUSTOM_HEADER(headername)) {
+                               /* store untranslated header name */
+                               g_string_append_printf(header, "%s %s\n",
+                                               compose_untranslated_header_name(headername_wcolon), headervalue);
+                       }
+               }                               
                g_free(headername);
                g_free(headername_wcolon);              
        }
@@ -6870,6 +7057,17 @@ extra_headers_done:
        g_slist_foreach(extra_headers, (GFunc)compose_add_extra_header, (gpointer)model);
 }
 
+#ifdef USE_LDAP
+static void _ldap_srv_func(gpointer data, gpointer user_data)
+{
+       LdapServer *server = (LdapServer *)data;
+       gboolean *enable = (gboolean *)user_data;
+
+       debug_print("%s server '%s'\n", (*enable == TRUE ? "enabling" : "disabling"), server->control->hostName);
+       server->searchFlag = *enable;
+}
+#endif
+
 static void compose_create_header_entry(Compose *compose) 
 {
        gchar *headers[] = {"To:", "Cc:", "Bcc:", "Newsgroups:", "Reply-To:", "Followup-To:", NULL};
@@ -6889,9 +7087,6 @@ static void compose_create_header_entry(Compose *compose)
 
        /* Combo box model */
        model = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN);
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       combo = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
-#endif
        COMBOBOX_ADD(model, prefs_common_translated_header_name("To:"),
                        COMPOSE_TO);
        COMBOBOX_ADD(model, prefs_common_translated_header_name("Cc:"),
@@ -6907,13 +7102,11 @@ static void compose_create_header_entry(Compose *compose)
        compose_add_extra_header_entries(model);
 
        /* Combo box */
-#if GTK_CHECK_VERSION(2, 24, 0)
        combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(model));
        GtkCellRenderer *cell = gtk_cell_renderer_text_new();
        gtk_cell_renderer_set_alignment(cell, 0.0, 0.5);
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
        gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(combo), 0);
-#endif
        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
        g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(combo))), "grab_focus",
                         G_CALLBACK(compose_grab_focus_cb), compose);
@@ -7008,7 +7201,24 @@ static void compose_create_header_entry(Compose *compose)
        g_signal_connect(G_OBJECT(entry), "populate-popup",
                         G_CALLBACK(compose_entry_popup_extend),
                         NULL);
-       
+
+#ifdef USE_LDAP
+#ifndef PASSWORD_CRYPTO_OLD
+       GSList *pwd_servers = addrindex_get_password_protected_ldap_servers();
+       if (pwd_servers != NULL && master_passphrase() == NULL) {
+               gboolean enable = FALSE;
+               debug_print("Master passphrase not available, disabling password-protected LDAP servers for this compose window.\n");
+               /* Temporarily disable password-protected LDAP servers,
+                * because user did not provide a master passphrase.
+                * We can safely enable searchFlag on all servers in this list
+                * later, since addrindex_get_password_protected_ldap_servers()
+                * includes servers which have it enabled initially. */
+               g_slist_foreach(pwd_servers, _ldap_srv_func, &enable);
+               compose->passworded_ldap_servers = pwd_servers;
+       }
+#endif /* PASSWORD_CRYPTO_OLD */
+#endif /* USE_LDAP */
+
        address_completion_register_entry(GTK_ENTRY(entry), TRUE);
 
         headerentry->compose = compose;
@@ -7266,23 +7476,14 @@ static GtkWidget *compose_create_others(Compose *compose)
        g_signal_connect(G_OBJECT(savemsg_checkbtn), "toggled",
                         G_CALLBACK(compose_savemsg_checkbtn_cb), compose);
 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       savemsg_combo = gtk_combo_box_entry_new_text();
-#else
        savemsg_combo = gtk_combo_box_text_new_with_entry();
-#endif
        compose->savemsg_checkbtn = savemsg_checkbtn;
        compose->savemsg_combo = savemsg_combo;
        gtk_widget_show(savemsg_combo);
 
        if (prefs_common.compose_save_to_history)
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               combobox_set_popdown_strings(GTK_COMBO_BOX(savemsg_combo),
-                               prefs_common.compose_save_to_history);
-#else
                combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(savemsg_combo),
                                prefs_common.compose_save_to_history);
-#endif
        gtk_table_attach(GTK_TABLE(table), savemsg_combo, 1, 2, rowcount, rowcount + 1, GTK_FILL|GTK_EXPAND, GTK_SHRINK, 0, 0);
        gtk_widget_set_sensitive(GTK_WIDGET(savemsg_combo), prefs_common.savemsg);
        g_signal_connect_after(G_OBJECT(savemsg_combo), "grab_focus",
@@ -7315,7 +7516,8 @@ static void compose_savemsg_select_cb(GtkWidget *widget, Compose *compose)
        FolderItem *dest;
        gchar * path;
 
-       dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE);
+       dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE,
+                       _("Select folder to save message to"));
        if (!dest) return;
 
        path = folder_item_get_identifier(dest);
@@ -7503,6 +7705,11 @@ static Compose *compose_create(PrefsAccount *account,
 
        cm_return_val_if_fail(account != NULL, NULL);
 
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_DEFAULT_HEADER_BG],
+                                          &default_header_bgcolor);
+       gtkut_convert_int_to_gdk_color(prefs_common.color[COL_DEFAULT_HEADER],
+                                          &default_header_color);
+
        debug_print("Creating compose window...\n");
        compose = g_new0(Compose, 1);
 
@@ -8014,7 +8221,7 @@ static Compose *compose_create(PrefsAccount *account,
                        gtkaspell = gtkaspell_new(prefs_common.dictionary,
                                                  prefs_common.alt_dictionary,
                                                  conv_get_locale_charset_str(),
-                                                 prefs_common.misspelled_col,
+                                                 prefs_common.color[COL_MISSPELLED],
                                                  prefs_common.check_while_typing,
                                                  prefs_common.recheck_when_changing_dict,
                                                  prefs_common.use_alternate,
@@ -8097,11 +8304,6 @@ static Compose *compose_create(PrefsAccount *account,
                gtk_widget_show(window);
        }
        
-       gtkut_convert_int_to_gdk_color(prefs_common.default_header_bgcolor,
-                                          &default_header_bgcolor);
-       gtkut_convert_int_to_gdk_color(prefs_common.default_header_color,
-                                          &default_header_color);
-
        return compose;
 }
 
@@ -8314,6 +8516,22 @@ static void compose_set_privacy_system_cb(GtkWidget *widget, gpointer data)
 
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options/Sign", can_sign);
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options/Encrypt", can_encrypt);
+       if (compose->toolbar->privacy_sign_btn != NULL) {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(compose->toolbar->privacy_sign_btn),
+                       can_sign);
+               gtk_toggle_tool_button_set_active(
+                       GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_sign_btn),
+                       can_sign ? compose->use_signing : FALSE);
+       }
+       if (compose->toolbar->privacy_encrypt_btn != NULL) {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(compose->toolbar->privacy_encrypt_btn),
+                       can_encrypt);
+               gtk_toggle_tool_button_set_active(
+                       GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_encrypt_btn),
+                       can_encrypt ? compose->use_encryption : FALSE);
+       }
 }
 
 static void compose_update_privacy_system_menu_item(Compose * compose, gboolean warn)
@@ -8370,8 +8588,18 @@ static void compose_update_privacy_system_menu_item(Compose * compose, gboolean
 
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options/Sign", can_sign);
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options/Encrypt", can_encrypt);
-}      
+       if (compose->toolbar->privacy_sign_btn != NULL) {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(compose->toolbar->privacy_sign_btn),
+                       can_sign);
+       }
+       if (compose->toolbar->privacy_encrypt_btn != NULL) {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(compose->toolbar->privacy_encrypt_btn),
+                       can_encrypt);
+       }
+}
+
 static void compose_set_out_encoding(Compose *compose)
 {
        CharSet out_encoding;
@@ -8642,9 +8870,11 @@ static void compose_template_apply(Compose *compose, Template *tmpl,
 
        /* process the other fields */
 
-       compose_template_apply_fields(compose, tmpl);
        compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
+       compose_template_apply_fields(compose, tmpl);
        quote_fmt_reset_vartable();
+       quote_fmtlex_destroy();
+
        compose_changed_cb(NULL, compose);
 
 #ifdef USE_ENCHANT
@@ -8653,6 +8883,20 @@ static void compose_template_apply(Compose *compose, Template *tmpl,
 #endif
 }
 
+static void compose_template_apply_fields_error(const gchar *header)
+{
+       gchar *tr;
+       gchar *text;
+
+       tr = g_strdup(C_("'%s' stands for a header name",
+                                 "Template '%s' format error."));
+       text = g_strdup_printf(tr, prefs_common_translated_header_name(header));
+       alertpanel_error("%s", text);
+
+       g_free(text);
+       g_free(tr);
+}
+
 static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 {
        MsgInfo* dummyinfo = NULL;
@@ -8680,10 +8924,13 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template From format error."));
+                       compose_template_apply_fields_error("From");
                } else {
                        gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
                }
+
+               quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
        }
 
        if (tmpl->to && *tmpl->to != '\0') {
@@ -8698,10 +8945,13 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template To format error."));
+                       compose_template_apply_fields_error("To");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_TO, PREF_TEMPLATE);
                }
+
+               quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
        }
 
        if (tmpl->cc && *tmpl->cc != '\0') {
@@ -8716,10 +8966,13 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template Cc format error."));
+                       compose_template_apply_fields_error("Cc");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_CC, PREF_TEMPLATE);
                }
+
+               quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
        }
 
        if (tmpl->bcc && *tmpl->bcc != '\0') {
@@ -8734,10 +8987,13 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template Bcc format error."));
+                       compose_template_apply_fields_error("Bcc");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_BCC, PREF_TEMPLATE);
                }
+
+               quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
        }
 
        if (tmpl->replyto && *tmpl->replyto != '\0') {
@@ -8752,10 +9008,13 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template Reply-To format error."));
+                       compose_template_apply_fields_error("Reply-To");
                } else {
                        compose_entry_append(compose, buf, COMPOSE_REPLYTO, PREF_TEMPLATE);
                }
+
+               quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
        }
 
        /* process the subject */
@@ -8771,10 +9030,13 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
                buf = quote_fmt_get_buffer();
                if (buf == NULL) {
-                       alertpanel_error(_("Template subject format error."));
+                       compose_template_apply_fields_error("Subject");
                } else {
                        gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
                }
+
+               quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
        }
 
        procmsg_msginfo_free( &dummyinfo );
@@ -8788,6 +9050,13 @@ static void compose_destroy(Compose *compose)
 
        compose_list = g_list_remove(compose_list, compose);
 
+#ifdef USE_LDAP
+       gboolean enable = TRUE;
+       g_slist_foreach(compose->passworded_ldap_servers,
+                       _ldap_srv_func, &enable);
+       g_slist_free(compose->passworded_ldap_servers);
+#endif
+
        if (compose->updating) {
                debug_print("danger, not destroying anything now\n");
                compose->deferred_destroy = TRUE;
@@ -8889,20 +9158,26 @@ static void compose_attach_update_label(Compose *compose)
        gint i = 1;
        gchar *text;
        GtkTreeModel *model;
-       
-       if(compose == NULL)
+       goffset total_size;
+       AttachInfo *ainfo;
+
+       if (compose == NULL)
                return;
-               
+
        model = gtk_tree_view_get_model(GTK_TREE_VIEW(compose->attach_clist));
-       if(!gtk_tree_model_get_iter_first(model, &iter)) {
+       if (!gtk_tree_model_get_iter_first(model, &iter)) {
                gtk_label_set_text(GTK_LABEL(compose->attach_label), "");       
                return;
        }
-       
-       while(gtk_tree_model_iter_next(model, &iter))
+
+       gtk_tree_model_get(model, &iter, COL_DATA, &ainfo, -1);
+       total_size = ainfo->size;
+       while(gtk_tree_model_iter_next(model, &iter)) {
+               gtk_tree_model_get(model, &iter, COL_DATA, &ainfo, -1);
+               total_size += ainfo->size;
                i++;
-       
-       text = g_strdup_printf("(%d)", i);
+       }
+       text = g_strdup_printf(" (%d/%s)", i, to_human_readable(total_size));
        gtk_label_set_text(GTK_LABEL(compose->attach_label), text);
        g_free(text);
 }
@@ -9150,11 +9425,7 @@ static void compose_attach_property_create(gboolean *cancelled)
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, (0 + 1), 
                         GTK_FILL, 0, 0, 0); 
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 
-#if !GTK_CHECK_VERSION(2, 24, 0)
-       mimetype_entry = gtk_combo_box_entry_new_text(); 
-#else
        mimetype_entry = gtk_combo_box_text_new_with_entry();
-#endif
        gtk_table_attach(GTK_TABLE(table), mimetype_entry, 1, 2, 0, (0 + 1), 
                         GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
                         
@@ -9176,11 +9447,7 @@ static void compose_attach_property_create(gboolean *cancelled)
 
        for (mime_type_list = strlist; mime_type_list != NULL; 
                mime_type_list = mime_type_list->next) {
-#if !GTK_CHECK_VERSION(2, 24, 0)
-               gtk_combo_box_append_text(GTK_COMBO_BOX(mimetype_entry), mime_type_list->data);
-#else
                gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mimetype_entry), mime_type_list->data);
-#endif
                g_free(mime_type_list->data);
        }
        g_list_free(strlist);
@@ -9371,6 +9638,14 @@ static void compose_exec_ext_editor(Compose *compose)
 #endif /* G_OS_UNIX */
 }
 
+static gboolean compose_can_autosave(Compose *compose)
+{
+       if (compose->privacy_system && compose->use_encryption)
+               return prefs_common.autosave && prefs_common.autosave_encrypted;
+       else
+               return prefs_common.autosave;
+}
+
 #ifdef G_OS_UNIX
 static gboolean compose_get_ext_editor_cmd_valid()
 {
@@ -9398,7 +9673,7 @@ static gboolean compose_get_ext_editor_cmd_valid()
 
 static gint compose_exec_ext_editor_real(const gchar *file, GdkNativeWindow socket_wid)
 {
-       gchar buf[1024];
+       gchar *buf;
        gchar *p, *s;
        gchar **cmdline;
        pid_t pid;
@@ -9423,22 +9698,22 @@ static gint compose_exec_ext_editor_real(const gchar *file, GdkNativeWindow sock
                        s = strstr(p, "%w");
                        s[1] = 'u';
                        if (strstr(p, "%s") < s)
-                               g_snprintf(buf, sizeof(buf), p, file, socket_wid);
+                               buf = g_strdup_printf(p, file, socket_wid);
                        else
-                               g_snprintf(buf, sizeof(buf), p, socket_wid, file);
+                               buf = g_strdup_printf(p, socket_wid, file);
                        g_free(p);
                } else {
-                       g_snprintf(buf, sizeof(buf),
-                                  prefs_common_get_ext_editor_cmd(), file);
+                       buf = g_strdup_printf(prefs_common_get_ext_editor_cmd(), file);
                }
        } else {
                if (prefs_common_get_ext_editor_cmd())
                        g_warning("External editor command-line is invalid: '%s'",
                                  prefs_common_get_ext_editor_cmd());
-               g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, file);
+               buf = g_strdup_printf(DEFAULT_EDITOR_CMD, file);
        }
 
-       cmdline = strsplit_with_quote(buf, " ", 1024);
+       cmdline = strsplit_with_quote(buf, " ", 0);
+       g_free(buf);
        execvp(cmdline[0], cmdline);
 
        perror("execvp");
@@ -9463,7 +9738,8 @@ static gboolean compose_ext_editor_kill(Compose *compose)
                           "Force terminating the process?\n"
                           "process group id: %d"), -pgid);
                val = alertpanel_full(_("Notice"), msg, GTK_STOCK_NO, GTK_STOCK_YES,
-                                     NULL, FALSE, NULL, ALERT_WARNING, G_ALERTDEFAULT);
+                                     NULL, ALERTFOCUS_FIRST, FALSE, NULL,
+                                                                               ALERT_WARNING);
                        
                g_free(msg);
 
@@ -9521,7 +9797,10 @@ static gboolean compose_input_cb(GIOChannel *source, GIOCondition condition,
                gtk_text_buffer_set_text(buffer, "", -1);
                compose_insert_file(compose, compose->exteditor_file);
                compose_changed_cb(NULL, compose);
-               compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
+
+               /* Check if we should save the draft or not */
+               if (compose_can_autosave(compose))
+                 compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
 
                if (claws_unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
@@ -9938,7 +10217,7 @@ static void compose_send_cb(GtkAction *action, gpointer data)
 static void compose_send_later_cb(GtkAction *action, gpointer data)
 {
        Compose *compose = (Compose *)data;
-       gint val;
+       ComposeQueueResult val;
 
        inc_lock();
        compose_allow_user_actions(compose, FALSE);
@@ -9946,25 +10225,12 @@ static void compose_send_later_cb(GtkAction *action, gpointer data)
        compose_allow_user_actions(compose, TRUE);
        inc_unlock();
 
-       if (!val) {
+       if (val == COMPOSE_QUEUE_SUCCESS) {
                compose_close(compose);
-       } else if (val == -1) {
-               alertpanel_error(_("Could not queue message."));
-       } else if (val == -2) {
-               alertpanel_error(_("Could not queue message:\n\n%s."), g_strerror(errno));
-       } else if (val == -3) {
-               if (privacy_peek_error())
-               alertpanel_error(_("Could not queue message for sending:\n\n"
-                                  "Signature failed: %s"), privacy_get_error());
-       } else if (val == -4) {
-               alertpanel_error(_("Could not queue message for sending:\n\n"
-                                  "Charset conversion failed."));
-       } else if (val == -5) {
-               alertpanel_error(_("Could not queue message for sending:\n\n"
-                                  "Couldn't get recipient encryption key."));
-       } else if (val == -6) {
-               /* silent error */
+       } else {
+               _display_queue_error(val);
        }
+
        toolbar_main_set_sensitive(mainwindow_get_mainwindow());
 }
 
@@ -10136,8 +10402,8 @@ warn_err:
                                val = alertpanel_full(_("Could not save draft"),
                                        _("Could not save draft.\n"
                                        "Do you want to cancel exit or discard this email?"),
-                                         _("_Cancel exit"), _("_Discard email"), NULL,
-                                         FALSE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
+                                         _("_Cancel exit"), _("_Discard email"), NULL, ALERTFOCUS_FIRST,
+                                         FALSE, NULL, ALERT_QUESTION);
                                if (val == G_ALERTALTERNATE) {
                                        lock = FALSE;
                                        g_mutex_unlock(compose->mutex); /* must be done before closing */
@@ -10184,26 +10450,55 @@ warn_err:
                compose_close(compose);
                return TRUE;
        } else {
+#ifdef G_OS_WIN32
+               GFile *f;
+               GFileInfo *fi;
+               GTimeVal tv;
+               GError *error = NULL;
+#else
                GStatBuf s;
+#endif
                gchar *path;
+               goffset size, mtime;
 
                path = folder_item_fetch_msg(draft, msgnum);
                if (path == NULL) {
                        debug_print("can't fetch %s:%d\n", draft->path, msgnum);
                        goto unlock;
                }
+#ifdef G_OS_WIN32
+               f = g_file_new_for_path(path);
+               fi = g_file_query_info(f, "standard::size,time::modified",
+                               G_FILE_QUERY_INFO_NONE, NULL, &error);
+               if (error != NULL) {
+                       debug_print("couldn't query file info for '%s': %s\n",
+                                       path, error->message);
+                       g_error_free(error);
+                       g_free(path);
+                       g_object_unref(f);
+                       goto unlock;
+               }
+               size = g_file_info_get_size(fi);
+               g_file_info_get_modification_time(fi, &tv);
+               mtime = tv.tv_sec;
+               g_object_unref(fi);
+               g_object_unref(f);
+#else
                if (g_stat(path, &s) < 0) {
                        FILE_OP_ERROR(path, "stat");
                        g_free(path);
                        goto unlock;
                }
+               size = s.st_size;
+               mtime = s.st_mtime;
+#endif
                g_free(path);
 
                procmsg_msginfo_free(&(compose->targetinfo));
                compose->targetinfo = procmsg_msginfo_new();
                compose->targetinfo->msgnum = msgnum;
-               compose->targetinfo->size = (goffset)s.st_size;
-               compose->targetinfo->mtime = s.st_mtime;
+               compose->targetinfo->size = size;
+               compose->targetinfo->mtime = mtime;
                compose->targetinfo->folder = draft;
                if (target_locked)
                        procmsg_msginfo_set_flags(compose->targetinfo, MSG_LOCKED, 0);
@@ -10382,14 +10677,6 @@ void compose_close_toolbar(Compose *compose)
        compose_close_cb(NULL, compose);
 }
 
-static gboolean compose_can_autosave(Compose *compose)
-{
-       if (compose->privacy_system && compose->use_encryption)
-               return prefs_common.autosave && prefs_common.autosave_encrypted;
-       else
-               return prefs_common.autosave;
-}
-
 static void compose_close_cb(GtkAction *action, gpointer data)
 {
        Compose *compose = (Compose *)data;
@@ -10415,12 +10702,13 @@ static void compose_close_cb(GtkAction *action, gpointer data)
                if (!reedit) {
                        val = alertpanel(_("Discard message"),
                                 _("This message has been modified. Discard it?"),
-                                _("_Discard"), _("_Save to Drafts"), GTK_STOCK_CANCEL);
+                                _("_Discard"), _("_Save to Drafts"), GTK_STOCK_CANCEL,
+                                ALERTFOCUS_FIRST);
                } else {
                        val = alertpanel(_("Save changes"),
                                 _("This message has been modified. Save the latest changes?"),
-                                _("_Don't save"), g_strconcat("+", _("_Save to Drafts"), NULL),
-                               GTK_STOCK_CANCEL);
+                                _("_Don't save"), _("_Save to Drafts"), GTK_STOCK_CANCEL,
+                                ALERTFOCUS_SECOND);
                }
                g_mutex_unlock(compose->mutex);
                switch (val) {
@@ -10493,7 +10781,7 @@ static void compose_template_activate_cb(GtkWidget *widget, gpointer data)
        msg = g_strdup_printf(_("Do you want to apply the template '%s'?"),
                              tmpl->name);
        val = alertpanel(_("Apply template"), msg,
-                        _("_Replace"), _("_Insert"), GTK_STOCK_CANCEL);
+                        _("_Replace"), _("_Insert"), GTK_STOCK_CANCEL, ALERTFOCUS_FIRST);
        g_free(msg);
 
        if (val == G_ALERTDEFAULT)
@@ -11034,14 +11322,14 @@ static ComposeCallAdvancedAction compose_call_advanced_action_from_path(GtkActio
        DO_ACTION("Edit/Advanced/DelForwWord", COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD);
        DO_ACTION("Edit/Advanced/DelLine", COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE);
        DO_ACTION("Edit/Advanced/DelEndLine", COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END);
-       return -1;
+       return COMPOSE_CALL_ADVANCED_ACTION_UNDEFINED;
 }
 
 static void compose_advanced_action_cb(GtkAction *gaction, gpointer data)
 {
        Compose *compose = (Compose *)data;
        GtkTextView *text = GTK_TEXT_VIEW(compose->text);
-       ComposeCallAdvancedAction action = -1;
+       ComposeCallAdvancedAction action = COMPOSE_CALL_ADVANCED_ACTION_UNDEFINED;
        
        action = compose_call_advanced_action_from_path(gaction);
 
@@ -11160,7 +11448,7 @@ static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
 static void compose_changed_cb(GtkTextBuffer *textbuf, Compose *compose)
 {
        compose->modified = TRUE;
-//     compose_beautify_paragraph(compose, NULL, TRUE);
+/*     compose_beautify_paragraph(compose, NULL, TRUE); */
 #ifndef GENERIC_UMPC
        compose_set_title(compose);
 #endif
@@ -11207,6 +11495,7 @@ static void compose_toggle_sign_cb(GtkToggleAction *action, gpointer data)
        Compose *compose = (Compose *)data;
 
        compose->use_signing = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_sign_btn), compose->use_signing);
 }
 
 static void compose_toggle_encrypt_cb(GtkToggleAction *action, gpointer data)
@@ -11214,6 +11503,7 @@ static void compose_toggle_encrypt_cb(GtkToggleAction *action, gpointer data)
        Compose *compose = (Compose *)data;
 
        compose->use_encryption = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_encrypt_btn), compose->use_encryption);
 }
 
 static void activate_privacy_system(Compose *compose, PrefsAccount *account, gboolean warn) 
@@ -11369,8 +11659,9 @@ static void compose_insert_drag_received_cb (GtkWidget          *widget,
                                                        num_files),
                                                num_files);
                                val = alertpanel_full(_("Insert or attach?"), msg,
-                                         GTK_STOCK_CANCEL, g_strconcat("+", _("_Insert"), NULL), _("_Attach"),
-                                         TRUE, NULL, ALERT_QUESTION, G_ALERTALTERNATE);
+                                         GTK_STOCK_CANCEL, _("_Insert"), _("_Attach"),
+                                               ALERTFOCUS_SECOND,
+                                         TRUE, NULL, ALERT_QUESTION);
                                g_free(msg);
                                break;
                        case COMPOSE_DND_INSERT:
@@ -11468,6 +11759,8 @@ static gboolean compose_headerentry_button_clicked_cb (GtkWidget *button,
                                         ComposeHeaderEntry *headerentry)
 {
        gtk_entry_set_text(GTK_ENTRY(headerentry->entry), "");
+       gtk_widget_modify_base(GTK_WIDGET(headerentry->entry), GTK_STATE_NORMAL, NULL);
+       gtk_widget_modify_text(GTK_WIDGET(headerentry->entry), GTK_STATE_NORMAL, NULL);
        return FALSE;
 }
 
@@ -11738,23 +12031,25 @@ static PrefsAccount *compose_find_account(MsgInfo *msginfo)
        }
 
        if (!account && prefs_common.forward_account_autosel) {
-               gchar cc[BUFFSIZE];
+               gchar *cc = NULL;
                if (!procheader_get_header_from_msginfo
-                       (msginfo, cc,sizeof cc , "Cc:")) { 
+                               (msginfo, &cc, "Cc:")) { 
                        gchar *buf = cc + strlen("Cc:");
-                       extract_address(buf);
-                       account = account_find_from_address(buf, FALSE);
-                }
+                       extract_address(buf);
+                       account = account_find_from_address(buf, FALSE);
+                       g_free(cc);
+               }
        }
        
        if (!account && prefs_common.forward_account_autosel) {
-               gchar deliveredto[BUFFSIZE];
+               gchar *deliveredto = NULL;
                if (!procheader_get_header_from_msginfo
-                       (msginfo, deliveredto,sizeof deliveredto , "Delivered-To:")) { 
+                               (msginfo, &deliveredto, "Delivered-To:")) { 
                        gchar *buf = deliveredto + strlen("Delivered-To:");
-                       extract_address(buf);
-                       account = account_find_from_address(buf, FALSE);
-                }
+                       extract_address(buf);
+                       account = account_find_from_address(buf, FALSE);
+                       g_free(deliveredto);
+               }
        }
 
        if (!account)
@@ -11888,8 +12183,8 @@ void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list,
                                               "want to continue?"), 
                                               g_slist_length(msginfo_list));
                if (g_slist_length(msginfo_list) > 9
-               &&  alertpanel(_("Warning"), msg, GTK_STOCK_CANCEL, "+" GTK_STOCK_YES, NULL)
-                   != G_ALERTALTERNATE) {
+               &&  alertpanel(_("Warning"), msg, GTK_STOCK_CANCEL, GTK_STOCK_YES, NULL,
+                       ALERTFOCUS_SECOND) != G_ALERTALTERNATE) {
                        g_free(msg);
                        return;
                }
@@ -11984,15 +12279,15 @@ static MsgInfo *compose_msginfo_new_from_compose(Compose *compose)
 {
        MsgInfo *newmsginfo;
        GSList *list;
-       gchar buf[BUFFSIZE];
+       gchar date[RFC822_DATE_BUFFSIZE];
 
        cm_return_val_if_fail( compose != NULL, NULL );
 
        newmsginfo = procmsg_msginfo_new();
 
        /* date is now */
-       get_rfc822_date(buf, sizeof(buf));
-       newmsginfo->date = g_strdup(buf);
+       get_rfc822_date(date, sizeof(date));
+       newmsginfo->date = g_strdup(date);
 
        /* from */
        if (compose->from_name) {