[Gpa-commits] r898 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jun 5 16:43:04 CEST 2008


Author: werner
Date: 2008-06-05 16:43:02 +0200 (Thu, 05 Jun 2008)
New Revision: 898

Modified:
   trunk/src/ChangeLog
   trunk/src/gpaoperation.c
   trunk/src/gpaoperation.h
   trunk/src/gpastreamdecryptop.c
   trunk/src/gpastreamdecryptop.h
   trunk/src/gpastreamverifyop.c
   trunk/src/gpastreamverifyop.h
   trunk/src/server.c
   trunk/src/verifydlg.c
   trunk/src/verifydlg.h
Log:
Support the Session command.
Display a title in the verify dialog.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/ChangeLog	2008-06-05 14:43:02 UTC (rev 898)
@@ -1,3 +1,27 @@
+2008-06-05  Werner Koch  <wk at g10code.com>
+
+	* gpastreamverifyop.c (done_cb): Take care not to write a SIGSTATUS
+	line ala "invalid signature foo: Success".
+	
+	* gpastreamdecryptop.c (gpa_stream_decrypt_operation_new): Ditto.
+	* server.c (cmd_decrypt, cmd_verify): Pass title arg.
+	* verifydlg.c (gpa_file_verify_dialog_set_title): New.
+	* gpastreamverifyop.c (gpa_stream_verify_operation_new): Add arg
+	TITLE.
+	(gpa_stream_verify_operation_ctor): Display title.
+	* gpaoperation.c (PROP_CLIENT_TITLE): New.
+	(gpa_operation_get_property, gpa_operation_set_property) 
+	(gpa_operation_class_init): Register this property.
+	* gpaoperation.h (_GpaOperation): Add field CLIENT_TITLE.
+
+	* server.c (struct conn_ctrl_s): Add fields session_number and
+	session_title.
+	(cmd_session): Implement.
+	(reset_notify): Release the new fields.
+
+	* server.c (cmd_start_confdialog): New.
+	(register_commands): Register new command.
+
 2008-05-27  Marcus Brinkmann  <marcus at ulysses.g10code.com>
 
 	* gpastreamsignop.c (gpa_stream_sign_operation_ctor): Force armor

Modified: trunk/src/gpaoperation.c
===================================================================
--- trunk/src/gpaoperation.c	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/gpaoperation.c	2008-06-05 14:43:02 UTC (rev 898)
@@ -45,6 +45,7 @@
 {
   PROP_0,
   PROP_WINDOW,
+  PROP_CLIENT_TITLE
 };
 
 static GObjectClass *parent_class = NULL;
@@ -63,6 +64,9 @@
     case PROP_WINDOW:
       g_value_set_object (value, op->window);
       break;
+    case PROP_CLIENT_TITLE:
+      g_value_set_string (value, op->client_title);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -70,18 +74,22 @@
 }
 
 static void
-gpa_operation_set_property (GObject     *object,
-			    guint        prop_id,
-			    const GValue      *value,
-			    GParamSpec  *pspec)
+gpa_operation_set_property (GObject      *object,
+			    guint         prop_id,
+			    const GValue *value,
+			    GParamSpec   *pspec)
 {
   GpaOperation *op = GPA_OPERATION (object);
-
+  
   switch (prop_id)
     {
     case PROP_WINDOW:
       op->window = (GtkWidget*) g_value_get_object (value);
       break;
+    case PROP_CLIENT_TITLE:
+      g_free (op->client_title);
+      op->client_title = g_value_dup_string (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -92,8 +100,10 @@
 gpa_operation_finalize (GObject *object)
 {
   GpaOperation *op = GPA_OPERATION (object);
-  
+
   g_object_unref (op->context);
+  g_free (op->client_title);
+  op->client_title = NULL;
   
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -103,6 +113,7 @@
 {
   op->window = NULL;
   op->context = NULL;
+  op->client_title = NULL;
 }
 
 static GObject*
@@ -166,6 +177,13 @@
                           "Parent window",
                           GTK_TYPE_WIDGET,
                           G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property 
+    (object_class, PROP_CLIENT_TITLE,
+     g_param_spec_string 
+     ("client-title", "Client Title",
+      "The client suggested title for the operation or NULL.", 
+      NULL,
+      G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
 }
 
 

Modified: trunk/src/gpaoperation.h
===================================================================
--- trunk/src/gpaoperation.h	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/gpaoperation.h	2008-06-05 14:43:02 UTC (rev 898)
@@ -43,6 +43,7 @@
 
   GtkWidget *window;
   GpaContext *context;
+  char *client_title;
 };
 
 struct _GpaOperationClass {

Modified: trunk/src/gpastreamdecryptop.c
===================================================================
--- trunk/src/gpastreamdecryptop.c	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/gpastreamdecryptop.c	2008-06-05 14:43:02 UTC (rev 898)
@@ -441,9 +441,11 @@
 /* FIXME: Doc.  */
 GpaStreamDecryptOperation *
 gpa_stream_decrypt_operation_new (GtkWidget *window,
-				 gpgme_data_t input_stream,
-				 gpgme_data_t output_stream,
-				 gboolean no_verify, gpgme_protocol_t protocol)
+                                  gpgme_data_t input_stream,
+                                  gpgme_data_t output_stream,
+                                  gboolean no_verify,
+                                  gpgme_protocol_t protocol,
+                                  const char *title)
 {
   GpaStreamDecryptOperation *op;
 
@@ -453,6 +455,7 @@
 		     "output_stream", output_stream,
                      "no-verify", no_verify,
                      "protocol", (int) protocol,
+                     "title", title,
 		     NULL);
 
   return op;

Modified: trunk/src/gpastreamdecryptop.h
===================================================================
--- trunk/src/gpastreamdecryptop.h	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/gpastreamdecryptop.h	2008-06-05 14:43:02 UTC (rev 898)
@@ -57,9 +57,10 @@
 /* Creates a new decrypt operation.  */
 GpaStreamDecryptOperation *
 gpa_stream_decrypt_operation_new (GtkWidget *window,
-				 gpgme_data_t input_stream,
-				 gpgme_data_t output_stream,
-				 gboolean no_verify,
-				 gpgme_protocol_t protocol);
+                                  gpgme_data_t input_stream,
+                                  gpgme_data_t output_stream,
+                                  gboolean no_verify,
+                                  gpgme_protocol_t protocol,
+                                  const char *title);
 
 #endif	/* GPA_STREAM_DECRYPT_OP_H */

Modified: trunk/src/gpastreamverifyop.c
===================================================================
--- trunk/src/gpastreamverifyop.c	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/gpastreamverifyop.c	2008-06-05 14:43:02 UTC (rev 898)
@@ -159,9 +159,15 @@
     gtk_widget_hide (GPA_STREAM_OPERATION (op)->progress_dialog);
   else
     {
+      char *strval;
+
       op->dialog = gpa_file_verify_dialog_new (GPA_OPERATION (op)->window);
       g_signal_connect (G_OBJECT (op->dialog), "response",
 			G_CALLBACK (response_cb), op);
+      g_object_get (G_OBJECT (op), "client-title", &strval, NULL);
+      gpa_file_verify_dialog_set_title (GPA_FILE_VERIFY_DIALOG (op->dialog),
+                                        strval);
+      g_free (strval);
     }
 
   return object;
@@ -330,7 +336,7 @@
 	  else
 	    sigsum = "red";
 
-	  sigstatus = gpg_strerror (sig->status);
+	  sigstatus = sig->status? gpg_strerror (sig->status) : "";
 
 	  if (sig->fpr)
 	    {
@@ -342,39 +348,64 @@
 	  
 	  if (sig->summary & GPGME_SIGSUM_RED)
 	    {
-	      if (keydesc)
+	      if (keydesc && *sigstatus)
 		sigdesc = g_strdup_printf (_("Bad signature by %s: %s"),
 					   keydesc, sigstatus);
+	      else if (keydesc)
+		sigdesc = g_strdup_printf (_("Bad signature by %s"),
+					   keydesc);
+	      else if (sig->fpr && *sigstatus)
+		sigdesc = g_strdup_printf (_("Bad signature by unknown key "
+					     "%s: %s"), sig->fpr, sigstatus);
 	      else if (sig->fpr)
 		sigdesc = g_strdup_printf (_("Bad signature by unknown key "
-					     "%s: %s"), sig->fpr, sigstatus);
-	      else
+					     "%s"), sig->fpr);
+	      else if (*sigstatus)
 		sigdesc = g_strdup_printf (_("Bad signature by unknown key: "
 					     "%s"), sigstatus);
+	      else
+		sigdesc = g_strdup_printf (_("Bad signature by unknown key"));
 	    }
 	  else if (sig->summary & GPGME_SIGSUM_VALID)
 	    {
-	      if (keydesc)
+	      if (keydesc && *sigstatus)
 		sigdesc = g_strdup_printf (_("Good signature by %s: %s"),
 					   keydesc, sigstatus);
+	      else if (keydesc)
+		sigdesc = g_strdup_printf (_("Good signature by %s"),
+					   keydesc);
+	      else if (sig->fpr && *sigstatus)
+		sigdesc = g_strdup_printf (_("Good signature by unknown key "
+					     "%s: %s"), sig->fpr, sigstatus);
 	      else if (sig->fpr)
 		sigdesc = g_strdup_printf (_("Good signature by unknown key "
-					     "%s: %s"), sig->fpr, sigstatus);
-	      else
+					     "%s"), sig->fpr);
+	      else if (*sigstatus)
 		sigdesc = g_strdup_printf (_("Good signature by unknown key: "
 					     "%s"), sigstatus);
+	      else
+		sigdesc = g_strdup_printf (_("Good signature by unknown key"));
 	    }
 	  else
 	    {
-	      if (keydesc)
+	      if (keydesc && *sigstatus)
 		sigdesc = g_strdup_printf (_("Invalid signature by %s: %s"),
 					   keydesc, sigstatus);
+	      else if (keydesc)
+		sigdesc = g_strdup_printf (_("Invalid signature by %s"),
+					   keydesc);
+	      else if (sig->fpr && *sigstatus)
+		sigdesc = g_strdup_printf (_("Invalid signature by unknown key "
+					     "%s: %s"), sig->fpr, sigstatus);
 	      else if (sig->fpr)
 		sigdesc = g_strdup_printf (_("Invalid signature by unknown key "
-					     "%s: %s"), sig->fpr, sigstatus);
+					     "%s"), sig->fpr);
+	      else if (*sigstatus)
+		sigdesc = g_strdup_printf (_("Invalid signature by unknown "
+					     "key: %s"), sigstatus);
 	      else
 		sigdesc = g_strdup_printf (_("Invalid signature by unknown "
-					     "key: %s"), sigstatus);
+					     "key"));
 	    }
 	  
 	  sigdesc_esc = my_percent_escape (sigdesc);
@@ -402,7 +433,6 @@
       gpgme_verify_result_t result;
       
       result = gpgme_op_verify_result (GPA_OPERATION (op)->context->ctx);
-      /* Add the file to the result dialog.  */
       gpa_file_verify_dialog_add_file (GPA_FILE_VERIFY_DIALOG (op->dialog),
 				       _("Document"), NULL, NULL,
 				       result->signatures);
@@ -446,7 +476,8 @@
 				 gpgme_data_t input_stream,
 				 gpgme_data_t message_stream,
 				 gpgme_data_t output_stream,
-				 gboolean silent, gpgme_protocol_t protocol)
+				 gboolean silent, gpgme_protocol_t protocol,
+                                 const char *title)
 {
   GpaStreamVerifyOperation *op;
 
@@ -457,6 +488,7 @@
 		     "output_stream", output_stream,
                      "silent", silent,
                      "protocol", (int) protocol,
+                     "client-title", title,
 		     NULL);
 
   return op;

Modified: trunk/src/gpastreamverifyop.h
===================================================================
--- trunk/src/gpastreamverifyop.h	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/gpastreamverifyop.h	2008-06-05 14:43:02 UTC (rev 898)
@@ -61,6 +61,7 @@
 				 gpgme_data_t message_stream,
 				 gpgme_data_t output_stream,
 				 gboolean silent,
-				 gpgme_protocol_t protocol);
+				 gpgme_protocol_t protocol,
+                                 const char *title);
 
 #endif	/* GPA_STREAM_VERIFY_OP_H */

Modified: trunk/src/server.c
===================================================================
--- trunk/src/server.c	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/server.c	2008-06-05 14:43:02 UTC (rev 898)
@@ -70,7 +70,7 @@
   int input_fd;
   int output_fd;
 
-  /* Fiel descriptor set with the MESSAGE command.  */
+  /* File descriptor set with the MESSAGE command.  */
   int message_fd;
 
   /* Channels used with the gpgme callbacks.  */
@@ -91,6 +91,10 @@
      the sender ist just informational. */
   gchar *sender;
   int sender_just_info;
+
+  /* Session information:  A session number and a malloced title or NULL.  */
+  unsigned int session_number;
+  char *session_title;
 };
 
 
@@ -533,13 +537,18 @@
 static int
 cmd_session (assuan_context_t ctx, char *line)
 {
-  gpg_error_t err = 0;
+  conn_ctrl_t ctrl = assuan_get_pointer (ctx);
+  char *endp;
 
   line = skip_options (line);
 
-  /* FIXME implement the command.  */
+  ctrl->session_number = strtoul (line, &endp, 10);
+  for (line = endp; spacep (line); line++)
+    ;
+  xfree (ctrl->session_title);
+  ctrl->session_title = *line? xstrdup (line) : NULL;
 
-  return assuan_process_done (ctx, err);
+  return assuan_process_done (ctx, 0);
 }
 
 
@@ -873,8 +882,6 @@
 static void
 cont_decrypt (assuan_context_t ctx, gpg_error_t err)
 {
-  conn_ctrl_t ctrl = assuan_get_pointer (ctx);
-
   g_debug ("cont_decrypt called with with ERR=%s <%s>",
            gpg_strerror (err), gpg_strsource (err));
 
@@ -925,7 +932,8 @@
   ctrl->cont_cmd = cont_decrypt;
 
   op = gpa_stream_decrypt_operation_new (NULL, input_data, output_data,
-					 no_verify, protocol);
+					 no_verify, protocol,
+                                         ctrl->session_title);
 
   input_data = output_data = NULL;
   g_signal_connect_swapped (G_OBJECT (op), "completed",
@@ -954,8 +962,6 @@
 static void
 cont_verify (assuan_context_t ctx, gpg_error_t err)
 {
-  conn_ctrl_t ctrl = assuan_get_pointer (ctx);
-
   g_debug ("cont_verify called with with ERR=%s <%s>",
            gpg_strerror (err), gpg_strsource (err));
 
@@ -1061,7 +1067,8 @@
   ctrl->cont_cmd = cont_verify;
 
   op = gpa_stream_verify_operation_new (NULL, input_data, message_data,
-					output_data, silent, protocol);
+					output_data, silent, protocol,
+                                        ctrl->session_title);
 
   input_data = output_data = message_data = NULL;
   g_signal_connect_swapped (G_OBJECT (op), "completed",
@@ -1100,7 +1107,23 @@
 }
 
 
+
+/* START_CONFDIALOG
 
+   Pop up the configure dialog.  The client expects that the key
+   manager is brought into the foregound and that this command
+   immediatley returns.
+*/
+static int
+cmd_start_confdialog (assuan_context_t ctx, char *line)
+{
+  gpa_open_settings_dialog (NULL, NULL);
+
+  return assuan_process_done (ctx, 0);
+}
+
+
+
 
 /* GETINFO <what>
 
@@ -1154,6 +1177,9 @@
       g_object_unref (ctrl->gpa_op);
       ctrl->gpa_op = NULL;
     }
+  ctrl->session_number = 0;
+  xfree (ctrl->session_title);
+  ctrl->session_title = NULL;
 }
 
 
@@ -1179,6 +1205,7 @@
     { "DECRYPT",   cmd_decrypt },
     { "VERIFY",    cmd_verify },
     { "START_KEYMANAGER", cmd_start_keymanager },
+    { "START_CONFDIALOG", cmd_start_confdialog },
     { "GETINFO",   cmd_getinfo },
     { NULL }
   };

Modified: trunk/src/verifydlg.c
===================================================================
--- trunk/src/verifydlg.c	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/verifydlg.c	2008-06-05 14:43:02 UTC (rev 898)
@@ -390,6 +390,15 @@
   return GTK_WIDGET(dialog);
 }
 
+void
+gpa_file_verify_dialog_set_title (GpaFileVerifyDialog *dialog, 
+                                  const char *title)
+{
+  if (dialog && title && *title)
+    gtk_window_set_title (GTK_WINDOW (dialog), title);
+}
+
+
 void gpa_file_verify_dialog_add_file (GpaFileVerifyDialog *dialog,
 				      const gchar *filename,
 				      const gchar *signed_file,

Modified: trunk/src/verifydlg.h
===================================================================
--- trunk/src/verifydlg.h	2008-05-27 14:42:24 UTC (rev 897)
+++ trunk/src/verifydlg.h	2008-06-05 14:43:02 UTC (rev 898)
@@ -55,6 +55,9 @@
 
 GtkWidget *gpa_file_verify_dialog_new (GtkWidget *parent);
 
+void gpa_file_verify_dialog_set_title (GpaFileVerifyDialog *dialog, 
+                                       const char *title);
+
 void gpa_file_verify_dialog_add_file (GpaFileVerifyDialog *dialog,
 				      const gchar *filename,
 				      const gchar *signed_file,



More information about the Gpa-commits mailing list