2004-11-17 [colin] 0.9.12cvs156
authorColin Leroy <colin@colino.net>
Wed, 17 Nov 2004 14:11:11 +0000 (14:11 +0000)
committerColin Leroy <colin@colino.net>
Wed, 17 Nov 2004 14:11:11 +0000 (14:11 +0000)
* src/prefs_account.c
* src/prefs_account.h
* src/procmsg.c
Add an option to let the user choose to store encrypted
mail as clear text or encrypted.

ChangeLog.claws
PATCHSETS
configure.ac
src/prefs_account.c
src/prefs_account.h
src/procmsg.c

index 294bc6c..c014290 100644 (file)
@@ -1,3 +1,11 @@
+2004-11-17 [colin]     0.9.12cvs156
+
+       * src/prefs_account.c
+       * src/prefs_account.h
+       * src/procmsg.c
+               Add an option to let the user choose to store encrypted
+               mail as clear text or encrypted.
+
 2004-11-17 [colin]     0.9.12cvs155
 
        * src/compose.c
index fddfa81..6f7832d 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.33 -r 1.34 src/procmime.h; ) > 0.9.12cvs153.patchset
 ( cvs diff -u -r 1.11 -r 1.12 src/privacy.c; ) > 0.9.12cvs154.patchset
 ( cvs diff -u -r 1.455 -r 1.456 src/compose.c; cvs diff -u -r 1.173 -r 1.174 src/procmsg.c; cvs diff -u -r 1.55 -r 1.56 src/toolbar.c; ) > 0.9.12cvs155.patchset
+( cvs diff -u -r 1.120 -r 1.121 src/prefs_account.c; cvs diff -u -r 1.55 -r 1.56 src/prefs_account.h; cvs diff -u -r 1.174 -r 1.175 src/procmsg.c; ) > 0.9.12cvs156.patchset
index d9d3c18..3587bf8 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=155
+EXTRA_VERSION=156
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 1c5a2bc..7d79172 100644 (file)
@@ -140,6 +140,7 @@ static struct Privacy {
        GtkWidget *default_privacy_system;
        GtkWidget *default_encrypt_chkbtn;
        GtkWidget *default_sign_chkbtn;
+       GtkWidget *save_clear_text_chkbtn;
 } privacy;
 
 #if USE_OPENSSL
@@ -409,6 +410,9 @@ static PrefParam param[] = {
        {"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL,
         &privacy.default_sign_chkbtn,
         prefs_set_data_from_toggle, prefs_set_toggle},
+       {"save_clear_text", "FALSE", &tmp_ac_prefs.save_encrypted_as_clear_text, P_BOOL,
+        &privacy.save_clear_text_chkbtn,
+        prefs_set_data_from_toggle, prefs_set_toggle},
 
 #if USE_OPENSSL
        /* SSL */
@@ -1687,6 +1691,7 @@ static void prefs_account_privacy_create(void)
        GtkWidget *default_privacy_system;
        GtkWidget *default_encrypt_chkbtn;
        GtkWidget *default_sign_chkbtn;
+       GtkWidget *save_clear_text_chkbtn;
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -1713,10 +1718,13 @@ static void prefs_account_privacy_create(void)
                           _("Encrypt message by default"));
        PACK_CHECK_BUTTON (vbox2, default_sign_chkbtn,
                           _("Sign message by default"));
-                           
+       PACK_CHECK_BUTTON (vbox2, save_clear_text_chkbtn,
+                          _("Save sent encrypted messages as clear text"));
+
        privacy.default_privacy_system = default_privacy_system;
        privacy.default_encrypt_chkbtn = default_encrypt_chkbtn;
        privacy.default_sign_chkbtn    = default_sign_chkbtn;
+       privacy.save_clear_text_chkbtn = save_clear_text_chkbtn;
 }
 
 #if USE_OPENSSL
index 4a4d125..a00c91f 100644 (file)
@@ -133,6 +133,7 @@ struct _PrefsAccount
        gchar    *default_privacy_system;
        gboolean  default_encrypt;
        gboolean  default_sign;
+       gboolean  save_encrypted_as_clear_text;
 
        /* Advanced */
        gboolean  set_smtpport;
index f5c0e4f..dd7ad64 100644 (file)
@@ -1067,6 +1067,9 @@ gint procmsg_send_message_queue(const gchar *file)
        gchar buf[BUFFSIZE];
        gint hnum;
        PrefsAccount *mailac = NULL, *newsac = NULL;
+       gboolean save_clear_text = TRUE;
+       gchar *tmp_enc_file = NULL;
+
        int local = 0;
 
        g_return_val_if_fail(file != NULL, -1);
@@ -1132,8 +1135,11 @@ gint procmsg_send_message_queue(const gchar *file)
        if (encrypt) {
                MimeInfo *mimeinfo;
 
+               save_clear_text = (mailac != NULL && mailac->save_encrypted_as_clear_text);
+
                fclose(fp);
-               
+               fp = NULL;
+
                mimeinfo = procmime_scan_queue_file(file);
                if (!privacy_encrypt(privacy_system, mimeinfo, encrypt_data)
                || (fp = my_tmpfile()) == NULL
@@ -1155,8 +1161,26 @@ gint procmsg_send_message_queue(const gchar *file)
                        return -1;
                }
                
-               procmime_mimeinfo_free_all(mimeinfo);
                rewind(fp);
+               if (!save_clear_text) {
+                       gchar *content = NULL;
+                       FILE *tmpfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmp_enc_file);
+                       if (tmpfp) {
+                               fclose(tmpfp);
+
+                               content = file_read_stream_to_str(fp);
+                               rewind(fp);
+
+                               get_tmpfile_in_dir(get_mime_tmp_dir(), &tmp_enc_file);
+                               str_write_to_file(content, tmp_enc_file);
+                               g_free(content);
+                       } else {
+                               g_warning("couldn't get tempfile\n");
+                       }
+               } 
+               
+               procmime_mimeinfo_free_all(mimeinfo);
+               
                filepos = 0;
        }
 
@@ -1250,8 +1274,14 @@ gint procmsg_send_message_queue(const gchar *file)
                outbox = folder_find_item_from_identifier(savecopyfolder);
                if (!outbox)
                        outbox = folder_get_default_outbox();
-
-               procmsg_save_to_outbox(outbox, file, TRUE);
+                       
+               if (save_clear_text || tmp_enc_file == NULL) {
+                       procmsg_save_to_outbox(outbox, file, TRUE);
+               } else {
+                       procmsg_save_to_outbox(outbox, tmp_enc_file, FALSE);
+                       unlink(tmp_enc_file);
+                       free(tmp_enc_file);
+               }
        }
 
        if (replymessageid != NULL || fwdmessageid != NULL) {