[svn] GpgOL - r197 - in trunk: . doc src

svn author wk cvs at cvs.gnupg.org
Mon Nov 12 15:19:11 CET 2007


Author: wk
Date: 2007-11-12 15:19:00 +0100 (Mon, 12 Nov 2007)
New Revision: 197

Modified:
   trunk/AUTHORS
   trunk/ChangeLog
   trunk/NEWS
   trunk/TODO
   trunk/configure.ac
   trunk/doc/gpgol.texi
   trunk/src/ChangeLog
   trunk/src/Makefile.am
   trunk/src/common.h
   trunk/src/dialogs.h
   trunk/src/dialogs.rc
   trunk/src/ext-commands.cpp
   trunk/src/ext-commands.h
   trunk/src/item-events.cpp
   trunk/src/main.c
   trunk/src/mapihelp.cpp
   trunk/src/mapihelp.h
   trunk/src/message-events.cpp
   trunk/src/message.cpp
   trunk/src/message.h
   trunk/src/mimeparser.c
   trunk/src/olflange-dlgs.cpp
   trunk/src/olflange.cpp
   trunk/src/olflange.h
   trunk/src/util.h
Log:
Fixes.


Modified: trunk/AUTHORS
===================================================================
--- trunk/AUTHORS	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/AUTHORS	2007-11-12 14:19:00 UTC (rev 197)
@@ -1,6 +1,7 @@
 Package: gpgol
 Contact: info-gpgol at g10code.com
 Bugs:    bug-gpgol at g10code.com
+License: LGPLv2.1+
 
 
 g10 Code GmbH 

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/ChangeLog	2007-11-12 14:19:00 UTC (rev 197)
@@ -1,3 +1,7 @@
+2007-10-22  Werner Koch  <wk at g10code.com>
+
+	Released 0.10.1 development version.
+
 2007-10-12  Werner Koch  <wk at g10code.com>
 
 	* po/POTFILES.in: Add more files.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/NEWS	2007-11-12 14:19:00 UTC (rev 197)
@@ -1,11 +1,16 @@
-Noteworthy changes for version 0.10.1 (2007-10-22)
+Noteworthy changes for version 0.10.2
 ==================================================
 
  UNDER HEAVY DEVELOPMENT - DO NOT USE FOR PRODUCTION!
 
-    - Signed and encrypt has not yet been implemented
     - Under OL2007 some menu entries are missing.
 
+ * New menu items to select the default protocol.
+
+
+Noteworthy changes for version 0.10.1 (2007-10-22)
+==================================================
+
  * Auto start the server.
 
  * Code cleanups. 

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/TODO	2007-11-12 14:19:00 UTC (rev 197)
@@ -1,6 +1,3 @@
-* inline PGG versenden wir als UTF-8. Andere aber wohl als Latin-1.
-  Heuristic implementieren. 
-
 * Show more details in case of some errors.
   For example 'No Secret Key' should contain the key-ID
   and if possible the primary user-ID.
@@ -19,11 +16,11 @@
 
 * Allow for symmetric encryption.
 
-* Please consider adding a few more options like key singing rules
+* Please consider adding a few more options like key signing rules
   like Enigmail has.
 
-* We should not rite a decrupted file without user content.  A
-  possible solution in attach-file-events.c is to keep tarck of
-  prensented file names and decrypt them only on OpenSzFile.  Need to
+* We should not write a decrypted file without user consent.  A
+  possible solution in attach-file-events.c is to keep track of
+  presented file names and decrypt them only on OpenSzFile.  Need to
   get some documentaion first.
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/configure.ac	2007-11-12 14:19:00 UTC (rev 197)
@@ -16,8 +16,8 @@
 # Remember to change the version number immediately *after* a release.
 # Set my_issvn to "yes" for non-released code.  Remember to run an
 # "svn up" and "autogen.sh" right before creating a distribution.
-m4_define([my_version], [0.10.1])
-m4_define([my_issvn], [no])
+m4_define([my_version], [0.10.2])
+m4_define([my_issvn], [yes])
 
 m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \
             || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))

Modified: trunk/doc/gpgol.texi
===================================================================
--- trunk/doc/gpgol.texi	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/doc/gpgol.texi	2007-11-12 14:19:00 UTC (rev 197)
@@ -113,9 +113,13 @@
 @c
 @node Introduction
 @chapter Introduction
-Bla bla
 
+To debug GpgOL you should set the Registry entry
+ at code{HKCU\Software\Gnu\GnuPG:enableDebug} to the string value @code{1}.
+This allows easy setting of a debug file by using the extended options
+menu and enables a few extra menu items.
 
+
 @c
 @c  P R O T O C O L  D E S C R I P T I O N
 @c
@@ -585,6 +589,12 @@
 re-encrypted attachment.  The existence of this property indicates that
 the attachment has been encrypted under the non-permanent session key.
 
+ at item GpgOL Last Decrypted
+This binary property is used on the message to save a session marker to
+tell GpgOL whether the message as already been decrypted.  If this
+property does not exists or the session marker does not macth the one of
+the current session, GpgOL needs to decrypt it again.
+
 @item GpgOL MIME Info
 This property is of type STRING8 and used to store the MIME structure of
 the orginal message.  The content are lines of colon delimited fields.
@@ -626,7 +636,31 @@
 actual program name contains spaces the program name nees to be enclosed
 in quotes.
 
+ at item HKCU\Software\Gnu\GnuPG:enableDebug
+Setting this key to the string @code{1} enables a few extra features in
+the UI, useful only for debugging.
 
+ at itemx HKCU\Software\Gnu\GnuPG:logFile
+If the value is not empty, GpgOL takes this as a log file and appends
+debug information to this file.  The file may get very large.
+
+ at itemx HKCU\Software\Gnu\GnuPG:compatFlags
+This is a string consisting of @code{0} and @code{1} to enable certain
+compatibility flags.  Not generally useful; use the source for a
+description.
+
+ at item HKCU\Software\Gnu\GnuPG:enableSmime   
+ at itemx HKCU\Software\Gnu\GnuPG:defaultProtocol
+ at itemx HKCU\Software\Gnu\GnuPG:encryptDefault
+ at itemx HKCU\Software\Gnu\GnuPG:signDefault   
+ at itemx HKCU\Software\Gnu\GnuPG:previewDecrypt
+ at itemx HKCU\Software\Gnu\GnuPG:storePasswdTime
+ at itemx HKCU\Software\Gnu\GnuPG:encodingFormat 
+ at itemx HKCU\Software\Gnu\GnuPG:defaultKey   
+ at itemx HKCU\Software\Gnu\GnuPG:enableDefaultKey
+ at itemx HKCU\Software\Gnu\GnuPG:preferHtml 
+These registry keys store the values from the configuration dialog.
+
 @end table
 
 

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/ChangeLog	2007-11-12 14:19:00 UTC (rev 197)
@@ -1,3 +1,37 @@
+2007-11-12  Werner Koch  <wk at g10code.com>
+
+	* olflange.h (class GpgolExt): Rename m_gpgSelectSmime to
+	m_protoSelection.
+	* message-events.cpp (OnWriteComplete): Use it accordingly.
+	* main.c (write_options, read_options): Load and save it.
+	* dialogs.rc: Add new check box for OpenPGP default protocol.
+	* olflange-dlgs.cpp (GPGOptionsDlgProc): Adjust for above chnages.
+
+2007-11-09  Werner Koch  <wk at g10code.com>
+
+	* main.c (read_options): New option ENABLE_DEBUG to be enabled
+	only using the Registry.
+	(read_options): Show warning for certain option combinations.
+	* olflange-dlgs.cpp (GPGOptionsDlgProc): Hide the Advanced options
+	button unless in debug mode.
+
+	* mapihelp.cpp (get_gpgollastdecrypted_tag): New.
+	(mapi_test_last_decrypted): New.
+	(mapi_has_last_decrypted): new.
+	* mimeparser.c (finish_message): Update the Last Decrypted property.
+	* message.cpp (message_decrypt): Use it here.
+	(message_wipe_body_cruft): New.
+
+	* main.c (do_log_window_hierarchy): Factor some code out to ..
+	(do_log_window_info): .. this.
+	(log_window_hierarchy): Log parent window info.
+	(get_64bit_session_marker): New.
+	(initialize_session_key): Init session marker.
+
+	* Makefile.am (gpgol_SOURCES): Remove item-events.cpp 
+	* olflange.cpp (GpgolExt): Disable the GpgOLItemEvents as they can
+	only be used with the undocumented ECF file.
+
 2007-10-29  Werner Koch  <wk at g10code.com>
 
 	* mimemaker.c (create_top_signing_header): Add arg FIRST.

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/Makefile.am	2007-11-12 14:19:00 UTC (rev 197)
@@ -11,8 +11,10 @@
 
 ## Process this file with automake to produce Makefile.in
 
+unused_sources = item-events.cpp 
+
 bin_PROGRAMS = gpgol 
-EXTRA_DIST = versioninfo.rc.in mapi32.def \
+EXTRA_DIST = versioninfo.rc.in mapi32.def $(unused_sources) \
 	     logo.bmp decrypt.bmp encrypt.bmp sign.bmp key_mana.bmp 
 
 EXEEXT = .dll
@@ -55,7 +57,7 @@
 	message-events.cpp  message-events.h  \
 	attached-file-events.cpp attached-file-events.h \
 	property-sheets.cpp property-sheets.h \
-	item-events.cpp item-events.h         \
+	item-events.h         \
 	ol-ext-callback.cpp ol-ext-callback.h \
 	w32-gettext.c w32-gettext.h 
 

Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/common.h	2007-11-12 14:19:00 UTC (rev 197)
@@ -105,11 +105,12 @@
 #endif
 struct 
 {
+  int enable_debug;	     /* Enable extra debug options. */
+  int enable_smime;	     /* Enable S/MIME support. */
   int passwd_ttl;            /* Time in seconds the passphrase is stored. */
-  int smime_default;         /* Use S/MIME by default. */
+  protocol_t default_protocol;/* The default protocol. */
   int encrypt_default;       /* Encrypt by default. */
   int sign_default;          /* Sign by default. */
-  int enable_smime;	     /* Enable S/MIME support. */
   int enc_format;            /* Encryption format for attachments. */
   char *default_key;         /* The key we want to always encrypt to. */
   int enable_default_key;    /* Enable the use of DEFAULT_KEY. */

Modified: trunk/src/dialogs.h
===================================================================
--- trunk/src/dialogs.h	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/dialogs.h	2007-11-12 14:19:00 UTC (rev 197)
@@ -25,18 +25,19 @@
 #define IDC_ENCRYPT_DEFAULT             4011
 #define IDC_SIGN_DEFAULT                4012
 #define IDC_ENCRYPT_WITH_STANDARD_KEY   4013
-#define IDC_SMIME_DEFAULT               4014
-#define IDC_GPG_OPTIONS                 4015
-#define IDC_BITMAP                      4016
-#define IDC_VERSION_INFO                4017
-#define IDC_ENCRYPT_TO                  4018
-#define IDC_ENABLE_SMIME                4019
-#define IDC_PREVIEW_DECRYPT             4020
-#define IDC_PREFER_HTML                 4021
-#define IDC_G_OPTIONS                   4022
-#define IDC_G_PASSPHRASE                4023
-#define IDC_T_PASSPHRASE_TTL            4024
-#define IDC_T_PASSPHRASE_MIN            4025
+#define IDC_OPENPGP_DEFAULT             4014
+#define IDC_SMIME_DEFAULT               4015
+#define IDC_GPG_OPTIONS                 4016
+#define IDC_BITMAP                      4017
+#define IDC_VERSION_INFO                4018
+#define IDC_ENCRYPT_TO                  4019
+#define IDC_ENABLE_SMIME                4020
+#define IDC_PREVIEW_DECRYPT             4021
+#define IDC_PREFER_HTML                 4022
+#define IDC_G_OPTIONS                   4023
+#define IDC_G_PASSPHRASE                4024
+#define IDC_T_PASSPHRASE_TTL            4025
+#define IDC_T_PASSPHRASE_MIN            4026
 
 
 /* Ids for the extended options dialog.  */

Modified: trunk/src/dialogs.rc
===================================================================
--- trunk/src/dialogs.rc	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/dialogs.rc	2007-11-12 14:19:00 UTC (rev 197)
@@ -37,7 +37,7 @@
 BEGIN
     /* Options box.  */
     GROUPBOX        "options", IDC_G_OPTIONS,
-                    9, 9, 242, 112
+                    9, 9, 242, 124
 
     CONTROL         "encrypt-by-default", IDC_ENCRYPT_DEFAULT,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
@@ -47,61 +47,65 @@
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
                     24, 30, 215, 10
 
-    CONTROL         "smime-by-default", IDC_SMIME_DEFAULT,
+    CONTROL         "openpgp-by-default", IDC_OPENPGP_DEFAULT,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
                     24, 42, 215, 10
 
-    CONTROL         "enable-smime", IDC_ENABLE_SMIME,
+    CONTROL         "smime-by-default", IDC_SMIME_DEFAULT,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
                     24, 54, 215, 10
 
+    CONTROL         "enable-smime", IDC_ENABLE_SMIME,
+                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+                    24, 66, 215, 10
+
     CONTROL         "encrypt-to", IDC_ENCRYPT_WITH_STANDARD_KEY,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 67, 215, 10
+                    24, 79, 215, 10
 
     EDITTEXT        IDC_ENCRYPT_TO, 
-                    36, 79, 133, 12, ES_AUTOHSCROLL
+                    36, 91, 133, 12, ES_AUTOHSCROLL
 
     CONTROL         "preview-decrypt", IDC_PREVIEW_DECRYPT,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 95, 215, 10
+                    24, 107, 215, 10
 
     CONTROL         "prefer-html", IDC_PREFER_HTML,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 107, 215, 10
+                    24, 119, 215, 10
  
     /* Passphrase option box.  */
     GROUPBOX        "Passphrase", IDC_G_PASSPHRASE,
-                    9, 124, 242, 31
+                    9, 136, 242, 31
 
     LTEXT           "passphrase-ttl", IDC_T_PASSPHRASE_TTL,
-                     24, 136, 80, 8
+                     24, 148, 80, 8
 
     EDITTEXT        IDC_TIME_PHRASES,
-                    107, 135, 39, 14, ES_AUTOHSCROLL
+                    107, 147, 39, 14, ES_AUTOHSCROLL
 
     LTEXT           "minutes", IDC_T_PASSPHRASE_MIN,
-                    151, 137, 50, 8
+                    151, 149, 50, 8
 
     /* Stuff below the group boxes.  */
     PUSHBUTTON      "advanced", IDC_GPG_OPTIONS,
-                    202, 166, 50, 14
+                    202, 178, 50, 14
 
     LTEXT           "GpgOL by g10 Code GmbH", IDC_STATIC, 
-                      8, 185, 100, 8
+                      8, 197, 100, 8
     LTEXT           "Version x ", IDC_VERSION_INFO,
-                    150, 185, 109, 9
+                    150, 197, 109, 9
 
     CONTROL         IDB_BANNER, IDC_BITMAP,
                     "Static", SS_BITMAP | SS_REALSIZEIMAGE,
-                      8, 200, 150, 64
+                      8, 212, 150, 64
 END
 
 
 
 IDD_EXT_OPTIONS DIALOG DISCARDABLE  0, 0, 167, 119
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
-CAPTION "GpgOL - Extended Options"
+CAPTION "GpgOL - Extended Options (debug only!)"
 FONT 8, "MS Sans Serif"
 BEGIN
     LTEXT           "keyman", IDC_T_OPT_KEYMAN_PATH,

Modified: trunk/src/ext-commands.cpp
===================================================================
--- trunk/src/ext-commands.cpp	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/ext-commands.cpp	2007-11-12 14:19:00 UTC (rev 197)
@@ -64,7 +64,7 @@
 
 
 
-static void add_menu (LPEXCHEXTCALLBACK pEECB, 
+static void add_menu (LPEXCHEXTCALLBACK eecb, 
                       UINT FAR *pnCommandIDBase, ...)
 #if __GNUC__ >= 4 
                                __attribute__ ((sentinel))
@@ -97,7 +97,9 @@
   m_pExchExt = pParentInterface; 
   m_lRef = 0; 
   m_lContext = 0; 
-  m_nCmdSelectSmime = 0;
+  m_nCmdProtoAuto = 0;
+  m_nCmdProtoPgpmime = 0;
+  m_nCmdProtoSmime = 0;
   m_nCmdEncrypt = 0;  
   m_nCmdDecrypt = 0;  
   m_nCmdSign = 0; 
@@ -144,20 +146,23 @@
 
 
 /* Add a new menu.  The variable entries are made up of pairs of
-   strings and UINT *.  A NULL is used to terminate this list. An empty
-   string is translated to a separator menu item. */
+   strings and UINT *.  A NULL is used to terminate this list.  An
+   empty string is translated to a separator menu item.  One level of
+   submenus are supported. */
 static void
-add_menu (LPEXCHEXTCALLBACK pEECB, UINT FAR *pnCommandIDBase, ...)
+add_menu (LPEXCHEXTCALLBACK eecb, UINT FAR *pnCommandIDBase, ...)
 {
   va_list arg_ptr;
-  HMENU menu;
+  HMENU mainmenu, submenu, menu;
   const char *string;
   UINT *cmdptr;
   
   va_start (arg_ptr, pnCommandIDBase);
   /* We put all new entries into the tools menu.  To make this work we
      need to pass the id of an existing item from that menu.  */
-  pEECB->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &menu, NULL, NULL, 0);
+  eecb->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &mainmenu, NULL, NULL, 0);
+  menu = mainmenu;
+  submenu = NULL;
   while ( (string = va_arg (arg_ptr, const char *)) )
     {
       cmdptr = va_arg (arg_ptr, UINT*);
@@ -166,11 +171,23 @@
         ; /* Ignore this entry.  */
       else if (*string == '@' && !string[1])
         AppendMenu (menu, MF_SEPARATOR, 0, NULL);
+      else if (*string == '>')
+        {
+          submenu = CreatePopupMenu ();
+          AppendMenu (menu, MF_STRING|MF_POPUP, (UINT_PTR)submenu, string+1);
+          menu = submenu;
+        }
+      else if (*string == '<')
+        {
+          menu = mainmenu;
+          submenu = NULL;
+        }
       else
 	{
           AppendMenu (menu, MF_STRING, *pnCommandIDBase, string);
-//           SetMenuItemBitmaps (menu, *pnCommandIDBase, MF_BYCOMMAND,
-//                                    my_uncheck_bitmap, my_check_bitmap);
+          if (menu == submenu)
+            SetMenuItemBitmaps (menu, *pnCommandIDBase, MF_BYCOMMAND,
+                                my_uncheck_bitmap, my_check_bitmap);
           if (cmdptr)
             *cmdptr = *pnCommandIDBase;
           (*pnCommandIDBase)++;
@@ -181,11 +198,13 @@
 
 
 static void
-check_menu (LPEXCHEXTCALLBACK pEECB, UINT menu_id, int checked)
+check_menu (LPEXCHEXTCALLBACK eecb, UINT menu_id, int checked)
 {
   HMENU menu;
-  
-  pEECB->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &menu, NULL, NULL, 0);
+
+  eecb->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &menu, NULL, NULL, 0);
+  log_debug ("check_menu: eecb=%p menu_id=%u checked=%d -> menu=%p\n", 
+             eecb, menu_id, checked, menu);
   CheckMenuItem (menu, menu_id, 
                  MF_BYCOMMAND | (checked?MF_CHECKED:MF_UNCHECKED));
 }
@@ -255,7 +274,7 @@
    S_FALSE to signal Exchange to continue calling extensions. */
 STDMETHODIMP 
 GpgolExtCommands::InstallCommands (
-	LPEXCHEXTCALLBACK pEECB, // The Exchange Callback Interface.
+	LPEXCHEXTCALLBACK eecb, // The Exchange Callback Interface.
 	HWND hWnd,               // The window handle to the main window
                                  // of context.
 	HMENU hMenu,             // The menu handle to main menu of context.
@@ -304,7 +323,7 @@
       /*  Note that for read and send the object returned by the
           outlook extension callback is of class 43 (MailItem) so we
           only need to ask for Body then. */
-      hr = pEECB->GetObject (&mdb, (LPMAPIPROP *)&message);
+      hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
       if (FAILED(hr))
         log_debug ("%s:%s: getObject failed: hr=%#lx\n", SRCNAME,__func__,hr);
       else if (!opt.compat.no_msgcache)
@@ -314,7 +333,7 @@
           size_t keylen = 0;
           void *refhandle = NULL;
      
-          pDisp = find_outlook_property (pEECB, "ConversationIndex", &dispid);
+          pDisp = find_outlook_property (eecb, "ConversationIndex", &dispid);
           if (pDisp)
             {
               DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
@@ -349,7 +368,7 @@
           
           if (key && keylen
               && (body = msgcache_get (key, keylen, &refhandle)) 
-              && (pDisp = find_outlook_property (pEECB, "Body", &dispid)))
+              && (pDisp = find_outlook_property (eecb, "Body", &dispid)))
             {
 #if 1
               dispparams.cNamedArgs = 1;
@@ -390,7 +409,7 @@
     {
       int need_dvm = 0;
 
-      switch (m_pExchExt->getMsgtype (pEECB))
+      switch (m_pExchExt->getMsgtype (eecb))
         {
         case MSGTYPE_GPGOL_MULTIPART_ENCRYPTED:
         case MSGTYPE_GPGOL_OPAQUE_ENCRYPTED:
@@ -403,15 +422,15 @@
 
       /* We always enable the verify button as it might be useful on
          an already decrypted message. */
-      add_menu (pEECB, pnCommandIDBase,
+      add_menu (eecb, pnCommandIDBase,
         "@", NULL,
         need_dvm? _("&Decrypt and verify message"):"", &m_nCmdDecrypt,
         _("&Verify signature"), &m_nCmdCheckSig,
         _("&Display crypto information"), &m_nCmdShowInfo,
-        "@", NULL,
-        "Debug-1 (open_inspector)", &m_nCmdDebug1,
-        "Debug-2 (n/a)", &m_nCmdDebug2,
-         NULL);
+                "@", NULL,
+        opt.enable_debug? "Debug-1 (open_inspector)":"", &m_nCmdDebug1,
+        opt.enable_debug? "Debug-2 (n/a)":"", &m_nCmdDebug2,
+        NULL);
       
       add_toolbar (pTBEArray, nTBECnt,
         _("Decrypt message and verify signature"), IDB_DECRYPT, m_nCmdDecrypt,
@@ -419,9 +438,13 @@
     }
   else if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
     {
-      add_menu (pEECB, pnCommandIDBase,
+      add_menu (eecb, pnCommandIDBase,
         "@", NULL,
-        opt.enable_smime? _("use S/MIME protocol"):"", &m_nCmdSelectSmime,
+        _(">GnuPG protocol"), NULL,
+        _("auto"),   &m_nCmdProtoAuto,        
+        _("OpenPGP"),&m_nCmdProtoPgpmime,        
+        _("S/MIME"), &m_nCmdProtoSmime,        
+          "<", NULL,
         _("&encrypt message with GnuPG"), &m_nCmdEncrypt,
         _("&sign message with GnuPG"), &m_nCmdSign,
         NULL );
@@ -431,15 +454,37 @@
         _("Sign message with GnuPG"),    IDB_SIGN,    m_nCmdSign,
         NULL, 0, 0);
 
-      m_pExchExt->m_gpgSelectSmime = opt.enable_smime && opt.smime_default;
+      m_pExchExt->m_protoSelection = opt.default_protocol;
+      switch (opt.default_protocol)
+        {
+        case PROTOCOL_OPENPGP:
+          check_menu (eecb, m_nCmdProtoAuto, FALSE);
+          check_menu (eecb, m_nCmdProtoPgpmime, TRUE);
+          check_menu (eecb, m_nCmdProtoSmime, FALSE);
+          break;
+        case PROTOCOL_SMIME:
+          check_menu (eecb, m_nCmdProtoAuto, FALSE);
+          check_menu (eecb, m_nCmdProtoPgpmime, FALSE);
+          check_menu (eecb, m_nCmdProtoSmime, TRUE);
+          break;
+        default:
+          check_menu (eecb, m_nCmdProtoAuto, TRUE);
+          check_menu (eecb, m_nCmdProtoPgpmime, FALSE);
+          check_menu (eecb, m_nCmdProtoSmime, FALSE);
+          break;
+        }
+
       m_pExchExt->m_gpgEncrypt = opt.encrypt_default;
+
       m_pExchExt->m_gpgSign    = opt.sign_default;
       if (force_encrypt)
         m_pExchExt->m_gpgEncrypt = true;
+      check_menu (eecb, m_nCmdEncrypt, m_pExchExt->m_gpgEncrypt);
+      check_menu (eecb, m_nCmdSign, m_pExchExt->m_gpgSign);
     }
   else if (m_lContext == EECONTEXT_VIEWER) 
     {
-      add_menu (pEECB, pnCommandIDBase, 
+      add_menu (eecb, pnCommandIDBase, 
         "@", NULL,
         _("GnuPG Certificate &Manager"), &m_nCmdKeyManager,
         NULL);
@@ -499,6 +544,7 @@
           if (hr == S_OK)
             {
               log_debug ("%s:%s: invoking Close succeeded", SRCNAME,__func__);
+              message_wipe_body_cruft (eecb);
               return S_OK; /* We handled the close command. */
             }
 
@@ -506,6 +552,8 @@
                      SRCNAME, __func__, hr);
         }
 
+      message_wipe_body_cruft (eecb);
+
       /* Closing on our own failed - pass it on. */
       return S_FALSE; 
     }
@@ -563,11 +611,32 @@
       ul_release (message);
       ul_release (mdb);
     }
-  else if (nCommandID == m_nCmdSelectSmime
+  else if (nCommandID == m_nCmdProtoAuto
            && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
     {
+      check_menu (eecb, m_nCmdProtoAuto, TRUE);
+      check_menu (eecb, m_nCmdProtoPgpmime, FALSE);
+      check_menu (eecb, m_nCmdProtoSmime, FALSE);
+      m_pExchExt->m_protoSelection = PROTOCOL_UNKNOWN;
+    }
+  else if (nCommandID == m_nCmdProtoPgpmime
+           && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
+    {
+      check_menu (eecb, m_nCmdProtoAuto, FALSE);
+      check_menu (eecb, m_nCmdProtoPgpmime, TRUE);
+      check_menu (eecb, m_nCmdProtoSmime, FALSE);
+      m_pExchExt->m_protoSelection = PROTOCOL_OPENPGP;
+    }
+  else if (nCommandID == m_nCmdProtoSmime
+           && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
+    {
       if (opt.enable_smime)
-        m_pExchExt->m_gpgSelectSmime = !m_pExchExt->m_gpgSelectSmime;
+        {
+          check_menu (eecb, m_nCmdProtoAuto, FALSE);
+          check_menu (eecb, m_nCmdProtoPgpmime, FALSE);
+          check_menu (eecb, m_nCmdProtoSmime, TRUE);
+          m_pExchExt->m_protoSelection = PROTOCOL_SMIME;
+        }
     }
   else if (nCommandID == m_nCmdEncrypt
            && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
@@ -587,9 +656,9 @@
       if (engine_start_keymanager ())
         if (start_key_manager ())
           MessageBox (NULL, _("Could not start certificate manager"),
-                      "GpgOL", MB_ICONERROR|MB_OK);
+                      _("GpgOL"), MB_ICONERROR|MB_OK);
     }
-  else if (nCommandID == m_nCmdDebug1
+  else if (opt.enable_debug && nCommandID == m_nCmdDebug1
            && m_lContext == EECONTEXT_READNOTEMESSAGE)
     {
       hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
@@ -615,14 +684,6 @@
 STDMETHODIMP_(VOID) 
 GpgolExtCommands::InitMenu(LPEXCHEXTCALLBACK eecb) 
 {
-  HRESULT hr;
-  HMENU menu;
-  
-  hr = eecb->GetMenu (&menu);
-  if (FAILED(hr))
-      return; /* Ooops.  */
-  CheckMenuItem (menu, m_nCmdEncrypt, MF_BYCOMMAND 
-                 | (m_pExchExt->m_gpgSign?MF_CHECKED:MF_UNCHECKED));
 }
 
 
@@ -655,10 +716,24 @@
                   _("Check the signature now and display the result"),
                   "GpgOL", MB_OK);
     }
-  else if (nCommandID == m_nCmdSelectSmime
+  else if (nCommandID == m_nCmdProtoAuto
            && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
     {
       MessageBox (m_hWnd,
+                  _("Select this option to automatically select the protocol."),
+                  "GpgOL", MB_OK);	
+    } 
+  else if (nCommandID == m_nCmdProtoPgpmime
+           && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
+    {
+      MessageBox (m_hWnd,
+                  _("Select this option to select the OpenPGP protocol."),
+                  "GpgOL", MB_OK);	
+    } 
+  else if (nCommandID == m_nCmdProtoSmime
+           && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
+    {
+      MessageBox (m_hWnd,
                   _("Select this option to select the S/MIME protocol."),
                   "GpgOL", MB_OK);	
     } 
@@ -731,7 +806,7 @@
                   _("Check the signature now and display the result"),
                   nCharCnt);
     }
-  else if (nCommandID == m_nCmdSelectSmime
+  else if (nCommandID == m_nCmdProtoSmime
            && m_lContext == EECONTEXT_SENDNOTEMESSAGE) 
     {
       if (lFlags == EECQHT_STATUS)
@@ -822,12 +897,24 @@
       if (m_pExchExt->m_gpgSign)
         pTBB->fsState |= TBSTATE_CHECKED;
     }
-  else if (tb_info->cmd_id == m_nCmdSelectSmime)
+  else if (tb_info->cmd_id == m_nCmdProtoAuto)
     {
       pTBB->fsStyle |= TBSTYLE_CHECK;
-      if (m_pExchExt->m_gpgSelectSmime)
+      if (m_pExchExt->m_protoSelection == PROTOCOL_UNKNOWN)
         pTBB->fsState |= TBSTATE_CHECKED;
     }
+  else if (tb_info->cmd_id == m_nCmdProtoPgpmime)
+    {
+      pTBB->fsStyle |= TBSTYLE_CHECK;
+      if (m_pExchExt->m_protoSelection == PROTOCOL_OPENPGP)
+        pTBB->fsState |= TBSTATE_CHECKED;
+    }
+  else if (tb_info->cmd_id == m_nCmdProtoSmime)
+    {
+      pTBB->fsStyle |= TBSTYLE_CHECK;
+      if (m_pExchExt->m_protoSelection == PROTOCOL_SMIME)
+        pTBB->fsState |= TBSTATE_CHECKED;
+    }
 
   return S_OK;
 }

Modified: trunk/src/ext-commands.h
===================================================================
--- trunk/src/ext-commands.h	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/ext-commands.h	2007-11-12 14:19:00 UTC (rev 197)
@@ -40,7 +40,9 @@
   ULONG m_lRef;
   ULONG m_lContext;
   
-  UINT  m_nCmdSelectSmime;
+  UINT  m_nCmdProtoAuto;
+  UINT  m_nCmdProtoPgpmime;
+  UINT  m_nCmdProtoSmime;
   UINT  m_nCmdEncrypt;
   UINT  m_nCmdDecrypt;
   UINT  m_nCmdSign;

Modified: trunk/src/item-events.cpp
===================================================================
--- trunk/src/item-events.cpp	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/item-events.cpp	2007-11-12 14:19:00 UTC (rev 197)
@@ -17,6 +17,8 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#error not used becuase it requires an ECF
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/main.c	2007-11-12 14:19:00 UTC (rev 197)
@@ -44,6 +44,10 @@
    initialized at startup.  */
 static char *the_session_key;
 
+/* The session marker to identify this session.  Its value is not
+  confidential.  It is initialized at startup.  */
+static char *the_session_marker;
+
 /* Local function prototypes. */
 static char *get_locale_dir (void);
 static void drop_locale_dir (char *locale_dir);
@@ -102,10 +106,11 @@
 }
 
 
+/* Initialize the session key and the session marker.  */
 static int
 initialize_session_key (void)
 {
-  the_session_key = get_crypt_random (16+sizeof (unsigned int));
+  the_session_key = get_crypt_random (16+sizeof (unsigned int)+8);
   if (the_session_key)
     {
       /* We use rand() in generate_boundary so we need to seed it. */
@@ -113,6 +118,9 @@
 
       memcpy (&tmp, the_session_key+16, sizeof (unsigned int));
       srand (tmp);
+
+      /* And save the session marker. */
+      the_session_marker = the_session_key + 16 + sizeof (unsigned int);
     }
   return !the_session_key;
 }
@@ -185,6 +193,13 @@
 }
 
 
+const void *
+get_64bit_session_marker (void)
+{
+  return the_session_marker;
+}
+
+
 /* Return a new allocated IV of size NBYTES.  Caller must free it.  On
    error NULL is returned. */
 void *
@@ -330,6 +345,32 @@
 }
 
 
+static void
+do_log_window_info (HWND window, int level)
+{
+  char buf[1024+1];
+  char name[200];
+  int nname;
+  char *pname;
+
+  if (!window)
+    return;
+      
+  memset (buf, 0, sizeof (buf));
+  GetWindowText (window, buf, sizeof (buf)-1);
+  nname = GetClassName (window, name, sizeof (name)-1);
+  if (nname)
+    pname = name;
+  else
+    pname = NULL;
+  if (level == -1)
+    log_debug ("  parent=%p (%s) `%s'", window, pname? pname:"", buf);
+  else
+    log_debug ("    %*shwnd=%p (%s) `%s'", level*2, "", window,
+               pname? pname:"", buf);
+}
+
+
 /* Helper to log_window_hierarchy.  */
 static HWND
 do_log_window_hierarchy (HWND parent, int level)
@@ -339,20 +380,7 @@
   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);
+      do_log_window_info (child, level);
       do_log_window_hierarchy (child, level+1);
       child = GetNextWindow (child, GW_HWNDNEXT);	
     }
@@ -371,7 +399,11 @@
   va_start (a, fmt);
   do_log (fmt, a, 0, 0, NULL, 0);
   va_end (a);
-  do_log_window_hierarchy (window, 0);
+  if (window)
+    {
+      do_log_window_info (window, -1);
+      do_log_window_hierarchy (window, 0);
+    }
 }
 
 
@@ -473,14 +505,25 @@
 void
 read_options (void)
 {
+  static int warnings_shown;
   char *val = NULL;
  
+  load_extension_value ("enableDebug", &val);
+  opt.enable_debug = val == NULL || *val != '1' ? 0 : 1;
+  xfree (val); val = NULL;
+
   load_extension_value ("enableSmime", &val);
   opt.enable_smime = val == NULL || *val != '1' ? 0 : 1;
   xfree (val); val = NULL;
   
-  load_extension_value ("smimeDefault", &val);
-  opt.smime_default = val == NULL || *val != '1'? 0 : 1;
+  load_extension_value ("defaultProtocol", &val);
+  switch ((!val || *val == '0')? 0 : atol (val))
+    {
+    case 1: opt.default_protocol = PROTOCOL_OPENPGP; break;
+    case 2: opt.default_protocol = PROTOCOL_SMIME; break;
+    case 0:
+    default: opt.default_protocol = PROTOCOL_UNKNOWN /*(auto*)*/; break;
+    }
   xfree (val); val = NULL;
 
   load_extension_value ("encryptDefault", &val);
@@ -547,7 +590,27 @@
         }
       log_debug ("Note: using compatibility flags: %s", val);
     }
+
+  if (!warnings_shown)
+    {
+      char tmpbuf[512];
+          
+      warnings_shown = 1;
+      if (val && *val)
+        {
+          snprintf (tmpbuf, sizeof tmpbuf,
+                    _("Note: Using compatibility flags: %s"), val);
+          MessageBox (NULL, tmpbuf, _("GpgOL"), MB_ICONWARNING|MB_OK);
+        }
+      if (logfile && !opt.enable_debug)
+        {
+          snprintf (tmpbuf, sizeof tmpbuf,
+                    _("Note: Writing debug logs to\n\n\"%s\""), logfile);
+          MessageBox (NULL, tmpbuf, _("GpgOL"), MB_ICONWARNING|MB_OK);
+        }
+    }
   xfree (val); val = NULL;
+
 }
 
 
@@ -562,10 +625,10 @@
     int  value;
     char *s_val;
   } table[] = {
-    {"smimeDefault",             0, opt.smime_default},
+    {"enableSmime",              0, opt.enable_smime},
+    {"defaultProtocol",          3, opt.default_protocol},
     {"encryptDefault",           0, opt.encrypt_default},
     {"signDefault",              0, opt.sign_default},
-    {"enableSmime",              0, opt.enable_smime},
     {"previewDecrypt",           0, opt.preview_decrypt},
     {"storePasswdTime",          1, opt.passwd_ttl},
     {"encodingFormat",           1, opt.enc_format},
@@ -594,6 +657,18 @@
           rc = store_extension_value (table[i].name,
                                       table[i].s_val? table[i].s_val : "");
           break;
+        case 3:
+          buf[0] = '0';
+          buf[1] = 0;
+          switch (opt.default_protocol)
+            {
+            case PROTOCOL_UNKNOWN: buf[0] = '0'; /* auto */ break;
+            case PROTOCOL_OPENPGP: buf[0] = '1'; break;
+            case PROTOCOL_SMIME:   buf[0] = '2'; break;
+            }
+          rc = store_extension_value (table[i].name, buf);
+          break;  
+
         default:
           rc = -1;
           break;

Modified: trunk/src/mapihelp.cpp
===================================================================
--- trunk/src/mapihelp.cpp	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/mapihelp.cpp	2007-11-12 14:19:00 UTC (rev 197)
@@ -153,7 +153,17 @@
   return 0;
 }
 
+/* Return the property tag for GpgOL Last Decrypted. */
+int 
+get_gpgollastdecrypted_tag (LPMESSAGE message, ULONG *r_tag)
+{
+  if (!(*r_tag = create_gpgol_tag (message, L"GpgOL Last Decrypted",__func__)))
+    return -1;
+  *r_tag |= PT_BINARY;
+  return 0;
+}
 
+
 /* Return the property tag for GpgOL MIME structure. */
 int 
 get_gpgolmimeinfo_tag (LPMESSAGE message, ULONG *r_tag)
@@ -1547,6 +1557,57 @@
 }
 
 
+/* Returns True if MESSAGE has a GpgOL Last Decrypted property with any value.
+   This indicates that there sghould be no PR_BODY tag.  */
+int
+mapi_has_last_decrypted (LPMESSAGE message)
+{
+  HRESULT hr;
+  LPSPropValue propval = NULL;
+  ULONG tag;
+  int yes = 0;
+  
+  if (get_gpgollastdecrypted_tag (message, &tag) )
+    return 0; /* No.  */
+  hr = HrGetOneProp ((LPMAPIPROP)message, tag, &propval);
+  if (FAILED (hr))
+    return 0; /* No.  */  
+  
+  if (PROP_TYPE (propval->ulPropTag) == PT_BINARY)
+    yes = 1;
+
+  MAPIFreeBuffer (propval);
+  return yes;
+}
+
+
+/* Returns True if MESSAGE has a GpgOL Last Decrypted property and
+   that matches the curren sessiobn. */
+int
+mapi_test_last_decrypted (LPMESSAGE message)
+{
+  HRESULT hr;
+  LPSPropValue propval = NULL;
+  ULONG tag;
+  int yes = 0;
+
+  if (get_gpgollastdecrypted_tag (message, &tag) )
+    return 0; /* No.  */
+  hr = HrGetOneProp ((LPMAPIPROP)message, tag, &propval);
+  if (FAILED (hr))
+    return 0; /* No.  */  
+
+  if (PROP_TYPE (propval->ulPropTag) == PT_BINARY
+      && propval->Value.bin.cb == 8
+      && !memcmp (propval->Value.bin.lpb, get_64bit_session_marker (), 8) )
+    yes = 1;
+
+  MAPIFreeBuffer (propval);
+  return yes;
+}
+
+
+
 /* Helper for mapi_get_gpgol_body_attachment.  */
 static int
 has_gpgol_body_name (LPATTACH obj)
@@ -1682,4 +1743,3 @@
   return body;
 }
 
-

Modified: trunk/src/mapihelp.h
===================================================================
--- trunk/src/mapihelp.h	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/mapihelp.h	2007-11-12 14:19:00 UTC (rev 197)
@@ -85,7 +85,8 @@
 int get_gpgolattachtype_tag (LPMESSAGE message, ULONG *r_tag);
 int get_gpgolsigstatus_tag (LPMESSAGE message, ULONG *r_tag);
 int get_gpgolprotectiv_tag (LPMESSAGE message, ULONG *r_tag);
-int  get_gpgolmimeinfo_tag (LPMESSAGE message, ULONG *r_tag);
+int get_gpgollastdecrypted_tag (LPMESSAGE message, ULONG *r_tag);
+int get_gpgolmimeinfo_tag (LPMESSAGE message, ULONG *r_tag);
 
 int mapi_set_header (LPMESSAGE msg, const char *name, const char *val);
 
@@ -117,6 +118,8 @@
 char *mapi_get_message_content_type (LPMESSAGE message, 
                                      char **r_protocol, char **r_smtype);
 
+int   mapi_has_last_decrypted (LPMESSAGE message);
+int   mapi_test_last_decrypted (LPMESSAGE message);
 char *mapi_get_gpgol_body_attachment (LPMESSAGE message, size_t *r_nbytes,
                                       int *r_ishtml, int *r_protected);
 

Modified: trunk/src/message-events.cpp
===================================================================
--- trunk/src/message-events.cpp	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/message-events.cpp	2007-11-12 14:19:00 UTC (rev 197)
@@ -109,7 +109,7 @@
   log_debug ("%s:%s: received\n", SRCNAME, __func__);
 
   m_wasencrypted = false;
-  if (opt.preview_decrypt)
+  if (1 /*opt.preview_decrypt*/)
     {
       eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
       if (message_incoming_handler (message, m_pExchExt->getMsgtype (eecb)))
@@ -270,9 +270,7 @@
   HRESULT hr = eecb->GetObject (&pMDB, (LPMAPIPROP *)&msg);
   if (SUCCEEDED (hr))
     {
-      protocol_t proto = (m_pExchExt->m_gpgSelectSmime
-                          ? PROTOCOL_SMIME
-                          : PROTOCOL_OPENPGP);
+      protocol_t proto = m_pExchExt->m_protoSelection;
       
       if (m_pExchExt->m_gpgEncrypt && m_pExchExt->m_gpgSign)
         rc = message_sign_encrypt (msg, proto, hWnd);

Modified: trunk/src/message.cpp
===================================================================
--- trunk/src/message.cpp	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/message.cpp	2007-11-12 14:19:00 UTC (rev 197)
@@ -119,12 +119,13 @@
   hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
   if (SUCCEEDED (hr))
     {
-      /* If the message was protected we don't allow a fallback to the
-         OOM display methods.  */
+      /* (old: If the message was protected we don't allow a fallback to the
+         OOM display methods.)  Now: As it is difficult to find the
+         actual winodw we now use the OOM display always.  */
       body = mapi_get_gpgol_body_attachment (message, NULL, 
                                              &ishtml, &wasprotected);
       if (body)
-        update_display (hwnd, wasprotected? NULL: eecb, ishtml, body);
+        update_display (hwnd, /*wasprotected? NULL:*/ eecb, ishtml, body);
       else
         update_display (hwnd, NULL, 0, 
                         _("[Crypto operation failed - "
@@ -143,6 +144,66 @@
 }
 
 
+/* If the current message is an encrypted one remove the body
+   properties which might have come up due to OL internal
+   syncronization and a failing olDiscard feature.  */
+void
+message_wipe_body_cruft (LPEXCHEXTCALLBACK eecb)
+{
+  
+  HRESULT hr;
+  LPMESSAGE message = NULL;
+  LPMDB mdb = NULL;
+      
+  log_debug ("%s:%s: enter", SRCNAME, __func__);
+  hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message);
+  if (SUCCEEDED (hr))
+    {
+      if (mapi_has_last_decrypted (message))
+        {
+          SPropTagArray proparray;
+          int anyokay = 0;
+          
+          proparray.cValues = 1;
+          proparray.aulPropTag[0] = PR_BODY;
+          hr = message->DeleteProps (&proparray, NULL);
+          if (hr)
+            log_debug_w32 (hr, "%s:%s: deleting PR_BODY failed",
+                           SRCNAME, __func__);
+          else
+            anyokay++;
+          
+          proparray.cValues = 1;
+          proparray.aulPropTag[0] = PR_BODY_HTML;
+          message->DeleteProps (&proparray, NULL);
+          if (hr)
+            log_debug_w32 (hr, "%s:%s: deleting PR_BODY_HTML failed", 
+                           SRCNAME, __func__);
+          else
+            anyokay++;
+
+          if (anyokay)
+            {
+              hr = message->SaveChanges (KEEP_OPEN_READWRITE);
+              if (hr)
+                log_error_w32 (hr, "%s:%s: SaveChanges failed",
+                               SRCNAME, __func__); 
+              else
+                log_debug ("%s:%s: SaveChanges succeded; body cruft removed",
+                           SRCNAME, __func__); 
+            }
+        }  
+      else
+        log_debug_w32 (hr, "%s:%s: error getting message", 
+                       SRCNAME, __func__);
+     
+      ul_release (message);
+      ul_release (mdb);
+    }
+}
+
+
+
 /* Display some information about MESSAGE.  */
 void
 message_show_info (LPMESSAGE message, HWND hwnd)
@@ -476,9 +537,8 @@
 
 /* Decrypt MESSAGE, check signature and update the attachments as
    required.  MSGTYPE should be the type of the message so that the
-   function can decide what to do.  With FORCE set the verification is
-   done regardlessless of a cached signature result - hmmm, should we
-   such a thing for an encrypted message? */
+   function can decide what to do.  With FORCE set the decryption is
+   done regardless whether it has already been done.  */
 int
 message_decrypt (LPMESSAGE message, msgtype_t msgtype, int force)
 {
@@ -508,6 +568,10 @@
       break;
     }
   
+  if (!force && mapi_test_last_decrypted (message))
+    return 0; /* Already decrypted this message once during this
+                 session.  No need to do it again. */
+
   if (msgtype == MSGTYPE_GPGOL_PGP_MESSAGE)
     {
       /* PGP messages are special:  All is contained in the body and thus

Modified: trunk/src/message.h
===================================================================
--- trunk/src/message.h	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/message.h	2007-11-12 14:19:00 UTC (rev 197)
@@ -23,6 +23,7 @@
 
 bool message_incoming_handler (LPMESSAGE message, msgtype_t msgtype);
 bool message_display_handler (LPEXCHEXTCALLBACK eecb, HWND hwnd);
+void message_wipe_body_cruft (LPEXCHEXTCALLBACK eecb);
 void message_show_info (LPMESSAGE message, HWND hwnd);
 
 

Modified: trunk/src/mimeparser.c
===================================================================
--- trunk/src/mimeparser.c	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/mimeparser.c	2007-11-12 14:19:00 UTC (rev 197)
@@ -559,12 +559,39 @@
 
 
 static int
-finish_message (LPMESSAGE message, gpg_error_t err, 
+finish_message (LPMESSAGE message, gpg_error_t err, int protect_mode, 
                 mimestruct_item_t mimestruct)
 {
   HRESULT hr;
   SPropValue prop;
 
+  /* If this was an encrypted message we save the session marker in a
+     specila property so that we now that we already decrypted that
+     message within this session.  This is pretty useful when
+     scrolling through messages and preview decryption has been
+     enabled.  */
+  if (protect_mode)
+    {
+      char sesmrk[8];
+
+      if (get_gpgollastdecrypted_tag (message, &prop.ulPropTag) )
+        return -1;
+      if (err)
+        memset (sesmrk, 0, 8);
+      else
+        memcpy (sesmrk, get_64bit_session_marker (), 8);
+      prop.Value.bin.cb = 8;
+      prop.Value.bin.lpb = sesmrk;
+      hr = IMessage_SetProps (message, 1, &prop, NULL);
+      if (hr)
+        {
+          log_error ("%s:%s: can't set %s property: hr=%#lx\n",
+                     SRCNAME, __func__, "GpgOL Last Decrypted", hr); 
+          return -1;
+        }
+    }
+
+  /* Store the MIME structure away.  */
   if (get_gpgolmimeinfo_tag (message, &prop.ulPropTag) )
     return -1;
   prop.Value.lpszA = build_mimeinfo (mimestruct);
@@ -1077,7 +1104,7 @@
       rfc822parse_close (ctx->msg);
       gpgme_data_release (ctx->signed_data);
       gpgme_data_release (ctx->sig_data);
-      finish_message (mapi_message, err, ctx->mimestruct);
+      finish_message (mapi_message, err, ctx->protect_mode, ctx->mimestruct);
       while (ctx->mimestruct)
         {
           mimestruct_item_t tmp = ctx->mimestruct->next;
@@ -1193,7 +1220,7 @@
         gpgme_data_release (ctx->signed_data);
       if (ctx->sig_data)
         gpgme_data_release (ctx->sig_data);
-      finish_message (mapi_message, err, ctx->mimestruct);
+      finish_message (mapi_message, err, ctx->protect_mode, ctx->mimestruct);
       while (ctx->mimestruct)
         {
           mimestruct_item_t tmp = ctx->mimestruct->next;

Modified: trunk/src/olflange-dlgs.cpp
===================================================================
--- trunk/src/olflange-dlgs.cpp	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/olflange-dlgs.cpp	2007-11-12 14:19:00 UTC (rev 197)
@@ -44,6 +44,7 @@
   static struct { int itemid; const char *label; } labels[] = {
     { IDC_ENCRYPT_DEFAULT,  N_("&Encrypt new messages by default")},
     { IDC_SIGN_DEFAULT,     N_("&Sign new messages by default")},
+    { IDC_OPENPGP_DEFAULT,  N_("Use OPENPGP by default")},
     { IDC_SMIME_DEFAULT,    N_("Use S/MIME by default")},
     { IDC_ENABLE_SMIME,     N_("Enable the S/MIME support")},
     { IDC_ENCRYPT_WITH_STANDARD_KEY, 
@@ -75,6 +76,8 @@
   BOOL bMsgResult = FALSE;    
   static LPNMHDR pnmhdr;
   static HWND hWndPage;
+  static BOOL openpgp_state = FALSE;
+  static BOOL smime_state = FALSE;
     
   switch (uMsg) 
     {
@@ -106,6 +109,9 @@
 /*             ReleaseDC (hDlg, hdc);	 */
 /*           } */
         
+        openpgp_state = opt.default_protocol = PROTOCOL_OPENPGP;
+        smime_state = opt.default_protocol = PROTOCOL_SMIME;
+
 	EnableWindow (GetDlgItem (hDlg, IDC_ENCRYPT_TO),
                       !!opt.enable_default_key);
         EnableWindow (GetDlgItem (hDlg, IDC_SMIME_DEFAULT), 
@@ -113,6 +119,8 @@
 	if (opt.enable_default_key)
           CheckDlgButton (hDlg, IDC_ENCRYPT_WITH_STANDARD_KEY, BST_CHECKED);
         set_labels (hDlg);
+        ShowWindow (GetDlgItem (hDlg, IDC_GPG_OPTIONS), 
+                    opt.enable_debug? SW_SHOW : SW_HIDE);
       }
       return TRUE;
 
@@ -153,6 +161,7 @@
 	    case IDC_ENCRYPT_WITH_STANDARD_KEY:
 	    case IDC_PREFER_HTML:
 	    case IDC_SIGN_DEFAULT:
+	    case IDC_OPENPGP_DEFAULT:
 	    case IDC_SMIME_DEFAULT:
 	    case IDC_PREVIEW_DECRYPT:
 	    case IDC_ENABLE_SMIME:
@@ -174,7 +183,27 @@
 	  EnableWindow (GetDlgItem (hDlg, IDC_SMIME_DEFAULT), 
                         opt.enable_smime);
 	}
-      if (LOWORD (wParam) == IDC_GPG_OPTIONS)
+      if (HIWORD (wParam) == BN_CLICKED &&
+	  LOWORD (wParam) == IDC_OPENPGP_DEFAULT) 
+	{
+	  openpgp_state = !openpgp_state;
+          if (openpgp_state)
+            {
+              smime_state = 0;
+              SendDlgItemMessage (hDlg, IDC_SMIME_DEFAULT, BM_SETCHECK,0,0L);
+            }
+	}
+      if (HIWORD (wParam) == BN_CLICKED &&
+	  LOWORD (wParam) == IDC_SMIME_DEFAULT) 
+	{
+	  smime_state = !smime_state;
+          if (smime_state)
+            {
+              openpgp_state = 0;
+              SendDlgItemMessage (hDlg, IDC_OPENPGP_DEFAULT, BM_SETCHECK,0,0L);
+            }
+	}
+      if (opt.enable_debug && LOWORD (wParam) == IDC_GPG_OPTIONS)
 	config_dialog_box (hDlg);
       break;
 	
@@ -189,7 +218,7 @@
 	    TCHAR s[30];
 	    
 	    if (opt.default_key && *opt.default_key)		
-		SetDlgItemText (hDlg, IDC_ENCRYPT_TO, opt.default_key);
+                SetDlgItemText (hDlg, IDC_ENCRYPT_TO, opt.default_key);
             else
 		SetDlgItemText (hDlg, IDC_ENCRYPT_TO, "");
 	    wsprintf (s, "%d", opt.passwd_ttl/60);
@@ -202,8 +231,10 @@
 			        !!opt.sign_default, 0L);
 	    SendDlgItemMessage (hDlg, IDC_ENCRYPT_WITH_STANDARD_KEY,
                                 BM_SETCHECK, opt.enable_default_key, 0L);
-	    SendDlgItemMessage (hDlg, IDC_SMIME_DEFAULT, BM_SETCHECK, 
-				!!opt.smime_default, 0L);
+            SendDlgItemMessage (hDlg, IDC_OPENPGP_DEFAULT, BM_SETCHECK, 
+                                openpgp_state, 0L);
+            SendDlgItemMessage (hDlg, IDC_SMIME_DEFAULT, BM_SETCHECK, 
+                                smime_state, 0L);
 	    SendDlgItemMessage (hDlg, IDC_ENABLE_SMIME, BM_SETCHECK,
 				!!opt.enable_smime, 0L);
 	    SendDlgItemMessage (hDlg, IDC_PREVIEW_DECRYPT, BM_SETCHECK,
@@ -254,8 +285,14 @@
             "provided when GpgOL arrives at production quality status."),
                             "GpgOL", MB_ICONWARNING|MB_OK);
               }
-	    opt.smime_default = !!SendDlgItemMessage
-              (hDlg, IDC_SMIME_DEFAULT, BM_GETCHECK, 0, 0L);
+
+	    if (openpgp_state)
+              opt.default_protocol = PROTOCOL_OPENPGP;
+	    else if (smime_state && opt.enable_smime)
+              opt.default_protocol = PROTOCOL_SMIME;
+            else
+              opt.default_protocol = PROTOCOL_UNKNOWN;
+            
             opt.preview_decrypt = !!SendDlgItemMessage
               (hDlg, IDC_PREVIEW_DECRYPT, BM_GETCHECK, 0, 0L);
             opt.prefer_html = !!SendDlgItemMessage

Modified: trunk/src/olflange.cpp
===================================================================
--- trunk/src/olflange.cpp	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/olflange.cpp	2007-11-12 14:19:00 UTC (rev 197)
@@ -287,7 +287,7 @@
   m_lRef = 1;
   m_lContext = 0;
   m_hWndExchange = 0;
-  m_gpgSelectSmime = FALSE;
+  m_protoSelection = PROTOCOL_UNKNOWN;
   m_gpgEncrypt = FALSE;
   m_gpgSign = FALSE;
   msgtype = MSGTYPE_UNKNOWN;
@@ -299,19 +299,19 @@
   m_pExchExtMessageEvents      = new GpgolMessageEvents (this);
   m_pExchExtAttachedFileEvents = new GpgolAttachedFileEvents (this);
   m_pExchExtPropertySheets     = new GpgolPropertySheets (this);
-  m_pOutlookExtItemEvents      = new GpgolItemEvents (this);
+//   m_pOutlookExtItemEvents      = new GpgolItemEvents (this);
   if (!m_pExchExtCommands
       || !m_pExchExtUserEvents
       || !m_pExchExtSessionEvents
       || !m_pExchExtMessageEvents
       || !m_pExchExtAttachedFileEvents
       || !m_pExchExtPropertySheets
-      || !m_pOutlookExtItemEvents)
+      /*|| !m_pOutlookExtItemEvents*/)
     out_of_core ();
 
   /* For this class we need to bump the reference counter intially.
      The question is why it works at all with the other stuff.  */
-  m_pOutlookExtItemEvents->AddRef ();
+//   m_pOutlookExtItemEvents->AddRef ();
 
   if (!g_initdll)
     {
@@ -330,8 +330,8 @@
   log_debug ("%s:%s: cleaning up GpgolExt object; context=%s\n",
              SRCNAME, __func__, ext_context_name (m_lContext));
     
-  if (m_pOutlookExtItemEvents)
-    m_pOutlookExtItemEvents->Release ();
+//   if (m_pOutlookExtItemEvents)
+//     m_pOutlookExtItemEvents->Release ();
 
   if (m_lContext == EECONTEXT_SESSION)
     {
@@ -394,10 +394,10 @@
 	return E_NOINTERFACE;
       *ppvObj = (LPUNKNOWN) m_pExchExtPropertySheets;
     }
-  else if (riid == IID_IOutlookExtItemEvents)
-    {
-      *ppvObj = (LPUNKNOWN)m_pOutlookExtItemEvents;
-    }  
+//   else if (riid == IID_IOutlookExtItemEvents)
+//     {
+//       *ppvObj = (LPUNKNOWN)m_pOutlookExtItemEvents;
+//     }  
   else
     hr = E_NOINTERFACE;
   

Modified: trunk/src/olflange.h
===================================================================
--- trunk/src/olflange.h	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/olflange.h	2007-11-12 14:19:00 UTC (rev 197)
@@ -39,7 +39,7 @@
   HWND m_hWndExchange;  /* Handle of the exchange window. */
 
   /* Parameters for sending mails.  */
-  BOOL  m_gpgSelectSmime;
+  protocol_t  m_protoSelection;
   BOOL  m_gpgEncrypt;
   BOOL  m_gpgSign;
   

Modified: trunk/src/util.h
===================================================================
--- trunk/src/util.h	2007-11-08 08:13:59 UTC (rev 196)
+++ trunk/src/util.h	2007-11-12 14:19:00 UTC (rev 197)
@@ -69,6 +69,7 @@
 
 /*-- main.c --*/
 const void *get_128bit_session_key (void);
+const void *get_64bit_session_marker (void);
 void *create_initialization_vector (size_t nbytes);
 
 void log_debug (const char *fmt, ...) __attribute__ ((format (printf,1,2)));




More information about the Gnupg-commits mailing list