2007-01-16 [paul] 2.7.1cvs6
[claws.git] / src / compose.c
index 86087823ee424aad9af403c89e357f1117ebcd50..096cba17cf5bee80bc2e2e1ebbf799141f98ec4a 100644 (file)
@@ -517,6 +517,11 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo    (MsgInfo *msginf
 
 static MsgInfo *compose_msginfo_new_from_compose(Compose *compose);
 
+#ifdef USE_ASPELL
+static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
+                                               FolderItem *folder_item);
+#endif
+
 static GtkItemFactoryEntry compose_popup_entries[] =
 {
        {N_("/_Add..."),        NULL, compose_attach_cb, 0, NULL},
@@ -972,15 +977,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
        undo_block(compose->undostruct);
 #ifdef USE_ASPELL
-       if (item && item->prefs && compose->gtkaspell) {
-               if (item->prefs->enable_default_dictionary)
-                       gtkaspell_change_dict(compose->gtkaspell, 
-                                   item->prefs->default_dictionary, FALSE);
-               if (item->prefs->enable_default_alt_dictionary)
-                       gtkaspell_change_alt_dict(compose->gtkaspell, 
-                                   item->prefs->default_alt_dictionary);
-               compose_spell_menu_changed(compose);
-       }
+       compose_set_dictionaries_from_folder_prefs(compose, item);
 #endif
 
        if (account->auto_sig)
@@ -1129,7 +1126,8 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
                }
        }
        if (privacy != NULL) {
-               compose->privacy_system = g_strdup(privacy);
+               if (compose->privacy_system == NULL)
+                       compose->privacy_system = g_strdup(privacy);
                compose_update_privacy_system_menu_item(compose, FALSE);
                compose_use_encryption(compose, TRUE);
        }
@@ -1149,7 +1147,8 @@ static void compose_force_signing(Compose *compose, PrefsAccount *account)
                }
        }
        if (privacy != NULL) {
-               compose->privacy_system = g_strdup(privacy);
+               if (compose->privacy_system == NULL)
+                       compose->privacy_system = g_strdup(privacy);
                compose_update_privacy_system_menu_item(compose, FALSE);
                compose_use_signing(compose, TRUE);
        }
@@ -1411,17 +1410,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, gboolean quote,
 
        undo_block(compose->undostruct);
 #ifdef USE_ASPELL
-       if (msginfo->folder && msginfo->folder->prefs && 
-           msginfo->folder->prefs && 
-           compose->gtkaspell) {
-               if (msginfo->folder->prefs->enable_default_dictionary)
-                       gtkaspell_change_dict(compose->gtkaspell, 
-                                   msginfo->folder->prefs->default_dictionary, FALSE);
-               if (msginfo->folder->prefs->enable_default_alt_dictionary)
-                       gtkaspell_change_alt_dict(compose->gtkaspell, 
-                                   msginfo->folder->prefs->default_alt_dictionary);
-               compose_spell_menu_changed(compose);
-       }
+               compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
 #endif
 
        if (quote) {
@@ -3288,6 +3277,8 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
      
        child = (MimeInfo *) mimeinfo->node->children->data;
        while (child != NULL) {
+               gint err;
+
                if (child == encrypted) {
                        /* skip this part of tree */
                        NEXT_PART_NOT_CHILD(child);
@@ -3306,8 +3297,8 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
                }
 
                outfile = procmime_get_tmp_file_name(child);
-               if (procmime_get_part(outfile, child) < 0)
-                       g_warning("Can't get the part of multipart message.");
+               if ((err = procmime_get_part(outfile, child)) < 0)
+                       g_warning("Can't get the part of multipart message. (%s)", strerror(-err));
                else {
                        gchar *content_type;
 
@@ -3315,7 +3306,9 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
 
                        /* if we meet a pgp signature, we don't attach it, but
                         * we force signing. */
-                       if (strcmp(content_type, "application/pgp-signature")) {
+                       if (strcmp(content_type, "application/pgp-signature") &&
+                           strcmp(content_type, "application/pkcs7-signature") &&
+                           strcmp(content_type, "application/x-pkcs7-signature")) {
                                partname = procmime_mimeinfo_get_parameter(child, "filename");
                                if (partname == NULL)
                                        partname = procmime_mimeinfo_get_parameter(child, "name");
@@ -4120,6 +4113,21 @@ static void compose_select_account(Compose *compose, PrefsAccount *account,
                compose_insert_sig(compose, TRUE);
                undo_unblock(compose->undostruct);
        }
+
+#ifdef USE_ASPELL
+       /* use account's dict info if set */
+       if (compose->gtkaspell) {
+               if (account->enable_default_dictionary)
+                       gtkaspell_change_dict(compose->gtkaspell,
+                                       account->default_dictionary, FALSE);
+               if (account->enable_default_alt_dictionary)
+                       gtkaspell_change_alt_dict(compose->gtkaspell,
+                                       account->default_alt_dictionary);
+               if (account->enable_default_dictionary
+                       || account->enable_default_alt_dictionary)
+                       compose_spell_menu_changed(compose);
+       }
+#endif
 }
 
 gboolean compose_check_for_valid_recipient(Compose *compose) {
@@ -9491,6 +9499,29 @@ static MsgInfo *compose_msginfo_new_from_compose(Compose *compose)
        return newmsginfo;
 }
 
+#ifdef USE_ASPELL
+/* update compose's dictionaries from folder dict settings */
+static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
+                                               FolderItem *folder_item)
+{
+       g_return_if_fail(compose != NULL);
+
+       if (compose->gtkaspell && folder_item && folder_item->prefs) {
+               FolderItemPrefs *prefs = folder_item->prefs;
+
+               if (prefs->enable_default_dictionary)
+                       gtkaspell_change_dict(compose->gtkaspell,
+                                       prefs->default_dictionary, FALSE);
+               if (folder_item->prefs->enable_default_alt_dictionary)
+                       gtkaspell_change_alt_dict(compose->gtkaspell,
+                                       prefs->default_alt_dictionary);
+               if (prefs->enable_default_dictionary
+                       || prefs->enable_default_alt_dictionary)
+                       compose_spell_menu_changed(compose);
+       }
+}
+#endif
+
 /*
  * End of Source.
  */