balsa r7962 - in trunk: . doc/C libbalsa src



Author: PeterB
Date: Thu Aug 28 12:22:51 2008
New Revision: 7962
URL: http://svn.gnome.org/viewvc/balsa?rev=7962&view=rev

Log:
specify a key id for an identity

Modified:
   trunk/ChangeLog
   trunk/doc/C/balsa.xml
   trunk/libbalsa/gmime-gpgme-context.c
   trunk/libbalsa/identity.c
   trunk/libbalsa/identity.h
   trunk/libbalsa/message.c
   trunk/libbalsa/message.h
   trunk/libbalsa/send.c
   trunk/src/sendmsg-window.c

Modified: trunk/doc/C/balsa.xml
==============================================================================
--- trunk/doc/C/balsa.xml	(original)
+++ trunk/doc/C/balsa.xml	Thu Aug 28 12:22:51 2008
@@ -4044,6 +4044,19 @@
     </listitem>
   </varlistentry>
 
+  <varlistentry>
+    <term><guilabel>Use secret key with this id for signing.</guilabel></term>
+    <listitem>
+      <para>
+        Usually, &Balsa; automaticylly selects a proper secret key for cryptographic
+        signatures from the identity's mail address. Therefore, most users should
+        leave this entry empty. If you want to force using a specific secret key for
+        cryptographic signatures, enter the key id here. You can get the key id by
+        running the command 'gpg --list-secret-keys'.
+      </para>
+    </listitem>
+  </varlistentry>
+
 </variablelist>
 
 <note>

Modified: trunk/libbalsa/gmime-gpgme-context.c
==============================================================================
--- trunk/libbalsa/gmime-gpgme-context.c	(original)
+++ trunk/libbalsa/gmime-gpgme-context.c	Thu Aug 28 12:22:51 2008
@@ -860,14 +860,25 @@
 
     if (!keys) {
 	if (error) {
-	    if (found_bad)
-		g_set_error(error, GPGME_ERROR_QUARK, GPG_ERR_KEY_SELECTION,
-			    _("%s: a key for %s is present, but it is expired, disabled, revoked or invalid"),
-			    "gmime-gpgme", name);
-	    else
-		g_set_error(error, GPGME_ERROR_QUARK, GPG_ERR_KEY_SELECTION,
-			    _("%s: could not find a key for %s"),
-			    "gmime-gpgme", name);
+            if (strchr(name, '@')) {
+                if (found_bad)
+                    g_set_error(error, GPGME_ERROR_QUARK, GPG_ERR_KEY_SELECTION,
+                                _("%s: a key for %s is present, but it is expired, disabled, revoked or invalid"),
+                                "gmime-gpgme", name);
+                else
+                    g_set_error(error, GPGME_ERROR_QUARK, GPG_ERR_KEY_SELECTION,
+                                _("%s: could not find a key for %s"),
+                                "gmime-gpgme", name);
+            } else {
+                if (found_bad)
+                    g_set_error(error, GPGME_ERROR_QUARK, GPG_ERR_KEY_SELECTION,
+                                _("%s: a key with id %s is present, but it is expired, disabled, revoked or invalid"),
+                                "gmime-gpgme", name);
+                else
+                    g_set_error(error, GPGME_ERROR_QUARK, GPG_ERR_KEY_SELECTION,
+                                _("%s: could not find a key with id %s"),
+                                "gmime-gpgme", name);
+            }
 	}
 	return NULL;
     }

Modified: trunk/libbalsa/identity.c
==============================================================================
--- trunk/libbalsa/identity.c	(original)
+++ trunk/libbalsa/identity.c	Thu Aug 28 12:22:51 2008
@@ -116,6 +116,7 @@
     ident->always_trust = FALSE;
     ident->warn_send_plain = TRUE;
     ident->crypt_protocol = LIBBALSA_PROTECT_OPENPGP;
+    ident->force_key_id = NULL;
 #endif
     ident->request_mdn = FALSE;
     /*
@@ -146,6 +147,9 @@
 #endif                          /* ENABLE_ESMTP */
     g_free(ident->face);
     g_free(ident->x_face);
+#ifdef HAVE_GPGME
+    g_free(ident->force_key_id);
+#endif
 
     G_OBJECT_CLASS(parent_class)->finalize(object);
 }
@@ -1067,6 +1071,9 @@
     ident_dialog_add_checkbutton(table, row++, dialog,
                                  _("remind me if messages can be encrypted"),
                                  "identity-warn-send-plain", TRUE);
+    ident_dialog_add_entry(table, row++, dialog,
+                           _("use secret key with this id for signing\n(leave empty for automatic selection)"), 
+                           "identity-keyid");
 #ifndef HAVE_GPGME
     gtk_widget_set_sensitive(table, FALSE);
 #endif
@@ -1511,6 +1518,7 @@
     id->warn_send_plain = ident_dialog_get_bool(dlg, "identity-warn-send-plain");
     id->crypt_protocol  = GPOINTER_TO_INT(ident_dialog_get_value
                                           (dlg, "identity-crypt-protocol"));
+    id->force_key_id    = g_strstrip(ident_dialog_get_text(dlg, "identity-keyid"));
 #endif
    
     return TRUE;
@@ -1895,6 +1903,7 @@
                               ident->warn_send_plain);    
     display_frame_set_gpg_mode(dialog, "identity-crypt-protocol",
 			   &ident->crypt_protocol);
+    display_frame_set_field(dialog, "identity-keyid", ident->force_key_id);
 #endif
 }
 
@@ -1997,6 +2006,7 @@
     ident->always_trust = libbalsa_conf_get_bool("GpgTrustAlways");
     ident->warn_send_plain = libbalsa_conf_get_bool("GpgWarnSendPlain=true");
     ident->crypt_protocol = libbalsa_conf_get_int("CryptProtocol=16");
+    ident->force_key_id = libbalsa_conf_get_string("ForceKeyID");
 #endif
 
     return ident;
@@ -2044,6 +2054,7 @@
     libbalsa_conf_set_bool("GpgTrustAlways", ident->always_trust);
     libbalsa_conf_set_bool("GpgWarnSendPlain", ident->warn_send_plain);
     libbalsa_conf_set_int("CryptProtocol", ident->crypt_protocol);
+    libbalsa_conf_set_string("ForceKeyID", ident->force_key_id);
 #endif
 
     libbalsa_conf_pop_group();

Modified: trunk/libbalsa/identity.h
==============================================================================
--- trunk/libbalsa/identity.h	(original)
+++ trunk/libbalsa/identity.h	Thu Aug 28 12:22:51 2008
@@ -87,6 +87,7 @@
 	gboolean always_trust;
 	gboolean warn_send_plain;
 	gint crypt_protocol;
+        gchar *force_key_id;
 #endif
 #if ENABLE_ESMTP
 	LibBalsaSmtpServer *smtp_server;

Modified: trunk/libbalsa/message.c
==============================================================================
--- trunk/libbalsa/message.c	(original)
+++ trunk/libbalsa/message.c	Thu Aug 28 12:22:51 2008
@@ -101,6 +101,7 @@
     message->has_all_headers = 0;
 #ifdef HAVE_GPGME
     message->prot_state = LIBBALSA_MSG_PROTECT_NONE;
+    message->force_key_id = NULL;
 #endif
 }
 
@@ -177,6 +178,11 @@
 	g_object_unref(message->mime_msg);
 	message->mime_msg = NULL;
     }
+
+#ifdef HAVE_GPGME
+    g_free(message->force_key_id);
+#endif
+
     G_OBJECT_CLASS(parent_class)->finalize(object);
 }
 

Modified: trunk/libbalsa/message.h
==============================================================================
--- trunk/libbalsa/message.h	(original)
+++ trunk/libbalsa/message.h	Thu Aug 28 12:22:51 2008
@@ -207,6 +207,9 @@
 
     /* protection (i.e. sign/encrypt) status (received message) */
     LibBalsaMsgProtectState prot_state;
+
+    /* forced id of the senders secret key, empty to choose it from the mail address */
+    gchar * force_key_id;
 #endif
 
     /* a forced multipart subtype or NULL for mixed; used only for

Modified: trunk/libbalsa/send.c
==============================================================================
--- trunk/libbalsa/send.c	(original)
+++ trunk/libbalsa/send.c	Thu Aug 28 12:22:51 2008
@@ -2067,6 +2067,9 @@
 lb_send_from(LibBalsaMessage *message)
 {
     InternetAddress *ia = message->headers->from->address;
+
+    if (message->force_key_id)
+        return message->force_key_id;
     
     if (ia->type == INTERNET_ADDRESS_NONE)
 	return NULL;

Modified: trunk/src/sendmsg-window.c
==============================================================================
--- trunk/src/sendmsg-window.c	(original)
+++ trunk/src/sendmsg-window.c	Thu Aug 28 12:22:51 2008
@@ -5573,6 +5573,8 @@
             (bsmsg->gpg_mode & LIBBALSA_PROTECT_MODE) != 0 ? bsmsg->gpg_mode : 0;
     else
         message->gpg_mode = 0;
+    if (ident->force_key_id && *ident->force_key_id)
+        message->force_key_id = strdup(ident->force_key_id);
 #endif
 
     /* remember the parent window */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]