2005-02-14 [colin] 1.0.1cvs6
[claws.git] / src / compose.c
index 01442d1ab10fbe4359f546a744d9a4e49a600603..4c7a3cf68cc9df473d378aa27dc40b8474eaee99 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * 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
@@ -1358,7 +1358,7 @@ Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
 
        gtk_widget_grab_focus(compose->header_last->entry);
 
-       filename = procmsg_get_message_file(msginfo);
+       filename = procmsg_get_message_file_path(msginfo);
        if (filename == NULL)
                return NULL;
 
@@ -1398,10 +1398,7 @@ Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
        menu_set_sensitive(ifactory, "/Message/Attach file", FALSE);
        menu_set_sensitive(ifactory, "/Message/Insert signature", FALSE);
        menu_set_sensitive(ifactory, "/Edit", FALSE);
-       menu_set_sensitive(ifactory, "/Options/Sign", FALSE);
-       menu_set_sensitive(ifactory, "/Options/Encrypt", FALSE);
-       menu_set_sensitive(ifactory, "/Options/Priority", FALSE);
-       menu_set_sensitive(ifactory, "/Options/Request Return Receipt", FALSE);
+       menu_set_sensitive(ifactory, "/Options", FALSE);
        menu_set_sensitive(ifactory, "/Tools/Show ruler", FALSE);
        menu_set_sensitive(ifactory, "/Tools/Actions", FALSE);
        
@@ -3035,11 +3032,11 @@ static void compose_select_account(Compose *compose, PrefsAccount *account,
 
 #endif
 
-       if (account->default_sign)
+       if (account->default_sign && compose->mode != COMPOSE_REDIRECT)
                menu_set_active(ifactory, "/Options/Sign", TRUE);
        else
                menu_set_active(ifactory, "/Options/Sign", FALSE);
-       if (account->default_encrypt)
+       if (account->default_encrypt && compose->mode != COMPOSE_REDIRECT)
                menu_set_active(ifactory, "/Options/Encrypt", TRUE);
        else
                menu_set_active(ifactory, "/Options/Encrypt", FALSE);
@@ -3430,6 +3427,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action)
 
                if (action == COMPOSE_WRITE_FOR_SEND) {
                        buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
+                       
                        if (!buf) {
                                AlertValue aval;
                                gchar *msg;
@@ -3458,6 +3456,13 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action)
        }
        g_free(chars);
 
+       if (encoding == ENC_8BIT || encoding == ENC_7BIT) {
+               if (!strncmp(buf, "From ", strlen("From ")) ||
+                   strstr(buf, "\nFrom ") != NULL) {
+                       encoding = ENC_QUOTED_PRINTABLE;
+               }
+       }
+
        mimetext = procmime_mimeinfo_new();
        mimetext->content = MIMECONTENT_MEM;
        mimetext->data.mem = buf;
@@ -3468,7 +3473,10 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action)
        /* protect trailing spaces when signing message */
        if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing && 
            privacy_system_can_sign(compose->privacy_system))
-               encoding = ENC_QUOTED_PRINTABLE;
+               if (encoding == ENC_7BIT)
+                       encoding = ENC_QUOTED_PRINTABLE;
+               else if (encoding == ENC_8BIT)
+                       encoding = ENC_BASE64;
        if (encoding != ENC_UNKNOWN)
                procmime_encode_content(mimetext, encoding);
 
@@ -6924,7 +6932,8 @@ void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list,
 {
        gchar *body;
        GSList *new_msglist = NULL;
-       
+       MsgInfo *tmp_msginfo = NULL;
+
        g_return_if_fail(msgview != NULL);
 
        g_return_if_fail(msginfo_list != NULL);
@@ -6934,9 +6943,9 @@ void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list,
                MsgInfo *orig_msginfo = (MsgInfo *)msginfo_list->data;
                
                if (mimeinfo != NULL && mimeinfo->type == MIMETYPE_MESSAGE && 
-                   !g_ascii_strcasecmp(mimeinfo->subtype, "rfc822")) {
+                   !g_strcasecmp(mimeinfo->subtype, "rfc822")) {
                        
-                       MsgInfo *tmp_msginfo = procmsg_msginfo_new_from_mimeinfo(
+                       tmp_msginfo = procmsg_msginfo_new_from_mimeinfo(
                                                orig_msginfo, mimeinfo);
                        if (tmp_msginfo != NULL) {
                                new_msglist = g_slist_append(NULL, tmp_msginfo);
@@ -6948,6 +6957,7 @@ void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list,
 
        if (new_msglist) {
                compose_reply_mode((ComposeMode)action, new_msglist, body);
+               procmsg_msginfo_free(tmp_msginfo);
                g_slist_free(new_msglist);
        } else
                compose_reply_mode((ComposeMode)action, msginfo_list, body);