[svn] GPGol - r148 - in trunk: . m4 po src

svn author wk cvs at cvs.gnupg.org
Mon Apr 24 17:13:30 CEST 2006


Author: wk
Date: 2006-04-24 17:13:29 +0200 (Mon, 24 Apr 2006)
New Revision: 148

Modified:
   trunk/NEWS
   trunk/configure.ac
   trunk/m4/gpgme.m4
   trunk/po/de.po
   trunk/src/ChangeLog
   trunk/src/display.cpp
   trunk/src/engine-gpgme.c
   trunk/src/engine.h
   trunk/src/gpgmsg.cpp
   trunk/src/gpgmsg.hh
   trunk/src/intern.h
   trunk/src/main.c
   trunk/src/olflange.cpp
   trunk/src/watcher.cpp
Log:
tried to fix other stuff without success.


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/NEWS	2006-04-24 15:13:29 UTC (rev 148)
@@ -1,9 +1,11 @@
 Noteworthy changes for version 0.9.9 (2006-04-24)
 =================================================
 
-* Mainly cosmetic changes.
+* Some cosmetic changes.
 
+* Encryption to the default key works again.
 
+
 Noteworthy changes for version 0.9.8 (2006-03-28)
 =================================================
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/configure.ac	2006-04-24 15:13:29 UTC (rev 148)
@@ -18,15 +18,16 @@
 # "svn up" and "autogen.sh" right before creating a distribution.
 m4_define([my_version], [0.9.9])
 m4_define([my_issvn], [no])
-NEED_GPGME_API=1
-NEED_GPGME_VERSION=1.1.0
 
-
 m4_define([svn_revision], m4_esyscmd([echo -n $((svn info 2>/dev/null \
             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q}')]))
 AC_INIT([gpgol], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]),
         [bug-gpgol at g10code.com])
 
+NEED_GPGME_API=1
+NEED_GPGME_VERSION=1.1.0
+
+
 SVN_REVISION=svn_revision
 PACKAGE=$PACKAGE_NAME
 PACKAGE_GT=${PACKAGE_NAME}

Modified: trunk/m4/gpgme.m4
===================================================================
--- trunk/m4/gpgme.m4	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/m4/gpgme.m4	2006-04-24 15:13:29 UTC (rev 148)
@@ -20,7 +20,9 @@
   fi
   AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
 
-  gpgme_version=`$GPGME_CONFIG --version`
+  if test "$GPGME_CONFIG" != "no" ; then
+    gpgme_version=`$GPGME_CONFIG --version`
+  fi
   gpgme_version_major=`echo $gpgme_version | \
                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
   gpgme_version_minor=`echo $gpgme_version | \
@@ -234,3 +236,72 @@
   AC_SUBST(GPGME_PTHREAD_CFLAGS)
   AC_SUBST(GPGME_PTHREAD_LIBS)
 ])
+
+
+dnl AM_PATH_GPGME_GLIB([MINIMUM-VERSION,
+dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgpgme-glib and define GPGME_GLIB_CFLAGS and GPGME_GLIB_LIBS.
+dnl
+AC_DEFUN([AM_PATH_GPGME_GLIB],
+[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
+  tmp=ifelse([$1], ,1:0.4.2,$1)
+  if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+     req_gpgme_api=`echo "$tmp"     | sed 's/\(.*\):\(.*\)/\1/'`
+     min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+  else
+     req_gpgme_api=0
+     min_gpgme_version="$tmp"
+  fi
+
+  AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
+  ok=no
+  if test "$GPGME_CONFIG" != "no" ; then
+    req_major=`echo $min_gpgme_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+    req_minor=`echo $min_gpgme_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+    req_micro=`echo $min_gpgme_version | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+    if test "$gpgme_version_major" -gt "$req_major"; then
+        ok=yes
+    else 
+        if test "$gpgme_version_major" -eq "$req_major"; then
+            if test "$gpgme_version_minor" -gt "$req_minor"; then
+               ok=yes
+            else
+               if test "$gpgme_version_minor" -eq "$req_minor"; then
+                   if test "$gpgme_version_micro" -ge "$req_micro"; then
+                     ok=yes
+                   fi
+               fi
+            fi
+        fi
+    fi
+  fi
+  if test $ok = yes; then
+     # If we have a recent GPGME, we should also check that the
+     # API is compatible.
+     if test "$req_gpgme_api" -gt 0 ; then
+        tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
+        if test "$tmp" -gt 0 ; then
+           if test "$req_gpgme_api" -ne "$tmp" ; then
+             ok=no
+           fi
+        fi
+     fi
+  fi
+  if test $ok = yes; then
+    GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
+    GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
+    AC_MSG_RESULT(yes)
+    ifelse([$2], , :, [$2])
+  else
+    GPGME_GLIB_CFLAGS=""
+    GPGME_GLIB_LIBS=""
+    AC_MSG_RESULT(no)
+    ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(GPGME_GLIB_CFLAGS)
+  AC_SUBST(GPGME_GLIB_LIBS)
+])
+

Modified: trunk/po/de.po
===================================================================
--- trunk/po/de.po	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/po/de.po	2006-04-24 15:13:29 UTC (rev 148)
@@ -7,8 +7,8 @@
 msgstr ""
 "Project-Id-Version: GPGol 0.9.4\n"
 "Report-Msgid-Bugs-To: bug-gpgol at g10code.com\n"
-"POT-Creation-Date: 2006-03-28 11:38+0200\n"
-"PO-Revision-Date: 2006-04-22 14:37+0200\n"
+"POT-Creation-Date: 2006-04-24 16:36+0200\n"
+"PO-Revision-Date: 2006-04-24 16:41+0200\n"
 "Last-Translator: Werner Koch <wk at gnupg.org>\n"
 "Language-Team: de\n"
 "MIME-Version: 1.0\n"
@@ -139,17 +139,28 @@
 msgid "*** End Notation ***\n"
 msgstr "*** Ende Notation ***\n"
 
-#: src/gpgmsg.cpp:1195
+#: src/gpgmsg.cpp:1194
 msgid "No valid OpenPGP data found."
 msgstr "Keine gültigen OpenPGP Daten gefunden"
 
-#: src/gpgmsg.cpp:1196 src/gpgmsg.cpp:1280 src/gpgmsg.cpp:1294
-#: src/gpgmsg.cpp:1310 src/gpgmsg.cpp:1489
+#: src/gpgmsg.cpp:1195 src/gpgmsg.cpp:1297 src/gpgmsg.cpp:1311
+#: src/gpgmsg.cpp:1327 src/gpgmsg.cpp:1506
 msgid "Decryption"
 msgstr "Entschlüsselung"
 
-#: src/gpgmsg.cpp:1249
+#: src/gpgmsg.cpp:1212
 msgid ""
+"[This is a PGP/MIME message]\r\n"
+"\r\n"
+"[Use the \"Decrypt\" button in the message window to show its content.]"
+msgstr ""
+"[Dies ist eine PGP/MIME Nachricht]\n"
+"\n"
+"[Benutzen Sie den \"Entschlüsselungs\"-Button im großen\n"
+"Nachrichtenfenster um den Inhalt anzuzeigen.]"
+
+#: src/gpgmsg.cpp:1266
+msgid ""
 "Note: This is a PGP/MIME signed message.  The GPGol plugin is not always "
 "able to verify such a message due to missing support in Outlook.\n"
 "\n"
@@ -161,27 +172,27 @@
 "\n"
 "(Dieser Hinweis wird nur einmalig pro Sitzung angezeigt)"
 
-#: src/gpgmsg.cpp:1253
+#: src/gpgmsg.cpp:1270
 msgid "Verification"
 msgstr "Überprüfung"
 
-#: src/gpgmsg.cpp:1271
+#: src/gpgmsg.cpp:1288
 msgid "[This is a PGP/MIME message]"
 msgstr "[PGP/MIME Nachricht]"
 
-#: src/gpgmsg.cpp:1279 src/gpgmsg.cpp:1293 src/gpgmsg.cpp:1309
+#: src/gpgmsg.cpp:1296 src/gpgmsg.cpp:1310 src/gpgmsg.cpp:1326
 msgid "Problem decrypting PGP/MIME message"
 msgstr "Problem bei Entschlüsseln einer PGP/MIME Nachricht"
 
-#: src/gpgmsg.cpp:1444
+#: src/gpgmsg.cpp:1461
 msgid "Verification Failure"
 msgstr "Überprüfungsfehler"
 
-#: src/gpgmsg.cpp:1447
+#: src/gpgmsg.cpp:1464
 msgid "Decryption Failure"
 msgstr "Entschlüsselungsfehler"
 
-#: src/gpgmsg.cpp:1483
+#: src/gpgmsg.cpp:1500
 msgid ""
 "The message text cannot be displayed.\n"
 "You have to save the decrypted message to view it.\n"
@@ -197,7 +208,7 @@
 
 #. TRANSLATORS: Keep the @LIST@ verbatim on a separate line; it
 #. will be expanded to a list of atatchment names.
-#: src/gpgmsg.cpp:1510
+#: src/gpgmsg.cpp:1527
 msgid ""
 "Signed attachments found.\n"
 "\n"
@@ -209,13 +220,13 @@
 "@LIST@\n"
 "Möchten Sie diese Unterschriften überprüfen?"
 
-#: src/gpgmsg.cpp:1518
+#: src/gpgmsg.cpp:1535
 msgid "Attachment Verification"
 msgstr "Überprüfung der Anhänge"
 
 #. TRANSLATORS: Keep the @LIST@ verbatim on a separate line; it
 #. will be expanded to a list of atatchment names.
-#: src/gpgmsg.cpp:1539
+#: src/gpgmsg.cpp:1556
 msgid ""
 "Encrypted attachments found.\n"
 "\n"
@@ -227,35 +238,52 @@
 "@LIST@\n"
 "Möchten Sie diese entschlüsseln und abspeichern?"
 
-#: src/gpgmsg.cpp:1546
+#: src/gpgmsg.cpp:1563
 msgid "Attachment Decryption"
 msgstr "Entschlüsselung eines Anhangs"
 
-#: src/gpgmsg.cpp:1615
+#: src/gpgmsg.cpp:1632
 msgid "Signing Failure"
 msgstr "Unterschrifterstellungsfehler"
 
-#: src/gpgmsg.cpp:1791
+#: src/gpgmsg.cpp:1800
+msgid ""
+"The configured default encryption key is not available or does not "
+"unambigiously specify a key. Please fix this in the option dialog.\n"
+"\n"
+"This message won't be be encrypted to this key!"
+msgstr ""
+"Der voreingestellte zusätzliche Schlüssel zum Verschlüsseln ist nicht\n"
+"vorhanden oder nicht eindeutig.  Bitte beheben Sie dies in den\n"
+"Optionseinstellungen.\n"
+"\n"
+"Die Nachricht wird deswegen nicht für diesen Schlüssel verschlüsselt!"
+
+#: src/gpgmsg.cpp:1804
+msgid "Encryption"
+msgstr "Verschlüsselung"
+
+#: src/gpgmsg.cpp:1847
 msgid "Encryption Failure"
 msgstr "Verschlüsselungsfehler"
 
-#: src/gpgmsg.cpp:1845 src/gpgmsg.cpp:3211
+#: src/gpgmsg.cpp:1901 src/gpgmsg.cpp:3267
 msgid "Attachment Encryption Failure"
 msgstr "Verschlüsselungsfehler eines Anhangs"
 
-#: src/gpgmsg.cpp:2618
+#: src/gpgmsg.cpp:2674
 msgid "Attachment Verification Failure"
 msgstr "Überprüfungsfehler eines Anhangs"
 
-#: src/gpgmsg.cpp:2801 src/gpgmsg.cpp:2850
+#: src/gpgmsg.cpp:2857 src/gpgmsg.cpp:2906
 msgid "Attachment Decryption Failure"
 msgstr "Entschlüsselungsfehler eines Anhangs"
 
-#: src/gpgmsg.cpp:3020
+#: src/gpgmsg.cpp:3076
 msgid "Attachment Signing Failure"
 msgstr "Unterschrifterstellungsfehler eines Anhangs"
 
-#: src/olflange-dlgs.cpp:167
+#: src/olflange-dlgs.cpp:183
 msgid "The default key may not contain any spaces."
 msgstr "Der Standardschlüssel darf keine Leerzeichen enthalten."
 
@@ -276,7 +304,7 @@
 "\n"
 "Bitte updaten Sie auf SP2 bevor Sie versuchen eine Nachricht zu versenden."
 
-#: src/olflange.cpp:939
+#: src/olflange.cpp:946
 msgid ""
 "Sorry, we can only encrypt plain text messages and\n"
 "no RTF messages. Please make sure that only the text\n"
@@ -287,51 +315,51 @@
 "Sie sicher, daß lediglich das Text Format ausgewählt wurde.\n"
 "(In der Menüleiste: \"Format\" => \"Nur Text\")"
 
-#: src/olflange.cpp:1329
+#: src/olflange.cpp:1336
 msgid "&Decrypt and verify message"
 msgstr "Entschlüsseln/Prüfen der Nachricht"
 
-#: src/olflange.cpp:1367
+#: src/olflange.cpp:1374
 msgid "GPG &encrypt message"
 msgstr "Mit GPG &verschlüsseln"
 
-#: src/olflange.cpp:1373
+#: src/olflange.cpp:1380
 msgid "GPG &sign message"
 msgstr "Mit GPG unter&schreiben"
 
-#: src/olflange.cpp:1419
+#: src/olflange.cpp:1426
 msgid "GPG Key &Manager"
 msgstr "GPG Schlüssel&verwaltung"
 
-#: src/olflange.cpp:1551
+#: src/olflange.cpp:1558
 msgid "Could not start Key-Manager"
 msgstr "Dei Schlüsselverwaltung konnte nicht aufgerufen werden"
 
-#: src/olflange.cpp:1597
+#: src/olflange.cpp:1604
 msgid "Decrypt and verify the message."
 msgstr "Entschlüsseln und Prüfen der Nachricht."
 
-#: src/olflange.cpp:1605
+#: src/olflange.cpp:1612
 msgid "Select this option to encrypt the message."
 msgstr "Wählen Sie diese Option zum Verschlüsseln der Nachricht."
 
-#: src/olflange.cpp:1611
+#: src/olflange.cpp:1618
 msgid "Select this option to sign the message."
 msgstr "Wählen Sie diese Option zum Unterschreiben der Nachricht."
 
-#: src/olflange.cpp:1620 src/olflange.cpp:1681 src/olflange.cpp:1763
+#: src/olflange.cpp:1627 src/olflange.cpp:1688 src/olflange.cpp:1770
 msgid "Open GPG Key Manager"
 msgstr "Die GPG Schlüsselverwaltung öffnen"
 
-#: src/olflange.cpp:1650 src/olflange.cpp:1714
+#: src/olflange.cpp:1657 src/olflange.cpp:1721
 msgid "Decrypt message and verify signature"
 msgstr "Nachricht entschlüsseln und Unterschrift prüfen"
 
-#: src/olflange.cpp:1661 src/olflange.cpp:1732
+#: src/olflange.cpp:1668 src/olflange.cpp:1739
 msgid "Encrypt message with GPG"
 msgstr "Nachricht mit GPG verschlüsseln"
 
-#: src/olflange.cpp:1670 src/olflange.cpp:1747
+#: src/olflange.cpp:1677 src/olflange.cpp:1754
 msgid "Sign message with GPG"
 msgstr "Nachricht mit GPG unterschreiben"
 
@@ -339,15 +367,15 @@
 msgid "No key hint given."
 msgstr "Kein Hinweis auf den Schlüssel"
 
-#: src/passphrase-dialog.c:325 src/passphrase-dialog.c:469
+#: src/passphrase-dialog.c:329 src/passphrase-dialog.c:473
 msgid "Invalid passphrase; please try again..."
 msgstr "Ungültige Passphrase; bitte nochmal versuchen..."
 
-#: src/passphrase-dialog.c:342
+#: src/passphrase-dialog.c:346
 msgid "Select Signing Key"
 msgstr "Signaturschlüssel auswählen"
 
-#: src/passphrase-dialog.c:409 src/passphrase-dialog.c:528
+#: src/passphrase-dialog.c:413 src/passphrase-dialog.c:532
 msgid ""
 "If you cancel this dialog, the message will be sent in cleartext!\n"
 "\n"
@@ -358,7 +386,7 @@
 "\n"
 "Möchten Sie wirklich abbrechen?"
 
-#: src/passphrase-dialog.c:415
+#: src/passphrase-dialog.c:419
 msgid ""
 "If you cancel this dialog, the message will be sent without signing.\n"
 "\n"
@@ -369,11 +397,11 @@
 "\n"
 "Möchten Sie wirklich abbrechen?"
 
-#: src/passphrase-dialog.c:424 src/passphrase-dialog.c:543
+#: src/passphrase-dialog.c:428 src/passphrase-dialog.c:547
 msgid "Secret Key Dialog"
 msgstr "Auswahl des geheimen Schlüssels"
 
-#: src/passphrase-dialog.c:534
+#: src/passphrase-dialog.c:538
 msgid ""
 "If you cancel this dialog, the message will be sent without signing.\n"
 "Do you really want to cancel?"

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/ChangeLog	2006-04-24 15:13:29 UTC (rev 148)
@@ -1,3 +1,14 @@
+2006-04-24  Werner Koch  <wk at g10code.com>
+
+	* gpgmsg.cpp (decrypt): New arg INFO_ONLY.
+	* olflange.cpp (OnReadComplete): Add code to call decrypt but with
+	INFO_ONLY if preview decryption has not been requested.
+	* main.c (read_options): New compatibility option no_preview_info.
+
+	* gpgmsg.cpp (getRecipients): Don't add the default key here.
+	(encrypt_and_sign): But do it here.
+	* engine-gpgme.c (op_get_one_key): New.
+
 2006-04-22  Timo Schulz  <ts at g10code.com>
 
 	* common.c (utf8_to_wincp): Corrected utf8 decoding.

Modified: trunk/src/display.cpp
===================================================================
--- trunk/src/display.cpp	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/display.cpp	2006-04-24 15:13:29 UTC (rev 148)
@@ -79,7 +79,36 @@
   
 }
 
+// static HWND
+// show_window_hierarchy (HWND parent, int level)
+// {
+//   HWND child;
 
+//   child = GetWindow (parent, GW_CHILD);
+//   while (child)
+//     {
+//       char buf[1024+1];
+//       char name[200];
+//       int nname;
+//       char *pname;
+      
+//       memset (buf, 0, sizeof (buf));
+//       GetWindowText (child, buf, sizeof (buf)-1);
+//       nname = GetClassName (child, name, sizeof (name)-1);
+//       if (nname)
+//         pname = name;
+//       else
+//         pname = NULL;
+//       log_debug ("### %*shwnd=%p (%s) `%s'", level*2, "", child,
+//                  pname? pname:"", buf);
+//       show_window_hierarchy (child, level+1);
+//       child = GetNextWindow (child, GW_HWNDNEXT);	
+//     }
+
+//   return NULL;
+// }
+
+
 /* We need this to find the mailer window because we directly change
    the text of the window instead of the MAPI object itself.  To do
    this we walk all windows to find a PGP signature.  */
@@ -137,6 +166,7 @@
 {
   HWND window;
 
+  /*show_window_hierarchy (hwnd, 0);*/
   window = find_message_window (hwnd);
   if (window && !is_html)
     {

Modified: trunk/src/engine-gpgme.c
===================================================================
--- trunk/src/engine-gpgme.c	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/engine-gpgme.c	2006-04-24 15:13:29 UTC (rev 148)
@@ -1286,7 +1286,7 @@
 /* Try to find a key for each item in array NAMES. Items not found are
    stored as malloced strings in the newly allocated array UNKNOWN.
    Found keys are stored in the newly allocated array KEYS.  Both
-   arrays are terminated by a NULL entry.  Caller needs to releade
+   arrays are terminated by a NULL entry.  Caller needs to release
    KEYS and UNKNOWN.
 
    Returns: 0 on success. However success may also be that one or all
@@ -1343,7 +1343,37 @@
 }
 
 
+/* Return a GPGME key object matching PATTERN.  If no key matches or
+   the match is ambiguous, return NULL. */
+gpgme_key_t 
+op_get_one_key (char *pattern)
+{
+  gpgme_error_t err;
+  gpgme_ctx_t ctx;
+  gpgme_key_t k, k2;
 
+  err = gpgme_new (&ctx);
+  if (err)
+    return NULL; /* Error. */
+  err = gpgme_op_keylist_start (ctx, pattern, 0);
+  if (!err)
+    {
+      err = gpgme_op_keylist_next (ctx, &k);
+      if (!err && !gpgme_op_keylist_next (ctx, &k2))
+        {
+          /* More than one matching key available.  Return an error
+             instead. */
+          gpgme_key_release (k);
+          gpgme_key_release (k2);
+          k = k2 = NULL;
+        }
+    }
+  gpgme_op_keylist_end (ctx);
+  gpgme_release (ctx);
+  return k;
+}
+
+
 /* Copy the data from the GPGME object DAT to a newly created file
    with name OUTFILE.  Returns 0 on success. */
 static gpgme_error_t

Modified: trunk/src/engine.h
===================================================================
--- trunk/src/engine.h	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/engine.h	2006-04-24 15:13:29 UTC (rev 148)
@@ -83,6 +83,7 @@
 int op_export_keys (const char *pattern[], const char *outfile);
 
 int op_lookup_keys (char **names, gpgme_key_t **keys, char ***unknown);
+gpgme_key_t op_get_one_key (char *pattern);
 
 const char *userid_from_key (gpgme_key_t k);
 const char *keyid_from_key (gpgme_key_t k);

Modified: trunk/src/gpgmsg.cpp
===================================================================
--- trunk/src/gpgmsg.cpp	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/gpgmsg.cpp	2006-04-24 15:13:29 UTC (rev 148)
@@ -174,7 +174,7 @@
   bool hasAttachments (void);
   const char *getPlainText (void);
 
-  int decrypt (HWND hwnd);
+  int decrypt (HWND hwnd, bool info_only);
   int sign (HWND hwnd, bool want_html);
   int encrypt (HWND hwnd, bool want_html)
   {
@@ -752,7 +752,7 @@
       return NULL;
     }
 
-  rset = (char**)xcalloc (lpRecipientRows->cRows+2, sizeof *rset);
+  rset = (char**)xcalloc (lpRecipientRows->cRows+1, sizeof *rset);
 
   for (i = j = 0; (unsigned int)i < lpRecipientRows->cRows; i++)
     {
@@ -783,9 +783,6 @@
           break;
         }
     }
-  if (opt.enable_default_key && opt.default_key && *opt.default_key)
-    rset[j++] = xstrdup (opt.default_key);
-  rset[j] = NULL;
 
   if (lpRecipientTable)
     lpRecipientTable->Release();
@@ -1065,9 +1062,11 @@
 
 
 /* Decrypt the message MSG and update the window.  HWND identifies the
-   current window.  */
+   current window.  With INFO_ONLY set, the function will only update
+   the display to indicate that a PGP/MIME message has been
+   detected. */
 int 
-GpgMsgImpl::decrypt (HWND hwnd)
+GpgMsgImpl::decrypt (HWND hwnd, bool info_only)
 {
   log_debug ("%s:%s: enter\n", SRCNAME, __func__);
   openpgp_t mtype;
@@ -1159,11 +1158,11 @@
   if (have_pgphtml_sig)
     log_debug ("%s:%s: pgphtml signature attachment found at pos %d\n",
                SRCNAME, __func__, pgphtml_pos);
-  
 
+
   if (mtype == OPENPGP_NONE && !n_encrypted && !n_signed
       && !have_pgphtml_enc && !have_pgphtml_sig && !is_pgpmime_sig) 
-    {
+     {
       /* Because we usually work around the OL object model, it can't
          notice that we changed the windows's text behind its back (by
          means of update_display and the SetWindowText API).  Thus it
@@ -1202,6 +1201,24 @@
       return 0;
     }
 
+
+  if (info_only)
+    {
+      /* Note, that we don't use the exchange_cb in the updatedisplay
+         because this might lead to storing the new text in the
+         message.  */
+      if (is_pgpmime_sig || is_pgpmime_enc)
+        update_display (hwnd, this, NULL, 0, 
+                        _("[This is a PGP/MIME message]\r\n\r\n"
+                          "[Use the \"Decrypt\" button in the message window "
+                          "to show its content.]"));        
+      release_attach_info (table);
+      xfree (body);
+      return 0;
+    }
+  
+
+
   /* We always want an attestation.  Note that we ignore any error
      because that would anyway be a out of core situation and thus we
      can't do much about it. */
@@ -1769,6 +1786,44 @@
 	}
     }
 
+
+  /* If a default key has been set, add it to the list of keys.  Check
+     that the key is actually available. */
+  if (opt.enable_default_key && opt.default_key && *opt.default_key)
+    {
+      gpgme_key_t defkey;
+
+      defkey = op_get_one_key (opt.default_key);
+      if (!defkey)
+        {
+          MessageBox (hwnd,
+                      _("The configured default encryption key is not "
+                        "available or does not unambigiously specify a key. "
+                        "Please fix this in the option dialog.\n\n"
+                        "This message won't be be encrypted to this key!"),
+                      _("Encryption"), MB_ICONWARNING|MB_OK);
+        }
+      else
+        {
+          gpgme_key_t *tmpkeys;
+          int i;
+
+          n_keys = count_keys (keys) + 1;
+          tmpkeys = (gpgme_key_t *)xcalloc (n_keys+1, sizeof *tmpkeys);
+          for (i = 0; keys[i]; i++) 
+            {
+              tmpkeys[i] = keys[i];
+              gpgme_key_ref (tmpkeys[i]);
+            }
+          tmpkeys[i++] = defkey;
+          tmpkeys[i] = NULL;
+          free_key_array (keys);
+          keys = tmpkeys;
+        }
+    }
+  
+
+  /* Show  some debug info. */
   if (sign_key)
     log_debug ("%s:%s: signer: 0x%s %s\n",  SRCNAME, __func__,
                keyid_from_key (sign_key), userid_from_key (sign_key));
@@ -1781,6 +1836,7 @@
                    i, keyid_from_key (keys[i]), userid_from_key (keys[i]));
     }
 
+  /* Do the encryption.  */
   if (plaintext && *plaintext)
     {
       err = op_encrypt (plaintext, &ciphertext, 

Modified: trunk/src/gpgmsg.hh
===================================================================
--- trunk/src/gpgmsg.hh	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/gpgmsg.hh	2006-04-24 15:13:29 UTC (rev 148)
@@ -65,7 +65,7 @@
   virtual char **getRecipients (void) = 0;
 
   /* Decrypt and verify the message and all attachments.  */
-  virtual int decrypt (HWND hwnd) = 0;
+  virtual int decrypt (HWND hwnd, bool info_only) = 0;
 
   /* Sign the message and optionally the attachments. */
   virtual int sign (HWND hwnd, bool want_html) = 0;

Modified: trunk/src/intern.h
===================================================================
--- trunk/src/intern.h	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/intern.h	2006-04-24 15:13:29 UTC (rev 148)
@@ -108,6 +108,7 @@
     unsigned int no_msgcache:1;
     unsigned int no_pgpmime:1;
     unsigned int no_oom_write:1; /* Don't write using Outlooks object model. */
+    unsigned int no_preview_info:1; /* No preview info about PGP/MIME. */
     unsigned int old_reply_hack: 1; /* See gpgmsg.cpp:decrypt. */
     unsigned int auto_decrypt: 1;   /* Try to decrypt when clicked. */
     unsigned int no_attestation: 1; /* Don't create an attestation. */

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/main.c	2006-04-24 15:13:29 UTC (rev 148)
@@ -428,7 +428,7 @@
             case 0: opt.compat.no_msgcache = x; break;
             case 1: opt.compat.no_pgpmime = x; break;
             case 2: opt.compat.no_oom_write = x; break;
-            case 3: /* Not used anymore */ break;
+            case 3: opt.compat.no_preview_info = x; break;
             case 4: opt.compat.old_reply_hack = x; break;
             case 5: opt.compat.auto_decrypt = x; break;
             case 6: opt.compat.no_attestation = x; break;

Modified: trunk/src/olflange.cpp
===================================================================
--- trunk/src/olflange.cpp	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/olflange.cpp	2006-04-24 15:13:29 UTC (rev 148)
@@ -835,7 +835,10 @@
                                           ULONG lFlags)
 {
   log_debug ("%s:%s: received\n", SRCNAME, __func__);
-  if (opt.preview_decrypt)
+
+  /* The preview_info stuff does not work because for some reasons we
+     can't update the window.  Thus disabled for now. */
+  if (opt.preview_decrypt /*|| !opt.compat.no_preview_info*/)
     {
       HRESULT hr;
       HWND hWnd = NULL;
@@ -850,14 +853,18 @@
           GpgMsg *m = CreateGpgMsg (pMessage);
           m->setExchangeCallback ((void*)pEECB);
           m->setPreview (1);
-          m->decrypt (hWnd);
+          /* If preview decryption has been requested, do so.  If not,
+             pass true as the second arg to let the fucntion display a
+             hint on what kind of message this is. */
+          m->decrypt (hWnd, !opt.preview_decrypt);
           delete m;
-	}
+ 	}
       ul_release (pMessage);
       ul_release (pMDB);
     }
+
+
 #if 0
-  else
     {
       HWND hWnd = NULL;
 
@@ -1531,7 +1538,7 @@
             {
               GpgMsg *m = CreateGpgMsg (pMessage);
               m->setExchangeCallback ((void*)pEECB);
-              m->decrypt (hWnd);
+              m->decrypt (hWnd, 0);
               delete m;
 	    }
 	}

Modified: trunk/src/watcher.cpp
===================================================================
--- trunk/src/watcher.cpp	2006-04-24 10:06:24 UTC (rev 147)
+++ trunk/src/watcher.cpp	2006-04-24 15:13:29 UTC (rev 148)
@@ -86,7 +86,7 @@
 {
   GpgMsg *m = CreateGpgMsg (msg);
   m->setExchangeCallback ((void *)g_cb);
-  m->decrypt (hwnd);
+  m->decrypt (hwnd, 0);
   delete m;
   UlRelease (msg);
   msg = NULL;




More information about the Gnupg-commits mailing list