balsa r7886 - in trunk: . libbalsa src



Author: PeterB
Date: Sun Mar  9 19:20:52 2008
New Revision: 7886
URL: http://svn.gnome.org/viewvc/balsa?rev=7886&view=rev

Log:
button to refresh expired gnupg key

Modified:
   trunk/ChangeLog
   trunk/libbalsa/rfc3156.c
   trunk/libbalsa/rfc3156.h
   trunk/src/balsa-mime-widget-crypto.c

Modified: trunk/libbalsa/rfc3156.c
==============================================================================
--- trunk/libbalsa/rfc3156.c	(original)
+++ trunk/libbalsa/rfc3156.c	Sun Mar  9 19:20:52 2008
@@ -1124,7 +1124,7 @@
 #include <sys/wait.h>
 #include <fcntl.h>
 
-/* run gpg asynchronously to import a key */
+/* run gpg asynchronously to import or update a key */
 typedef struct _spawned_gpg_T {
     gint child_pid;
     gint standard_error;
@@ -1135,7 +1135,8 @@
 static gboolean check_gpg_child(gpointer data);
 
 gboolean
-gpg_run_import_key(const gchar * fingerprint, GtkWindow * parent)
+gpg_keyserver_op(const gchar * fingerprint, gpg_keyserver_action_t action,
+                 GtkWindow * parent)
 {
     gchar **argv;
     spawned_gpg_T *spawned_gpg;
@@ -1145,7 +1146,16 @@
     argv = g_new(gchar *, 5);
     argv[0] = g_strdup(GPG_PATH);
     argv[1] = g_strdup("--no-greeting");
-    argv[2] = g_strdup("--recv-keys");
+    switch (action) {
+    case GPG_KEYSERVER_IMPORT:
+        argv[2] = g_strdup("--recv-keys");
+        break;
+    case GPG_KEYSERVER_UPDATE:
+        argv[2] = g_strdup("--refresh-keys");
+        break;
+    default:
+        g_assert_not_reached();
+    }
     argv[3] = g_strdup(fingerprint);
     argv[4] = NULL;
     spawned_gpg = g_new0(spawned_gpg_T, 1);
@@ -1159,7 +1169,7 @@
     if (spawnres == FALSE) {
 	libbalsa_information(LIBBALSA_INFORMATION_ERROR,
 			     _
-			     ("Could not launch %s to get the public key %s."),
+			     ("Could not launch %s to query the public key %s."),
 			     GPG_PATH, fingerprint);
 	g_free(spawned_gpg);
 	return FALSE;
@@ -1209,15 +1219,15 @@
 				   GTK_DIALOG_DESTROY_WITH_PARENT,
 				   GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
 				   _
-				   ("Running gpg failed with return value %d:\n%s"),
-				   WEXITSTATUS(status), gpg_message);
+				   ("Running %s failed with return value %d:\n%s"),
+				   GPG_PATH, WEXITSTATUS(status), gpg_message);
     else
 	dialog =
 	    gtk_message_dialog_new(spawned_gpg->parent,
 				   GTK_DIALOG_DESTROY_WITH_PARENT,
 				   GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
-				   _("Running gpg successful:\n%s"),
-				   gpg_message);
+				   _("Running %s successful:\n%s"),
+				   GPG_PATH, gpg_message);
     g_free(gpg_message);
     g_string_free(spawned_gpg->stderr_buf, TRUE);
     g_free(spawned_gpg);

Modified: trunk/libbalsa/rfc3156.h
==============================================================================
--- trunk/libbalsa/rfc3156.h	(original)
+++ trunk/libbalsa/rfc3156.h	Sun Mar  9 19:20:52 2008
@@ -107,7 +107,15 @@
 					const gchar * date_string);
 
 #ifdef HAVE_GPG
-gboolean gpg_run_import_key(const gchar * fingerprint, GtkWindow * parent);
+
+typedef enum {
+    GPG_KEYSERVER_IMPORT = 1,
+    GPG_KEYSERVER_UPDATE
+} gpg_keyserver_action_t;
+
+gboolean gpg_keyserver_op(const gchar * fingerprint,
+                          gpg_keyserver_action_t action,
+                          GtkWindow * parent);
 
 #endif
 #endif				/* HAVE_GPGME */

Modified: trunk/src/balsa-mime-widget-crypto.c
==============================================================================
--- trunk/src/balsa-mime-widget-crypto.c	(original)
+++ trunk/src/balsa-mime-widget-crypto.c	Sun Mar  9 19:20:52 2008
@@ -30,7 +30,7 @@
 
 
 #ifdef HAVE_GPG
-static void on_import_gpg_key_button(GtkButton * button, const gchar * fingerprint);
+static void on_gpg_key_button(GtkButton * button, const gchar * fingerprint);
 #endif
 
 
@@ -83,15 +83,22 @@
     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
     g_free(infostr);
 #ifdef HAVE_GPG
-    if (mime_body->sig_info->protocol == GPGME_PROTOCOL_OpenPGP &&
-        mime_body->sig_info->status == GPG_ERR_NO_PUBKEY) {
-        GtkWidget *button =
-            gtk_button_new_with_mnemonic(_("_Run gpg to import this key"));
+    if (mime_body->sig_info->protocol == GPGME_PROTOCOL_OpenPGP) {
+        GtkWidget *button;
 
-        gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+        if (mime_body->sig_info->status == GPG_ERR_NO_PUBKEY) {
+            button = gtk_button_new_with_mnemonic(_("_Run GnuPG to import this key"));
+            g_object_set_data(G_OBJECT(button), "gpg-keyserver-op",
+                              GINT_TO_POINTER(GPG_KEYSERVER_IMPORT));
+        } else {
+            button = gtk_button_new_with_mnemonic(_("_Run GnuPG to check for an update of this key"));
+            g_object_set_data(G_OBJECT(button), "gpg-keyserver-op",
+                              GINT_TO_POINTER(GPG_KEYSERVER_UPDATE));
+        }
         g_signal_connect(G_OBJECT(button), "clicked",
-                         G_CALLBACK(on_import_gpg_key_button),
+                         G_CALLBACK(on_gpg_key_button),
                          (gpointer)mime_body->sig_info->fingerprint);
+        gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
     }
 #endif /* HAVE_GPG */
 
@@ -160,9 +167,12 @@
 
 /* Callback: run gpg to import a public key */
 static void
-on_import_gpg_key_button(GtkButton * button, const gchar * fingerprint)
+on_gpg_key_button(GtkButton * button, const gchar * fingerprint)
 {
-    gpg_run_import_key(fingerprint, GTK_WINDOW(balsa_app.main_window));
+    gpg_keyserver_action_t action =
+        GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "gpg-keyserver-op"));
+
+    gpg_keyserver_op(fingerprint, action, GTK_WINDOW(balsa_app.main_window));
 }
 #endif /* HAVE_GPG */
 



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