2008-12-15 [colin] 3.6.1cvs78
authorColin Leroy <colin@colino.net>
Mon, 15 Dec 2008 16:46:27 +0000 (16:46 +0000)
committerColin Leroy <colin@colino.net>
Mon, 15 Dec 2008 16:46:27 +0000 (16:46 +0000)
* src/compose.c
* src/privacy.c
* src/privacy.h
* src/plugins/pgpcore/sgpgme.c
* src/plugins/pgpcore/sgpgme.h
* src/plugins/pgpinline/pgpinline.c
* src/plugins/pgpmime/pgpmime.c
* src/plugins/smime/smime.c
Fix bug 1796, 'PGP/MIME setting: "select key by your
email address" doesn't work'. Use custom from address
if set

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/plugins/pgpcore/sgpgme.c
src/plugins/pgpcore/sgpgme.h
src/plugins/pgpinline/pgpinline.c
src/plugins/pgpmime/pgpmime.c
src/plugins/smime/smime.c
src/privacy.c
src/privacy.h

index dcc48eb..c429aae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008-12-15 [colin]     3.6.1cvs78
+
+       * src/compose.c
+       * src/privacy.c
+       * src/privacy.h
+       * src/plugins/pgpcore/sgpgme.c
+       * src/plugins/pgpcore/sgpgme.h
+       * src/plugins/pgpinline/pgpinline.c
+       * src/plugins/pgpmime/pgpmime.c
+       * src/plugins/smime/smime.c
+               Fix bug 1796, 'PGP/MIME setting: "select key by your 
+               email address" doesn't work'. Use custom from address
+               if set
+
 2008-12-15 [colin]     3.6.1cvs77
 
        * src/common/utils.c
index 6c72706..c4e0433 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.24.2.24 -r 1.24.2.25 Makefile.am;  cvs diff -u -r 1.155.2.94 -r 1.155.2.95 src/Makefile.am;  cvs diff -u -r 1.9.2.38 -r 1.9.2.39 src/common/ssl.c;  cvs diff -u -r 1.36.2.156 -r 1.36.2.157 src/common/utils.c;  cvs diff -u -r 1.20.2.64 -r 1.20.2.65 src/common/utils.h;  cvs diff -u -r 1.25.2.30 -r 1.25.2.31 tools/Makefile.am;  ) > 3.6.1cvs75.patchset
 ( cvs diff -u -r 1.1.4.3 -r 1.1.4.4 m4/spamassassin.m4;  ) > 3.6.1cvs76.patchset
 ( cvs diff -u -r 1.36.2.157 -r 1.36.2.158 src/common/utils.c;  ) > 3.6.1cvs77.patchset
+( cvs diff -u -r 1.382.2.489 -r 1.382.2.490 src/compose.c;  cvs diff -u -r 1.10.2.16 -r 1.10.2.17 src/privacy.c;  cvs diff -u -r 1.10.2.17 -r 1.10.2.18 src/privacy.h;  cvs diff -u -r 1.1.2.58 -r 1.1.2.59 src/plugins/pgpcore/sgpgme.c;  cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/plugins/pgpcore/sgpgme.h;  cvs diff -u -r 1.1.2.40 -r 1.1.2.41 src/plugins/pgpinline/pgpinline.c;  cvs diff -u -r 1.1.2.51 -r 1.1.2.52 src/plugins/pgpmime/pgpmime.c;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/smime/smime.c;  ) > 3.6.1cvs78.patchset
index 61409da..8f80859 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=6
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=77
+EXTRA_VERSION=78
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 63d6458..daa43bc 100644 (file)
@@ -5111,6 +5111,8 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        MimeInfo *mimemsg, *mimetext;
        gint line;
        const gchar *src_codeset = CS_INTERNAL;
+       gchar *from_addr = NULL;
+       gchar *from_name = NULL;
 
        if (action == COMPOSE_WRITE_FOR_SEND)
                attach_parts = TRUE;
@@ -5294,12 +5296,31 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
 
        g_free(buf);
 
+       if (strlen(gtk_entry_get_text(GTK_ENTRY(compose->from_name))) != 0) {
+               gchar *spec = gtk_editable_get_chars(GTK_EDITABLE(compose->from_name), 0, -1);
+               /* extract name and address */
+               if (strstr(spec, " <") && strstr(spec, ">")) {
+                       from_addr = g_strdup(strrchr(spec, '<')+1);
+                       *(strrchr(from_addr, '>')) = '\0';
+                       from_name = g_strdup(spec);
+                       *(strrchr(from_name, '<')) = '\0';
+               } else {
+                       from_name = NULL;
+                       from_addr = NULL;
+               }
+               g_free(spec);
+       }
        /* sign message if sending */
        if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing && 
            privacy_system_can_sign(compose->privacy_system))
-               if (!privacy_sign(compose->privacy_system, mimemsg, compose->account))
+               if (!privacy_sign(compose->privacy_system, mimemsg, 
+                       compose->account, from_addr)) {
+                       g_free(from_name);
+                       g_free(from_addr);
                        return -2;
-
+       }
+       g_free(from_name);
+       g_free(from_addr);
        procmime_write_mimeinfo(mimemsg, fp);
        
        procmime_mimeinfo_free_all(mimemsg);
index 2cd3139..2ba23ba 100644 (file)
@@ -470,12 +470,16 @@ gchar *sgpgme_get_encrypt_data(GSList *recp_names, gpgme_protocol_t proto)
        return ret;
 }
 
-gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account)
+gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account,
+                             const gchar *from_addr)
 {
        GPGAccountConfig *config;
+       const gchar *signer_addr = account->address;
 
        gpgme_signers_clear(ctx);
 
+       if (from_addr)
+               signer_addr = from_addr;
        config = prefs_gpg_account_get_config(account);
 
        switch(config->sign_key) {
@@ -483,7 +487,7 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account)
                debug_print("using default gnupg key\n");
                break;
        case SIGN_KEY_BY_FROM:
-               debug_print("using key for %s\n", account->address);
+               debug_print("using key for %s\n", signer_addr);
                break;
        case SIGN_KEY_CUSTOM:
                debug_print("using key for %s\n", config->sign_key_id);
@@ -496,7 +500,7 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account)
                gpgme_error_t err;
 
                if (config->sign_key == SIGN_KEY_BY_FROM)
-                       keyid = account->address;
+                       keyid = signer_addr;
                else if (config->sign_key == SIGN_KEY_CUSTOM)
                        keyid = config->sign_key_id;
                else
index 51a8914..33604c5 100644 (file)
@@ -44,7 +44,8 @@ gpgme_data_t sgpgme_decrypt_verify    (gpgme_data_t cipher,
                                         gpgme_ctx_t ctx);
 gchar *sgpgme_get_encrypt_data         (GSList *recp_names,
                                         gpgme_protocol_t proto);
-gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account);
+gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account,
+                             const gchar *from_addr);
 void sgpgme_check_create_key(void);
 gboolean sgpgme_has_secret_key(void);
 void sgpgme_create_secret_key(PrefsAccount *account, gboolean ask_create);
index 9ee4ca8..fd8d84b 100644 (file)
@@ -566,7 +566,7 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
        return decinfo;
 }
 
-static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account)
+static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
 {
        MimeInfo *msgcontent;
        gchar *textstr, *tmp;
@@ -613,7 +613,7 @@ static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account)
        gpgme_set_textmode(ctx, 1);
        gpgme_set_armor(ctx, 1);
 
-       if (!sgpgme_setup_signers(ctx, account)) {
+       if (!sgpgme_setup_signers(ctx, account, from_addr)) {
                gpgme_release(ctx);
                return FALSE;
        }
index 2b7d106..be21e5c 100644 (file)
@@ -419,7 +419,7 @@ static MimeInfo *pgpmime_decrypt(MimeInfo *mimeinfo)
        return decinfo;
 }
 
-gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
+gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
 {
        MimeInfo *msgcontent, *sigmultipart, *newinfo;
        gchar *textstr, *micalg;
@@ -497,7 +497,7 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
        gpgme_set_armor(ctx, 1);
        gpgme_signers_clear (ctx);
 
-       if (!sgpgme_setup_signers(ctx, account)) {
+       if (!sgpgme_setup_signers(ctx, account, from_addr)) {
                gpgme_release(ctx);
                return FALSE;
        }
index 06684aa..b48faf3 100644 (file)
@@ -516,7 +516,7 @@ static MimeInfo *smime_decrypt(MimeInfo *mimeinfo)
        return decinfo;
 }
 
-gboolean smime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
+gboolean smime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
 {
        MimeInfo *msgcontent, *sigmultipart, *newinfo;
        gchar *textstr, *micalg;
@@ -602,7 +602,7 @@ gboolean smime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
                return FALSE;
        }
 
-       if (!sgpgme_setup_signers(ctx, account)) {
+       if (!sgpgme_setup_signers(ctx, account, from_addr)) {
                debug_print("setup_signers failed\n");
                gpgme_data_release(gpgtext);
                gpgme_release(ctx);
index 29038a4..7c2b797 100644 (file)
@@ -382,7 +382,7 @@ gboolean privacy_system_can_encrypt(const gchar *id)
        return system->can_encrypt;
 }
 
-gboolean privacy_sign(const gchar *id, MimeInfo *target, PrefsAccount *account)
+gboolean privacy_sign(const gchar *id, MimeInfo *target, PrefsAccount *account, const gchar *from_addr)
 {
        PrivacySystem *system;
 
@@ -397,7 +397,7 @@ gboolean privacy_sign(const gchar *id, MimeInfo *target, PrefsAccount *account)
        if (system->sign == NULL)
                return FALSE;
 
-       return system->sign(target, account);
+       return system->sign(target, account, from_addr);
 }
 
 gchar *privacy_get_encrypt_data(const gchar *id, GSList *recp_names)
index cf9aa9f..55b008b 100644 (file)
@@ -60,7 +60,8 @@ gboolean privacy_system_can_encrypt           (const gchar *);
 
 gboolean privacy_sign                          (const gchar  *system,
                                                 MimeInfo     *mimeinfo,
-                                                PrefsAccount *account);
+                                                PrefsAccount *account,
+                                                const gchar *from_addr);
 gchar *privacy_get_encrypt_data                        (const gchar  *system,
                                                 GSList       *recp_names);
 const gchar *privacy_get_encrypt_warning       (const gchar  *system);
@@ -92,7 +93,8 @@ struct _PrivacySystem {
 
        gboolean           can_sign;
        gboolean         (*sign)                (MimeInfo *mimeinfo,
-                                                PrefsAccount *account);
+                                                PrefsAccount *account, 
+                                                const gchar *from_addr);
 
        gboolean           can_encrypt;
        gchar           *(*get_encrypt_data)    (GSList *recp_names);