[svn] GpgOL - r302 - in trunk: . src

svn author wk cvs at cvs.gnupg.org
Tue Jul 21 13:21:41 CEST 2009


Author: wk
Date: 2009-07-21 13:21:40 +0200 (Tue, 21 Jul 2009)
New Revision: 302

Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/engine-assuan.c
   trunk/src/engine-assuan.h
   trunk/src/engine.c
   trunk/src/engine.h
   trunk/src/mimemaker.c
Log:
Help UI servers to present a unified sign/encrypt dialog.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-06-19 23:03:39 UTC (rev 301)
+++ trunk/src/ChangeLog	2009-07-21 11:21:40 UTC (rev 302)
@@ -1,3 +1,11 @@
+2009-07-21  Werner Koch  <wk at g10code.com>
+
+	* engine.h (ENGINE_FLAG_SIGN_FOLLOWS): New macro.
+	* engine.c (engine_encrypt_prepare): Add arg flags.  Change callers.
+	* engine-assuan.c (op_assuan_encrypt): Ditto.  send PREP_ENCRYPT
+	if the sign-follows flag is used.
+	* mimemaker.c (mime_sign_encrypt): Pass new flag.
+
 2009-06-18  Werner Koch  <wk at g10code.com>
 
 	* common.h (struct opt): Add ANNOUNCE_NUMBER.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-06-19 23:03:39 UTC (rev 301)
+++ trunk/NEWS	2009-07-21 11:21:40 UTC (rev 302)
@@ -1,7 +1,7 @@
 Noteworthy changes for version 1.0.0 (2009-06-18)
 =================================================
 
- * Show a notice about portential problems.
+ * Show a notice about potential problems.
 
  * After about 2 years of development, the 1.0 version is now due.
 

Modified: trunk/src/engine-assuan.c
===================================================================
--- trunk/src/engine-assuan.c	2009-06-19 23:03:39 UTC (rev 301)
+++ trunk/src/engine-assuan.c	2009-07-21 11:21:40 UTC (rev 302)
@@ -1570,6 +1570,7 @@
 op_assuan_encrypt (protocol_t protocol, 
                    gpgme_data_t indata, gpgme_data_t outdata,
                    engine_filter_t filter, void *hwnd,
+                   unsigned int flags,
                    const char *sender, char **recipients,
                    protocol_t *r_used_protocol,
                    struct engine_assuan_encstate_s **r_encstate)
@@ -1634,11 +1635,16 @@
     }
 
   /* If the protocol has not been given, let the UI server tell us the
-     protocol to use. */
+     protocol to use.  If we know that we will also sign the message,
+     send the prep_encrypt anyway to tell the server about a
+     forthcoming sign command.  */
   if (detect_protocol)
     {
       protocol = PROTOCOL_UNKNOWN;
-      err = assuan_transact (ctx, "PREP_ENCRYPT", NULL, NULL, NULL, NULL,
+      err = assuan_transact (ctx,
+                             (flags & ENGINE_FLAG_SIGN_FOLLOWS)
+                             ? "PREP_ENCRYPT --expect-sign": "PREP_ENCRYPT",
+                             NULL, NULL, NULL, NULL,
                              prep_foo_status_cb, &protocol);
       if (err)
         {
@@ -1652,7 +1658,25 @@
           goto leave;
         }
     }
+  else if ((flags & ENGINE_FLAG_SIGN_FOLLOWS))
+    {
+      if ( !protocol_name )
+        {
+          err = gpg_error (GPG_ERR_INV_VALUE);
+          goto leave;
+        }
 
+      snprintf (line, sizeof line, "PREP_ENCRYPT --protocol=%s --expect-sign",
+                protocol_name);
+      err = assuan_transact (ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
+      if (err)
+        {
+          if (gpg_err_code (err) == GPG_ERR_ASS_UNKNOWN_CMD)
+            err = gpg_error (GPG_ERR_INV_VALUE);
+          goto leave;
+        }
+    }
+
   *r_used_protocol = protocol;
 
   /* Note: We don't use real descriptor passing but a hack: We

Modified: trunk/src/engine-assuan.h
===================================================================
--- trunk/src/engine-assuan.h	2009-06-19 23:03:39 UTC (rev 301)
+++ trunk/src/engine-assuan.h	2009-07-21 11:21:40 UTC (rev 302)
@@ -40,6 +40,7 @@
 int op_assuan_encrypt (protocol_t protocol, 
                        gpgme_data_t indata, gpgme_data_t outdata,
                        engine_filter_t notify_data, void *hwnd,
+                       unsigned int flags,
                        const char *sender, char **recipients,
                        protocol_t *r_used_protocol,
                        struct engine_assuan_encstate_s **r_encstate);

Modified: trunk/src/engine.c
===================================================================
--- trunk/src/engine.c	2009-06-19 23:03:39 UTC (rev 301)
+++ trunk/src/engine.c	2009-07-21 11:21:40 UTC (rev 302)
@@ -837,12 +837,18 @@
    latter command has just one argument CANCEL which can be set to
    true to cancel the prepared command. 
 
+   FLAGS modifies the operation.  Valid flags are:
+
+     ENGINE_FLAG_SIGN_FOLLOWS 
+       Expect that we are part of a sign+encrypt operaion.  This
+       allows the UI-server to presetn a better dialog.
+
    SENDER is the sender's mailbox or NULL; this information may be
    used by the UI-server for role selection.
  */
 int
 engine_encrypt_prepare (engine_filter_t filter, HWND hwnd,
-                        protocol_t req_protocol, 
+                        protocol_t req_protocol, unsigned int flags,
                         const char *sender, char **recipients,
                         protocol_t *r_protocol)
 {
@@ -853,7 +859,7 @@
   if (filter->use_assuan)
     {
       err = op_assuan_encrypt (req_protocol, filter->indata, filter->outdata,
-                               filter, hwnd, sender, recipients,
+                               filter, hwnd, flags, sender, recipients,
                                &used_protocol, &filter->encstate);
       if (!err)
         *r_protocol = used_protocol;

Modified: trunk/src/engine.h
===================================================================
--- trunk/src/engine.h	2009-06-19 23:03:39 UTC (rev 301)
+++ trunk/src/engine.h	2009-07-21 11:21:40 UTC (rev 302)
@@ -44,6 +44,8 @@
 struct engine_filter_s;
 typedef struct engine_filter_s *engine_filter_t;
 
+/* Flag values used by the engine functions.  */ 
+#define ENGINE_FLAG_SIGN_FOLLOWS 1  /* Expect a sign+encrypt operation.  */
 
 
 
@@ -72,7 +74,7 @@
 void engine_cancel (engine_filter_t filter);
 
 int engine_encrypt_prepare (engine_filter_t filter, HWND hwnd,
-                            protocol_t req_protocol, 
+                            protocol_t req_protocol, unsigned int flags,
                             const char *sender, char **recipients,
                             protocol_t *r_protocol);
 int engine_encrypt_start (engine_filter_t filter, int cancel);

Modified: trunk/src/mimemaker.c
===================================================================
--- trunk/src/mimemaker.c	2009-06-19 23:03:39 UTC (rev 301)
+++ trunk/src/mimemaker.c	2009-07-21 11:21:40 UTC (rev 302)
@@ -1648,7 +1648,7 @@
   }
 
   sender = mapi_get_sender (message);
-  if (engine_encrypt_prepare (filter, hwnd, protocol, 
+  if (engine_encrypt_prepare (filter, hwnd, protocol, 0,
                               sender, recipients, &protocol))
     goto failure;
   if (engine_encrypt_start (filter, 0))
@@ -1829,7 +1829,8 @@
 
   sender = mapi_get_sender (message);
   if ((rc=engine_encrypt_prepare (filter, hwnd, 
-                                  protocol, sender, recipients, &protocol)))
+                                  protocol, ENGINE_FLAG_SIGN_FOLLOWS,
+                                  sender, recipients, &protocol)))
     goto failure;
 
   protocol = check_protocol (protocol);




More information about the Gnupg-commits mailing list