[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sylpheed
Subject:    [sylpheed:23344] PATCH: encrypt-to-self
From:       Ian Bruce <ian_bruce () fastmail ! fm>
Date:       2004-08-19 12:14:35
Message-ID: 20040819051435.69ebf0f3.ian_bruce () fastmail ! fm
[Download RAW message or body]

Description:

This patch adds a per-account configuration option to self-encrypt
messages to the same key selected for signing. The default behavior is
unchanged.

Motivation:

It's a major nuisance to not be able to read encrypted messages in your
Outbox. Possible solutions are CC'ing to yourself, or using the
"encrypt-to" option in the GPG configuration file. The first clutters up
incoming mail, and the second does not allow the key to be selected
depending on which account you are sending from. This patch provides the
option of self-encrypting messages to the same key used for signing,
which is a much more flexible and transparent solution.

Patch follows as an attachment.


-- Ian Bruce


["sylpheed.patch.txt" (text/plain)]

--- sylpheed-0.9.12/src/prefs_account.orig.h	2003-07-15 00:16:26.000000000 -0700
+++ sylpheed-0.9.12/src/prefs_account.h	2004-08-18 17:35:51.000000000 -0700
@@ -126,6 +126,7 @@
 	/* Privacy */
 	gboolean default_encrypt;
 	gboolean default_sign;
+	gboolean self_encrypt;
 	gboolean ascii_armored;
 	gboolean clearsign;
 	SignKeyType sign_key;
--- sylpheed-0.9.12/src/prefs_account.orig.c	2004-01-27 22:31:02.000000000 -0800
+++ sylpheed-0.9.12/src/prefs_account.c	2004-08-18 17:30:36.000000000 -0700
@@ -126,6 +126,7 @@
 static struct Privacy {
 	GtkWidget *default_encrypt_chkbtn;
 	GtkWidget *default_sign_chkbtn;
+	GtkWidget *self_encrypt_chkbtn;
 	GtkWidget *ascii_armored_chkbtn;
 	GtkWidget *clearsign_chkbtn;
 	GtkWidget *defaultkey_radiobtn;
@@ -357,6 +358,9 @@
 	{"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL,
 	 &privacy.default_sign_chkbtn,
 	 prefs_set_data_from_toggle, prefs_set_toggle},
+	{"self_encrypt", "FALSE", &tmp_ac_prefs.self_encrypt, P_BOOL,
+	 &privacy.self_encrypt_chkbtn,
+	 prefs_set_data_from_toggle, prefs_set_toggle},
 	{"ascii_armored", "FALSE", &tmp_ac_prefs.ascii_armored, P_BOOL,
 	 &privacy.ascii_armored_chkbtn,
 	 prefs_set_data_from_toggle, prefs_set_toggle},
@@ -1413,6 +1417,7 @@
 	GtkWidget *label;
 	GtkWidget *default_encrypt_chkbtn;
 	GtkWidget *default_sign_chkbtn;
+	GtkWidget *self_encrypt_chkbtn;
 	GtkWidget *ascii_armored_chkbtn;
 	GtkWidget *clearsign_chkbtn;
 	GtkWidget *defaultkey_radiobtn;
@@ -1433,6 +1438,8 @@
 			   _("Encrypt message by default"));
 	PACK_CHECK_BUTTON (vbox2, default_sign_chkbtn,
 			   _("Sign message by default"));
+	PACK_CHECK_BUTTON (vbox2, self_encrypt_chkbtn,
+			   _("Encrypt message to self"));
 	PACK_CHECK_BUTTON (vbox2, ascii_armored_chkbtn,
 			   _("Use ASCII-armored format for encryption"));
 	PACK_CHECK_BUTTON (vbox2, clearsign_chkbtn,
@@ -1440,7 +1447,7 @@
 	gtk_signal_connect (GTK_OBJECT (ascii_armored_chkbtn), "toggled",
 			    prefs_account_ascii_armored_warning, NULL);
 
-	PACK_FRAME (vbox1, frame1, _("Sign key"));
+	PACK_FRAME (vbox1, frame1, _("Sign and self-encrypt key"));
 
 	vbox2 = gtk_vbox_new (FALSE, 0);
 	gtk_widget_show (vbox2);
@@ -1495,6 +1502,7 @@
 
 	privacy.default_encrypt_chkbtn = default_encrypt_chkbtn;
 	privacy.default_sign_chkbtn    = default_sign_chkbtn;
+	privacy.self_encrypt_chkbtn    = self_encrypt_chkbtn;
 	privacy.ascii_armored_chkbtn   = ascii_armored_chkbtn;
 	privacy.clearsign_chkbtn       = clearsign_chkbtn;
 	privacy.defaultkey_radiobtn    = defaultkey_radiobtn;
--- sylpheed-0.9.12/src/compose.orig.c	2004-05-18 23:24:17.000000000 -0700
+++ sylpheed-0.9.12/src/compose.c	2004-08-19 03:57:16.000000000 -0700
@@ -2820,12 +2820,46 @@
 			return -1;
 		}
 	}
+
 	if (compose->use_encryption) {
-		if (rfc2015_encrypt(file, compose->to_list,
-				    compose->account->ascii_armored) < 0) {
+		gchar *key_id;
+		GSList *recp_list;
+		PrefsAccount *account = compose->account;
+
+		if (account->self_encrypt) {
+			switch (account->sign_key) {
+			case SIGN_KEY_BY_FROM:
+				key_id = account->address;
+				break;
+			case SIGN_KEY_CUSTOM:
+				key_id = account->sign_key_id;
+				break;
+			default:
+				key_id = NULL;
+				break;
+			}
+
+			if (!(key_id && *key_id)) {
+				alertpanel_error(_("No self-encrypt key specified"));
+				unlink(file);
+				return -1;
+			}
+
+			recp_list = g_slist_copy(compose->to_list);
+			recp_list = g_slist_prepend(recp_list, key_id);
+		}
+		else
+			recp_list = compose->to_list;
+
+		if (rfc2015_encrypt(file, recp_list, account->ascii_armored) < 0) {
+			if (account->self_encrypt)
+				g_slist_free(recp_list);
 			unlink(file);
 			return -1;
 		}
+
+		if (account->self_encrypt)
+			g_slist_free(recp_list);
 	}
 #endif /* USE_GPGME */
 




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic