2005-09-10 [colin] 1.9.14cvs17
authorColin Leroy <colin@colino.net>
Sat, 10 Sep 2005 19:53:00 +0000 (19:53 +0000)
committerColin Leroy <colin@colino.net>
Sat, 10 Sep 2005 19:53:00 +0000 (19:53 +0000)
* src/compose.c
* src/plugins/pgpcore/select-keys.c
* src/plugins/pgpcore/select-keys.h
* src/plugins/pgpcore/sgpgme.c
Add a "Don't encrypt" button to the key
selection dialog. Fixes bug #177 (There should be a
'Don't encrypt button in the Select Keys dialog)

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/compose.c
src/plugins/pgpcore/select-keys.c
src/plugins/pgpcore/select-keys.h
src/plugins/pgpcore/sgpgme.c

index 9365b258fb2a6782eaaa8d9bac93e99da143b0b4..565f2336349e9756002a7192c36d68c71742b28a 100644 (file)
@@ -1,3 +1,13 @@
+2005-09-10 [colin]     1.9.14cvs17
+
+       * src/compose.c
+       * src/plugins/pgpcore/select-keys.c
+       * src/plugins/pgpcore/select-keys.h
+       * src/plugins/pgpcore/sgpgme.c
+               Add a "Don't encrypt" button to the key
+               selection dialog. Fixes bug #177 (There should be a 
+               'Don't encrypt button in the Select Keys dialog)
+
 2005-09-10 [colin]     1.9.14cvs16
 
        * src/compose.c
index 7e84c0e3dbdf98f97c5164f049a71d4be0ebddf6..231ab0141e30ba5e760c27e89127049b42d1d7d5 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.69 -r 1.179.2.70 src/imap.c;  ) > 1.9.14cvs14.patchset
 ( cvs diff -u -r 1.43.2.24 -r 1.43.2.25 src/toolbar.c;  ) > 1.9.14cvs15.patchset
 ( cvs diff -u -r 1.382.2.163 -r 1.382.2.164 src/compose.c;  ) > 1.9.14cvs16.patchset
+( cvs diff -u -r 1.382.2.164 -r 1.382.2.165 src/compose.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/pgpcore/select-keys.c;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/pgpcore/select-keys.h;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpcore/sgpgme.c;  ) > 1.9.14cvs17.patchset
index 8c232ed3d5dac90634ec24a213abc7730681c0f1..764e2c02c6cbaa1bb06b03d45ff23e3be1047ba6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=14
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=16
+EXTRA_VERSION=17
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 344c1f9a659f043fd6ffe609cf4366990f4513d7..ccad422effce7c4ba8d55af97626f0f160de6053 100644 (file)
@@ -4063,14 +4063,21 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        if (compose->privacy_system != NULL) {
                fprintf(fp, "X-Sylpheed-Privacy-System:%s\n", compose->privacy_system);
                fprintf(fp, "X-Sylpheed-Sign:%d\n", compose->use_signing);
-               fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
                if (compose->use_encryption) {
                        gchar *encdata;
 
                        encdata = privacy_get_encrypt_data(compose->privacy_system, compose->to_list);
-                       if (encdata != NULL)
-                               fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n", 
-                                       encdata);
+                       if (encdata != NULL) {
+                               if (strcmp(encdata, "_DONT_ENCRYPT_")) {
+                                       fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
+                                       fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n", 
+                                               encdata);
+                               } /* else we finally dont want to encrypt */
+                       } else {
+                               fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
+                               /* and if encdata was null, it means there's been a problem in 
+                                * key selection */
+                       }
                        g_free(encdata);
                }
        }
index d1d46153df1edfb220ae90a99b712b9fd0363927..be80dca83241c821f4c6f6e4b904a0596df38609 100644 (file)
@@ -73,7 +73,7 @@ struct select_keys_s {
 
     GtkSortType sort_type;
     enum col_titles sort_column;
-    
+    SelectionResult result;
 };
 
 
@@ -88,6 +88,7 @@ static gboolean key_pressed_cb (GtkWidget *widget,
                                 GdkEventKey *event, gpointer data);
 static void select_btn_cb (GtkWidget *widget, gpointer data);
 static void cancel_btn_cb (GtkWidget *widget, gpointer data);
+static void dont_encrypt_btn_cb (GtkWidget *widget, gpointer data);
 static void other_btn_cb (GtkWidget *widget, gpointer data);
 static void sort_keys (struct select_keys_s *sk, enum col_titles column);
 static void sort_keys_name (GtkWidget *widget, gpointer data);
@@ -124,7 +125,7 @@ update_progress (struct select_keys_s *sk, int running, const char *pattern)
  * Return value: NULL on error or a list of list of recipients.
  **/
 gpgme_key_t *
-gpgmegtk_recipient_selection (GSList *recp_names)
+gpgmegtk_recipient_selection (GSList *recp_names, SelectionResult *result)
 {
     struct select_keys_s sk;
 
@@ -151,6 +152,8 @@ gpgmegtk_recipient_selection (GSList *recp_names)
         sk.kset = g_realloc(sk.kset, sizeof(gpgme_key_t) * (sk.num_keys + 1));
         sk.kset[sk.num_keys] = NULL;
     }
+    if (result)
+           *result = sk.result;
     return sk.kset;
 } 
 
@@ -291,7 +294,7 @@ create_dialog (struct select_keys_s *sk)
     GtkWidget *scrolledwin;
     GtkWidget *clist;
     GtkWidget *label;
-    GtkWidget *select_btn, *cancel_btn, *other_btn;
+    GtkWidget *select_btn, *cancel_btn, *dont_encrypt_btn, *other_btn;
     const char *titles[N_COL_TITLES];
 
     g_assert (!sk->window);
@@ -351,7 +354,12 @@ create_dialog (struct select_keys_s *sk)
     gtkut_stock_button_set_create (&bbox, 
                                    &select_btn, _("Select"),
                                    &cancel_btn, GTK_STOCK_CANCEL,
-                                   &other_btn,  _("Other"));
+                                  &dont_encrypt_btn, _("Don't encrypt"));
+    
+    other_btn = gtk_button_new_from_stock(_("Other"));
+    GTK_WIDGET_SET_FLAGS(other_btn, GTK_CAN_DEFAULT);
+    gtk_box_pack_start(GTK_BOX(bbox), other_btn, TRUE, TRUE, 0);
+    gtk_widget_show(other_btn);
     gtk_box_pack_end (GTK_BOX (hbox), bbox, FALSE, FALSE, 0);
     gtk_widget_grab_default (select_btn);
 
@@ -359,6 +367,8 @@ create_dialog (struct select_keys_s *sk)
                       G_CALLBACK (select_btn_cb), sk);
     g_signal_connect (G_OBJECT(cancel_btn), "clicked",
                       G_CALLBACK (cancel_btn_cb), sk);
+    g_signal_connect (G_OBJECT(dont_encrypt_btn), "clicked",
+                      G_CALLBACK (dont_encrypt_btn_cb), sk);
     g_signal_connect (G_OBJECT (other_btn), "clicked",
                       G_CALLBACK (other_btn_cb), sk);
 
@@ -449,8 +459,9 @@ select_btn_cb (GtkWidget *widget, gpointer data)
         gpgme_key_ref(key);
         sk->kset[sk->num_keys] = key;
         sk->num_keys++;
-            sk->okay = 1;
-            gtk_main_quit ();
+        sk->okay = 1;
+       sk->result = KEY_SELECTION_OK;
+        gtk_main_quit ();
     }
 }
 
@@ -462,11 +473,24 @@ cancel_btn_cb (GtkWidget *widget, gpointer data)
 
     g_return_if_fail (sk);
     sk->okay = 0;
+    sk->result = KEY_SELECTION_CANCEL;
     if (sk->select_ctx)
         gpgme_cancel (sk->select_ctx);
     gtk_main_quit ();
 }
 
+static void 
+dont_encrypt_btn_cb (GtkWidget *widget, gpointer data)
+{
+    struct select_keys_s *sk = data;
+
+    g_return_if_fail (sk);
+    sk->okay = 0;
+    sk->result = KEY_SELECTION_DONT;
+    if (sk->select_ctx)
+        gpgme_cancel (sk->select_ctx);
+    gtk_main_quit ();
+}
 
 static void
 other_btn_cb (GtkWidget *widget, gpointer data)
index 4ca96e7535577242aa830e52b9bd359f3e0a4f0d..307b4633e485772c7d6b19d74b72a55e1c10cf3f 100644 (file)
 #include <glib.h>
 #include <gpgme.h>
 
-
-gpgme_key_t *gpgmegtk_recipient_selection (GSList *recp_names);
+typedef enum {
+       KEY_SELECTION_OK,
+       KEY_SELECTION_CANCEL,
+       KEY_SELECTION_DONT,
+} SelectionResult;
+       
+gpgme_key_t *gpgmegtk_recipient_selection (GSList *recp_names, SelectionResult *result);
 
 
 #endif /* GPGMEGTK_SELECT_KEYS_H */
index fbac4f4efacfd9df672c3d8596a3945974684180..6cfe3ced16b1f1ff6b73eb1f04880359145fdbc3 100644 (file)
@@ -295,13 +295,17 @@ gpgme_data_t sgpgme_decrypt_verify(gpgme_data_t cipher, gpgme_verify_result_t *s
 
 gchar *sgpgme_get_encrypt_data(GSList *recp_names)
 {
-       gpgme_key_t *keys = gpgmegtk_recipient_selection(recp_names);
+       SelectionResult result = KEY_SELECTION_CANCEL;
+       gpgme_key_t *keys = gpgmegtk_recipient_selection(recp_names, &result);
        gchar *ret = NULL;
        int i = 0;
 
-       if (!keys)
-               return NULL;
-
+       if (!keys) {
+               if (result == KEY_SELECTION_DONT)
+                       return g_strdup("_DONT_ENCRYPT_");
+               else
+                       return NULL;
+       }
        while (keys[i]) {
                gpgme_subkey_t skey = keys[i]->subkeys;
                gchar *fpr = skey->fpr;