commit 21de5ccd1fe7bb1df899255a7cd1e27e73944d13
parent 8f36a4ffc47b3b01eb3b6c1016ff8f29762638b9
Author: Colin Leroy <colin@colino.net>
Date: Thu, 22 Jan 2009 18:06:02 +0000
2009-01-22 [colin] 3.7.0cvs42
* src/compose.c
* src/privacy.c
* src/privacy.h
When replying to signed/encrypted mail and the
preference to sign/encrypt in this case is set,
choose the original mail's privacy system (if
available).
Diffstat:
6 files changed, 61 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,13 @@
+2009-01-22 [colin] 3.7.0cvs42
+
+ * src/compose.c
+ * src/privacy.c
+ * src/privacy.h
+ When replying to signed/encrypted mail and the
+ preference to sign/encrypt in this case is set,
+ choose the original mail's privacy system (if
+ available).
+
2009-01-21 [colin] 3.7.0cvs41
* src/addressbook.h
diff --git a/PATCHSETS b/PATCHSETS
@@ -3703,3 +3703,4 @@
( cvs diff -u -r 1.149.2.98 -r 1.149.2.99 src/inc.c; ) > 3.7.0cvs39.patchset
( cvs diff -u -r 1.61.2.92 -r 1.61.2.93 src/account.c; cvs diff -u -r 1.60.2.129 -r 1.60.2.130 src/addressbook.c; ) > 3.7.0cvs40.patchset
( cvs diff -u -r 1.18.2.15 -r 1.18.2.16 src/addressbook.h; ) > 3.7.0cvs41.patchset
+( cvs diff -u -r 1.382.2.495 -r 1.382.2.496 src/compose.c; cvs diff -u -r 1.10.2.18 -r 1.10.2.19 src/privacy.c; cvs diff -u -r 1.10.2.19 -r 1.10.2.20 src/privacy.h; ) > 3.7.0cvs42.patchset
diff --git a/configure.ac b/configure.ac
@@ -11,7 +11,7 @@ MINOR_VERSION=7
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=41
+EXTRA_VERSION=42
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
diff --git a/src/compose.c b/src/compose.c
@@ -1157,9 +1157,9 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
}
static void compose_force_encryption(Compose *compose, PrefsAccount *account,
- gboolean override_pref)
+ gboolean override_pref, const gchar *system)
{
- gchar *privacy = NULL;
+ const gchar *privacy = NULL;
g_return_if_fail(compose != NULL);
g_return_if_fail(account != NULL);
@@ -1167,7 +1167,9 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
if (override_pref == FALSE && account->default_encrypt_reply == FALSE)
return;
- if (account->default_privacy_system
+ if (system)
+ privacy = system;
+ else if (account->default_privacy_system
&& strlen(account->default_privacy_system)) {
privacy = account->default_privacy_system;
} else {
@@ -1177,6 +1179,10 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
}
}
if (privacy != NULL) {
+ if (system) {
+ g_free(compose->privacy_system);
+ compose->privacy_system = NULL;
+ }
if (compose->privacy_system == NULL)
compose->privacy_system = g_strdup(privacy);
else if (*(compose->privacy_system) == '\0') {
@@ -1188,11 +1194,13 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
}
}
-static void compose_force_signing(Compose *compose, PrefsAccount *account)
+static void compose_force_signing(Compose *compose, PrefsAccount *account, const gchar *system)
{
gchar *privacy = NULL;
- if (account->default_privacy_system
+ if (system)
+ privacy = system;
+ else if (account->default_privacy_system
&& strlen(account->default_privacy_system)) {
privacy = account->default_privacy_system;
} else {
@@ -1201,7 +1209,12 @@ static void compose_force_signing(Compose *compose, PrefsAccount *account)
privacy = (gchar *)(privacy_avail->data);
}
}
+
if (privacy != NULL) {
+ if (system) {
+ g_free(compose->privacy_system);
+ compose->privacy_system = NULL;
+ }
if (compose->privacy_system == NULL)
compose->privacy_system = g_strdup(privacy);
compose_update_privacy_system_menu_item(compose, FALSE);
@@ -1418,6 +1431,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
gboolean quote = FALSE;
const gchar *qmark = NULL;
const gchar *body_fmt = NULL;
+ gchar *s_system = NULL;
START_TIMING("");
g_return_val_if_fail(msginfo != NULL, NULL);
g_return_val_if_fail(msginfo->folder != NULL, NULL);
@@ -1535,13 +1549,14 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
}
if (MSG_IS_ENCRYPTED(compose->replyinfo->flags)) {
- compose_force_encryption(compose, account, FALSE);
+ compose_force_encryption(compose, account, FALSE, s_system);
}
- privacy_msginfo_get_signed_state(compose->replyinfo);
+ privacy_msginfo_get_signed_state(compose->replyinfo, &s_system);
if (MSG_IS_SIGNED(compose->replyinfo->flags) && account->default_sign_reply) {
- compose_force_signing(compose, account);
+ compose_force_signing(compose, account, s_system);
}
+ g_free(s_system);
SIGNAL_BLOCK(textbuf);
@@ -2185,7 +2200,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
if (MSG_IS_ENCRYPTED(msginfo->flags)) {
fp = procmime_get_first_encrypted_text_content(msginfo);
if (fp) {
- compose_force_encryption(compose, account, TRUE);
+ compose_force_encryption(compose, account, TRUE, NULL);
}
} else {
fp = procmime_get_first_text_content(msginfo);
@@ -3563,7 +3578,7 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
compose_attach_append(compose, outfile,
partname, content_type);
} else {
- compose_force_signing(compose, compose->account);
+ compose_force_signing(compose, compose->account, NULL);
}
g_free(content_type);
}
@@ -10597,6 +10612,7 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
gboolean originally_enc = FALSE;
gboolean originally_sig = FALSE;
Compose *compose = NULL;
+ gchar *s_system = NULL;
g_return_if_fail(msgview != NULL);
@@ -10614,7 +10630,7 @@ 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);
+ privacy_msginfo_get_signed_state(orig_msginfo, &s_system);
originally_sig = MSG_IS_SIGNED(orig_msginfo->flags);
tmp_msginfo->folder = orig_msginfo->folder;
@@ -10636,13 +10652,13 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
compose = compose_reply_mode((ComposeMode)action, msginfo_list, body);
if (compose && originally_enc) {
- compose_force_encryption(compose, compose->account, FALSE);
+ compose_force_encryption(compose, compose->account, FALSE, s_system);
}
if (compose && originally_sig && compose->account->default_sign_reply) {
- compose_force_signing(compose, compose->account);
+ compose_force_signing(compose, compose->account, s_system);
}
-
+ g_free(s_system);
g_free(body);
}
diff --git a/src/privacy.c b/src/privacy.c
@@ -147,26 +147,40 @@ try_others:
return FALSE;
}
+struct SignedState {
+ MsgInfo *msginfo;
+ gchar **system;
+};
+
static void msginfo_set_signed_flag(GNode *node, gpointer data)
{
- MsgInfo *msginfo = data;
+ struct SignedState *sstate = (struct SignedState *)data;
+ MsgInfo *msginfo = sstate->msginfo;
MimeInfo *mimeinfo = node->data;
if (privacy_mimeinfo_is_signed(mimeinfo)) {
procmsg_msginfo_set_flags(msginfo, 0, MSG_SIGNED);
+ if (sstate->system && !*(sstate->system) && mimeinfo->privacy)
+ *(sstate->system) = g_strdup(mimeinfo->privacy->system->id);
}
if (privacy_mimeinfo_is_encrypted(mimeinfo)) {
procmsg_msginfo_set_flags(msginfo, 0, MSG_ENCRYPTED);
+ if (sstate->system && !*(sstate->system) && mimeinfo->privacy)
+ *(sstate->system) = g_strdup(mimeinfo->privacy->system->id);
} else {
/* searching inside encrypted parts doesn't really make sense */
- g_node_children_foreach(mimeinfo->node, G_TRAVERSE_ALL, msginfo_set_signed_flag, msginfo);
+ g_node_children_foreach(mimeinfo->node, G_TRAVERSE_ALL, msginfo_set_signed_flag, sstate);
}
}
-void privacy_msginfo_get_signed_state(MsgInfo *msginfo)
+void privacy_msginfo_get_signed_state(MsgInfo *msginfo, gchar **system)
{
+ struct SignedState sstate;
MimeInfo *mimeinfo = procmime_scan_message(msginfo);
- g_node_children_foreach(mimeinfo->node, G_TRAVERSE_ALL, msginfo_set_signed_flag, msginfo);
+
+ sstate.msginfo = msginfo;
+ sstate.system = system;
+ g_node_children_foreach(mimeinfo->node, G_TRAVERSE_ALL, msginfo_set_signed_flag, &sstate);
}
/**
diff --git a/src/privacy.h b/src/privacy.h
@@ -43,7 +43,7 @@ void privacy_unregister_system (PrivacySystem *system);
void privacy_free_privacydata (PrivacyData *);
-void privacy_msginfo_get_signed_state (MsgInfo *);
+void privacy_msginfo_get_signed_state (MsgInfo *, gchar **system);
gboolean privacy_mimeinfo_is_signed (MimeInfo *);
gint privacy_mimeinfo_check_signature (MimeInfo *);
SignatureStatus privacy_mimeinfo_get_sig_status (MimeInfo *);