2008-09-20 [colin] 3.5.0cvs118
[claws.git] / src / compose.c
index 5daa602aecdcd47e48137e23a9609d85754708fe..b55d6374d28b134d834b73a252e2374414fb30e9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2008 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -238,7 +238,6 @@ static void compose_reedit_set_entry                (Compose        *compose,
 
 static void compose_insert_sig                 (Compose        *compose,
                                                 gboolean        replace);
-static gchar *compose_get_signature_str                (Compose        *compose);
 static ComposeInsertResult compose_insert_file (Compose        *compose,
                                                 const gchar    *file);
 
@@ -332,7 +331,7 @@ static void compose_add_header_entry        (Compose *compose, const gchar *header, gch
 static void compose_remove_header_entries(Compose *compose);
 
 static void compose_update_priority_menu_item(Compose * compose);
-#if USE_ASPELL
+#if USE_ENCHANT
 static void compose_spell_menu_changed (void *data);
 #endif
 static void compose_add_field_list     ( Compose *compose,
@@ -505,7 +504,7 @@ static void compose_nothing_cb                 (GtkAction *action, gpointer data)
 
 }
 
-#if USE_ASPELL
+#if USE_ENCHANT
 static void compose_check_all             (GtkAction *action, gpointer data);
 static void compose_highlight_all         (GtkAction *action, gpointer data);
 static void compose_check_backwards       (GtkAction *action, gpointer data);
@@ -517,7 +516,7 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo     (MsgInfo *msginf
 
 static MsgInfo *compose_msginfo_new_from_compose(Compose *compose);
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
 static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
                                                FolderItem *folder_item);
 #endif
@@ -540,7 +539,7 @@ static GtkActionEntry compose_entries[] =
 /* menus */
        {"Message",                     NULL, N_("_Message") },
        {"Edit",                        NULL, N_("_Edit") },
-#if USE_ASPELL
+#if USE_ENCHANT
        {"Spelling",                    NULL, N_("_Spelling") },
 #endif
        {"Options",                     NULL, N_("_Options") },
@@ -599,7 +598,7 @@ static GtkActionEntry compose_entries[] =
        {"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) },
-#if USE_ASPELL
+#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) },
@@ -651,7 +650,7 @@ static GtkActionEntry compose_entries[] =
 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_("Follow _indentation"), NULL, NULL, G_CALLBACK(compose_toggle_autoindent_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 */
@@ -942,7 +941,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        tmp = malloc(strlen(item->prefs->compose_override_from_format)+1);
                        pref_get_unescaped_pref(tmp, item->prefs->compose_override_from_format);
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                        quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE,
                                        compose->gtkaspell);
 #else
@@ -969,7 +968,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        compose_create_tags(textview, compose);
 
        undo_block(compose->undostruct);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
        compose_set_dictionaries_from_folder_prefs(compose, item);
 #endif
 
@@ -1034,7 +1033,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        pref_get_unescaped_pref(tmp, subject_format);
 
                        subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                        quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE,
                                        compose->gtkaspell);
 #else
@@ -1437,7 +1436,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                tmp = malloc(strlen(msginfo->folder->prefs->reply_override_from_format)+1);
                pref_get_unescaped_pref(tmp, msginfo->folder->prefs->reply_override_from_format);
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -1461,7 +1460,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
        compose_create_tags(textview, compose);
 
        undo_block(compose->undostruct);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
 #endif
 
@@ -1504,6 +1503,11 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                compose_force_encryption(compose, account, FALSE);
        }
 
+       privacy_msginfo_get_signed_state(compose->replyinfo);
+       if (MSG_IS_SIGNED(compose->replyinfo->flags) && account->default_sign_reply) {
+               compose_force_signing(compose, account);
+       }
+
        SIGNAL_BLOCK(textbuf);
        
        if (account->auto_sig)
@@ -1602,7 +1606,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
                pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -1784,7 +1788,7 @@ static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_
                        tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
                        pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                        quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                        compose->gtkaspell);
 #else
@@ -2195,7 +2199,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
                return NULL;
        }
        
-       compose->sig_str = compose_get_signature_str(compose);
+       compose->sig_str = account_get_signature_str(compose->account);
        
        return compose;
 }
@@ -2446,7 +2450,7 @@ void compose_toolbar_cb(gint action, gpointer data)
        case A_ADDRBOOK:
                compose_address_cb(NULL, compose);
                break;
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
        case A_CHECK_SPELLING:
                compose_check_all(NULL, compose);
                break;
@@ -2761,7 +2765,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
        }
 
        if (qmark != NULL) {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -2783,7 +2787,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
                        while (*trimmed_body == '\n')
                                trimmed_body++;
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -3195,7 +3199,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
        } 
 
        g_free(compose->sig_str);
-       compose->sig_str = compose_get_signature_str(compose);
+       compose->sig_str = account_get_signature_str(compose->account);
 
        cur_pos = gtk_text_iter_get_offset(&iter);
 
@@ -3235,58 +3239,6 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
        UNBLOCK_WRAP();
 }
 
-static gchar *compose_get_signature_str(Compose *compose)
-{
-       gchar *sig_body = NULL;
-       gchar *sig_str = NULL;
-       gchar *utf8_sig_str = NULL;
-
-       g_return_val_if_fail(compose->account != NULL, NULL);
-
-       if (!compose->account->sig_path)
-               return NULL;
-
-       if (compose->account->sig_type == SIG_FILE) {
-               if (!is_file_or_fifo_exist(compose->account->sig_path)) {
-                       g_warning("can't open signature file: %s\n",
-                                 compose->account->sig_path);
-                       return NULL;
-               }
-       }
-
-       if (compose->account->sig_type == SIG_COMMAND)
-               sig_body = get_command_output(compose->account->sig_path);
-       else {
-               gchar *tmp;
-
-               tmp = file_read_to_str(compose->account->sig_path);
-               if (!tmp)
-                       return NULL;
-               sig_body = normalize_newlines(tmp);
-               g_free(tmp);
-       }
-
-       if (compose->account->sig_sep) {
-               sig_str = g_strconcat("\n", compose->account->sig_sep, "\n", sig_body,
-                                     NULL);
-               g_free(sig_body);
-       } else
-               sig_str = g_strconcat("\n", sig_body, NULL);
-
-       if (sig_str) {
-               if (g_utf8_validate(sig_str, -1, NULL) == TRUE)
-                       utf8_sig_str = sig_str;
-               else {
-                       utf8_sig_str = conv_codeset_strdup
-                               (sig_str, conv_get_locale_charset_str_no_utf8(),
-                                CS_INTERNAL);
-                       g_free(sig_str);
-               }
-       }
-
-       return utf8_sig_str;
-}
-
 static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *file)
 {
        GtkTextView *text;
@@ -4547,7 +4499,7 @@ static void compose_select_account(Compose *compose, PrefsAccount *account,
                undo_unblock(compose->undostruct);
        }
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
        /* use account's dict info if set */
        if (compose->gtkaspell) {
                if (account->enable_default_dictionary)
@@ -6569,7 +6521,7 @@ static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
 {
        gint prev_autowrap;
        GtkTextBuffer *buffer = GTK_TEXT_VIEW(text)->buffer;
-#if USE_ASPELL
+#if USE_ENCHANT
        if (event->button == 3) {
                GtkTextIter iter;
                GtkTextIter sel_start, sel_end;
@@ -6623,7 +6575,7 @@ static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
        return FALSE;
 }
 
-#if USE_ASPELL
+#if USE_ENCHANT
 static void compose_spell_menu_changed(void *data)
 {
        Compose *compose = (Compose *)data;
@@ -6720,7 +6672,7 @@ static Compose *compose_create(PrefsAccount *account,
        GtkWidget *tmpl_menu;
        GtkActionGroup *action_group = NULL;
 
-#if USE_ASPELL
+#if USE_ENCHANT
         GtkAspell * gtkaspell = NULL;
 #endif
 
@@ -6800,7 +6752,7 @@ static Compose *compose_create(PrefsAccount *account,
 
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Message", "Message", GTK_UI_MANAGER_MENU)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU)
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Spelling", "Spelling", GTK_UI_MANAGER_MENU)
 #endif
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Options", "Options", GTK_UI_MANAGER_MENU)
@@ -6863,7 +6815,7 @@ static Compose *compose_create(PrefsAccount *account,
 
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Edit", "ExtEditor", "Edit/ExtEditor", GTK_UI_MANAGER_MENUITEM)
 
-#if USE_ASPELL
+#if USE_ENCHANT
 /* Spelling menu */
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "CheckAllSel", "Spelling/CheckAllSel", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "HighlightAll", "Spelling/HighlightAll", GTK_UI_MANAGER_MENUITEM)
@@ -7234,13 +7186,12 @@ static Compose *compose_create(PrefsAccount *account,
        compose->exteditor_tag     = -1;
        compose->draft_timeout_tag = -2; /* inhibit auto-drafting while loading */
 
-#if USE_ASPELL
+#if USE_ENCHANT
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", FALSE);
        if (mode != COMPOSE_REDIRECT) {
                if (prefs_common.enable_aspell && prefs_common.dictionary &&
                    strcmp(prefs_common.dictionary, "")) {
-                       gtkaspell = gtkaspell_new(prefs_common.aspell_path,
-                                                 prefs_common.dictionary,
+                       gtkaspell = gtkaspell_new(prefs_common.dictionary,
                                                  prefs_common.alt_dictionary,
                                                  conv_get_locale_charset_str(),
                                                  prefs_common.misspelled_col,
@@ -7258,14 +7209,6 @@ static Compose *compose_create(PrefsAccount *account,
                                                gtkaspell_checkers_strerror());
                                gtkaspell_checkers_reset_error();
                        } else {
-                               if (!gtkaspell_set_sug_mode(gtkaspell,
-                                               prefs_common.aspell_sugmode)) {
-                                       debug_print("Aspell: could not set "
-                                                   "suggestion mode %s\n",
-                                                   gtkaspell_checkers_strerror());
-                                       gtkaspell_checkers_reset_error();
-                               }
-
                                cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", TRUE);
                        }
                }
@@ -7871,7 +7814,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
        }
 
        if (tmpl->from && *tmpl->from != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -7889,7 +7832,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
        }
 
        if (tmpl->to && *tmpl->to != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -7907,7 +7850,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
        }
 
        if (tmpl->cc && *tmpl->cc != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -7925,7 +7868,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
        }
 
        if (tmpl->bcc && *tmpl->bcc != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -7944,7 +7887,7 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
        /* process the subject */
        if (tmpl->subject && *tmpl->subject != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
                quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
@@ -8019,15 +7962,17 @@ static void compose_destroy(Compose *compose)
        if (addressbook_get_target_compose() == compose)
                addressbook_set_target_compose(NULL);
 
-#if USE_ASPELL
+#if USE_ENCHANT
         if (compose->gtkaspell) {
                gtkaspell_delete(compose->gtkaspell);
                compose->gtkaspell = NULL;
         }
 #endif
 
-       prefs_common.compose_width = compose->scrolledwin->allocation.width;
-       prefs_common.compose_height = compose->window->allocation.height;
+       if (!compose->batch) {
+               prefs_common.compose_width = compose->scrolledwin->allocation.width;
+               prefs_common.compose_height = compose->window->allocation.height;
+       }
 
        if (!gtk_widget_get_parent(compose->paned))
                gtk_widget_destroy(compose->paned);
@@ -8457,7 +8402,11 @@ static void compose_exec_ext_editor(Compose *compose)
 
                compose_set_ext_editor_sensitive(compose, FALSE);
 
+#ifndef G_OS_WIN32
                compose->exteditor_ch = g_io_channel_unix_new(pipe_fds[0]);
+#else
+               compose->exteditor_ch = g_io_channel_win32_new_fd(pipe_fds[0]);
+#endif
                compose->exteditor_tag = g_io_add_watch(compose->exteditor_ch,
                                                        G_IO_IN,
                                                        compose_input_cb,
@@ -8840,7 +8789,7 @@ static void compose_allow_user_actions (Compose *compose, gboolean allow)
        toolbar_comp_set_sensitive(compose, allow);
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Message", allow);
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Edit", allow);
-#if USE_ASPELL
+#if USE_ENCHANT
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", allow);
 #endif 
        cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options", allow);
@@ -8905,7 +8854,7 @@ static void compose_register_draft(MsgInfo *info)
 {
        gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                                      DRAFTED_AT_EXIT, NULL);
-       FILE *fp = fopen(filepath, "ab");
+       FILE *fp = g_fopen(filepath, "ab");
        
        if (fp) {
                fprintf(fp, "%s\t%d\n", folder_item_get_identifier(info->folder), 
@@ -9152,7 +9101,7 @@ void compose_reopen_exit_drafts(void)
 {
        gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                                      DRAFTED_AT_EXIT, NULL);
-       FILE *fp = fopen(filepath, "rb");
+       FILE *fp = g_fopen(filepath, "rb");
        gchar buf[1024];
        
        if (fp) {
@@ -9260,9 +9209,10 @@ static gint compose_delete_cb(GtkWidget *widget, GdkEventAny *event,
        Compose *compose = (Compose *)data;
 
        gtkut_widget_get_uposition(widget, &x, &y);
-       prefs_common.compose_x = x;
-       prefs_common.compose_y = y;
-
+       if (!compose->batch) {
+               prefs_common.compose_x = x;
+               prefs_common.compose_y = y;
+       }
        if (compose->sending || compose->updating)
                return TRUE;
        compose_close_cb(NULL, compose);
@@ -9287,6 +9237,7 @@ static void compose_close_cb(GtkAction *action, gpointer data)
 #endif
 
        if (compose->modified) {
+               gboolean reedit = (compose->rmode == COMPOSE_REEDIT);
                if (!g_mutex_trylock(compose->mutex)) {
                        /* we don't want to lock the mutex once it's available,
                         * because as the only other part of compose.c locking
@@ -9295,13 +9246,19 @@ static void compose_close_cb(GtkAction *action, gpointer data)
                        debug_print("couldn't lock mutex, probably sending\n");
                        return;
                }
-               val = alertpanel(_("Discard message"),
+               if (!reedit) {
+                       val = alertpanel(_("Discard message"),
                                 _("This message has been modified. Discard it?"),
                                 _("_Discard"), _("_Save to Drafts"), GTK_STOCK_CANCEL);
+               } else {
+                       val = alertpanel(_("Save changes"),
+                                _("This message has been modified. Save the latest changes?"),
+                                _("_Don't save"), _("+_Save to Drafts"), GTK_STOCK_CANCEL);
+               }
                g_mutex_unlock(compose->mutex);
                switch (val) {
                case G_ALERTDEFAULT:
-                       if (prefs_common.autosave)
+                       if (prefs_common.autosave && !reedit)
                                compose_remove_draft(compose);                  
                        break;
                case G_ALERTALTERNATE:
@@ -10429,7 +10386,7 @@ static gint compose_defer_auto_save_draft(Compose *compose)
        return FALSE;
 }
 
-#if USE_ASPELL
+#if USE_ENCHANT
 static void compose_check_all(GtkAction *action, gpointer data)
 {
        Compose *compose = (Compose *)data;
@@ -10528,8 +10485,10 @@ gboolean compose_close(Compose *compose)
        }
        g_return_val_if_fail(compose, FALSE);
        gtkut_widget_get_uposition(compose->window, &x, &y);
-       prefs_common.compose_x = x;
-       prefs_common.compose_y = y;
+       if (!compose->batch) {
+               prefs_common.compose_x = x;
+               prefs_common.compose_y = y;
+       }
        g_mutex_unlock(compose->mutex);
        compose_destroy(compose);
        return FALSE;
@@ -10558,6 +10517,7 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
        GSList *new_msglist = NULL;
        MsgInfo *tmp_msginfo = NULL;
        gboolean originally_enc = FALSE;
+       gboolean originally_sig = FALSE;
        Compose *compose = NULL;
 
        g_return_if_fail(msgview != NULL);
@@ -10576,6 +10536,9 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
                                new_msglist = g_slist_append(NULL, tmp_msginfo);
 
                                originally_enc = MSG_IS_ENCRYPTED(orig_msginfo->flags);
+                               privacy_msginfo_get_signed_state(orig_msginfo);
+                               originally_sig = MSG_IS_SIGNED(orig_msginfo->flags);
+
                                tmp_msginfo->folder = orig_msginfo->folder;
                                tmp_msginfo->msgnum = orig_msginfo->msgnum; 
                                if (orig_msginfo->tags)
@@ -10598,6 +10561,10 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
                compose_force_encryption(compose, compose->account, FALSE);
        }
 
+       if (compose && originally_sig && compose->account->default_sign_reply) {
+               compose_force_signing(compose, compose->account);
+       }
+
        g_free(body);
 }
 
@@ -10730,7 +10697,7 @@ static MsgInfo *compose_msginfo_new_from_compose(Compose *compose)
        return newmsginfo;
 }
 
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
 /* update compose's dictionaries from folder dict settings */
 static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
                                                FolderItem *folder_item)