[Gpa-commits] r1020 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 17 12:45:29 CET 2009


Author: werner
Date: 2009-11-17 12:45:28 +0100 (Tue, 17 Nov 2009)
New Revision: 1020

Modified:
   trunk/src/ChangeLog
   trunk/src/gpastreamencryptop.c
   trunk/src/selectkeydlg.c
   trunk/src/selectkeydlg.h
   trunk/src/server.c
Log:
Some fizes


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-11-10 15:16:04 UTC (rev 1019)
+++ trunk/src/ChangeLog	2009-11-17 11:45:28 UTC (rev 1020)
@@ -1,3 +1,12 @@
+2009-11-13    <wk at g10code.com>
+
+	* gpastreamencryptop.c (struct _GpaStreamEncryptOperation): Add
+	field KEY_DIALOG.
+	(gpa_stream_encrypt_operation_constructor): Use a simple key
+	selection dialog if no recipients are given.
+	(response_cb): Get the keys from the new dialog.
+	* selectkeydlg.c (select_key_dlg_get_keys): New.
+
 2009-11-10  Werner Koch  <wk at g10code.com>
 
 	* server.c (register_commands): Add a couple of help strings.

Modified: trunk/src/gpastreamencryptop.c
===================================================================
--- trunk/src/gpastreamencryptop.c	2009-11-10 15:16:04 UTC (rev 1019)
+++ trunk/src/gpastreamencryptop.c	2009-11-17 11:45:28 UTC (rev 1020)
@@ -25,13 +25,14 @@
 #include "recipientdlg.h"
 #include "gpawidgets.h"
 #include "gpastreamencryptop.h"
+#include "selectkeydlg.h"
 
 
-
 struct _GpaStreamEncryptOperation 
 {
   GpaStreamOperation parent;
   
+  SelectKeyDlg *key_dialog;  
   RecipientDlg *recp_dialog;
   GSList *recipients;
   gpgme_key_t *keys;
@@ -170,6 +171,7 @@
 static void
 gpa_stream_encrypt_operation_init (GpaStreamEncryptOperation *op)
 {
+  op->key_dialog = NULL;
   op->recp_dialog = NULL;
   op->recipients = NULL;
   op->keys = NULL;
@@ -193,8 +195,17 @@
 
   /* Create the recipient key selection dialog if we don't know the
      keys yet. */
-  if (!op->keys)
+  if (!op->keys && (!op->recipients || !g_slist_length (op->recipients)))
     {
+      /* No recipients - use a generic key selection dialog.  */
+      op->key_dialog = select_key_dlg_new (GPA_OPERATION (op)->window);
+      g_signal_connect (G_OBJECT (op->key_dialog), "response",
+                        G_CALLBACK (response_cb), op);
+    }
+  else if (!op->keys)
+    {
+      /* Caller gave us some recipients - use the mail address
+         matching key selectiion dialog.  */
       op->recp_dialog = recipient_dlg_new (GPA_OPERATION (op)->window);
       recipient_dlg_set_recipients (op->recp_dialog,
                                     op->recipients,
@@ -217,6 +228,8 @@
     (GTK_WINDOW (GPA_STREAM_OPERATION (op)->progress_dialog),
 			_("Encrypting message ..."));
 
+  if (op->key_dialog)
+    gtk_widget_show_all (GTK_WIDGET (op->key_dialog));
   if (op->recp_dialog)
     gtk_widget_show_all (GTK_WIDGET (op->recp_dialog));
 
@@ -394,13 +407,17 @@
 	 operation.  */
       g_signal_emit_by_name (GPA_OPERATION (op), "completed",
                                    gpg_error (GPG_ERR_CANCELED));
+      /* FIXME: We might need to destroy the widget in the KEY_DIALOG case.  */
       return;
     }
 
   /* Get the keys.  */
   gpa_gpgme_release_keyarray (op->keys);
   op->keys = NULL;
-  op->keys = recipient_dlg_get_keys (op->recp_dialog, &op->selected_protocol);
+  if (op->key_dialog)
+    op->keys = select_key_dlg_get_keys (op->key_dialog);
+  else if (op->recp_dialog)
+    op->keys = recipient_dlg_get_keys (op->recp_dialog, &op->selected_protocol);
 
   start_encryption (op);
 }
@@ -476,7 +493,7 @@
   GpaStreamEncryptOperation *op;
 
   /* Fixme: SILENT is not yet implemented.  */
-
+  g_debug ("recipients %p  recp_keys %p", recipients, recp_keys);
   op = g_object_new (GPA_STREAM_ENCRYPT_OPERATION_TYPE,
 		     "window", window,
 		     "input_stream", input_stream,

Modified: trunk/src/selectkeydlg.c
===================================================================
--- trunk/src/selectkeydlg.c	2009-11-10 15:16:04 UTC (rev 1019)
+++ trunk/src/selectkeydlg.c	2009-11-17 11:45:28 UTC (rev 1020)
@@ -352,5 +352,22 @@
   return key;
 }
 
+/* Return an array of selected keys. 
 
+   FIXME: For now it returns only one key. */
+gpgme_key_t *
+select_key_dlg_get_keys (SelectKeyDlg *dialog)
+{
+  gpgme_key_t *keyarray;
 
+  g_return_val_if_fail (dialog, NULL);
+  g_return_val_if_fail (dialog->keylist, NULL);
+
+  keyarray = g_new (gpgme_key_t, 1+1); 
+  keyarray[0] = gpa_keylist_get_selected_key (dialog->keylist);
+  keyarray[1] = NULL;
+
+  return keyarray;
+}
+
+

Modified: trunk/src/selectkeydlg.h
===================================================================
--- trunk/src/selectkeydlg.h	2009-11-10 15:16:04 UTC (rev 1019)
+++ trunk/src/selectkeydlg.h	2009-11-17 11:45:28 UTC (rev 1020)
@@ -109,6 +109,7 @@
                                             const char *pattern);
 
 gpgme_key_t select_key_dlg_get_key (SelectKeyDlg *dialog);
+gpgme_key_t *select_key_dlg_get_keys (SelectKeyDlg *dialog);
 
 
 

Modified: trunk/src/server.c
===================================================================
--- trunk/src/server.c	2009-11-10 15:16:04 UTC (rev 1019)
+++ trunk/src/server.c	2009-11-17 11:45:28 UTC (rev 1020)
@@ -645,7 +645,7 @@
 {
   conn_ctrl_t ctrl = assuan_get_pointer (ctx);
 
-  g_debug ("cont_encrypt called with with ERR=%s <%s>",
+  g_debug ("cont_encrypt called with ERR=%s <%s>",
            gpg_strerror (err), gpg_strsource (err));
 
   finish_io_streams (ctx, NULL, NULL, NULL);
@@ -727,7 +727,7 @@
 {
   conn_ctrl_t ctrl = assuan_get_pointer (ctx);
 
-  g_debug ("cont_prep_encrypt called with with ERR=%s <%s>",
+  g_debug ("cont_prep_encrypt called with ERR=%s <%s>",
            gpg_strerror (err), gpg_strsource (err));
 
   if (!err)
@@ -851,7 +851,7 @@
 {
   conn_ctrl_t ctrl = assuan_get_pointer (ctx);
 
-  g_debug ("cont_sign called with with ERR=%s <%s>",
+  g_debug ("cont_sign called with ERR=%s <%s>",
            gpg_strerror (err), gpg_strsource (err));
 
   finish_io_streams (ctx, NULL, NULL, NULL);
@@ -929,7 +929,7 @@
 static void
 cont_decrypt (assuan_context_t ctx, gpg_error_t err)
 {
-  g_debug ("cont_decrypt called with with ERR=%s <%s>",
+  g_debug ("cont_decrypt called with ERR=%s <%s>",
            gpg_strerror (err), gpg_strsource (err));
 
   finish_io_streams (ctx, NULL, NULL, NULL);
@@ -1010,7 +1010,7 @@
 static void
 cont_verify (assuan_context_t ctx, gpg_error_t err)
 {
-  g_debug ("cont_verify called with with ERR=%s <%s>",
+  g_debug ("cont_verify called with ERR=%s <%s>",
            gpg_strerror (err), gpg_strsource (err));
 
   finish_io_streams (ctx, NULL, NULL, NULL);



More information about the Gpa-commits mailing list