See ChangeLog.
authorTimo Schulz <twoaday@freakmail.de>
Tue, 20 Sep 2005 11:35:31 +0000 (11:35 +0000)
committerTimo Schulz <twoaday@freakmail.de>
Tue, 20 Sep 2005 11:35:31 +0000 (11:35 +0000)
15 files changed:
src/ChangeLog
src/Makefile.am
src/attach.cpp [new file with mode: 0644]
src/attach.h [new file with mode: 0644]
src/gpgmsg.cpp
src/intern.h
src/myexchext.h
src/olflange-def.h
src/olflange.cpp
src/olflange.h
src/passphrase-dialog.c
src/recipient-dialog.c
src/rfc822parse.c
src/verify-dialog.c
src/watcher.cpp

index 80844ef..4209c4b 100644 (file)
@@ -1,19 +1,29 @@
+2005-09-20  Timo Schulz  <ts@g10code.com>
+
+       * attach.c: New.
+       * attach.h: New.
+       * olflange.cpp (CGPGExchExt): Allocate class for
+       attached file events.
+       (QueryInterface): Return interface pointer for
+       attached file events.
+       * passphrase-dialog.c (load_secbox): Use new GPGME
+       interface.
+       (get_pubkey_algo_str): New.
+       * verify-dialog.c (load_sigbox): Likewise.
+       * recipient-dialog.c (load_recipbox): Likewise.
+
 2005-09-19  Werner Koch  <wk@g10code.com>
 
        * msgcache.c (flush_if_needed): New.
        (msgcache_put): use it.
-
        * intern.h (opt): New compatibility flags AUTO_DECRYPT and
        NO_ATTESTATION.
        * olflange.cpp (InstallCommands): Use watcher stuff only when this
        option has been enabled.
        * gpgmsg.cpp (decrypt): Take care of NO_ATTESTATION.
-
        * main.c (DllMain): Removed debug output; this should not be
        used before initialization!
-
        * watcher.cpp: Include config.h.  Removed weird line endings.
-
        * gpgmsg.cpp (encrypt_and_sign): Call SaveChanges.
 
 2005-09-15  Timo Schulz  <ts@g10code.com>
index b8fd88d..99d1f6b 100644 (file)
@@ -43,7 +43,8 @@ gpgol_SOURCES = \
         verify-dialog.c             \
        mymapi.h  mymapitags.h      \
         vasprintf.c                 \
-       watcher.cpp
+       watcher.cpp \
+       attach.cpp attach.h
 
 gpgol_LDADD = gpgol.def  \
                $(GPGME_LIBS) mapi32.dll -lshell32 -lgdi32 -lcomdlg32
diff --git a/src/attach.cpp b/src/attach.cpp
new file mode 100644 (file)
index 0000000..5d89e45
--- /dev/null
@@ -0,0 +1,57 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <windows.h>
+
+#include "mymapi.h"
+#include "mymapitags.h"
+#include "myexchext.h"
+#include "olflange-def.h"
+#include "olflange.h"
+#include "attach.h"
+#include "util.h"
+
+
+STDMETHODIMP 
+CGPGExchExtAttachedFileEvents::OnReadPattFromSzFile 
+  (LPATTACH att, LPTSTR lpszFile, ULONG ulFlags)
+{
+  log_debug ("%s: att=%p lpszFile=%s ulFlags=%lx\n", 
+            __func__, att, lpszFile, ulFlags);
+  return S_FALSE;
+}
+  
+
+STDMETHODIMP 
+CGPGExchExtAttachedFileEvents::OnWritePattToSzFile 
+  (LPATTACH att, LPTSTR lpszFile, ULONG ulFlags)
+{
+  log_debug ("%s: att=%p lpszFile=%s ulFlags=%lx\n",
+            __func__, att, lpszFile, ulFlags);
+  return S_FALSE;
+}
+
+
+STDMETHODIMP
+CGPGExchExtAttachedFileEvents::QueryDisallowOpenPatt (LPATTACH att)
+{
+  log_debug ("%s: att=%p\n", __func__, att);
+  return S_FALSE;
+}
+
+
+STDMETHODIMP 
+CGPGExchExtAttachedFileEvents::OnOpenPatt (LPATTACH att)
+{
+  log_debug ("%s: att=%p\n", __func__, att);
+  return S_FALSE;
+}
+
+
+
+STDMETHODIMP 
+CGPGExchExtAttachedFileEvents::OnOpenSzFile (LPTSTR lpszFile, ULONG ulFlags)
+{
+  log_debug ("%s: lpszFile=%s ulflags=%lx\n", __func__, lpszFile, ulFlags);
+  return S_FALSE;
+}
diff --git a/src/attach.h b/src/attach.h
new file mode 100644 (file)
index 0000000..cd1e139
--- /dev/null
@@ -0,0 +1,64 @@
+
+#ifndef ATTACH_H
+#define ATTACH_H
+
+#include "util.h"
+
+class CGPGExchExtAttachedFileEvents : public IExchExtAttachedFileEvents
+{
+private:
+  CGPGExchExt *m_pExchExt;
+  ULONG        m_ref;
+
+public:
+  CGPGExchExtAttachedFileEvents (CGPGExchExt *pParentInterface)
+    {
+      m_pExchExt = pParentInterface;
+      m_ref = 0;
+    }
+  
+  
+  inline STDMETHODIMP_(ULONG) AddRef (void)
+    {
+      ++m_ref;
+      return m_ref;
+    }
+  
+  inline STDMETHODIMP_(ULONG) Release (void)
+    {
+      ULONG count = --m_ref;
+      if (!count)
+       delete this;
+      return count;
+    }
+  
+  STDMETHODIMP QueryInterface (REFIID riid, LPVOID FAR *ppvObj)
+    {
+      *ppvObj = NULL;
+      if (riid == IID_IExchExtAttachedFileEvents)
+       {
+         *ppvObj = (LPVOID)this;
+         AddRef ();
+         return S_OK;
+       }
+      
+      if (riid == IID_IUnknown)
+       {
+         *ppvObj = (LPVOID)m_pExchExt;
+         m_pExchExt->AddRef ();
+         return S_OK;
+       }
+      log_debug ("%s: request for unknown interface\n", __func__);
+      return E_NOINTERFACE;
+    }
+  
+  STDMETHODIMP OnReadPattFromSzFile (LPATTACH att, LPTSTR lpszFile, 
+                                    ULONG ulFlags);
+  STDMETHODIMP OnWritePattToSzFile (LPATTACH att, LPTSTR lpszFile, 
+                                   ULONG ulFlags);
+  STDMETHODIMP QueryDisallowOpenPatt (LPATTACH att);
+  STDMETHODIMP OnOpenPatt (LPATTACH att);
+  STDMETHODIMP OnOpenSzFile (LPTSTR lpszFile, ULONG ulFlags);
+};
+
+#endif /*ATTACH_H*/
index ee2a684..4b79752 100644 (file)
@@ -1342,7 +1342,6 @@ GpgMsgImpl::encrypt_and_sign (HWND hwnd, bool sign_flag)
         }
     }
 
-
  leave:
   /* FIXME: What to do with already encrypted attachments if some of
      the encrypted (or other operations) failed? */
index 343025c..1fefa61 100644 (file)
@@ -139,6 +139,7 @@ gpgme_error_t passphrase_callback_box (void *opaque, const char *uid_hint,
                             const char *pass_info,
                             int prev_was_bad, int fd);
 void free_decrypt_key (struct decrypt_key_s * ctx);
+const char *get_pubkey_algo_str (gpgme_pubkey_algo_t id);
 
 /*-- config-dialog.c --*/
 void config_dialog_box (HWND parent);
index 9fa2822..a2aabf1 100644 (file)
-/* myexchext.h - Simple replacement for exchext.h
-
- * This file defines the interface used by Exchange extensions.  It
- * has been compiled by g10 Code GmbH from several sources describing
- * the interface.
- *
- * Revisions:
- * 2005-08-12  Initial version.
- *
- */
-
-#ifndef EXCHEXT_H
-#define EXCHEXT_H
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-}
-#endif
-#endif
-
-#include <commctrl.h>
-#include <unknwn.h>
-#include "mymapi.h"
-
-
-/* Constants used by Install. */
-#define EECONTEXT_SESSION               0x00000001
-#define EECONTEXT_VIEWER                0x00000002
-#define EECONTEXT_REMOTEVIEWER          0x00000003
-#define EECONTEXT_SEARCHVIEWER          0x00000004
-#define EECONTEXT_ADDRBOOK              0x00000005
-#define EECONTEXT_SENDNOTEMESSAGE       0x00000006
-#define EECONTEXT_READNOTEMESSAGE       0x00000007
-#define EECONTEXT_SENDPOSTMESSAGE       0x00000008
-#define EECONTEXT_READPOSTMESSAGE       0x00000009
-#define EECONTEXT_READREPORTMESSAGE     0x0000000A
-#define EECONTEXT_SENDRESENDMESSAGE     0x0000000B
-#define EECONTEXT_PROPERTYSHEETS        0x0000000C
-#define EECONTEXT_ADVANCEDCRITERIA      0x0000000D
-#define EECONTEXT_TASK                  0x0000000E
-
-/* Constants for GetVersion. */
-#define EECBGV_GETBUILDVERSION          0x00000001
-#define EECBGV_GETACTUALVERSION         0x00000002
-#define EECBGV_GETVIRTUALVERSION        0x00000004
-#define EECBGV_BUILDVERSION_MAJOR       0x000d0000
-#define EECBGV_BUILDVERSION_MAJOR_MASK  0xffff0000
-#define EECBGV_BUILDVERSION_MINOR_MASK  0x0000ffff
-
-/* Some toolbar IDs. */
-#define EETBID_STANDARD                 0x00000001
-
-/* Constants use for QueryHelpText. */
-#define EECQHT_STATUS                   0x00000001
-#define EECQHT_TOOLTIP                  0x00000002
-
-/* Flags use by the methods of IExchExtPropertySheets.  */
-#define EEPS_MESSAGE                    0x00000001
-#define EEPS_FOLDER                     0x00000002
-#define EEPS_STORE                      0x00000003
-#define EEPS_TOOLSOPTIONS               0x00000004
-
-/* Flags used by OnFooComplete. */
-#define EEME_FAILED                     0x00000001
-#define EEME_COMPLETE_FAILED            0x00000002
-
-
-/* Command IDs. */
-#define EECMDID_ToolsCustomizeToolbar          134
-#define EECMDID_ToolsOptions                   136
-
-
-/* GUIDs */
-DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
-DEFINE_OLEGUID(IID_IUnknown,                  0x00000000, 0, 0);
-DEFINE_OLEGUID(IID_IDispatch,                 0x00020400, 0, 0);
-
-DEFINE_OLEGUID(IID_IExchExtCallback,          0x00020d10, 0, 0);
-DEFINE_OLEGUID(IID_IExchExt,                  0x00020d11, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtCommands,          0x00020d12, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtUserEvents,        0x00020d13, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtSessionEvents,     0x00020d14, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtMessageEvents,     0x00020d15, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtAttachedFileEvents,0x00020d16, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtPropertySheets,    0x00020d17, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtAdvancedCriteria,  0x00020d18, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtModeless,          0x00020d19, 0, 0);
-DEFINE_OLEGUID(IID_IExchExtModelessCallback,  0x00020d1a, 0, 0);
-DEFINE_OLEGUID(IID_IOutlookExtCallback,       0x0006720d, 0, 0);
-
-
-/* Type definitions. */
-
-/* Parameters for the toolbar entries for
-   IExchExtCommands::InstallCommands. */
-struct TBENTRY
-{
-  HWND hwnd;
-  ULONG tbid;
-  ULONG ulFlags;
-  UINT itbbBase;
-};
-typedef struct TBENTRY TBENTRY;
-typedef struct TBENTRY *LPTBENTRY;
-
-
-
-
-
-\f
-/**** Class declarations.  ***/
-typedef struct IExchExt IExchExt;
-typedef IExchExt *LPEXCHEXT;
-
-typedef struct IExchExtMessageEvents IExchExtMessageEvents;
-typedef IExchExtMessageEvents *LPEXCHEXTMESSAGEEVENTS;
-
-typedef struct IExchExtCommands IExchExtCommands;
-typedef IExchExtCommands *LPEXCHEXTCOMMANDS;
-
-typedef struct IExchExtPropertySheets IExchExtPropertySheets;
-typedef IExchExtPropertySheets *LPEXCHEXTPROPERTYSHEETS;
-
-typedef struct IExchExtCallback IExchExtCallback;
-typedef IExchExtCallback *LPEXCHEXTCALLBACK;
-
-typedef struct IOutlookExtCallback IOutlookExtCallback;
-typedef IOutlookExtCallback *LPOUTLOOKEXTCALLBACK;
-
-/* The next classes are not yet defined. but if so they should go here. */
-typedef struct IExchExtModeless IExchExtModeless; 
-typedef IExchExtModeless *LPEXCHEXTMODELESS;
-typedef struct IExchExtModelessCallback IExchExtModelessCallback;
-typedef IExchExtModelessCallback *LPEXCHEXTMODELESSCALLBACK;
-
-
-
-
-/*** Class declarations of classes defined elsewhere. ***/
-struct IMAPISession;
-typedef struct IMAPISession *LPMAPISESSION;
-
-struct IAddrBook;
-typedef struct IAddrBook *LPADRBOOK;
-
-struct IMAPIFolder;
-typedef struct IMAPIFolder *LPMAPIFOLDER;
-
-struct IMAPIProp;
-typedef struct IMAPIProp *LPMAPIPROP;
-
-struct IPersistMessage;
-typedef struct IPersistMessage *LPPERSISTMESSAGE;
-
-struct IMAPIMessageSite;
-typedef struct IMAPIMessageSite *LPMAPIMESSAGESITE;
-
-struct IMAPIViewContext;
-typedef struct IMAPIViewContext *LPMAPIVIEWCONTEXT;
-
-
-
-/*** Types derived from the above class definitions. ***/
-
-/* Callback used to load an extension. */
-typedef LPEXCHEXT (CALLBACK *LPFNEXCHEXTENTRY)(void);
-
-/* Parameters for the IExchExtCallback::ChooseFolder. */
-typedef UINT (STDAPICALLTYPE *LPEECFHOOKPROC)(HWND, UINT, WPARAM, LPARAM);
-
-struct EXCHEXTCHOOSEFOLDER
-{
-  UINT cbLength;
-  HWND hwnd;
-  LPTSTR szCaption;
-  LPTSTR szLabel;
-  LPTSTR szHelpFile;
-  ULONG ulHelpID;
-  HINSTANCE hinst;
-  UINT uiDlgID;
-  LPEECFHOOKPROC lpeecfhp;
-  DWORD dwHookData;
-  ULONG ulFlags;
-  LPMDB pmdb;
-  LPMAPIFOLDER pfld;
-  LPTSTR szName;
-  DWORD dwReserved1;
-  DWORD dwReserved2;
-  DWORD dwReserved3;
-};
-typedef struct EXCHEXTCHOOSEFOLDER EXCHEXTCHOOSEFOLDER;
-typedef struct EXCHEXTCHOOSEFOLDER *LPEXCHEXTCHOOSEFOLDER;
-
-
-
-
-/**** Class definitions.  ***/
-
-EXTERN_C const IID IID_IExchExt;
-#undef INTERFACE
-#define INTERFACE IExchExt
-DECLARE_INTERFACE_(IExchExt, IUnknown)
-{
-  /*** IUnknown methods. ***/
-  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;
-  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-  STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-  /*** IExchExt methods. ***/
-  STDMETHOD(Install)(THIS_ LPEXCHEXTCALLBACK, ULONG, ULONG) PURE;
-};
-
-
-
-EXTERN_C const IID IID_IExchExtMessageEvents;
-#undef INTERFACE
-#define INTERFACE IExchExtMessageEvents
-DECLARE_INTERFACE_(IExchExtMessageEvents, IUnknown)
-{
-  /*** IUnknown methods. ***/
-  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;
-  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-  STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-  /*** IExchExtMessageEvents methods. ***/
-  STDMETHOD(OnRead)(THIS_ LPEXCHEXTCALLBACK) PURE;
-  STDMETHOD(OnReadComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;
-  STDMETHOD(OnWrite)(THIS_ LPEXCHEXTCALLBACK) PURE;
-  STDMETHOD(OnWriteComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;
-  STDMETHOD(OnCheckNames)(THIS_ LPEXCHEXTCALLBACK) PURE;
-  STDMETHOD(OnCheckNamesComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;
-  STDMETHOD(OnSubmit)(THIS_ LPEXCHEXTCALLBACK) PURE;
-  STDMETHOD_(void, OnSubmitComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;
-};
-
-
-
-EXTERN_C const IID IID_IExchExtCommands;
-#undef INTERFACE
-#define INTERFACE IExchExtCommands
-DECLARE_INTERFACE_(IExchExtCommands, IUnknown)
-{
-  /*** IUnknown methods. ***/
-  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;
-  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-  STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-  /*** IExchExtCommands methods. ***/
-  STDMETHOD(InstallCommands)(THIS_ LPEXCHEXTCALLBACK, HWND, HMENU,
-                             UINT*, LPTBENTRY, UINT, ULONG) PURE;
-  STDMETHOD_(void, InitMenu)(THIS_ LPEXCHEXTCALLBACK) PURE;
-  STDMETHOD(DoCommand)(THIS_ LPEXCHEXTCALLBACK, UINT) PURE;
-  STDMETHOD(Help)(THIS_ LPEXCHEXTCALLBACK, UINT) PURE;
-  STDMETHOD(QueryHelpText)(THIS_ UINT, ULONG, LPTSTR, UINT) PURE;
-  STDMETHOD(QueryButtonInfo)(THIS_ ULONG, UINT, LPTBBUTTON,
-                             LPTSTR, UINT, ULONG) PURE;
-  STDMETHOD(ResetToolbar)(THIS_ ULONG, ULONG) PURE;
-};
-
-
-
-EXTERN_C const IID IID_IExchExtPropertySheets;
-#undef INTERFACE
-#define INTERFACE IExchExtPropertySheets
-DECLARE_INTERFACE_(IExchExtPropertySheets, IUnknown)
-{
-  /*** IUnknown methods. ***/
-  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;
-  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-  STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-  /*** IExchExtPropertySheet methods. ***/
-  STDMETHOD_(ULONG, GetMaxPageCount)(THIS_ ULONG) PURE;
-  STDMETHOD(GetPages)(THIS_ LPEXCHEXTCALLBACK, ULONG,
-                      LPPROPSHEETPAGE, ULONG*) PURE;
-  STDMETHOD_(void, FreePages)(THIS_ LPPROPSHEETPAGE, ULONG, ULONG) PURE;
-};
-
-
-
-EXTERN_C const IID IID_IExchExtCallback;
-#undef INTERFACE
-#define INTERFACE IExchExtCallback
-DECLARE_INTERFACE_(IExchExtCallback, IUnknown)
-{
-  /*** IUnknown methods. ***/
-  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;
-  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-  STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-  /*** IExchExtCallback methods. ***/
-  STDMETHOD(GetVersion)(THIS_ ULONG*, ULONG) PURE;
-  STDMETHOD(GetWindow)(THIS_ HWND*) PURE;
-  STDMETHOD(GetMenu)(THIS_ HMENU*) PURE;
-  STDMETHOD(GetToolbar)(THIS_ ULONG, HWND*) PURE;
-  STDMETHOD(GetSession)(THIS_ LPMAPISESSION*, LPADRBOOK*) PURE;
-  STDMETHOD(GetObject)(THIS_ LPMDB*, LPMAPIPROP*) PURE;
-  STDMETHOD(GetSelectionCount)(THIS_ ULONG*) PURE;
-  STDMETHOD(GetSelectionItem)(THIS_ ULONG, ULONG*, LPENTRYID*, ULONG*,
-                              LPTSTR, ULONG, ULONG*, ULONG) PURE;
-  STDMETHOD(GetMenuPos)(THIS_ ULONG, HMENU*, ULONG*, ULONG*, ULONG) PURE;
-  STDMETHOD(GetSharedExtsDir)(THIS_ LPTSTR, ULONG, ULONG) PURE;
-  STDMETHOD(GetRecipients)(THIS_ LPADRLIST*) PURE;
-  STDMETHOD(SetRecipients)(THIS_ LPADRLIST) PURE;
-  STDMETHOD(GetNewMessageSite)(THIS_ ULONG, LPMAPIFOLDER, LPPERSISTMESSAGE,
-                               LPMESSAGE*, LPMAPIMESSAGESITE*,
-                               LPMAPIVIEWCONTEXT*, ULONG) PURE;
-  STDMETHOD(RegisterModeless)(THIS_ LPEXCHEXTMODELESS,
-                              LPEXCHEXTMODELESSCALLBACK*) PURE;
-  STDMETHOD(ChooseFolder)(THIS_ LPEXCHEXTCHOOSEFOLDER) PURE;
-};
-
-
-
-EXTERN_C const IID IID_IOutlookExtCallback;
-#undef INTERFACE
-#define INTERFACE IOutlookExtCallback
-DECLARE_INTERFACE_(IOutlookExtCallback, IUnknown)
-{
-  /*** IUnknown methods. ***/
-  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;
-  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-  STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-  /*** IOutlookExtCallback.  **/
-  STDMETHOD(GetObject)(LPUNKNOWN *ppunk);
-  STDMETHOD(GetOfficeCharacter)(void **ppmsotfc);
-};
-
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif /*EXCHEXT_H*/
+/* myexchext.h - Simple replacement for exchext.h\r
+\r
+ * This file defines the interface used by Exchange extensions.  It\r
+ * has been compiled by g10 Code GmbH from several sources describing\r
+ * the interface.\r
+ *\r
+ * Revisions:\r
+ * 2005-08-12  Initial version.\r
+ * 2005-09-18  Add IExchExtAttachedFileEvents.\r
+ *\r
+ */\r
+\r
+#ifndef EXCHEXT_H\r
+#define EXCHEXT_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#if 0\r
+}\r
+#endif\r
+#endif\r
+\r
+#include <commctrl.h>\r
+#include <unknwn.h>\r
+#include "mymapi.h"\r
+\r
+\r
+/* Constants used by Install. */\r
+#define EECONTEXT_SESSION               0x00000001\r
+#define EECONTEXT_VIEWER                0x00000002\r
+#define EECONTEXT_REMOTEVIEWER          0x00000003\r
+#define EECONTEXT_SEARCHVIEWER          0x00000004\r
+#define EECONTEXT_ADDRBOOK              0x00000005\r
+#define EECONTEXT_SENDNOTEMESSAGE       0x00000006\r
+#define EECONTEXT_READNOTEMESSAGE       0x00000007\r
+#define EECONTEXT_SENDPOSTMESSAGE       0x00000008\r
+#define EECONTEXT_READPOSTMESSAGE       0x00000009\r
+#define EECONTEXT_READREPORTMESSAGE     0x0000000A\r
+#define EECONTEXT_SENDRESENDMESSAGE     0x0000000B\r
+#define EECONTEXT_PROPERTYSHEETS        0x0000000C\r
+#define EECONTEXT_ADVANCEDCRITERIA      0x0000000D\r
+#define EECONTEXT_TASK                  0x0000000E\r
+\r
+/* Constants for GetVersion. */\r
+#define EECBGV_GETBUILDVERSION          0x00000001\r
+#define EECBGV_GETACTUALVERSION         0x00000002\r
+#define EECBGV_GETVIRTUALVERSION        0x00000004\r
+#define EECBGV_BUILDVERSION_MAJOR       0x000d0000\r
+#define EECBGV_BUILDVERSION_MAJOR_MASK  0xffff0000\r
+#define EECBGV_BUILDVERSION_MINOR_MASK  0x0000ffff\r
+\r
+/* Some toolbar IDs. */\r
+#define EETBID_STANDARD                 0x00000001\r
+\r
+/* Constants use for QueryHelpText. */\r
+#define EECQHT_STATUS                   0x00000001\r
+#define EECQHT_TOOLTIP                  0x00000002\r
+\r
+/* Flags use by the methods of IExchExtPropertySheets.  */\r
+#define EEPS_MESSAGE                    0x00000001\r
+#define EEPS_FOLDER                     0x00000002\r
+#define EEPS_STORE                      0x00000003\r
+#define EEPS_TOOLSOPTIONS               0x00000004\r
+\r
+/* Flags used by OnFooComplete. */\r
+#define EEME_FAILED                     0x00000001\r
+#define EEME_COMPLETE_FAILED            0x00000002\r
+\r
+\r
+/* Command IDs. */\r
+#define EECMDID_ToolsCustomizeToolbar          134\r
+#define EECMDID_ToolsOptions                   136\r
+\r
+\r
+/* GUIDs */\r
+DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\r
+\r
+DEFINE_OLEGUID(IID_IUnknown,                  0x00000000, 0, 0);\r
+DEFINE_OLEGUID(IID_IDispatch,                 0x00020400, 0, 0);\r
+\r
+DEFINE_OLEGUID(IID_IExchExtCallback,          0x00020d10, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExt,                  0x00020d11, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtCommands,          0x00020d12, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtUserEvents,        0x00020d13, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtSessionEvents,     0x00020d14, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtMessageEvents,     0x00020d15, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtAttachedFileEvents,0x00020d16, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtPropertySheets,    0x00020d17, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtAdvancedCriteria,  0x00020d18, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtModeless,          0x00020d19, 0, 0);\r
+DEFINE_OLEGUID(IID_IExchExtModelessCallback,  0x00020d1a, 0, 0);\r
+DEFINE_OLEGUID(IID_IOutlookExtCallback,       0x0006720d, 0, 0);\r
+\r
+\r
+/* Type definitions. */\r
+\r
+/* Parameters for the toolbar entries for\r
+   IExchExtCommands::InstallCommands. */\r
+struct TBENTRY\r
+{\r
+  HWND hwnd;\r
+  ULONG tbid;\r
+  ULONG ulFlags;\r
+  UINT itbbBase;\r
+};\r
+typedef struct TBENTRY TBENTRY;\r
+typedef struct TBENTRY *LPTBENTRY;\r
+\r
+\r
+\r
+\r
+\r
+\f\r
+/**** Class declarations.  ***/\r
+typedef struct IExchExt IExchExt;\r
+typedef IExchExt *LPEXCHEXT;\r
+\r
+typedef struct IExchExtMessageEvents IExchExtMessageEvents;\r
+typedef IExchExtMessageEvents *LPEXCHEXTMESSAGEEVENTS;\r
+\r
+typedef struct IExchExtCommands IExchExtCommands;\r
+typedef IExchExtCommands *LPEXCHEXTCOMMANDS;\r
+\r
+typedef struct IExchExtPropertySheets IExchExtPropertySheets;\r
+typedef IExchExtPropertySheets *LPEXCHEXTPROPERTYSHEETS;\r
+\r
+typedef struct IExchExtCallback IExchExtCallback;\r
+typedef IExchExtCallback *LPEXCHEXTCALLBACK;\r
+\r
+typedef struct IOutlookExtCallback IOutlookExtCallback;\r
+typedef IOutlookExtCallback *LPOUTLOOKEXTCALLBACK;\r
+\r
+/* The next classes are not yet defined. but if so they should go here. */\r
+typedef struct IExchExtModeless IExchExtModeless; \r
+typedef IExchExtModeless *LPEXCHEXTMODELESS;\r
+typedef struct IExchExtModelessCallback IExchExtModelessCallback;\r
+typedef IExchExtModelessCallback *LPEXCHEXTMODELESSCALLBACK;\r
+\r
+\r
+\r
+\r
+/*** Class declarations of classes defined elsewhere. ***/\r
+struct IMAPISession;\r
+typedef struct IMAPISession *LPMAPISESSION;\r
+\r
+struct IAddrBook;\r
+typedef struct IAddrBook *LPADRBOOK;\r
+\r
+struct IMAPIFolder;\r
+typedef struct IMAPIFolder *LPMAPIFOLDER;\r
+\r
+struct IMAPIProp;\r
+typedef struct IMAPIProp *LPMAPIPROP;\r
+\r
+struct IPersistMessage;\r
+typedef struct IPersistMessage *LPPERSISTMESSAGE;\r
+\r
+struct IMAPIMessageSite;\r
+typedef struct IMAPIMessageSite *LPMAPIMESSAGESITE;\r
+\r
+struct IMAPIViewContext;\r
+typedef struct IMAPIViewContext *LPMAPIVIEWCONTEXT;\r
+\r
+\r
+\r
+/*** Types derived from the above class definitions. ***/\r
+\r
+/* Callback used to load an extension. */\r
+typedef LPEXCHEXT (CALLBACK *LPFNEXCHEXTENTRY)(void);\r
+\r
+/* Parameters for the IExchExtCallback::ChooseFolder. */\r
+typedef UINT (STDAPICALLTYPE *LPEECFHOOKPROC)(HWND, UINT, WPARAM, LPARAM);\r
+\r
+struct EXCHEXTCHOOSEFOLDER\r
+{\r
+  UINT cbLength;\r
+  HWND hwnd;\r
+  LPTSTR szCaption;\r
+  LPTSTR szLabel;\r
+  LPTSTR szHelpFile;\r
+  ULONG ulHelpID;\r
+  HINSTANCE hinst;\r
+  UINT uiDlgID;\r
+  LPEECFHOOKPROC lpeecfhp;\r
+  DWORD dwHookData;\r
+  ULONG ulFlags;\r
+  LPMDB pmdb;\r
+  LPMAPIFOLDER pfld;\r
+  LPTSTR szName;\r
+  DWORD dwReserved1;\r
+  DWORD dwReserved2;\r
+  DWORD dwReserved3;\r
+};\r
+typedef struct EXCHEXTCHOOSEFOLDER EXCHEXTCHOOSEFOLDER;\r
+typedef struct EXCHEXTCHOOSEFOLDER *LPEXCHEXTCHOOSEFOLDER;\r
+\r
+\r
+\r
+\r
+/**** Class definitions.  ***/\r
+\r
+EXTERN_C const IID IID_IExchExt;\r
+#undef INTERFACE\r
+#define INTERFACE IExchExt\r
+DECLARE_INTERFACE_(IExchExt, IUnknown)\r
+{\r
+  /*** IUnknown methods. ***/\r
+  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;\r
+  STDMETHOD_(ULONG, AddRef)(THIS) PURE;\r
+  STDMETHOD_(ULONG, Release)(THIS) PURE;\r
+\r
+  /*** IExchExt methods. ***/\r
+  STDMETHOD(Install)(THIS_ LPEXCHEXTCALLBACK, ULONG, ULONG) PURE;\r
+};\r
+\r
+\r
+\r
+EXTERN_C const IID IID_IExchExtMessageEvents;\r
+#undef INTERFACE\r
+#define INTERFACE IExchExtMessageEvents\r
+DECLARE_INTERFACE_(IExchExtMessageEvents, IUnknown)\r
+{\r
+  /*** IUnknown methods. ***/\r
+  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;\r
+  STDMETHOD_(ULONG, AddRef)(THIS) PURE;\r
+  STDMETHOD_(ULONG, Release)(THIS) PURE;\r
+\r
+  /*** IExchExtMessageEvents methods. ***/\r
+  STDMETHOD(OnRead)(THIS_ LPEXCHEXTCALLBACK) PURE;\r
+  STDMETHOD(OnReadComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;\r
+  STDMETHOD(OnWrite)(THIS_ LPEXCHEXTCALLBACK) PURE;\r
+  STDMETHOD(OnWriteComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;\r
+  STDMETHOD(OnCheckNames)(THIS_ LPEXCHEXTCALLBACK) PURE;\r
+  STDMETHOD(OnCheckNamesComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;\r
+  STDMETHOD(OnSubmit)(THIS_ LPEXCHEXTCALLBACK) PURE;\r
+  STDMETHOD_(void, OnSubmitComplete)(THIS_ LPEXCHEXTCALLBACK, ULONG) PURE;\r
+};\r
+\r
+\r
+\r
+EXTERN_C const IID IID_IExchExtCommands;\r
+#undef INTERFACE\r
+#define INTERFACE IExchExtCommands\r
+DECLARE_INTERFACE_(IExchExtCommands, IUnknown)\r
+{\r
+  /*** IUnknown methods. ***/\r
+  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;\r
+  STDMETHOD_(ULONG, AddRef)(THIS) PURE;\r
+  STDMETHOD_(ULONG, Release)(THIS) PURE;\r
+\r
+  /*** IExchExtCommands methods. ***/\r
+  STDMETHOD(InstallCommands)(THIS_ LPEXCHEXTCALLBACK, HWND, HMENU,\r
+                             UINT*, LPTBENTRY, UINT, ULONG) PURE;\r
+  STDMETHOD_(void, InitMenu)(THIS_ LPEXCHEXTCALLBACK) PURE;\r
+  STDMETHOD(DoCommand)(THIS_ LPEXCHEXTCALLBACK, UINT) PURE;\r
+  STDMETHOD(Help)(THIS_ LPEXCHEXTCALLBACK, UINT) PURE;\r
+  STDMETHOD(QueryHelpText)(THIS_ UINT, ULONG, LPTSTR, UINT) PURE;\r
+  STDMETHOD(QueryButtonInfo)(THIS_ ULONG, UINT, LPTBBUTTON,\r
+                             LPTSTR, UINT, ULONG) PURE;\r
+  STDMETHOD(ResetToolbar)(THIS_ ULONG, ULONG) PURE;\r
+};\r
+\r
+\r
+\r
+EXTERN_C const IID IID_IExchExtPropertySheets;\r
+#undef INTERFACE\r
+#define INTERFACE IExchExtPropertySheets\r
+DECLARE_INTERFACE_(IExchExtPropertySheets, IUnknown)\r
+{\r
+  /*** IUnknown methods. ***/\r
+  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;\r
+  STDMETHOD_(ULONG, AddRef)(THIS) PURE;\r
+  STDMETHOD_(ULONG, Release)(THIS) PURE;\r
+\r
+  /*** IExchExtPropertySheet methods. ***/\r
+  STDMETHOD_(ULONG, GetMaxPageCount)(THIS_ ULONG) PURE;\r
+  STDMETHOD(GetPages)(THIS_ LPEXCHEXTCALLBACK, ULONG,\r
+                      LPPROPSHEETPAGE, ULONG*) PURE;\r
+  STDMETHOD_(void, FreePages)(THIS_ LPPROPSHEETPAGE, ULONG, ULONG) PURE;\r
+};\r
+\r
+\r
+\r
+EXTERN_C const IID IID_IExchExtCallback;\r
+#undef INTERFACE\r
+#define INTERFACE IExchExtCallback\r
+DECLARE_INTERFACE_(IExchExtCallback, IUnknown)\r
+{\r
+  /*** IUnknown methods. ***/\r
+  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;\r
+  STDMETHOD_(ULONG, AddRef)(THIS) PURE;\r
+  STDMETHOD_(ULONG, Release)(THIS) PURE;\r
+\r
+  /*** IExchExtCallback methods. ***/\r
+  STDMETHOD(GetVersion)(THIS_ ULONG*, ULONG) PURE;\r
+  STDMETHOD(GetWindow)(THIS_ HWND*) PURE;\r
+  STDMETHOD(GetMenu)(THIS_ HMENU*) PURE;\r
+  STDMETHOD(GetToolbar)(THIS_ ULONG, HWND*) PURE;\r
+  STDMETHOD(GetSession)(THIS_ LPMAPISESSION*, LPADRBOOK*) PURE;\r
+  STDMETHOD(GetObject)(THIS_ LPMDB*, LPMAPIPROP*) PURE;\r
+  STDMETHOD(GetSelectionCount)(THIS_ ULONG*) PURE;\r
+  STDMETHOD(GetSelectionItem)(THIS_ ULONG, ULONG*, LPENTRYID*, ULONG*,\r
+                              LPTSTR, ULONG, ULONG*, ULONG) PURE;\r
+  STDMETHOD(GetMenuPos)(THIS_ ULONG, HMENU*, ULONG*, ULONG*, ULONG) PURE;\r
+  STDMETHOD(GetSharedExtsDir)(THIS_ LPTSTR, ULONG, ULONG) PURE;\r
+  STDMETHOD(GetRecipients)(THIS_ LPADRLIST*) PURE;\r
+  STDMETHOD(SetRecipients)(THIS_ LPADRLIST) PURE;\r
+  STDMETHOD(GetNewMessageSite)(THIS_ ULONG, LPMAPIFOLDER, LPPERSISTMESSAGE,\r
+                               LPMESSAGE*, LPMAPIMESSAGESITE*,\r
+                               LPMAPIVIEWCONTEXT*, ULONG) PURE;\r
+  STDMETHOD(RegisterModeless)(THIS_ LPEXCHEXTMODELESS,\r
+                              LPEXCHEXTMODELESSCALLBACK*) PURE;\r
+  STDMETHOD(ChooseFolder)(THIS_ LPEXCHEXTCHOOSEFOLDER) PURE;\r
+};\r
+\r
+\r
+\r
+EXTERN_C const IID IID_IOutlookExtCallback;\r
+#undef INTERFACE\r
+#define INTERFACE IOutlookExtCallback\r
+DECLARE_INTERFACE_(IOutlookExtCallback, IUnknown)\r
+{\r
+  /*** IUnknown methods. ***/\r
+  STDMETHOD(QueryInterface)(THIS_ REFIID, PVOID*) PURE;\r
+  STDMETHOD_(ULONG, AddRef)(THIS) PURE;\r
+  STDMETHOD_(ULONG, Release)(THIS) PURE;\r
+\r
+  /*** IOutlookExtCallback.  **/\r
+  STDMETHOD(GetObject)(LPUNKNOWN *ppunk);\r
+  STDMETHOD(GetOfficeCharacter)(void **ppmsotfc);\r
+};\r
+\r
+// Flag values for IExchExtAttachedFileEvents::OpenSzFile\r
+#define EEAFE_OPEN         (0x00000001)\r
+#define EEAFE_PRINT       (0x00000002)\r
+#define EEAFE_QUICKVIEW           (0x00000003)\r
+\r
+#undef INTERFACE\r
+#define INTERFACE   IExchExtAttachedFileEvents\r
+\r
+DECLARE_INTERFACE_(IExchExtAttachedFileEvents, IUnknown)\r
+{\r
+  // *** IUnknown methods ***\r
+  STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * lppvObj) PURE;\r
+  STDMETHOD_(ULONG,AddRef) (THIS)  PURE;\r
+  STDMETHOD_(ULONG,Release) (THIS) PURE;\r
+  \r
+  // *** IExchExtAttachedFileEvents methods ***\r
+  STDMETHOD(OnReadPattFromSzFile)(THIS_ LPATTACH lpatt, LPTSTR lpszFile,\r
+                                 ULONG ulFlags) PURE;\r
+  STDMETHOD(OnWritePattToSzFile)(THIS_ LPATTACH lpatt, LPTSTR lpszFile,\r
+                                ULONG ulFlags) PURE;\r
+  STDMETHOD(QueryDisallowOpenPatt)(THIS_ LPATTACH lpatt) PURE;\r
+  STDMETHOD(OnOpenPatt)(THIS_ LPATTACH lpatt) PURE;\r
+  STDMETHOD(OnOpenSzFile)(THIS_ LPTSTR lpszFile, ULONG ulFlags) PURE;\r
+};\r
+typedef IExchExtAttachedFileEvents FAR * LPEXCHEXTATTACHEDFILEEVENTS;\r
+\r
+EXTERN_C const IID IID_IExchExtAttachedFileEvents;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /*EXCHEXT.h*/\r
index 444e577..94e61f3 100644 (file)
@@ -25,7 +25,7 @@
 class CGPGExchExtMessageEvents;
 class CGPGExchExtCommands;
 class CGPGExchExtPropertySheets;
-class CGPGExchApp;
+class CGPGExchExtAttachedFileEvents;
 
 bool GPGOptionsDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
index ce07b75..1126f9e 100644 (file)
@@ -43,6 +43,7 @@
 #include "olflange-ids.h"
 #include "olflange-def.h"
 #include "olflange.h"
+#include "attach.h"
 
 #define CLSIDSTR_GPGOL   "{42d30988-1a3a-11da-c687-000d6080e735}"
 DEFINE_GUID(CLSID_GPGOL, 0x42d30988, 0x1a3a, 0x11da, 
@@ -462,8 +463,9 @@ CGPGExchExt::CGPGExchExt (void)
   m_pExchExtMessageEvents = new CGPGExchExtMessageEvents (this);
   m_pExchExtCommands = new CGPGExchExtCommands (this);
   m_pExchExtPropertySheets = new CGPGExchExtPropertySheets (this);
+  m_pExchExtAttachedFileEvents = new CGPGExchExtAttachedFileEvents (this);
   if (!m_pExchExtMessageEvents || !m_pExchExtCommands
-      || !m_pExchExtPropertySheets)
+      || !m_pExchExtPropertySheets || !m_pExchExtAttachedFileEvents)
     out_of_core ();
   
   if (!g_initdll)
@@ -506,35 +508,43 @@ CGPGExchExt::~CGPGExchExt (void)
 STDMETHODIMP 
 CGPGExchExt::QueryInterface(REFIID riid, LPVOID *ppvObj)
 {
-    HRESULT hr = S_OK;
-
-    *ppvObj = NULL;
-
-    if ((riid == IID_IUnknown) || (riid == IID_IExchExt)) {
-        *ppvObj = (LPUNKNOWN) this;
+  HRESULT hr = S_OK;
+  
+  *ppvObj = NULL;
+  
+  if ((riid == IID_IUnknown) || (riid == IID_IExchExt)) 
+    {
+      *ppvObj = (LPUNKNOWN) this;
     }
-    else if (riid == IID_IExchExtMessageEvents) {
-        *ppvObj = (LPUNKNOWN) m_pExchExtMessageEvents;
-        m_pExchExtMessageEvents->SetContext (m_lContext);
+  else if (riid == IID_IExchExtMessageEvents) 
+    {
+      *ppvObj = (LPUNKNOWN) m_pExchExtMessageEvents;
+      m_pExchExtMessageEvents->SetContext (m_lContext);
     }
-    else if (riid == IID_IExchExtCommands) {
-        *ppvObj = (LPUNKNOWN)m_pExchExtCommands;
-        m_pExchExtCommands->SetContext (m_lContext);
+  else if (riid == IID_IExchExtCommands) 
+    {
+      *ppvObj = (LPUNKNOWN)m_pExchExtCommands;
+      m_pExchExtCommands->SetContext (m_lContext);
     }
-    else if (riid == IID_IExchExtPropertySheets) {
-       if (m_lContext != EECONTEXT_PROPERTYSHEETS)
-           return E_NOINTERFACE;
-        *ppvObj = (LPUNKNOWN) m_pExchExtPropertySheets;
+  else if (riid == IID_IExchExtPropertySheets) 
+    {
+      if (m_lContext != EECONTEXT_PROPERTYSHEETS)
+       return E_NOINTERFACE;
+      *ppvObj = (LPUNKNOWN) m_pExchExtPropertySheets;
     }
-    else
-        hr = E_NOINTERFACE;
-
-    /* On success we need to bump up the reference counter for the
-       requested object. */
-    if (*ppvObj)
-        ((LPUNKNOWN)*ppvObj)->AddRef();
-
-    /*log_debug("QueryInterface %d\n", __LINE__);*/
+  else if (riid == IID_IExchExtAttachedFileEvents)
+    {
+      *ppvObj = (LPUNKNOWN)m_pExchExtAttachedFileEvents;
+    }  
+  else
+    hr = E_NOINTERFACE;
+  
+  /* On success we need to bump up the reference counter for the
+   requested object. */
+  if (*ppvObj)
+    ((LPUNKNOWN)*ppvObj)->AddRef();
+  
+  /*log_debug("QueryInterface %d\n", __LINE__);*/
     return hr;
 }
 
index 02b14e4..45ca1fb 100644 (file)
 class CGPGExchExt : public IExchExt
 {
 public:
-    CGPGExchExt();
-    virtual ~CGPGExchExt();
+  CGPGExchExt();
+  virtual ~CGPGExchExt();
 
 public:        
-    HWND m_hWndExchange;  /* Handle of the exchange window. */
-    /* parameter for sending mails */
-    BOOL  m_gpgEncrypt;
-    BOOL  m_gpgSign;
-
+  HWND m_hWndExchange;  /* Handle of the exchange window. */
+  /* parameter for sending mails */
+  BOOL  m_gpgEncrypt;
+  BOOL  m_gpgSign;
+  
 private:
-    ULONG m_lRef;
-    ULONG m_lContext;
-
-    /* pointer to the other extension objects */
-    CGPGExchExtMessageEvents* m_pExchExtMessageEvents;
-    CGPGExchExtCommands* m_pExchExtCommands;
-    CGPGExchExtPropertySheets* m_pExchExtPropertySheets;
+  ULONG m_lRef;
+  ULONG m_lContext;
+  
+  /* pointer to the other extension objects */
+  CGPGExchExtMessageEvents* m_pExchExtMessageEvents;
+  CGPGExchExtCommands* m_pExchExtCommands;
+  CGPGExchExtPropertySheets* m_pExchExtPropertySheets;
+  CGPGExchExtAttachedFileEvents *m_pExchExtAttachedFileEvents;
 
 public:
-    STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj);
-    inline STDMETHODIMP_(ULONG) AddRef() { ++m_lRef;  return m_lRef; };
-    inline STDMETHODIMP_(ULONG) Release()
+  STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj);
+  inline STDMETHODIMP_(ULONG) AddRef() { ++m_lRef;  return m_lRef; };
+  inline STDMETHODIMP_(ULONG) Release()
     {
-       ULONG lCount = --m_lRef;
-       if (!lCount) 
-           delete this;
-       return lCount;  
+      ULONG lCount = --m_lRef;
+      if (!lCount) 
+       delete this;
+      return lCount;   
     };
-    STDMETHODIMP Install(LPEXCHEXTCALLBACK pEECB, ULONG lContext, ULONG lFlags);
+  STDMETHODIMP Install(LPEXCHEXTCALLBACK pEECB, ULONG lContext, ULONG lFlags);
 };
 
 /*
index 2050ba7..4c648fc 100644 (file)
@@ -114,14 +114,13 @@ load_recipbox (HWND dlg, int ctlid, gpgme_ctx_t ctx)
   r = rset;
   for (;;) 
     {
-      const char *uid;
       err = gpgme_op_keylist_next (keyctx, &key);
       if (err)
        break;
-      uid = gpgme_key_get_string_attr (key, GPGME_ATTR_USERID, NULL, 0);
-      if (uid != NULL) 
+
+      if (key && key->uids != NULL)
        SendDlgItemMessage (dlg, ctlid, LB_ADDSTRING, 0,
-                           (LPARAM)(const char *)uid);
+                           (LPARAM)(const char *)key->uids->uid);
        gpgme_key_release (key);
        key = NULL;
        r = r->next;
@@ -134,58 +133,80 @@ fail:
 }
 
 
+const char*
+get_pubkey_algo_str (gpgme_pubkey_algo_t alg)
+{
+  
+  switch (alg)
+    {
+    case GPGME_PK_RSA:
+    case GPGME_PK_RSA_E:
+    case GPGME_PK_RSA_S:
+      return "RSA";
+      
+    case GPGME_PK_ELG_E:
+      return "ELG";
+      
+    default:
+      break;
+    }
+  
+  return "???";
+}
+
+
 static void
 load_secbox (HWND dlg, int ctlid)
 {
-    gpgme_key_t sk;
-    size_t n=0, doloop=1;
-    void *ctx=NULL;
-
-    enum_gpg_seckeys (NULL, &ctx);
-    while (doloop) {
-       const char *name, *email, *keyid, *algo;
-       char *p;
-
-       if (enum_gpg_seckeys (&sk, &ctx))
-           doloop = 0;
-
-       if (gpgme_key_get_ulong_attr (sk, GPGME_ATTR_KEY_REVOKED, NULL, 0) ||
-           gpgme_key_get_ulong_attr (sk, GPGME_ATTR_KEY_EXPIRED, NULL, 0) ||
-           gpgme_key_get_ulong_attr (sk, GPGME_ATTR_KEY_INVALID, NULL, 0))
-           continue;
-       
-       name = gpgme_key_get_string_attr (sk, GPGME_ATTR_NAME, NULL, 0);
-       email = gpgme_key_get_string_attr (sk, GPGME_ATTR_EMAIL, NULL, 0);
-       keyid = gpgme_key_get_string_attr (sk, GPGME_ATTR_KEYID, NULL, 0);
-       algo = gpgme_key_get_string_attr (sk, GPGME_ATTR_ALGO, NULL, 0);
-       if (!email)
-           email = "";
-       p = (char *)xcalloc (1, strlen (name) + strlen (email) + 17 + 32);
-       if (email && strlen (email))
-           sprintf (p, "%s <%s> (0x%s, %s)", name, email, keyid+8, algo);
-       else
-           sprintf (p, "%s (0x%s, %s)", name, keyid+8, algo);
-       SendDlgItemMessage (dlg, ctlid, CB_ADDSTRING, 0, 
-                           (LPARAM)(const char *) p);
-       xfree (p);
+  gpgme_key_t sk;
+  size_t n=0, doloop=1;
+  void *ctx=NULL;
+  
+  enum_gpg_seckeys (NULL, &ctx);
+  while (doloop) 
+    {
+      const char *name, *email, *keyid, *algo;
+      char *p;
+      
+      if (enum_gpg_seckeys (&sk, &ctx))
+       doloop = 0;
+      
+      if (sk->revoked || sk->expired || sk->disabled || sk->invalid)
+       continue;
+      if (!sk->uids)
+       continue;
+
+      name = sk->uids->name;
+      email = sk->uids->email;
+      keyid = sk->subkeys->keyid;
+      algo = get_pubkey_algo_str (sk->subkeys->pubkey_algo);
+      if (!email)
+       email = "";
+      p = (char *)xcalloc (1, strlen (name) + strlen (email) + 17 + 32);
+      if (email && strlen (email))
+       sprintf (p, "%s <%s> (0x%s, %s)", name, email, keyid+8, algo);
+      else
+       sprintf (p, "%s (0x%s, %s)", name, keyid+8, algo);
+      SendDlgItemMessage (dlg, ctlid, CB_ADDSTRING, 0, 
+                         (LPARAM)(const char *) p);
+      xfree (p);
     }
-    
-    ctx = NULL;
-    reset_gpg_seckeys (&ctx);
-    doloop = 1;
-    n = 0;
-    while (doloop) {
-       if (enum_gpg_seckeys (&sk, &ctx))
-           doloop = 0;
-       if (gpgme_key_get_ulong_attr (sk, GPGME_ATTR_KEY_REVOKED, NULL, 0) ||
-           gpgme_key_get_ulong_attr (sk, GPGME_ATTR_KEY_EXPIRED, NULL, 0) ||
-           gpgme_key_get_ulong_attr (sk, GPGME_ATTR_KEY_INVALID, NULL, 0))
-           continue;
-       SendDlgItemMessage (dlg, ctlid, CB_SETITEMDATA, n, (LPARAM)(DWORD)sk);
-       n++;
+  
+  ctx = NULL;
+  reset_gpg_seckeys (&ctx);
+  doloop = 1;
+  n = 0;
+  while (doloop) 
+    {
+      if (enum_gpg_seckeys (&sk, &ctx))
+       doloop = 0;
+      if (sk->revoked || sk->expired || sk->invalid || sk->disabled)
+       continue;
+      SendDlgItemMessage (dlg, ctlid, CB_SETITEMDATA, n, (LPARAM)(DWORD)sk);
+      n++;
     }
-    SendDlgItemMessage (dlg, ctlid, CB_SETCURSEL, 0, 0);
-    reset_gpg_seckeys (&ctx);
+  SendDlgItemMessage (dlg, ctlid, CB_SETCURSEL, 0, 0);
+  reset_gpg_seckeys (&ctx);
 }
 
 
index ce3cb32..1a319ba 100644 (file)
@@ -27,6 +27,7 @@
 #include "gpgol-ids.h"
 #include "keycache.h"
 #include "intern.h"
+#include "util.h"
 
 struct recipient_cb_s {
     char **unknown_keys;    
@@ -84,65 +85,69 @@ initialize_rsetbox (HWND hwnd)
 static void 
 load_rsetbox (HWND hwnd)
 {
-    
-    LVITEM lvi;
-    DWORD val;
-    char keybuf[128];
-    const char * s;
-    const char * trust_items[] = {
-       "UNKNOWN",
+  LVITEM lvi;
+  gpgme_key_t key = NULL;
+  void *ctx = NULL;
+  char keybuf[128], *s;
+  const char * trust_items[] = 
+    {
+      "UNKNOWN",
        "UNDEFINED",
        "NEVER",
        "MARGINAL",
        "FULL",
-       "ULTIMATE"
+      "ULTIMATE"
     };
-    void *ctx=NULL;
-    size_t doloop=1;
-    gpgme_key_t key=NULL;
-
-    memset (&lvi, 0, sizeof (lvi));
-    cleanup_keycache_objects (); /*XXX: rewrite the entire key cache! */
-    enum_gpg_keys (NULL, &ctx);
-    while (doloop) {
-       if (enum_gpg_keys(&key, &ctx))
-           doloop = 0;
-       if (!gpgme_key_get_ulong_attr (key, GPGME_ATTR_CAN_ENCRYPT, NULL, 0))
-           continue;
-       /* check that the primary key is *not* revoked, expired or invalid */
-       if (gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_REVOKED, NULL, 0)
-         || gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_EXPIRED, NULL, 0)
-        || gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_INVALID, NULL, 0))
-           continue;
-       ListView_InsertItem (hwnd, &lvi);
-
-       s = gpgme_key_get_string_attr( key, GPGME_ATTR_NAME, NULL, 0 );
-       ListView_SetItemText( hwnd, 0, 0, (char *)s );
-
-       s = gpgme_key_get_string_attr( key, GPGME_ATTR_EMAIL, NULL, 0 );
-       ListView_SetItemText( hwnd, 0, 1, (char *)s );
-
-       s = gpgme_key_get_string_attr( key, GPGME_ATTR_ALGO, NULL, 0 );
-       sprintf( keybuf, "%s", s );
-       if( (s = gpgme_key_get_string_attr( key, GPGME_ATTR_ALGO, NULL, 1 )) )
-           sprintf( keybuf+strlen( keybuf ), "/%s", s );
-       strcat( keybuf, " " );
-       if( (val = gpgme_key_get_ulong_attr( key, GPGME_ATTR_LEN, NULL, 1 )) )
-           sprintf( keybuf+strlen( keybuf ), "%ld", val );
-       else {
-           val = gpgme_key_get_ulong_attr( key, GPGME_ATTR_LEN, NULL, 0 );
-           sprintf( keybuf+strlen( keybuf ), "%ld", val );
-       }
-       s = keybuf;
-       ListView_SetItemText( hwnd, 0, 2, (char *) s );
-
-       s = gpgme_key_get_string_attr( key, GPGME_ATTR_KEYID, NULL, 0 ) + 8;
-       ListView_SetItemText( hwnd, 0, 3, (char *)s );
-
-       val = gpgme_key_get_ulong_attr (key, GPGME_ATTR_VALIDITY, NULL, 0);
-       if (val < 0 || val > 5) val = 0;
-       s = (char *)trust_items[val];
-       ListView_SetItemText (hwnd, 0, 4, (char *)s);
+  enum {COL_NAME, COL_EMAIL, COL_KEYINF, COL_KEYID, COL_TRUST};
+  DWORD val;
+  size_t doloop=1;
+
+  memset (&lvi, 0, sizeof (lvi));
+  cleanup_keycache_objects (); /*XXX: rewrite the entire key cache! */
+  enum_gpg_keys (NULL, &ctx);
+  while (doloop) 
+    {
+      if (enum_gpg_keys(&key, &ctx))
+       doloop = 0;
+      if (!key->subkeys->can_encrypt)
+       continue;
+      
+      /* check that the primary key is *not* revoked, expired or invalid */
+      if (key->revoked || key->expired || key->invalid || key->disabled)
+       continue;
+      if (!key->uids)
+       continue;
+      ListView_InsertItem (hwnd, &lvi);
+      
+      s = key->uids->name;
+      ListView_SetItemText (hwnd, 0, COL_NAME, s);
+      
+      s = key->uids->email;
+      ListView_SetItemText (hwnd, 0, COL_EMAIL, s);
+      
+      s = (char*)get_pubkey_algo_str (key->subkeys->pubkey_algo);
+      sprintf (keybuf, "%s", s);
+      if (key->subkeys->next)
+       {
+         s = (char*)get_pubkey_algo_str (key->subkeys->next->pubkey_algo);
+         sprintf (keybuf+strlen (keybuf), "/%s", s);
+       }      
+      strcat (keybuf, " ");
+      if (key->subkeys->next)
+       sprintf (keybuf+strlen (keybuf), "%d", key->subkeys->next->length);
+      else
+       sprintf (keybuf+strlen (keybuf), "%d", key->subkeys->length);
+
+      s = keybuf;
+      ListView_SetItemText (hwnd, 0, COL_KEYINF, s);
+      
+      ListView_SetItemText( hwnd, 0, COL_KEYID, key->subkeys->keyid+8);
+      
+      val = key->uids->validity;
+      if (val < 0 || val > 5) 
+       val = 0;
+      s = (char *)trust_items[val];
+      ListView_SetItemText (hwnd, 0, COL_TRUST, s);
     }
 }
 
@@ -365,39 +370,43 @@ int
 recipient_dialog_box2 (gpgme_key_t *fnd, char **unknown, size_t n,
                       gpgme_key_t **ret_rset, int *ret_opts)
 {
-    struct recipient_cb_s *cb;
-    int i;
-    
-    cb = xcalloc (1, sizeof (struct recipient_cb_s));
-    cb->n = n;
-    cb->fnd_keys = xcalloc (n+1, sizeof (char*));
-    for (i = 0; i < (int)n; i++) {
-       const char *name;
-       if (fnd[i] == NULL) {
-           cb->fnd_keys[i] = xstrdup ("User-ID not found");
-           continue;
-       }
-       name = gpgme_key_get_string_attr (fnd[i], GPGME_ATTR_NAME, NULL, 0);
-       if (!name)
-           name = "User-ID not found";
-       cb->fnd_keys[i] = xstrdup (name);
+  struct recipient_cb_s *cb;
+  int i;
+  
+  cb = xcalloc (1, sizeof (struct recipient_cb_s));
+  cb->n = n;
+  cb->fnd_keys = xcalloc (n+1, sizeof (char*));
+  for (i = 0; i < (int)n; i++) 
+    {
+      const char *name;
+      if (fnd[i] == NULL) {
+       cb->fnd_keys[i] = xstrdup (_("User-ID not found"));
+       continue;
+      }
+      name = fnd[i]->uids->uid;
+      if (!name)
+       name = _("User-ID not found");
+      cb->fnd_keys[i] = xstrdup (name);
     }
-    cb->unknown_keys = unknown;
-    DialogBoxParam (glob_hinst, (LPCTSTR)IDD_ENC, GetDesktopWindow (),
-                   recipient_dlg_proc, (LPARAM)cb);
-    if (cb->opts & OPT_FLAG_CANCEL) {
-       *ret_opts = cb->opts;
-       *ret_rset = NULL;
+  cb->unknown_keys = unknown;
+  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_ENC, GetDesktopWindow (),
+                 recipient_dlg_proc, (LPARAM)cb);
+  if (cb->opts & OPT_FLAG_CANCEL) 
+    {
+      *ret_opts = cb->opts;
+      *ret_rset = NULL;
     }
-    else {
-       *ret_rset = keycache_to_key_array (cb->rset);
-       keycache_free (cb->rset);
+  else 
+    {
+      *ret_rset = keycache_to_key_array (cb->rset);
+      keycache_free (cb->rset);
     }
-    for (i = 0; i < (int)n; i++) {
-       xfree (cb->fnd_keys[i]);
-       cb->fnd_keys[i] = NULL;
+  for (i = 0; i < (int)n; i++) 
+    {
+      xfree (cb->fnd_keys[i]);
+      cb->fnd_keys[i] = NULL;
     }
-    xfree (cb->fnd_keys);
-    xfree (cb);
-    return 0;
+  xfree (cb->fnd_keys);
+  xfree (cb);
+  return 0;
 }
index 622fe8d..20844bf 100644 (file)
@@ -155,7 +155,6 @@ capitalize_header_name (unsigned char *name)
       *name = *name - 'A' + 'a';
 }
 
-
 static char *
 stpcpy (char *a,const char *b)
 {
@@ -166,7 +165,6 @@ stpcpy (char *a,const char *b)
   return (char*)a;
 }
 
-
 /* If a callback has been registerd, call it for the event of type
    EVENT. */
 static int
index 6b03218..73fcc39 100644 (file)
@@ -28,6 +28,7 @@
 #include "gpgol-ids.h"
 #include "keycache.h"
 #include "intern.h"
+#include "util.h"
 
 struct dialog_context
 {
@@ -76,95 +77,96 @@ load_akalist (HWND dlg, gpgme_key_t key)
 static void 
 load_sigbox (HWND dlg, gpgme_verify_result_t ctx)
 {
-    gpgme_key_t key;
-    char *s, buf[2+16+1];
-    char *p;
-    int stat;
-    int valid, no_key = 0, n = 0;
-
-    s = get_timestamp (ctx->signatures->timestamp);
-    SetDlgItemText (dlg, IDC_VRY_TIME, s);
-
-    s = ctx->signatures->fpr;
-    if (strlen (s) == 40)
-       strncpy (buf+2, s+40-8, 8);
-    else if (strlen (s) == 32) /* MD5:RSAv3 */
-       strncpy (buf+2, s+32-8, 8);
-    else
-       strncpy (buf+2, s+8, 8);
-    buf[10] = 0;
-    buf[0] = '0'; 
-    buf[1] = 'x';
-    SetDlgItemText (dlg, IDC_VRY_KEYID, buf);
-    /*key = find_gpg_key (buf+2, 0);*/
-    key = get_gpg_key (buf+2);
-    
-    stat = ctx->signatures->summary;
-    if (stat & GPGME_SIGSUM_GREEN)
-       s = "Good signature";
-    else if (stat & GPGME_SIGSUM_RED)
-       s = "BAD signature!";
-    else if (stat & GPGME_SIGSUM_KEY_REVOKED)
-       s = "Good signature from revoked key";
-    else if (stat & GPGME_SIGSUM_KEY_EXPIRED)
-       s = "Good signature from expired key";
-    else if (stat & GPGME_SIGSUM_SIG_EXPIRED)
-       s = "Good expired signature";
-    else if (stat & GPGME_SIGSUM_KEY_MISSING) {
-       s = "Could not check signature: missing key";
-       no_key = 1;
-    }
-    else
-       s = "Verification error";
-    /* XXX: if we have a key we do _NOT_ trust, stat is 'wrong' */
-    SetDlgItemText (dlg, IDC_VRY_STATUS, s);
-    
-    if (key) {
-       s = (char*)gpgme_key_get_string_attr (key, GPGME_ATTR_USERID, NULL, 0);
-       SetDlgItemText (dlg, IDC_VRY_ISSUER, s);
-
-       n = load_akalist (dlg, key);
-       gpgme_key_release (key);
-       if (n == 0)
-           EnableWindow (GetDlgItem (dlg, IDC_VRY_AKALIST), FALSE);
+  gpgme_key_t key;
+  char *s, buf[2+16+1];
+  char *p;
+  int stat;
+  int valid, no_key = 0, n = 0;
+  
+  s = get_timestamp (ctx->signatures->timestamp);
+  SetDlgItemText (dlg, IDC_VRY_TIME, s);
+  
+  s = ctx->signatures->fpr;
+  if (strlen (s) == 40)
+    strncpy (buf+2, s+40-8, 8);
+  else if (strlen (s) == 32) /* MD5:RSAv3 */
+    strncpy (buf+2, s+32-8, 8);
+  else
+    strncpy (buf+2, s+8, 8);
+  buf[10] = 0;
+  buf[0] = '0'; 
+  buf[1] = 'x';
+  SetDlgItemText (dlg, IDC_VRY_KEYID, buf);
+  key = get_gpg_key (buf+2);
+  
+  stat = ctx->signatures->summary;
+  if (stat & GPGME_SIGSUM_GREEN)
+    s = _("Good signature");
+  else if (stat & GPGME_SIGSUM_RED)
+    s = _("BAD signature!");
+  else if (stat & GPGME_SIGSUM_KEY_REVOKED)
+    s = _("Good signature from revoked key");
+  else if (stat & GPGME_SIGSUM_KEY_EXPIRED)
+    s = _("Good signature from expired key");
+  else if (stat & GPGME_SIGSUM_SIG_EXPIRED)
+    s = _("Good expired signature");
+  else if (stat & GPGME_SIGSUM_KEY_MISSING) 
+    {
+      s = _("Could not check signature: missing key");
+      no_key = 1;
     }
-    else {
-       s = "User-ID not found";
-       SetDlgItemText (dlg, IDC_VRY_ISSUER, s);
+  else
+    s = _("Verification error");
+  /* XXX: if we have a key we do _NOT_ trust, stat is 'wrong' */
+  SetDlgItemText (dlg, IDC_VRY_STATUS, s);
+  
+  if (key && key->uids) 
+    {
+      s = key->uids->uid;
+      SetDlgItemText (dlg, IDC_VRY_ISSUER, s);
+      
+      n = load_akalist (dlg, key);
+      gpgme_key_release (key);
+      if (n == 0)
+       EnableWindow (GetDlgItem (dlg, IDC_VRY_AKALIST), FALSE);
     }
-
-    switch (ctx->signatures->pubkey_algo) {
-    case GPGME_PK_RSA: s = "RSA"; break;
-    case GPGME_PK_DSA: s = "DSA"; break;
-    default:           s = "???"; break;
+  else 
+    {
+      s = _("User-ID not found");
+      SetDlgItemText (dlg, IDC_VRY_ISSUER, s);
     }
-    SetDlgItemText (dlg, IDC_VRY_PKALGO, s);
-
-    valid = ctx->signatures->validity;
-    if (stat & GPGME_SIGSUM_SIG_EXPIRED) {
-       char *fmt;
-
-       fmt = "Signature expired on %s";
-       s = get_timestamp (ctx->signatures->exp_timestamp);
-       p = xmalloc (strlen (s)+1+strlen (fmt)+2);
-       sprintf (p, fmt, s);
-       SetDlgItemText (dlg, IDC_VRY_HINT, s);
-       xfree (p);
+  
+  s = (char *)get_pubkey_algo_str (ctx->signatures->pubkey_algo);
+  SetDlgItemText (dlg, IDC_VRY_PKALGO, s);
+  
+  valid = ctx->signatures->validity;
+  if (stat & GPGME_SIGSUM_SIG_EXPIRED) 
+    {
+      char *fmt;
+    
+      fmt = "Signature expired on %s";
+      s = get_timestamp (ctx->signatures->exp_timestamp);
+      p = xmalloc (strlen (s)+1+strlen (fmt)+2);
+      sprintf (p, fmt, s);
+      SetDlgItemText (dlg, IDC_VRY_HINT, s);
+      xfree (p);
     }
-    else if (valid < GPGME_VALIDITY_MARGINAL) {
-       switch (valid) {
+  else if (valid < GPGME_VALIDITY_MARGINAL) 
+    {
+      switch (valid) 
+       {
        case GPGME_VALIDITY_NEVER:
-           s = "Signature issued by a key we do NOT trust.";
-           break;
-
+         s = "Signature issued by a key we do NOT trust.";
+         break;
+         
        default:
-           if (no_key)
-               s = "";
-           else
-               s = "Signature issued by a non-valid key.";
-           break;
+         if (no_key)
+           s = "";
+         else
+           s = "Signature issued by a non-valid key.";
+         break;
        }
-       SetDlgItemText (dlg, IDC_VRY_HINT, s);
+      SetDlgItemText (dlg, IDC_VRY_HINT, s);
     }
 }
 
index 0bf8cda..0ba9afd 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include <config.h>
-
 #include <windows.h>
 #include <stdio.h>
 #include <gpgme.h>
@@ -81,6 +80,7 @@ find_message_window2 (HWND parent)
 }
 
 
+/* Decrypt a single message. */
 static void
 decrypt_message (HWND hwnd, LPMESSAGE msg)
 {
@@ -92,9 +92,19 @@ decrypt_message (HWND hwnd, LPMESSAGE msg)
   msg = NULL;
 }
 
-
-/* XXX: describe what we are doing here! */
-
+/* This hook procedure allows to monitor all windows which are created
+ * and/or activated.
+ * We use it to find the new opened message window and start automatically
+ * the decryption code. The pre-condition is, that the new window has the
+ * proper window class and a child window with valid OpenPGP data.
+ *
+ * We cannot use the HCBT_CREATEWND alone because at the point the hook
+ * procedure is called, the window is only about to be created but the
+ * procedure has not finished yet. Plus the child windows are not yet
+ * created. Thus we check if the new window has the proper class. If
+ * this window is then activated, we call the decryption code and reset
+ * the window handle so the decryption is only called once.
+ */
 static LRESULT CALLBACK
 cbt_proc (int code, WPARAM w, LPARAM l)
 {