Added eol-style property
authorWerner Koch <wk@gnupg.org>
Fri, 12 Aug 2005 16:07:21 +0000 (16:07 +0000)
committerWerner Koch <wk@gnupg.org>
Fri, 12 Aug 2005 16:07:21 +0000 (16:07 +0000)
olflange/GPGExch.cpp
olflange/GPGExch.h
olflange/StdAfx.h
olflange/resource.h

index 03bbdde..b4d7660 100644 (file)
-/* GPGExch.cpp - exchange extension classes\r
- *     Copyright (C) 2001 G Data Software AG, http://www.gdata.de\r
- *     Copyright (C) 2004, 2005 g10 Code GmbH\r
- * \r
- * This file is part of the G DATA Outlook Plugin for GnuPG.\r
- * \r
- * This plugin is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2 of the License, or (at your option) any later version.\r
- * \r
- * This plugin is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU Lesser General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU Lesser General\r
- * Public License along with this plugin; if not, write to the \r
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, \r
- * Boston, MA 02111-1307, USA.\r
- */\r
-\r
-#include "stdafx.h"\r
-\r
-#ifndef INITGUID\r
-#define INITGUID\r
-#endif\r
-#include <INITGUID.H>\r
-#include <MAPIGUID.H>\r
-#include <EXCHEXT.H>\r
-\r
-#include "GPGExchange.h"\r
-#include "GPGExch.h"\r
-#include "../src/MapiGPGME.h"\r
-\r
-BOOL g_bInitDll = FALSE;\r
-MapiGPGME *m_gpg = NULL;\r
-\r
-static void \r
-ExchLogInfo (const char * fmt, ...)\r
-{\r
-    if (m_gpg) {\r
-        va_list a;\r
-  \r
-        va_start (a, fmt);\r
-        m_gpg->logDebug (fmt, a);\r
-        va_end (a);\r
-    }\r
-}\r
-\r
-/* The one and only CGPGExchApp object */\r
-BEGIN_MESSAGE_MAP(CGPGExchApp, CWinApp)\r
-END_MESSAGE_MAP()\r
-\r
-CGPGExchApp::CGPGExchApp (void)\r
-{\r
-    ExchLogInfo("GPGExch\n");\r
-}\r
-\r
-CGPGExchApp theApp;\r
-\r
-\r
-\r
-/* ExchEntryPoint -\r
- The entry point which Exchange calls.\r
- This is called for each context entry. Creates a new CAvkExchExt object\r
- every time so each context will get its own CAvkExchExt interface.\r
\r
- Return value: Pointer to Exchange Extension Object */\r
-LPEXCHEXT CALLBACK \r
-ExchEntryPoint (void)\r
-{\r
-    ExchLogInfo ("extension entry point...\n");\r
-    return new CGPGExchExt;\r
-}\r
-\r
-\r
-/* DllRegisterServer\r
- Registers this object as exchange extension. Sets the contextes which are \r
- implemented by this object. */\r
-STDAPI \r
-DllRegisterServer (void)\r
-{    \r
-    HKEY hkey;\r
-    CHAR szKeyBuf[1024];\r
-    CHAR szEntry[512];\r
-    TCHAR szModuleFileName[MAX_PATH];\r
-    DWORD dwTemp = 0;\r
-    long ec;\r
-\r
-    /* get server location */\r
-    DWORD dwResult = ::GetModuleFileName(theApp.m_hInstance, szModuleFileName, MAX_PATH);\r
-    if (dwResult == 0) \r
-       return E_FAIL;\r
-\r
-    lstrcpy (szKeyBuf, "Software\\Microsoft\\Exchange\\Client\\Extensions");\r
-    lstrcpy (szEntry, "4.0;");\r
-    lstrcat (szEntry, szModuleFileName);\r
-    lstrcat (szEntry, ";1;11000111111100");  /* context information */\r
-    ec = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szKeyBuf, 0, NULL, \r
-                                  REG_OPTION_NON_VOLATILE,\r
-                                  KEY_ALL_ACCESS, NULL, &hkey, NULL);\r
-    if (ec != ERROR_SUCCESS) {\r
-       ExchLogInfo ("DllRegisterServer failed\n");\r
-       return E_ACCESSDENIED;\r
-    }\r
-    \r
-    dwTemp = lstrlen (szEntry) + 1;\r
-    RegSetValueEx (hkey, "OutlGPG", 0, REG_SZ, (BYTE*) szEntry, dwTemp);\r
-\r
-    /* set outlook update flag */\r
-    strcpy (szEntry, "4.0;Outxxx.dll;7;000000000000000;0000000000;OutXXX");\r
-    dwTemp = lstrlen (szEntry) + 1;\r
-    RegSetValueEx (hkey, "Outlook Setup Extension", 0, REG_SZ, (BYTE*) szEntry, dwTemp);\r
-    RegCloseKey (hkey);\r
-    \r
-    hkey = NULL;\r
-    lstrcpy (szKeyBuf, "Software\\GNU\\OutlGPG");\r
-    RegCreateKeyEx (HKEY_CURRENT_USER, szKeyBuf, 0, NULL,\r
-                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);\r
-    if (hkey != NULL)\r
-       RegCloseKey (hkey);\r
-\r
-    ExchLogInfo ("DllRegisterServer succeeded\n");\r
-    return S_OK;\r
-}\r
-\r
-\r
-/* DllUnregisterServer - Unregisters this object in the exchange extension list. */\r
-STDAPI \r
-DllUnregisterServer (void)\r
-{\r
-    HKEY hkey;\r
-    CHAR szKeyBuf[1024];\r
-\r
-    lstrcpy(szKeyBuf, "Software\\Microsoft\\Exchange\\Client\\Extensions");\r
-    /* create and open key and subkey */\r
-    long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKeyBuf, 0, NULL, \r
-                                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, \r
-                                   NULL, &hkey, NULL);\r
-    if (lResult != ERROR_SUCCESS) {\r
-       ExchLogInfo ("DllUnregisterServer: access denied.\n");\r
-       return E_ACCESSDENIED;\r
-    }\r
-    RegDeleteValue (hkey, "OutlGPG");\r
-    /* set outlook update flag */\r
-    CHAR szEntry[512];\r
-    strcpy (szEntry, "4.0;Outxxx.dll;7;000000000000000;0000000000;OutXXX");\r
-    DWORD dwTemp = lstrlen (szEntry) + 1;\r
-    RegSetValueEx (hkey, "Outlook Setup Extension", 0, REG_SZ, (BYTE*) szEntry, dwTemp);\r
-    RegCloseKey (hkey);\r
-\r
-    return S_OK;\r
-}\r
-\r
-\r
-/* constructor of CGPGExchExt\r
- Initializes members and creates the interface objects for the new context.\r
- Does the dll initialization if it was not done before. */\r
-CGPGExchExt::CGPGExchExt (void)\r
-{ \r
-    m_lRef = 1;\r
-    m_lContext = 0;\r
-    m_hWndExchange = 0;\r
-    m_gpgEncrypt = FALSE;\r
-    m_gpgSign = FALSE;\r
-    m_pExchExtMessageEvents = new CGPGExchExtMessageEvents (this);\r
-    m_pExchExtCommands = new CGPGExchExtCommands (this);\r
-    m_pExchExtPropertySheets = new CGPGExchExtPropertySheets (this);\r
-    if (!g_bInitDll) {\r
-       if (m_gpg == NULL) {\r
-           m_gpg = CreateMapiGPGME (NULL);\r
-           m_gpg->readOptions ();\r
-       }\r
-       g_bInitDll = TRUE;\r
-       ExchLogInfo("CGPGExchExt load\n");\r
-    }\r
-    else\r
-       ExchLogInfo("CGPGExchExt exists\n");\r
-}\r
-\r
-\r
-/* constructor of CGPGExchExt - Uninitializes the dll in the dession context. */\r
-CGPGExchExt::~CGPGExchExt (void) \r
-{\r
-    if (m_lContext == EECONTEXT_SESSION) {\r
-       if (g_bInitDll) {\r
-           if (m_gpg != NULL) {\r
-               m_gpg->writeOptions ();\r
-               delete m_gpg;\r
-               m_gpg = NULL;\r
-           }\r
-           g_bInitDll = FALSE;\r
-       }       \r
-    }\r
-}\r
-\r
-\r
-/* CGPGExchExt::QueryInterface\r
- Called by Exchage to request for interfaces.\r
-\r
- Return value: S_OK if the interface is supported, otherwise E_NOINTERFACE: */\r
-STDMETHODIMP \r
-CGPGExchExt::QueryInterface(\r
-       REFIID riid,      // The interface ID.\r
-       LPVOID * ppvObj)  // The address of interface object pointer.\r
-{\r
-    HRESULT hr = S_OK;\r
-\r
-    *ppvObj = NULL;\r
-\r
-    if ((riid == IID_IUnknown) || (riid == IID_IExchExt)) {\r
-        *ppvObj = (LPUNKNOWN) this;\r
-    }\r
-    else if (riid == IID_IExchExtMessageEvents) {\r
-        *ppvObj = (LPUNKNOWN) m_pExchExtMessageEvents;\r
-    }\r
-    else if (riid == IID_IExchExtCommands) {\r
-        *ppvObj = (LPUNKNOWN)m_pExchExtCommands;\r
-        m_pExchExtCommands->SetContext(m_lContext);\r
-    }\r
-    else if (riid == IID_IExchExtPropertySheets) {\r
-       if (m_lContext != EECONTEXT_PROPERTYSHEETS)\r
-           return E_NOINTERFACE;\r
-        *ppvObj = (LPUNKNOWN) m_pExchExtPropertySheets;\r
-    }\r
-    else\r
-        hr = E_NOINTERFACE;\r
-\r
-    if (*ppvObj != NULL)\r
-        ((LPUNKNOWN)*ppvObj)->AddRef();\r
-\r
-    /*ExchLogInfo("QueryInterface %d\n", __LINE__);*/\r
-    return hr;\r
-}\r
-\r
-\r
-/* CGPGExchExt::Install\r
- Called once for each new context. Checks the exchange extension version \r
- number and the context.\r
\r
- Return value: S_OK if the extension should used in the requested context, \r
-               otherwise S_FALSE. */\r
-STDMETHODIMP CGPGExchExt::Install(\r
-       LPEXCHEXTCALLBACK pEECB, // The pointer to Exchange Extension callback function.\r
-       ULONG lContext,          // The context code at time of being called.\r
-       ULONG lFlags)            // The flag to say if install is for modal or not.\r
-{\r
-    ULONG lBuildVersion;\r
-\r
-    m_lContext = lContext;\r
-\r
-    /*ExchLogInfo("Install %d\n", __LINE__);*/\r
-    // check the version \r
-    pEECB->GetVersion (&lBuildVersion, EECBGV_GETBUILDVERSION);\r
-    if (EECBGV_BUILDVERSION_MAJOR != (lBuildVersion & EECBGV_BUILDVERSION_MAJOR_MASK))\r
-        return S_FALSE;\r
-\r
-    // and the context\r
-    if ((lContext == EECONTEXT_PROPERTYSHEETS) ||\r
-       (lContext == EECONTEXT_SENDNOTEMESSAGE) ||\r
-       (lContext == EECONTEXT_SENDPOSTMESSAGE) ||\r
-       (lContext == EECONTEXT_SENDRESENDMESSAGE) ||\r
-       (lContext == EECONTEXT_READNOTEMESSAGE) ||\r
-       (lContext == EECONTEXT_READPOSTMESSAGE) ||\r
-       (lContext == EECONTEXT_READREPORTMESSAGE) ||\r
-       (lContext == EECONTEXT_VIEWER))\r
-       return S_OK;\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-CGPGExchExtMessageEvents::CGPGExchExtMessageEvents (CGPGExchExt *pParentInterface)\r
-{ \r
-    m_pExchExt = pParentInterface;\r
-    m_lRef = 0; \r
-    m_bOnSubmitCalled = FALSE;\r
-};\r
-\r
-\r
-STDMETHODIMP \r
-CGPGExchExtMessageEvents::QueryInterface (REFIID riid, LPVOID FAR *ppvObj)\r
-{   \r
-    *ppvObj = NULL;\r
-    if (riid == IID_IExchExtMessageEvents) {\r
-        *ppvObj = (LPVOID)this;\r
-        AddRef();\r
-        return S_OK;\r
-    }\r
-    if (riid == IID_IUnknown) {\r
-        *ppvObj = (LPVOID)m_pExchExt;  \r
-        m_pExchExt->AddRef();\r
-        return S_OK;\r
-    }\r
-    return E_NOINTERFACE;\r
-}\r
-\r
-\r
-/* CGPGExchExtMessageEvents::OnRead - Called from Exchange on reading a message.\r
- Return value: S_FALSE to signal Exchange to continue calling extensions. */\r
-STDMETHODIMP CGPGExchExtMessageEvents::OnRead(\r
-       LPEXCHEXTCALLBACK pEECB) // A pointer to IExchExtCallback interface.\r
-{\r
-    ExchLogInfo ("OnRead\n");\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-/* CGPGExchExtMessageEvents::OnReadComplete\r
- Called by Exchange after a message has been read.\r
-\r
- Return value: S_FALSE to signal Exchange to continue calling extensions. */\r
-STDMETHODIMP CGPGExchExtMessageEvents::OnReadComplete(\r
-       LPEXCHEXTCALLBACK pEECB, // A pointer to IExchExtCallback interface.\r
-       ULONG lFlags)\r
-{\r
-    ExchLogInfo ("OnReadComplete\n");\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-/* CGPGExchExtMessageEvents::OnWrite - Called by Exchange when a message will be written.\r
- @rdesc S_FALSE to signal Exchange to continue calling extensions. */\r
-STDMETHODIMP CGPGExchExtMessageEvents::OnWrite(\r
-       LPEXCHEXTCALLBACK pEECB) // A pointer to IExchExtCallback interface.\r
-{\r
-    ExchLogInfo ("OnWrite\n");\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-/* CGPGExchExtMessageEvents::OnWriteComplete\r
- Called by Exchange when the data has been written to the message.\r
- Encrypts and signs the message if the options are set.\r
- @pEECB - A pointer to IExchExtCallback interface.\r
-\r
- Return value: S_FALSE: signals Exchange to continue calling extensions\r
-               E_FAIL:  signals Exchange an error; the message will not be sent */\r
-STDMETHODIMP CGPGExchExtMessageEvents::OnWriteComplete (\r
-                 LPEXCHEXTCALLBACK pEECB, ULONG lFlags)\r
-{\r
-    HRESULT hrReturn = S_FALSE;\r
-    LPMESSAGE pMessage = NULL;\r
-    LPMDB pMDB = NULL;\r
-    HWND hWnd = NULL;\r
-\r
-    if (FAILED(pEECB->GetWindow (&hWnd)))\r
-       hWnd = NULL;\r
-\r
-    if (!m_bOnSubmitCalled) /* the user is just saving the message */\r
-       return S_FALSE;\r
-\r
-    if (m_bWriteFailed)     /* operation failed already */\r
-       return S_FALSE;\r
-\r
-    HRESULT hr = pEECB->GetObject (&pMDB, (LPMAPIPROP *)&pMessage);\r
-    if (SUCCEEDED (hr)) {\r
-       if (m_pExchExt->m_gpgEncrypt || m_pExchExt->m_gpgSign) {\r
-           m_gpg->setMessage (pMessage);\r
-           if (m_gpg->doCmd (m_pExchExt->m_gpgEncrypt,\r
-                             m_pExchExt->m_gpgSign)) {\r
-               hrReturn = E_FAIL;\r
-               m_bWriteFailed = TRUE;  \r
-           }\r
-       }\r
-    }\r
-    if (pMessage != NULL)\r
-       UlRelease(pMessage);\r
-    if (pMDB != NULL)\r
-       UlRelease(pMDB);\r
-\r
-    return hrReturn;\r
-}\r
-\r
-/* CGPGExchExtMessageEvents::OnCheckNames\r
-\r
- Called by Exchange when the user selects the "check names" command.\r
-\r
- @pEECB - A pointer to IExchExtCallback interface.\r
-\r
- Return value: S_FALSE to signal Exchange to continue calling extensions.\r
-*/\r
-STDMETHODIMP CGPGExchExtMessageEvents::OnCheckNames(LPEXCHEXTCALLBACK pEECB)\r
-{\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-/* CGPGExchExtMessageEvents::OnCheckNamesComplete\r
-\r
- Called by Exchange when "check names" command is complete.\r
-\r
-  @pEECB - A pointer to IExchExtCallback interface.\r
-\r
- Return value: S_FALSE to signal Exchange to continue calling extensions.\r
-*/\r
-STDMETHODIMP CGPGExchExtMessageEvents::OnCheckNamesComplete(\r
-                       LPEXCHEXTCALLBACK pEECB, ULONG lFlags)\r
-{\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-/* CGPGExchExtMessageEvents::OnSubmit\r
-\r
- Called by Exchange before the message data will be written and submitted.\r
- to MAPI.\r
-\r
- @pEECB - A pointer to IExchExtCallback interface.\r
-\r
- Return value: S_FALSE to signal Exchange to continue calling extensions.\r
-*/\r
-STDMETHODIMP CGPGExchExtMessageEvents::OnSubmit(\r
-                           LPEXCHEXTCALLBACK pEECB)\r
-{\r
-    m_bOnSubmitCalled = TRUE;\r
-    m_bWriteFailed = FALSE;\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-/* CGPGExchExtMessageEvents::OnSubmitComplete\r
-\r
-  @pEECB - A pointer to IExchExtCallback interface.\r
-\r
- Called by Echange after the message has been submitted to MAPI.\r
-*/\r
-STDMETHODIMP_ (VOID) CGPGExchExtMessageEvents::OnSubmitComplete (\r
-                           LPEXCHEXTCALLBACK pEECB, ULONG lFlags)\r
-{\r
-    m_bOnSubmitCalled = FALSE; \r
-}\r
-\r
-\r
-CGPGExchExtCommands::CGPGExchExtCommands (CGPGExchExt* pParentInterface)\r
-{ \r
-    m_pExchExt = pParentInterface; \r
-    m_lRef = 0; \r
-    m_lContext = 0; \r
-    m_nCmdEncrypt = 0;  \r
-    m_nCmdSign = 0; \r
-    m_nToolbarButtonID1 = 0; \r
-    m_nToolbarButtonID2 = 0; \r
-    m_nToolbarBitmap1 = 0;\r
-    m_nToolbarBitmap2 = 0; \r
-    m_hWnd = NULL; \r
-};\r
-\r
-\r
-\r
-STDMETHODIMP \r
-CGPGExchExtCommands::QueryInterface (REFIID riid, LPVOID FAR * ppvObj)\r
-{\r
-    *ppvObj = NULL;\r
-    if ((riid == IID_IExchExtCommands) || (riid == IID_IUnknown)) {\r
-        *ppvObj = (LPVOID)this;\r
-        AddRef ();\r
-        return S_OK;\r
-    }\r
-    return E_NOINTERFACE;\r
-}\r
-\r
-\r
-// XXX IExchExtSessionEvents::OnDelivery: could be used to automatically decrypt new mails\r
-// when they arrive\r
-\r
-/* CGPGExchExtCommands::InstallCommands\r
-\r
- Called by Echange to install commands and toolbar buttons.\r
-\r
- Return value: S_FALSE to signal Exchange to continue calling extensions.\r
-*/\r
-STDMETHODIMP CGPGExchExtCommands::InstallCommands(\r
-       LPEXCHEXTCALLBACK pEECB, // The Exchange Callback Interface.\r
-       HWND hWnd,               // The window handle to main window of context.\r
-       HMENU hMenu,             // The menu handle to main menu of context.\r
-       UINT FAR * pnCommandIDBase,  // The base conmmand id.\r
-       LPTBENTRY pTBEArray,     // The array of toolbar button entries.\r
-       UINT nTBECnt,            // The count of button entries in array.\r
-       ULONG lFlags)            // reserved\r
-{\r
-    HMENU hMenuTools;\r
-    m_hWnd = hWnd;\r
-\r
-    /* XXX: factor out common code */\r
-    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {\r
-       int nTBIndex;\r
-       HWND hwndToolbar = NULL;\r
-       CHAR szBuffer[128];\r
-\r
-        pEECB->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &hMenuTools, NULL, NULL, 0);\r
-        AppendMenu (hMenuTools, MF_SEPARATOR, 0, NULL);\r
-       \r
-       LoadString (theApp.m_hInstance, IDS_DECRYPT_MENU_ITEM, szBuffer, 128);\r
-        AppendMenu (hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);\r
-\r
-        m_nCmdEncrypt = *pnCommandIDBase;\r
-        (*pnCommandIDBase)++;\r
-       \r
-       for (nTBIndex = nTBECnt-1; nTBIndex > -1; --nTBIndex) { \r
-           if (EETBID_STANDARD == pTBEArray[nTBIndex].tbid) {\r
-               hwndToolbar = pTBEArray[nTBIndex].hwnd;         \r
-               m_nToolbarButtonID1 = pTBEArray[nTBIndex].itbbBase;\r
-               pTBEArray[nTBIndex].itbbBase++;\r
-               break;          \r
-           }   \r
-       }\r
-\r
-       if (hwndToolbar) {\r
-           TBADDBITMAP tbab;\r
-           tbab.hInst = theApp.m_hInstance;\r
-           tbab.nID = IDB_DECRYPT;\r
-           m_nToolbarBitmap1 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);\r
-           m_nToolbarButtonID2 = pTBEArray[nTBIndex].itbbBase;\r
-           pTBEArray[nTBIndex].itbbBase++;\r
-       }\r
-    }\r
-\r
-    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {\r
-       CHAR szBuffer[128];\r
-       int nTBIndex;\r
-       HWND hwndToolbar = NULL;\r
-\r
-        pEECB->GetMenuPos(EECMDID_ToolsCustomizeToolbar, &hMenuTools, NULL, NULL, 0);\r
-        AppendMenu(hMenuTools, MF_SEPARATOR, 0, NULL);\r
-       \r
-       LoadString(theApp.m_hInstance, IDS_ENCRYPT_MENU_ITEM, szBuffer, 128);\r
-        AppendMenu(hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);\r
-\r
-        m_nCmdEncrypt = *pnCommandIDBase;\r
-        (*pnCommandIDBase)++;\r
-\r
-       LoadString(theApp.m_hInstance, IDS_SIGN_MENU_ITEM, szBuffer, 128);\r
-        AppendMenu(hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);\r
-\r
-        m_nCmdSign = *pnCommandIDBase;\r
-        (*pnCommandIDBase)++;\r
-\r
-       for (nTBIndex = nTBECnt-1; nTBIndex > -1; --nTBIndex)\r
-       {\r
-           if (EETBID_STANDARD == pTBEArray[nTBIndex].tbid)\r
-           {\r
-               hwndToolbar = pTBEArray[nTBIndex].hwnd;\r
-               m_nToolbarButtonID1 = pTBEArray[nTBIndex].itbbBase;\r
-               pTBEArray[nTBIndex].itbbBase++;\r
-               break;  \r
-           }\r
-       }\r
-\r
-       if (hwndToolbar) {\r
-           TBADDBITMAP tbab;\r
-           tbab.hInst = theApp.m_hInstance;\r
-           tbab.nID = IDB_ENCRYPT;\r
-           m_nToolbarBitmap1 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);\r
-           m_nToolbarButtonID2 = pTBEArray[nTBIndex].itbbBase;\r
-           pTBEArray[nTBIndex].itbbBase++;\r
-           tbab.nID = IDB_SIGN;\r
-           m_nToolbarBitmap2 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);\r
-       }\r
-       m_pExchExt->m_gpgEncrypt = m_gpg->getEncryptDefault ();\r
-       m_pExchExt->m_gpgSign = m_gpg->getSignDefault ();\r
-    }\r
-\r
-    if (m_lContext == EECONTEXT_VIEWER) {\r
-       CHAR szBuffer[128];\r
-       int nTBIndex;\r
-       HWND hwndToolbar = NULL;\r
-\r
-        pEECB->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &hMenuTools, NULL, NULL, 0);\r
-        AppendMenu (hMenuTools, MF_SEPARATOR, 0, NULL);\r
-       \r
-       LoadString (theApp.m_hInstance, IDS_KEY_MANAGER, szBuffer, 128);\r
-        AppendMenu (hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);\r
-\r
-        m_nCmdEncrypt = *pnCommandIDBase;\r
-        (*pnCommandIDBase)++;  \r
-\r
-       for (nTBIndex = nTBECnt-1; nTBIndex > -1; --nTBIndex) {\r
-           if (EETBID_STANDARD == pTBEArray[nTBIndex].tbid) {\r
-               hwndToolbar = pTBEArray[nTBIndex].hwnd;\r
-               m_nToolbarButtonID1 = pTBEArray[nTBIndex].itbbBase;\r
-               pTBEArray[nTBIndex].itbbBase++;\r
-               break;  \r
-           }\r
-       }\r
-       if (hwndToolbar) {\r
-           TBADDBITMAP tbab;\r
-           tbab.hInst = theApp.m_hInstance;\r
-           tbab.nID = IDB_KEY_MANAGER;\r
-           m_nToolbarBitmap1 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);\r
-       }       \r
-    }\r
-    return S_FALSE;\r
-}\r
-\r
-\r
-/* CGPGExchExtCommands::DoCommand - Called by Exchange when a user selects a command. \r
-\r
- Return value: S_OK if command is handled, otherwise S_FALSE.\r
-*/\r
-STDMETHODIMP CGPGExchExtCommands::DoCommand(\r
-       LPEXCHEXTCALLBACK pEECB, // The Exchange Callback Interface.\r
-       UINT nCommandID)         // The command id.\r
-{\r
-\r
-    if ((nCommandID != m_nCmdEncrypt) && \r
-       (nCommandID != m_nCmdSign))\r
-       return S_FALSE; \r
-\r
-    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {\r
-       LPMESSAGE pMessage = NULL;\r
-       LPMDB pMDB = NULL;\r
-       HWND hWnd = NULL;\r
-\r
-       if (FAILED (pEECB->GetWindow (&hWnd)))\r
-           hWnd = NULL;\r
-       HRESULT hr = pEECB->GetObject (&pMDB, (LPMAPIPROP *)&pMessage);\r
-       if (SUCCEEDED (hr)) {\r
-           if (nCommandID == m_nCmdEncrypt) {\r
-               m_gpg->setWindow (hWnd);\r
-               m_gpg->setMessage (pMessage);\r
-               m_gpg->decrypt ();\r
-           }\r
-       }\r
-       if (pMessage != NULL)\r
-           UlRelease(pMessage);\r
-       if (pMDB != NULL)\r
-           UlRelease(pMDB);\r
-    }\r
-    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {\r
-       HWND hWnd = NULL;\r
-       if (FAILED(pEECB->GetWindow (&hWnd)))\r
-           hWnd = NULL;\r
-       if (nCommandID == m_nCmdEncrypt)\r
-           m_pExchExt->m_gpgEncrypt = !m_pExchExt->m_gpgEncrypt;\r
-       if (nCommandID == m_nCmdSign)\r
-           m_pExchExt->m_gpgSign = !m_pExchExt->m_gpgSign;\r
-    }\r
-    if (m_lContext == EECONTEXT_VIEWER) {\r
-       if (m_gpg->startKeyManager ())\r
-           MessageBox (NULL, "Could not start Key-Manager", "GPGExch", MB_ICONERROR|MB_OK);\r
-    }\r
-    return S_OK; \r
-}\r
-\r
-STDMETHODIMP_(VOID) CGPGExchExtCommands::InitMenu(\r
-       LPEXCHEXTCALLBACK pEECB) // The pointer to Exchange Callback Interface.\r
-{\r
-}\r
-\r
-/* CGPGExchExtCommands::Help\r
-\r
- Called by Exhange when the user requests help for a menu item.\r
-\r
- Return value: S_OK when it is a menu item of this plugin and the help was shown;\r
-               otherwise S_FALSE\r
-*/\r
-STDMETHODIMP CGPGExchExtCommands::Help (\r
-       LPEXCHEXTCALLBACK pEECB, // The pointer to Exchange Callback Interface.\r
-       UINT nCommandID)         // The command id.\r
-{\r
-    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {\r
-       if (nCommandID == m_nCmdEncrypt) {\r
-           CHAR szBuffer[512];\r
-           CHAR szAppName[128];\r
-\r
-           LoadString (theApp.m_hInstance, IDS_DECRYPT_HELP, szBuffer, 511);\r
-           LoadString (theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);\r
-           MessageBox (m_hWnd, szBuffer, szAppName, MB_OK);\r
-           return S_OK;\r
-       }\r
-    }\r
-    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {\r
-       if (nCommandID == m_nCmdEncrypt) {\r
-           CHAR szBuffer[512];\r
-           CHAR szAppName[128];\r
-           LoadString(theApp.m_hInstance, IDS_ENCRYPT_HELP, szBuffer, 511);\r
-           LoadString(theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);\r
-           MessageBox(m_hWnd, szBuffer, szAppName, MB_OK);     \r
-           return S_OK;\r
-       } \r
-       if (nCommandID == m_nCmdSign) {\r
-           CHAR szBuffer[512]; \r
-           CHAR szAppName[128];        \r
-           LoadString(theApp.m_hInstance, IDS_SIGN_HELP, szBuffer, 511);       \r
-           LoadString(theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);       \r
-           MessageBox(m_hWnd, szBuffer, szAppName, MB_OK);     \r
-           return S_OK;\r
-       } \r
-    }\r
-\r
-    if (m_lContext == EECONTEXT_VIEWER) {\r
-       if (nCommandID == m_nCmdEncrypt) {\r
-               CHAR szBuffer[512];\r
-               CHAR szAppName[128];\r
-               LoadString(theApp.m_hInstance, IDS_KEY_MANAGER_HELP, szBuffer, 511);\r
-               LoadString(theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);\r
-               MessageBox(m_hWnd, szBuffer, szAppName, MB_OK);\r
-               return S_OK;\r
-       } \r
-    }\r
-\r
-    return S_FALSE;\r
-}\r
-\r
-/* CGPGExchExtCommands::QueryHelpText\r
-\r
- Called by Exhange to get the status bar text or the tooltip of a menu item.\r
-\r
- @rdesc S_OK when it is a menu item of this plugin and the text was set;\r
-        otherwise S_FALSE.\r
-*/\r
-STDMETHODIMP CGPGExchExtCommands::QueryHelpText(\r
-       UINT nCommandID,  // The command id corresponding to menu item activated.\r
-       ULONG lFlags,     // Identifies either EECQHT_STATUS or EECQHT_TOOLTIP.\r
-    LPTSTR pszText,   // A pointer to buffer to be populated with text to display.\r
-       UINT nCharCnt)    // The count of characters available in psz buffer.\r
-{\r
-       \r
-    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {\r
-       if (nCommandID == m_nCmdEncrypt) {\r
-           if (lFlags == EECQHT_STATUS)\r
-               LoadString (theApp.m_hInstance, IDS_DECRYPT_STATUSBAR, pszText, nCharCnt);\r
-           if (lFlags == EECQHT_TOOLTIP)\r
-               LoadString (theApp.m_hInstance, IDS_DECRYPT_TOOLTIP, pszText, nCharCnt);\r
-           return S_OK;\r
-       }\r
-    }\r
-    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {\r
-       if (nCommandID == m_nCmdEncrypt) {\r
-           if (lFlags == EECQHT_STATUS)\r
-               LoadString (theApp.m_hInstance, IDS_ENCRYPT_STATUSBAR, pszText, nCharCnt);\r
-           if (lFlags == EECQHT_TOOLTIP)\r
-               LoadString (theApp.m_hInstance, IDS_ENCRYPT_TOOLTIP, pszText, nCharCnt);\r
-           return S_OK;\r
-       }\r
-       if (nCommandID == m_nCmdSign) {\r
-           if (lFlags == EECQHT_STATUS)\r
-               LoadString (theApp.m_hInstance, IDS_SIGN_STATUSBAR, pszText, nCharCnt);\r
-           if (lFlags == EECQHT_TOOLTIP)\r
-               LoadString (theApp.m_hInstance, IDS_SIGN_TOOLTIP, pszText, nCharCnt);\r
-           return S_OK;\r
-       }\r
-    }\r
-    if (m_lContext == EECONTEXT_VIEWER) {\r
-       if (nCommandID == m_nCmdEncrypt) {\r
-           if (lFlags == EECQHT_STATUS)\r
-               LoadString (theApp.m_hInstance, IDS_KEY_MANAGER_STATUSBAR, pszText, nCharCnt);\r
-           if (lFlags == EECQHT_TOOLTIP)\r
-               LoadString (theApp.m_hInstance, IDS_KEY_MANAGER_TOOLTIP, pszText, nCharCnt);\r
-           return S_OK;\r
-       }       \r
-    }\r
-    return S_FALSE;\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CGPGExchExtCommands::QueryButtonInfo \r
-//\r
-// Called by Exchange to get toolbar button infos,\r
-//\r
-// @rdesc S_OK when it is a button of this plugin and the requested info was delivered;\r
-//        otherwise S_FALSE\r
-//\r
-STDMETHODIMP CGPGExchExtCommands::QueryButtonInfo (\r
-       ULONG lToolbarID,       // The toolbar identifier.\r
-       UINT nToolbarButtonID,  // The toolbar button index.\r
-    LPTBBUTTON pTBB,        // A pointer to toolbar button structure (see TBBUTTON structure).\r
-       LPTSTR lpszDescription, // A pointer to string describing button.\r
-       UINT nCharCnt,          // The maximum size of lpsz buffer.\r
-    ULONG lFlags)           // EXCHEXT_UNICODE may be specified\r
-{\r
-       if (m_lContext == EECONTEXT_READNOTEMESSAGE)\r
-       {\r
-               if (nToolbarButtonID == m_nToolbarButtonID1)\r
-               {\r
-                       pTBB->iBitmap = m_nToolbarBitmap1;             \r
-                       pTBB->idCommand = m_nCmdEncrypt;\r
-                       pTBB->fsState = TBSTATE_ENABLED;\r
-                       pTBB->fsStyle = TBSTYLE_BUTTON;\r
-                       pTBB->dwData = 0;\r
-                       pTBB->iString = -1;\r
-                       LoadString(theApp.m_hInstance, IDS_DECRYPT_TOOLTIP, lpszDescription, nCharCnt);\r
-                       return S_OK;\r
-               }\r
-       }\r
-       if (m_lContext == EECONTEXT_SENDNOTEMESSAGE)\r
-       {\r
-               if (nToolbarButtonID == m_nToolbarButtonID1)\r
-               {\r
-                       pTBB->iBitmap = m_nToolbarBitmap1;             \r
-                       pTBB->idCommand = m_nCmdEncrypt;\r
-                       pTBB->fsState = TBSTATE_ENABLED;\r
-                       if (m_pExchExt->m_gpgEncrypt)\r
-                               pTBB->fsState |= TBSTATE_CHECKED;\r
-                       pTBB->fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECK;\r
-                       pTBB->dwData = 0;\r
-                       pTBB->iString = -1;\r
-                       LoadString(theApp.m_hInstance, IDS_ENCRYPT_TOOLTIP, lpszDescription, nCharCnt);\r
-                       return S_OK;\r
-               }\r
-               if (nToolbarButtonID == m_nToolbarButtonID2)\r
-               {\r
-                       pTBB->iBitmap = m_nToolbarBitmap2;             \r
-                       pTBB->idCommand = m_nCmdSign;\r
-                       pTBB->fsState = TBSTATE_ENABLED;\r
-                       if (m_pExchExt->m_gpgSign)\r
-                               pTBB->fsState |= TBSTATE_CHECKED;\r
-                       pTBB->fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECK;\r
-                       pTBB->dwData = 0;\r
-                       pTBB->iString = -1;\r
-                       LoadString(theApp.m_hInstance, IDS_SIGN_TOOLTIP, lpszDescription, nCharCnt);\r
-                       return S_OK;\r
-               }\r
-       }\r
-       if (m_lContext == EECONTEXT_VIEWER)\r
-       {\r
-               if (nToolbarButtonID == m_nToolbarButtonID1)\r
-               {\r
-                       pTBB->iBitmap = m_nToolbarBitmap1;             \r
-                       pTBB->idCommand = m_nCmdEncrypt;\r
-                       pTBB->fsState = TBSTATE_ENABLED;\r
-                       pTBB->fsStyle = TBSTYLE_BUTTON;\r
-                       pTBB->dwData = 0;\r
-                       pTBB->iString = -1;\r
-                       LoadString(theApp.m_hInstance, IDS_KEY_MANAGER_TOOLTIP, lpszDescription, nCharCnt);\r
-                       return S_OK;\r
-               }\r
-       }\r
-\r
-       return S_FALSE;\r
-}\r
-\r
-\r
-STDMETHODIMP \r
-CGPGExchExtCommands::ResetToolbar (ULONG lToolbarID, ULONG lFlags)\r
-{      \r
-    return S_OK;\r
-}\r
-\r
-\r
-CGPGExchExtPropertySheets::CGPGExchExtPropertySheets(CGPGExchExt* pParentInterface)\r
-{ \r
-    m_pExchExt = pParentInterface;\r
-    m_lRef = 0; \r
-}\r
-\r
-\r
-STDMETHODIMP \r
-CGPGExchExtPropertySheets::QueryInterface(REFIID riid, LPVOID FAR * ppvObj)\r
-{   \r
-    *ppvObj = NULL;\r
-    if (riid == IID_IExchExtPropertySheets) {\r
-        *ppvObj = (LPVOID)this;\r
-        AddRef();\r
-        return S_OK;\r
-    }\r
-    if (riid == IID_IUnknown) {\r
-        *ppvObj = (LPVOID)m_pExchExt;\r
-        m_pExchExt->AddRef();\r
-        return S_OK;\r
-    }\r
-\r
-    return E_NOINTERFACE;\r
-}\r
-\r
-\r
-/* CGPGExchExtPropertySheets::GetMaxPageCount\r
-\r
- Called by Echange to get the maximum number of property pages which are\r
- to be added.\r
-\r
- Return value: The maximum number of custom pages for the property sheet.\r
-*/\r
-STDMETHODIMP_ (ULONG) \r
-CGPGExchExtPropertySheets::GetMaxPageCount(\r
-       ULONG lFlags) // A bitmask indicating what type of property sheet is being displayed.\r
-{\r
-    if (lFlags == EEPS_TOOLSOPTIONS)\r
-       return 1;       \r
-    return 0;\r
-}\r
-\r
-\r
-BOOL CALLBACK GPGOptionsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
-\r
-\r
-/* CGPGExchExtPropertySheets::GetPages\r
-\r
- Called by Exchange to request information about the property page.\r
-\r
- Return value: S_OK to signal Echange to use the pPSP information.\r
-*/\r
-STDMETHODIMP \r
-CGPGExchExtPropertySheets::GetPages(\r
-       LPEXCHEXTCALLBACK pEECB, // A pointer to Exchange callback interface.\r
-       ULONG lFlags,            // A  bitmask indicating what type of property sheet is being displayed.\r
-       LPPROPSHEETPAGE pPSP,    // The output parm pointing to pointer to list of property sheets.\r
-       ULONG FAR * plPSP)       // The output parm pointing to buffer contaiing number of property sheets actually used.\r
-{\r
-    int resid = 0;\r
-\r
-    switch (GetUserDefaultLangID ()) {\r
-    case 0x0407:    resid = IDD_GPG_OPTIONS_DE;break;\r
-    default:       resid = IDD_GPG_OPTIONS; break;\r
-    }\r
-\r
-    pPSP[0].dwSize = sizeof (PROPSHEETPAGE);\r
-    pPSP[0].dwFlags = PSP_DEFAULT | PSP_HASHELP;\r
-    pPSP[0].hInstance = theApp.m_hInstance;\r
-    pPSP[0].pszTemplate = MAKEINTRESOURCE (resid);\r
-    pPSP[0].hIcon = NULL;     \r
-    pPSP[0].pszTitle = NULL;  \r
-    pPSP[0].pfnDlgProc = (DLGPROC) GPGOptionsDlgProc;\r
-    pPSP[0].lParam = 0;     \r
-    pPSP[0].pfnCallback = NULL;\r
-    pPSP[0].pcRefParent = NULL; \r
-\r
-    *plPSP = 1;\r
-\r
-    return S_OK;\r
-}\r
-\r
-STDMETHODIMP_ (VOID) \r
-CGPGExchExtPropertySheets::FreePages (LPPROPSHEETPAGE pPSP, ULONG lFlags, ULONG lPSP)\r
-{\r
-}\r
+/* GPGExch.cpp - exchange extension classes
+ *     Copyright (C) 2001 G Data Software AG, http://www.gdata.de
+ *     Copyright (C) 2004, 2005 g10 Code GmbH
+ * 
+ * This file is part of the G DATA Outlook Plugin for GnuPG.
+ * 
+ * This plugin is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * 
+ * This plugin is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this plugin; if not, write to the 
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "stdafx.h"
+
+#ifndef INITGUID
+#define INITGUID
+#endif
+#include <INITGUID.H>
+#include <MAPIGUID.H>
+#include <EXCHEXT.H>
+
+#include "GPGExchange.h"
+#include "GPGExch.h"
+#include "../src/MapiGPGME.h"
+
+BOOL g_bInitDll = FALSE;
+MapiGPGME *m_gpg = NULL;
+
+static void 
+ExchLogInfo (const char * fmt, ...)
+{
+    if (m_gpg) {
+        va_list a;
+  
+        va_start (a, fmt);
+        m_gpg->logDebug (fmt, a);
+        va_end (a);
+    }
+}
+
+/* The one and only CGPGExchApp object */
+BEGIN_MESSAGE_MAP(CGPGExchApp, CWinApp)
+END_MESSAGE_MAP()
+
+CGPGExchApp::CGPGExchApp (void)
+{
+    ExchLogInfo("GPGExch\n");
+}
+
+CGPGExchApp theApp;
+
+
+
+/* ExchEntryPoint -
+ The entry point which Exchange calls.
+ This is called for each context entry. Creates a new CAvkExchExt object
+ every time so each context will get its own CAvkExchExt interface.
+ Return value: Pointer to Exchange Extension Object */
+LPEXCHEXT CALLBACK 
+ExchEntryPoint (void)
+{
+    ExchLogInfo ("extension entry point...\n");
+    return new CGPGExchExt;
+}
+
+
+/* DllRegisterServer
+ Registers this object as exchange extension. Sets the contextes which are 
+ implemented by this object. */
+STDAPI 
+DllRegisterServer (void)
+{    
+    HKEY hkey;
+    CHAR szKeyBuf[1024];
+    CHAR szEntry[512];
+    TCHAR szModuleFileName[MAX_PATH];
+    DWORD dwTemp = 0;
+    long ec;
+
+    /* get server location */
+    DWORD dwResult = ::GetModuleFileName(theApp.m_hInstance, szModuleFileName, MAX_PATH);
+    if (dwResult == 0) 
+       return E_FAIL;
+
+    lstrcpy (szKeyBuf, "Software\\Microsoft\\Exchange\\Client\\Extensions");
+    lstrcpy (szEntry, "4.0;");
+    lstrcat (szEntry, szModuleFileName);
+    lstrcat (szEntry, ";1;11000111111100");  /* context information */
+    ec = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szKeyBuf, 0, NULL, 
+                                  REG_OPTION_NON_VOLATILE,
+                                  KEY_ALL_ACCESS, NULL, &hkey, NULL);
+    if (ec != ERROR_SUCCESS) {
+       ExchLogInfo ("DllRegisterServer failed\n");
+       return E_ACCESSDENIED;
+    }
+    
+    dwTemp = lstrlen (szEntry) + 1;
+    RegSetValueEx (hkey, "OutlGPG", 0, REG_SZ, (BYTE*) szEntry, dwTemp);
+
+    /* set outlook update flag */
+    strcpy (szEntry, "4.0;Outxxx.dll;7;000000000000000;0000000000;OutXXX");
+    dwTemp = lstrlen (szEntry) + 1;
+    RegSetValueEx (hkey, "Outlook Setup Extension", 0, REG_SZ, (BYTE*) szEntry, dwTemp);
+    RegCloseKey (hkey);
+    
+    hkey = NULL;
+    lstrcpy (szKeyBuf, "Software\\GNU\\OutlGPG");
+    RegCreateKeyEx (HKEY_CURRENT_USER, szKeyBuf, 0, NULL,
+                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
+    if (hkey != NULL)
+       RegCloseKey (hkey);
+
+    ExchLogInfo ("DllRegisterServer succeeded\n");
+    return S_OK;
+}
+
+
+/* DllUnregisterServer - Unregisters this object in the exchange extension list. */
+STDAPI 
+DllUnregisterServer (void)
+{
+    HKEY hkey;
+    CHAR szKeyBuf[1024];
+
+    lstrcpy(szKeyBuf, "Software\\Microsoft\\Exchange\\Client\\Extensions");
+    /* create and open key and subkey */
+    long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKeyBuf, 0, NULL, 
+                                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 
+                                   NULL, &hkey, NULL);
+    if (lResult != ERROR_SUCCESS) {
+       ExchLogInfo ("DllUnregisterServer: access denied.\n");
+       return E_ACCESSDENIED;
+    }
+    RegDeleteValue (hkey, "OutlGPG");
+    /* set outlook update flag */
+    CHAR szEntry[512];
+    strcpy (szEntry, "4.0;Outxxx.dll;7;000000000000000;0000000000;OutXXX");
+    DWORD dwTemp = lstrlen (szEntry) + 1;
+    RegSetValueEx (hkey, "Outlook Setup Extension", 0, REG_SZ, (BYTE*) szEntry, dwTemp);
+    RegCloseKey (hkey);
+
+    return S_OK;
+}
+
+
+/* constructor of CGPGExchExt
+ Initializes members and creates the interface objects for the new context.
+ Does the dll initialization if it was not done before. */
+CGPGExchExt::CGPGExchExt (void)
+{ 
+    m_lRef = 1;
+    m_lContext = 0;
+    m_hWndExchange = 0;
+    m_gpgEncrypt = FALSE;
+    m_gpgSign = FALSE;
+    m_pExchExtMessageEvents = new CGPGExchExtMessageEvents (this);
+    m_pExchExtCommands = new CGPGExchExtCommands (this);
+    m_pExchExtPropertySheets = new CGPGExchExtPropertySheets (this);
+    if (!g_bInitDll) {
+       if (m_gpg == NULL) {
+           m_gpg = CreateMapiGPGME (NULL);
+           m_gpg->readOptions ();
+       }
+       g_bInitDll = TRUE;
+       ExchLogInfo("CGPGExchExt load\n");
+    }
+    else
+       ExchLogInfo("CGPGExchExt exists\n");
+}
+
+
+/* constructor of CGPGExchExt - Uninitializes the dll in the dession context. */
+CGPGExchExt::~CGPGExchExt (void) 
+{
+    if (m_lContext == EECONTEXT_SESSION) {
+       if (g_bInitDll) {
+           if (m_gpg != NULL) {
+               m_gpg->writeOptions ();
+               delete m_gpg;
+               m_gpg = NULL;
+           }
+           g_bInitDll = FALSE;
+       }       
+    }
+}
+
+
+/* CGPGExchExt::QueryInterface
+ Called by Exchage to request for interfaces.
+
+ Return value: S_OK if the interface is supported, otherwise E_NOINTERFACE: */
+STDMETHODIMP 
+CGPGExchExt::QueryInterface(
+       REFIID riid,      // The interface ID.
+       LPVOID * ppvObj)  // The address of interface object pointer.
+{
+    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;
+    }
+    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
+        hr = E_NOINTERFACE;
+
+    if (*ppvObj != NULL)
+        ((LPUNKNOWN)*ppvObj)->AddRef();
+
+    /*ExchLogInfo("QueryInterface %d\n", __LINE__);*/
+    return hr;
+}
+
+
+/* CGPGExchExt::Install
+ Called once for each new context. Checks the exchange extension version 
+ number and the context.
+ Return value: S_OK if the extension should used in the requested context, 
+               otherwise S_FALSE. */
+STDMETHODIMP CGPGExchExt::Install(
+       LPEXCHEXTCALLBACK pEECB, // The pointer to Exchange Extension callback function.
+       ULONG lContext,          // The context code at time of being called.
+       ULONG lFlags)            // The flag to say if install is for modal or not.
+{
+    ULONG lBuildVersion;
+
+    m_lContext = lContext;
+
+    /*ExchLogInfo("Install %d\n", __LINE__);*/
+    // check the version 
+    pEECB->GetVersion (&lBuildVersion, EECBGV_GETBUILDVERSION);
+    if (EECBGV_BUILDVERSION_MAJOR != (lBuildVersion & EECBGV_BUILDVERSION_MAJOR_MASK))
+        return S_FALSE;
+
+    // and the context
+    if ((lContext == EECONTEXT_PROPERTYSHEETS) ||
+       (lContext == EECONTEXT_SENDNOTEMESSAGE) ||
+       (lContext == EECONTEXT_SENDPOSTMESSAGE) ||
+       (lContext == EECONTEXT_SENDRESENDMESSAGE) ||
+       (lContext == EECONTEXT_READNOTEMESSAGE) ||
+       (lContext == EECONTEXT_READPOSTMESSAGE) ||
+       (lContext == EECONTEXT_READREPORTMESSAGE) ||
+       (lContext == EECONTEXT_VIEWER))
+       return S_OK;
+    return S_FALSE;
+}
+
+
+CGPGExchExtMessageEvents::CGPGExchExtMessageEvents (CGPGExchExt *pParentInterface)
+{ 
+    m_pExchExt = pParentInterface;
+    m_lRef = 0; 
+    m_bOnSubmitCalled = FALSE;
+};
+
+
+STDMETHODIMP 
+CGPGExchExtMessageEvents::QueryInterface (REFIID riid, LPVOID FAR *ppvObj)
+{   
+    *ppvObj = NULL;
+    if (riid == IID_IExchExtMessageEvents) {
+        *ppvObj = (LPVOID)this;
+        AddRef();
+        return S_OK;
+    }
+    if (riid == IID_IUnknown) {
+        *ppvObj = (LPVOID)m_pExchExt;  
+        m_pExchExt->AddRef();
+        return S_OK;
+    }
+    return E_NOINTERFACE;
+}
+
+
+/* CGPGExchExtMessageEvents::OnRead - Called from Exchange on reading a message.
+ Return value: S_FALSE to signal Exchange to continue calling extensions. */
+STDMETHODIMP CGPGExchExtMessageEvents::OnRead(
+       LPEXCHEXTCALLBACK pEECB) // A pointer to IExchExtCallback interface.
+{
+    ExchLogInfo ("OnRead\n");
+    return S_FALSE;
+}
+
+
+/* CGPGExchExtMessageEvents::OnReadComplete
+ Called by Exchange after a message has been read.
+
+ Return value: S_FALSE to signal Exchange to continue calling extensions. */
+STDMETHODIMP CGPGExchExtMessageEvents::OnReadComplete(
+       LPEXCHEXTCALLBACK pEECB, // A pointer to IExchExtCallback interface.
+       ULONG lFlags)
+{
+    ExchLogInfo ("OnReadComplete\n");
+    return S_FALSE;
+}
+
+
+/* CGPGExchExtMessageEvents::OnWrite - Called by Exchange when a message will be written.
+ @rdesc S_FALSE to signal Exchange to continue calling extensions. */
+STDMETHODIMP CGPGExchExtMessageEvents::OnWrite(
+       LPEXCHEXTCALLBACK pEECB) // A pointer to IExchExtCallback interface.
+{
+    ExchLogInfo ("OnWrite\n");
+    return S_FALSE;
+}
+
+
+/* CGPGExchExtMessageEvents::OnWriteComplete
+ Called by Exchange when the data has been written to the message.
+ Encrypts and signs the message if the options are set.
+ @pEECB - A pointer to IExchExtCallback interface.
+
+ Return value: S_FALSE: signals Exchange to continue calling extensions
+               E_FAIL:  signals Exchange an error; the message will not be sent */
+STDMETHODIMP CGPGExchExtMessageEvents::OnWriteComplete (
+                 LPEXCHEXTCALLBACK pEECB, ULONG lFlags)
+{
+    HRESULT hrReturn = S_FALSE;
+    LPMESSAGE pMessage = NULL;
+    LPMDB pMDB = NULL;
+    HWND hWnd = NULL;
+
+    if (FAILED(pEECB->GetWindow (&hWnd)))
+       hWnd = NULL;
+
+    if (!m_bOnSubmitCalled) /* the user is just saving the message */
+       return S_FALSE;
+
+    if (m_bWriteFailed)     /* operation failed already */
+       return S_FALSE;
+
+    HRESULT hr = pEECB->GetObject (&pMDB, (LPMAPIPROP *)&pMessage);
+    if (SUCCEEDED (hr)) {
+       if (m_pExchExt->m_gpgEncrypt || m_pExchExt->m_gpgSign) {
+           m_gpg->setMessage (pMessage);
+           if (m_gpg->doCmd (m_pExchExt->m_gpgEncrypt,
+                             m_pExchExt->m_gpgSign)) {
+               hrReturn = E_FAIL;
+               m_bWriteFailed = TRUE;  
+           }
+       }
+    }
+    if (pMessage != NULL)
+       UlRelease(pMessage);
+    if (pMDB != NULL)
+       UlRelease(pMDB);
+
+    return hrReturn;
+}
+
+/* CGPGExchExtMessageEvents::OnCheckNames
+
+ Called by Exchange when the user selects the "check names" command.
+
+ @pEECB - A pointer to IExchExtCallback interface.
+
+ Return value: S_FALSE to signal Exchange to continue calling extensions.
+*/
+STDMETHODIMP CGPGExchExtMessageEvents::OnCheckNames(LPEXCHEXTCALLBACK pEECB)
+{
+    return S_FALSE;
+}
+
+
+/* CGPGExchExtMessageEvents::OnCheckNamesComplete
+
+ Called by Exchange when "check names" command is complete.
+
+  @pEECB - A pointer to IExchExtCallback interface.
+
+ Return value: S_FALSE to signal Exchange to continue calling extensions.
+*/
+STDMETHODIMP CGPGExchExtMessageEvents::OnCheckNamesComplete(
+                       LPEXCHEXTCALLBACK pEECB, ULONG lFlags)
+{
+    return S_FALSE;
+}
+
+
+/* CGPGExchExtMessageEvents::OnSubmit
+
+ Called by Exchange before the message data will be written and submitted.
+ to MAPI.
+
+ @pEECB - A pointer to IExchExtCallback interface.
+
+ Return value: S_FALSE to signal Exchange to continue calling extensions.
+*/
+STDMETHODIMP CGPGExchExtMessageEvents::OnSubmit(
+                           LPEXCHEXTCALLBACK pEECB)
+{
+    m_bOnSubmitCalled = TRUE;
+    m_bWriteFailed = FALSE;
+    return S_FALSE;
+}
+
+
+/* CGPGExchExtMessageEvents::OnSubmitComplete
+
+  @pEECB - A pointer to IExchExtCallback interface.
+
+ Called by Echange after the message has been submitted to MAPI.
+*/
+STDMETHODIMP_ (VOID) CGPGExchExtMessageEvents::OnSubmitComplete (
+                           LPEXCHEXTCALLBACK pEECB, ULONG lFlags)
+{
+    m_bOnSubmitCalled = FALSE; 
+}
+
+
+CGPGExchExtCommands::CGPGExchExtCommands (CGPGExchExt* pParentInterface)
+{ 
+    m_pExchExt = pParentInterface; 
+    m_lRef = 0; 
+    m_lContext = 0; 
+    m_nCmdEncrypt = 0;  
+    m_nCmdSign = 0; 
+    m_nToolbarButtonID1 = 0; 
+    m_nToolbarButtonID2 = 0; 
+    m_nToolbarBitmap1 = 0;
+    m_nToolbarBitmap2 = 0; 
+    m_hWnd = NULL; 
+};
+
+
+
+STDMETHODIMP 
+CGPGExchExtCommands::QueryInterface (REFIID riid, LPVOID FAR * ppvObj)
+{
+    *ppvObj = NULL;
+    if ((riid == IID_IExchExtCommands) || (riid == IID_IUnknown)) {
+        *ppvObj = (LPVOID)this;
+        AddRef ();
+        return S_OK;
+    }
+    return E_NOINTERFACE;
+}
+
+
+// XXX IExchExtSessionEvents::OnDelivery: could be used to automatically decrypt new mails
+// when they arrive
+
+/* CGPGExchExtCommands::InstallCommands
+
+ Called by Echange to install commands and toolbar buttons.
+
+ Return value: S_FALSE to signal Exchange to continue calling extensions.
+*/
+STDMETHODIMP CGPGExchExtCommands::InstallCommands(
+       LPEXCHEXTCALLBACK pEECB, // The Exchange Callback Interface.
+       HWND hWnd,               // The window handle to main window of context.
+       HMENU hMenu,             // The menu handle to main menu of context.
+       UINT FAR * pnCommandIDBase,  // The base conmmand id.
+       LPTBENTRY pTBEArray,     // The array of toolbar button entries.
+       UINT nTBECnt,            // The count of button entries in array.
+       ULONG lFlags)            // reserved
+{
+    HMENU hMenuTools;
+    m_hWnd = hWnd;
+
+    /* XXX: factor out common code */
+    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {
+       int nTBIndex;
+       HWND hwndToolbar = NULL;
+       CHAR szBuffer[128];
+
+        pEECB->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &hMenuTools, NULL, NULL, 0);
+        AppendMenu (hMenuTools, MF_SEPARATOR, 0, NULL);
+       
+       LoadString (theApp.m_hInstance, IDS_DECRYPT_MENU_ITEM, szBuffer, 128);
+        AppendMenu (hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);
+
+        m_nCmdEncrypt = *pnCommandIDBase;
+        (*pnCommandIDBase)++;
+       
+       for (nTBIndex = nTBECnt-1; nTBIndex > -1; --nTBIndex) { 
+           if (EETBID_STANDARD == pTBEArray[nTBIndex].tbid) {
+               hwndToolbar = pTBEArray[nTBIndex].hwnd;         
+               m_nToolbarButtonID1 = pTBEArray[nTBIndex].itbbBase;
+               pTBEArray[nTBIndex].itbbBase++;
+               break;          
+           }   
+       }
+
+       if (hwndToolbar) {
+           TBADDBITMAP tbab;
+           tbab.hInst = theApp.m_hInstance;
+           tbab.nID = IDB_DECRYPT;
+           m_nToolbarBitmap1 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);
+           m_nToolbarButtonID2 = pTBEArray[nTBIndex].itbbBase;
+           pTBEArray[nTBIndex].itbbBase++;
+       }
+    }
+
+    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {
+       CHAR szBuffer[128];
+       int nTBIndex;
+       HWND hwndToolbar = NULL;
+
+        pEECB->GetMenuPos(EECMDID_ToolsCustomizeToolbar, &hMenuTools, NULL, NULL, 0);
+        AppendMenu(hMenuTools, MF_SEPARATOR, 0, NULL);
+       
+       LoadString(theApp.m_hInstance, IDS_ENCRYPT_MENU_ITEM, szBuffer, 128);
+        AppendMenu(hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);
+
+        m_nCmdEncrypt = *pnCommandIDBase;
+        (*pnCommandIDBase)++;
+
+       LoadString(theApp.m_hInstance, IDS_SIGN_MENU_ITEM, szBuffer, 128);
+        AppendMenu(hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);
+
+        m_nCmdSign = *pnCommandIDBase;
+        (*pnCommandIDBase)++;
+
+       for (nTBIndex = nTBECnt-1; nTBIndex > -1; --nTBIndex)
+       {
+           if (EETBID_STANDARD == pTBEArray[nTBIndex].tbid)
+           {
+               hwndToolbar = pTBEArray[nTBIndex].hwnd;
+               m_nToolbarButtonID1 = pTBEArray[nTBIndex].itbbBase;
+               pTBEArray[nTBIndex].itbbBase++;
+               break;  
+           }
+       }
+
+       if (hwndToolbar) {
+           TBADDBITMAP tbab;
+           tbab.hInst = theApp.m_hInstance;
+           tbab.nID = IDB_ENCRYPT;
+           m_nToolbarBitmap1 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);
+           m_nToolbarButtonID2 = pTBEArray[nTBIndex].itbbBase;
+           pTBEArray[nTBIndex].itbbBase++;
+           tbab.nID = IDB_SIGN;
+           m_nToolbarBitmap2 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);
+       }
+       m_pExchExt->m_gpgEncrypt = m_gpg->getEncryptDefault ();
+       m_pExchExt->m_gpgSign = m_gpg->getSignDefault ();
+    }
+
+    if (m_lContext == EECONTEXT_VIEWER) {
+       CHAR szBuffer[128];
+       int nTBIndex;
+       HWND hwndToolbar = NULL;
+
+        pEECB->GetMenuPos (EECMDID_ToolsCustomizeToolbar, &hMenuTools, NULL, NULL, 0);
+        AppendMenu (hMenuTools, MF_SEPARATOR, 0, NULL);
+       
+       LoadString (theApp.m_hInstance, IDS_KEY_MANAGER, szBuffer, 128);
+        AppendMenu (hMenuTools, MF_BYPOSITION | MF_STRING, *pnCommandIDBase, szBuffer);
+
+        m_nCmdEncrypt = *pnCommandIDBase;
+        (*pnCommandIDBase)++;  
+
+       for (nTBIndex = nTBECnt-1; nTBIndex > -1; --nTBIndex) {
+           if (EETBID_STANDARD == pTBEArray[nTBIndex].tbid) {
+               hwndToolbar = pTBEArray[nTBIndex].hwnd;
+               m_nToolbarButtonID1 = pTBEArray[nTBIndex].itbbBase;
+               pTBEArray[nTBIndex].itbbBase++;
+               break;  
+           }
+       }
+       if (hwndToolbar) {
+           TBADDBITMAP tbab;
+           tbab.hInst = theApp.m_hInstance;
+           tbab.nID = IDB_KEY_MANAGER;
+           m_nToolbarBitmap1 = SendMessage(hwndToolbar, TB_ADDBITMAP, 1, (LPARAM)&tbab);
+       }       
+    }
+    return S_FALSE;
+}
+
+
+/* CGPGExchExtCommands::DoCommand - Called by Exchange when a user selects a command. 
+
+ Return value: S_OK if command is handled, otherwise S_FALSE.
+*/
+STDMETHODIMP CGPGExchExtCommands::DoCommand(
+       LPEXCHEXTCALLBACK pEECB, // The Exchange Callback Interface.
+       UINT nCommandID)         // The command id.
+{
+
+    if ((nCommandID != m_nCmdEncrypt) && 
+       (nCommandID != m_nCmdSign))
+       return S_FALSE; 
+
+    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {
+       LPMESSAGE pMessage = NULL;
+       LPMDB pMDB = NULL;
+       HWND hWnd = NULL;
+
+       if (FAILED (pEECB->GetWindow (&hWnd)))
+           hWnd = NULL;
+       HRESULT hr = pEECB->GetObject (&pMDB, (LPMAPIPROP *)&pMessage);
+       if (SUCCEEDED (hr)) {
+           if (nCommandID == m_nCmdEncrypt) {
+               m_gpg->setWindow (hWnd);
+               m_gpg->setMessage (pMessage);
+               m_gpg->decrypt ();
+           }
+       }
+       if (pMessage != NULL)
+           UlRelease(pMessage);
+       if (pMDB != NULL)
+           UlRelease(pMDB);
+    }
+    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {
+       HWND hWnd = NULL;
+       if (FAILED(pEECB->GetWindow (&hWnd)))
+           hWnd = NULL;
+       if (nCommandID == m_nCmdEncrypt)
+           m_pExchExt->m_gpgEncrypt = !m_pExchExt->m_gpgEncrypt;
+       if (nCommandID == m_nCmdSign)
+           m_pExchExt->m_gpgSign = !m_pExchExt->m_gpgSign;
+    }
+    if (m_lContext == EECONTEXT_VIEWER) {
+       if (m_gpg->startKeyManager ())
+           MessageBox (NULL, "Could not start Key-Manager", "GPGExch", MB_ICONERROR|MB_OK);
+    }
+    return S_OK; 
+}
+
+STDMETHODIMP_(VOID) CGPGExchExtCommands::InitMenu(
+       LPEXCHEXTCALLBACK pEECB) // The pointer to Exchange Callback Interface.
+{
+}
+
+/* CGPGExchExtCommands::Help
+
+ Called by Exhange when the user requests help for a menu item.
+
+ Return value: S_OK when it is a menu item of this plugin and the help was shown;
+               otherwise S_FALSE
+*/
+STDMETHODIMP CGPGExchExtCommands::Help (
+       LPEXCHEXTCALLBACK pEECB, // The pointer to Exchange Callback Interface.
+       UINT nCommandID)         // The command id.
+{
+    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {
+       if (nCommandID == m_nCmdEncrypt) {
+           CHAR szBuffer[512];
+           CHAR szAppName[128];
+
+           LoadString (theApp.m_hInstance, IDS_DECRYPT_HELP, szBuffer, 511);
+           LoadString (theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);
+           MessageBox (m_hWnd, szBuffer, szAppName, MB_OK);
+           return S_OK;
+       }
+    }
+    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {
+       if (nCommandID == m_nCmdEncrypt) {
+           CHAR szBuffer[512];
+           CHAR szAppName[128];
+           LoadString(theApp.m_hInstance, IDS_ENCRYPT_HELP, szBuffer, 511);
+           LoadString(theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);
+           MessageBox(m_hWnd, szBuffer, szAppName, MB_OK);     
+           return S_OK;
+       } 
+       if (nCommandID == m_nCmdSign) {
+           CHAR szBuffer[512]; 
+           CHAR szAppName[128];        
+           LoadString(theApp.m_hInstance, IDS_SIGN_HELP, szBuffer, 511);       
+           LoadString(theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);       
+           MessageBox(m_hWnd, szBuffer, szAppName, MB_OK);     
+           return S_OK;
+       } 
+    }
+
+    if (m_lContext == EECONTEXT_VIEWER) {
+       if (nCommandID == m_nCmdEncrypt) {
+               CHAR szBuffer[512];
+               CHAR szAppName[128];
+               LoadString(theApp.m_hInstance, IDS_KEY_MANAGER_HELP, szBuffer, 511);
+               LoadString(theApp.m_hInstance, IDS_APP_NAME, szAppName, 127);
+               MessageBox(m_hWnd, szBuffer, szAppName, MB_OK);
+               return S_OK;
+       } 
+    }
+
+    return S_FALSE;
+}
+
+/* CGPGExchExtCommands::QueryHelpText
+
+ Called by Exhange to get the status bar text or the tooltip of a menu item.
+
+ @rdesc S_OK when it is a menu item of this plugin and the text was set;
+        otherwise S_FALSE.
+*/
+STDMETHODIMP CGPGExchExtCommands::QueryHelpText(
+       UINT nCommandID,  // The command id corresponding to menu item activated.
+       ULONG lFlags,     // Identifies either EECQHT_STATUS or EECQHT_TOOLTIP.
+    LPTSTR pszText,   // A pointer to buffer to be populated with text to display.
+       UINT nCharCnt)    // The count of characters available in psz buffer.
+{
+       
+    if (m_lContext == EECONTEXT_READNOTEMESSAGE) {
+       if (nCommandID == m_nCmdEncrypt) {
+           if (lFlags == EECQHT_STATUS)
+               LoadString (theApp.m_hInstance, IDS_DECRYPT_STATUSBAR, pszText, nCharCnt);
+           if (lFlags == EECQHT_TOOLTIP)
+               LoadString (theApp.m_hInstance, IDS_DECRYPT_TOOLTIP, pszText, nCharCnt);
+           return S_OK;
+       }
+    }
+    if (m_lContext == EECONTEXT_SENDNOTEMESSAGE) {
+       if (nCommandID == m_nCmdEncrypt) {
+           if (lFlags == EECQHT_STATUS)
+               LoadString (theApp.m_hInstance, IDS_ENCRYPT_STATUSBAR, pszText, nCharCnt);
+           if (lFlags == EECQHT_TOOLTIP)
+               LoadString (theApp.m_hInstance, IDS_ENCRYPT_TOOLTIP, pszText, nCharCnt);
+           return S_OK;
+       }
+       if (nCommandID == m_nCmdSign) {
+           if (lFlags == EECQHT_STATUS)
+               LoadString (theApp.m_hInstance, IDS_SIGN_STATUSBAR, pszText, nCharCnt);
+           if (lFlags == EECQHT_TOOLTIP)
+               LoadString (theApp.m_hInstance, IDS_SIGN_TOOLTIP, pszText, nCharCnt);
+           return S_OK;
+       }
+    }
+    if (m_lContext == EECONTEXT_VIEWER) {
+       if (nCommandID == m_nCmdEncrypt) {
+           if (lFlags == EECQHT_STATUS)
+               LoadString (theApp.m_hInstance, IDS_KEY_MANAGER_STATUSBAR, pszText, nCharCnt);
+           if (lFlags == EECQHT_TOOLTIP)
+               LoadString (theApp.m_hInstance, IDS_KEY_MANAGER_TOOLTIP, pszText, nCharCnt);
+           return S_OK;
+       }       
+    }
+    return S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CGPGExchExtCommands::QueryButtonInfo 
+//
+// Called by Exchange to get toolbar button infos,
+//
+// @rdesc S_OK when it is a button of this plugin and the requested info was delivered;
+//        otherwise S_FALSE
+//
+STDMETHODIMP CGPGExchExtCommands::QueryButtonInfo (
+       ULONG lToolbarID,       // The toolbar identifier.
+       UINT nToolbarButtonID,  // The toolbar button index.
+    LPTBBUTTON pTBB,        // A pointer to toolbar button structure (see TBBUTTON structure).
+       LPTSTR lpszDescription, // A pointer to string describing button.
+       UINT nCharCnt,          // The maximum size of lpsz buffer.
+    ULONG lFlags)           // EXCHEXT_UNICODE may be specified
+{
+       if (m_lContext == EECONTEXT_READNOTEMESSAGE)
+       {
+               if (nToolbarButtonID == m_nToolbarButtonID1)
+               {
+                       pTBB->iBitmap = m_nToolbarBitmap1;             
+                       pTBB->idCommand = m_nCmdEncrypt;
+                       pTBB->fsState = TBSTATE_ENABLED;
+                       pTBB->fsStyle = TBSTYLE_BUTTON;
+                       pTBB->dwData = 0;
+                       pTBB->iString = -1;
+                       LoadString(theApp.m_hInstance, IDS_DECRYPT_TOOLTIP, lpszDescription, nCharCnt);
+                       return S_OK;
+               }
+       }
+       if (m_lContext == EECONTEXT_SENDNOTEMESSAGE)
+       {
+               if (nToolbarButtonID == m_nToolbarButtonID1)
+               {
+                       pTBB->iBitmap = m_nToolbarBitmap1;             
+                       pTBB->idCommand = m_nCmdEncrypt;
+                       pTBB->fsState = TBSTATE_ENABLED;
+                       if (m_pExchExt->m_gpgEncrypt)
+                               pTBB->fsState |= TBSTATE_CHECKED;
+                       pTBB->fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECK;
+                       pTBB->dwData = 0;
+                       pTBB->iString = -1;
+                       LoadString(theApp.m_hInstance, IDS_ENCRYPT_TOOLTIP, lpszDescription, nCharCnt);
+                       return S_OK;
+               }
+               if (nToolbarButtonID == m_nToolbarButtonID2)
+               {
+                       pTBB->iBitmap = m_nToolbarBitmap2;             
+                       pTBB->idCommand = m_nCmdSign;
+                       pTBB->fsState = TBSTATE_ENABLED;
+                       if (m_pExchExt->m_gpgSign)
+                               pTBB->fsState |= TBSTATE_CHECKED;
+                       pTBB->fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECK;
+                       pTBB->dwData = 0;
+                       pTBB->iString = -1;
+                       LoadString(theApp.m_hInstance, IDS_SIGN_TOOLTIP, lpszDescription, nCharCnt);
+                       return S_OK;
+               }
+       }
+       if (m_lContext == EECONTEXT_VIEWER)
+       {
+               if (nToolbarButtonID == m_nToolbarButtonID1)
+               {
+                       pTBB->iBitmap = m_nToolbarBitmap1;             
+                       pTBB->idCommand = m_nCmdEncrypt;
+                       pTBB->fsState = TBSTATE_ENABLED;
+                       pTBB->fsStyle = TBSTYLE_BUTTON;
+                       pTBB->dwData = 0;
+                       pTBB->iString = -1;
+                       LoadString(theApp.m_hInstance, IDS_KEY_MANAGER_TOOLTIP, lpszDescription, nCharCnt);
+                       return S_OK;
+               }
+       }
+
+       return S_FALSE;
+}
+
+
+STDMETHODIMP 
+CGPGExchExtCommands::ResetToolbar (ULONG lToolbarID, ULONG lFlags)
+{      
+    return S_OK;
+}
+
+
+CGPGExchExtPropertySheets::CGPGExchExtPropertySheets(CGPGExchExt* pParentInterface)
+{ 
+    m_pExchExt = pParentInterface;
+    m_lRef = 0; 
+}
+
+
+STDMETHODIMP 
+CGPGExchExtPropertySheets::QueryInterface(REFIID riid, LPVOID FAR * ppvObj)
+{   
+    *ppvObj = NULL;
+    if (riid == IID_IExchExtPropertySheets) {
+        *ppvObj = (LPVOID)this;
+        AddRef();
+        return S_OK;
+    }
+    if (riid == IID_IUnknown) {
+        *ppvObj = (LPVOID)m_pExchExt;
+        m_pExchExt->AddRef();
+        return S_OK;
+    }
+
+    return E_NOINTERFACE;
+}
+
+
+/* CGPGExchExtPropertySheets::GetMaxPageCount
+
+ Called by Echange to get the maximum number of property pages which are
+ to be added.
+
+ Return value: The maximum number of custom pages for the property sheet.
+*/
+STDMETHODIMP_ (ULONG) 
+CGPGExchExtPropertySheets::GetMaxPageCount(
+       ULONG lFlags) // A bitmask indicating what type of property sheet is being displayed.
+{
+    if (lFlags == EEPS_TOOLSOPTIONS)
+       return 1;       
+    return 0;
+}
+
+
+BOOL CALLBACK GPGOptionsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+
+/* CGPGExchExtPropertySheets::GetPages
+
+ Called by Exchange to request information about the property page.
+
+ Return value: S_OK to signal Echange to use the pPSP information.
+*/
+STDMETHODIMP 
+CGPGExchExtPropertySheets::GetPages(
+       LPEXCHEXTCALLBACK pEECB, // A pointer to Exchange callback interface.
+       ULONG lFlags,            // A  bitmask indicating what type of property sheet is being displayed.
+       LPPROPSHEETPAGE pPSP,    // The output parm pointing to pointer to list of property sheets.
+       ULONG FAR * plPSP)       // The output parm pointing to buffer contaiing number of property sheets actually used.
+{
+    int resid = 0;
+
+    switch (GetUserDefaultLangID ()) {
+    case 0x0407:    resid = IDD_GPG_OPTIONS_DE;break;
+    default:       resid = IDD_GPG_OPTIONS; break;
+    }
+
+    pPSP[0].dwSize = sizeof (PROPSHEETPAGE);
+    pPSP[0].dwFlags = PSP_DEFAULT | PSP_HASHELP;
+    pPSP[0].hInstance = theApp.m_hInstance;
+    pPSP[0].pszTemplate = MAKEINTRESOURCE (resid);
+    pPSP[0].hIcon = NULL;     
+    pPSP[0].pszTitle = NULL;  
+    pPSP[0].pfnDlgProc = (DLGPROC) GPGOptionsDlgProc;
+    pPSP[0].lParam = 0;     
+    pPSP[0].pfnCallback = NULL;
+    pPSP[0].pcRefParent = NULL; 
+
+    *plPSP = 1;
+
+    return S_OK;
+}
+
+STDMETHODIMP_ (VOID) 
+CGPGExchExtPropertySheets::FreePages (LPPROPSHEETPAGE pPSP, ULONG lFlags, ULONG lPSP)
+{
+}
index 0adb2b5..d9c52fa 100644 (file)
-/* GPGExch.h - exchange extension classes\r
- *     Copyright (C) 2001 G Data Software AG, http://www.gdata.de\r
- *     Copyright (C) 2005 g10 Code GmbH\r
- * \r
- * This file is part of the G DATA Outlook Plugin for GnuPG.\r
- * \r
- * This plugin is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2 of the License, or (at your option) any later version.\r
- * \r
- * This plugin is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU Lesser General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU Lesser General\r
- * Public License along with this plugin; if not, write to the \r
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, \r
- * Boston, MA 02111-1307, USA.\r
- */\r
-\r
-#ifndef INC_GPGEXCH_H\r
-#define INC_GPGEXCH_H\r
-\r
-#include "resource.h"          // main symbols\r
-\r
-class CGPGExchApp : public CWinApp\r
-{\r
-public:\r
-    CGPGExchApp();\r
-    DECLARE_MESSAGE_MAP()\r
-};\r
-\r
-/*\r
- CGPGExchExt \r
-\r
- The CGPGExchExt class is the main exchange extension class. The other \r
- extensions will be created in the constructor of this class.\r
-*/\r
-class CGPGExchExt : public IExchExt\r
-{\r
-public:\r
-    CGPGExchExt();\r
-    ~CGPGExchExt();\r
-\r
-public:        \r
-    HWND m_hWndExchange;  /* Handle of the exchange window. */\r
-    /* parameter for sending mails */\r
-    BOOL  m_gpgEncrypt;\r
-    BOOL  m_gpgSign;\r
-\r
-private:\r
-    ULONG m_lRef;\r
-    ULONG m_lContext;\r
-\r
-    /* pointer to the other extension objects */\r
-    CGPGExchExtMessageEvents* m_pExchExtMessageEvents;\r
-    CGPGExchExtCommands* m_pExchExtCommands;\r
-    CGPGExchExtPropertySheets* m_pExchExtPropertySheets;\r
-\r
-public:\r
-    STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj);\r
-    inline STDMETHODIMP_(ULONG) AddRef() { ++m_lRef;  return m_lRef; };\r
-    inline STDMETHODIMP_(ULONG) Release()\r
-    {\r
-       ULONG lCount = --m_lRef;\r
-       if (!lCount) \r
-           delete this;\r
-       return lCount;  \r
-    };\r
-    STDMETHODIMP Install(LPEXCHEXTCALLBACK pEECB, ULONG lContext, ULONG lFlags);\r
-};\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CGPGExchExtMessageEvents \r
-//\r
-// The CGPGExchExtMessageEvents class implements the reaction of the exchange \r
-// message events.\r
-//\r
-class CGPGExchExtMessageEvents : public IExchExtMessageEvents\r
-{\r
-// constructor\r
-public:\r
-       CGPGExchExtMessageEvents (CGPGExchExt* pParentInterface);\r
-\r
-// attributes\r
-private:\r
-    ULONG   m_lRef;\r
-    BOOL    m_bOnSubmitCalled;\r
-    CGPGExchExt* m_pExchExt;\r
-    BOOL    m_bWriteFailed;\r
-\r
-public:\r
-    STDMETHODIMP QueryInterface (REFIID riid, LPVOID *ppvObj);\r
-    inline STDMETHODIMP_(ULONG) AddRef (void) { ++m_lRef; return m_lRef; };\r
-    inline STDMETHODIMP_(ULONG) Release (void) \r
-    {\r
-       ULONG lCount = --m_lRef;\r
-       if (!lCount) \r
-           delete this;\r
-       return lCount;  \r
-    };\r
-\r
-    STDMETHODIMP OnRead (LPEXCHEXTCALLBACK pEECB);\r
-    STDMETHODIMP OnReadComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);\r
-    STDMETHODIMP OnWrite (LPEXCHEXTCALLBACK pEECB);\r
-    STDMETHODIMP OnWriteComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);\r
-    STDMETHODIMP OnCheckNames (LPEXCHEXTCALLBACK pEECB);\r
-    STDMETHODIMP OnCheckNamesComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);\r
-    STDMETHODIMP OnSubmit (LPEXCHEXTCALLBACK pEECB);\r
-    STDMETHODIMP_ (VOID)OnSubmitComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);\r
-};\r
-\r
-/* CGPGExchExtCommands \r
- Makes the menu and toolbar extensions. Implements the own commands.\r
-*/\r
-class CGPGExchExtCommands : public IExchExtCommands\r
-{\r
-public:\r
-    CGPGExchExtCommands (CGPGExchExt* pParentInterface);\r
-\r
-private:\r
-    ULONG m_lRef;\r
-    ULONG m_lContext;\r
-\r
-    UINT  m_nCmdEncrypt;\r
-    UINT  m_nCmdSign;\r
-\r
-    UINT  m_nToolbarButtonID1;\r
-    UINT  m_nToolbarButtonID2;     \r
-    UINT  m_nToolbarBitmap1;\r
-    UINT  m_nToolbarBitmap2;\r
-\r
-    HWND  m_hWnd;\r
-\r
-    CGPGExchExt* m_pExchExt;\r
-\r
-public:\r
-    STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);\r
-    inline STDMETHODIMP_(ULONG) AddRef (void) { ++m_lRef; return m_lRef; };\r
-    inline STDMETHODIMP_(ULONG) Release (void) \r
-    {\r
-       ULONG lCount = --m_lRef;\r
-       if (!lCount) \r
-           delete this;\r
-       return lCount;  \r
-    };\r
-\r
-    STDMETHODIMP InstallCommands (LPEXCHEXTCALLBACK pEECB, HWND hWnd, HMENU hMenu,    \r
-                                 UINT FAR * pnCommandIDBase, LPTBENTRY pTBEArray, UINT nTBECnt, ULONG lFlags);\r
-    STDMETHODIMP DoCommand (LPEXCHEXTCALLBACK pEECB, UINT nCommandID);\r
-    STDMETHODIMP_(VOID) InitMenu (LPEXCHEXTCALLBACK pEECB);\r
-    STDMETHODIMP Help (LPEXCHEXTCALLBACK pEECB, UINT nCommandID);\r
-    STDMETHODIMP QueryHelpText (UINT nCommandID, ULONG lFlags, LPTSTR szText, UINT nCharCnt);\r
-    STDMETHODIMP QueryButtonInfo (ULONG lToolbarID, UINT nToolbarButtonID, \r
-                                 LPTBBUTTON pTBB, LPTSTR lpszDescription, UINT nCharCnt, ULONG lFlags);\r
-    STDMETHODIMP ResetToolbar (ULONG nToolbarID, ULONG lFlags);\r
-\r
-    inline VOID SetContext (ULONG lContext) { m_lContext = lContext; };\r
-};\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CGPGExchExtPropertySheets \r
-//\r
-// The CGPGExchExtPropertySheets implements the exchange property sheet extension \r
-// to put the GPG options page in the exchanges options property sheet.\r
-//\r
-class CGPGExchExtPropertySheets : public IExchExtPropertySheets\r
-{\r
-// constructor\r
-public:\r
-    CGPGExchExtPropertySheets(CGPGExchExt* pParentInterface);\r
-\r
-// attibutes\r
-private:\r
-    ULONG m_lRef;\r
-    CGPGExchExt* m_pExchExt;\r
-\r
-public:        \r
-    STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);\r
-    inline STDMETHODIMP_(ULONG) AddRef() { ++m_lRef; return m_lRef; };\r
-    inline STDMETHODIMP_(ULONG) Release() \r
-    {\r
-       ULONG lCount = --m_lRef;\r
-       if (!lCount)\r
-           delete this;\r
-       return lCount;  \r
-    };\r
-\r
-    STDMETHODIMP_ (ULONG) GetMaxPageCount(ULONG lFlags);          \r
-    STDMETHODIMP  GetPages(LPEXCHEXTCALLBACK pEECB,\r
-           ULONG lFlags, LPPROPSHEETPAGE pPSP, ULONG FAR * pcpsp);\r
-    STDMETHODIMP_ (VOID) FreePages(LPPROPSHEETPAGE pPSP, \r
-               ULONG lFlags, ULONG cpsp);          \r
-\r
-};\r
-\r
-#endif // INC_GPGEXCH_H\r
+/* GPGExch.h - exchange extension classes
+ *     Copyright (C) 2001 G Data Software AG, http://www.gdata.de
+ *     Copyright (C) 2005 g10 Code GmbH
+ * 
+ * This file is part of the G DATA Outlook Plugin for GnuPG.
+ * 
+ * This plugin is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * 
+ * This plugin is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this plugin; if not, write to the 
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef INC_GPGEXCH_H
+#define INC_GPGEXCH_H
+
+#include "resource.h"          // main symbols
+
+class CGPGExchApp : public CWinApp
+{
+public:
+    CGPGExchApp();
+    DECLARE_MESSAGE_MAP()
+};
+
+/*
+ CGPGExchExt 
+
+ The CGPGExchExt class is the main exchange extension class. The other 
+ extensions will be created in the constructor of this class.
+*/
+class CGPGExchExt : public IExchExt
+{
+public:
+    CGPGExchExt();
+    ~CGPGExchExt();
+
+public:        
+    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;
+
+public:
+    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;  
+    };
+    STDMETHODIMP Install(LPEXCHEXTCALLBACK pEECB, ULONG lContext, ULONG lFlags);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// CGPGExchExtMessageEvents 
+//
+// The CGPGExchExtMessageEvents class implements the reaction of the exchange 
+// message events.
+//
+class CGPGExchExtMessageEvents : public IExchExtMessageEvents
+{
+// constructor
+public:
+       CGPGExchExtMessageEvents (CGPGExchExt* pParentInterface);
+
+// attributes
+private:
+    ULONG   m_lRef;
+    BOOL    m_bOnSubmitCalled;
+    CGPGExchExt* m_pExchExt;
+    BOOL    m_bWriteFailed;
+
+public:
+    STDMETHODIMP QueryInterface (REFIID riid, LPVOID *ppvObj);
+    inline STDMETHODIMP_(ULONG) AddRef (void) { ++m_lRef; return m_lRef; };
+    inline STDMETHODIMP_(ULONG) Release (void) 
+    {
+       ULONG lCount = --m_lRef;
+       if (!lCount) 
+           delete this;
+       return lCount;  
+    };
+
+    STDMETHODIMP OnRead (LPEXCHEXTCALLBACK pEECB);
+    STDMETHODIMP OnReadComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);
+    STDMETHODIMP OnWrite (LPEXCHEXTCALLBACK pEECB);
+    STDMETHODIMP OnWriteComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);
+    STDMETHODIMP OnCheckNames (LPEXCHEXTCALLBACK pEECB);
+    STDMETHODIMP OnCheckNamesComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);
+    STDMETHODIMP OnSubmit (LPEXCHEXTCALLBACK pEECB);
+    STDMETHODIMP_ (VOID)OnSubmitComplete (LPEXCHEXTCALLBACK pEECB, ULONG lFlags);
+};
+
+/* CGPGExchExtCommands 
+ Makes the menu and toolbar extensions. Implements the own commands.
+*/
+class CGPGExchExtCommands : public IExchExtCommands
+{
+public:
+    CGPGExchExtCommands (CGPGExchExt* pParentInterface);
+
+private:
+    ULONG m_lRef;
+    ULONG m_lContext;
+
+    UINT  m_nCmdEncrypt;
+    UINT  m_nCmdSign;
+
+    UINT  m_nToolbarButtonID1;
+    UINT  m_nToolbarButtonID2;     
+    UINT  m_nToolbarBitmap1;
+    UINT  m_nToolbarBitmap2;
+
+    HWND  m_hWnd;
+
+    CGPGExchExt* m_pExchExt;
+
+public:
+    STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);
+    inline STDMETHODIMP_(ULONG) AddRef (void) { ++m_lRef; return m_lRef; };
+    inline STDMETHODIMP_(ULONG) Release (void) 
+    {
+       ULONG lCount = --m_lRef;
+       if (!lCount) 
+           delete this;
+       return lCount;  
+    };
+
+    STDMETHODIMP InstallCommands (LPEXCHEXTCALLBACK pEECB, HWND hWnd, HMENU hMenu,    
+                                 UINT FAR * pnCommandIDBase, LPTBENTRY pTBEArray, UINT nTBECnt, ULONG lFlags);
+    STDMETHODIMP DoCommand (LPEXCHEXTCALLBACK pEECB, UINT nCommandID);
+    STDMETHODIMP_(VOID) InitMenu (LPEXCHEXTCALLBACK pEECB);
+    STDMETHODIMP Help (LPEXCHEXTCALLBACK pEECB, UINT nCommandID);
+    STDMETHODIMP QueryHelpText (UINT nCommandID, ULONG lFlags, LPTSTR szText, UINT nCharCnt);
+    STDMETHODIMP QueryButtonInfo (ULONG lToolbarID, UINT nToolbarButtonID, 
+                                 LPTBBUTTON pTBB, LPTSTR lpszDescription, UINT nCharCnt, ULONG lFlags);
+    STDMETHODIMP ResetToolbar (ULONG nToolbarID, ULONG lFlags);
+
+    inline VOID SetContext (ULONG lContext) { m_lContext = lContext; };
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CGPGExchExtPropertySheets 
+//
+// The CGPGExchExtPropertySheets implements the exchange property sheet extension 
+// to put the GPG options page in the exchanges options property sheet.
+//
+class CGPGExchExtPropertySheets : public IExchExtPropertySheets
+{
+// constructor
+public:
+    CGPGExchExtPropertySheets(CGPGExchExt* pParentInterface);
+
+// attibutes
+private:
+    ULONG m_lRef;
+    CGPGExchExt* m_pExchExt;
+
+public:        
+    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;  
+    };
+
+    STDMETHODIMP_ (ULONG) GetMaxPageCount(ULONG lFlags);          
+    STDMETHODIMP  GetPages(LPEXCHEXTCALLBACK pEECB,
+           ULONG lFlags, LPPROPSHEETPAGE pPSP, ULONG FAR * pcpsp);
+    STDMETHODIMP_ (VOID) FreePages(LPPROPSHEETPAGE pPSP, 
+               ULONG lFlags, ULONG cpsp);          
+
+};
+
+#endif // INC_GPGEXCH_H
index 4835290..0a0af9a 100644 (file)
@@ -1,40 +1,40 @@
-// include file for standard system include files\r
\r
-#ifndef INC_STDAFX_H\r
-#define INC_STDAFX_H\r
-\r
-#define VC_EXTRALEAN           // Exclude rarely-used stuff from Windows headers\r
-\r
-#include <afxwin.h>         // MFC core and standard components\r
-#include <afxext.h>         // MFC extensions\r
-\r
-#ifndef _AFX_NO_OLE_SUPPORT\r
-#include <afxole.h>         // MFC OLE classes\r
-#include <afxodlgs.h>       // MFC OLE dialog classes\r
-#include <afxdisp.h>        // MFC Automation classes\r
-#endif // _AFX_NO_OLE_SUPPORT\r
-\r
-#ifndef _AFX_NO_DB_SUPPORT\r
-#include <afxdb.h>                     // MFC ODBC database classes\r
-#endif // _AFX_NO_DB_SUPPORT\r
-\r
-#ifndef _AFX_NO_DAO_SUPPORT\r
-#include <afxdao.h>                    // MFC DAO database classes\r
-#endif // _AFX_NO_DAO_SUPPORT\r
-\r
-#include <afxdtctl.h>          // MFC support for Internet Explorer 4 Common Controls\r
-#ifndef _AFX_NO_AFXCMN_SUPPORT\r
-#include <afxcmn.h>                    // MFC support for Windows Common Controls\r
-#endif // _AFX_NO_AFXCMN_SUPPORT\r
-\r
-// MAPI includes\r
-#include <MAPIX.H>\r
-#include <MAPIUTIL.H>\r
-#include <MAPIFORM.H>\r
-\r
-#include <atlbase.h>\r
-#include <string>\r
-#include <vector>\r
-using namespace std;\r
-\r
-#endif // INC_STDAFX_H\r
+// include file for standard system include files
+#ifndef INC_STDAFX_H
+#define INC_STDAFX_H
+
+#define VC_EXTRALEAN           // Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxole.h>         // MFC OLE classes
+#include <afxodlgs.h>       // MFC OLE dialog classes
+#include <afxdisp.h>        // MFC Automation classes
+#endif // _AFX_NO_OLE_SUPPORT
+
+#ifndef _AFX_NO_DB_SUPPORT
+#include <afxdb.h>                     // MFC ODBC database classes
+#endif // _AFX_NO_DB_SUPPORT
+
+#ifndef _AFX_NO_DAO_SUPPORT
+#include <afxdao.h>                    // MFC DAO database classes
+#endif // _AFX_NO_DAO_SUPPORT
+
+#include <afxdtctl.h>          // MFC support for Internet Explorer 4 Common Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>                    // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+// MAPI includes
+#include <MAPIX.H>
+#include <MAPIUTIL.H>
+#include <MAPIFORM.H>
+
+#include <atlbase.h>
+#include <string>
+#include <vector>
+using namespace std;
+
+#endif // INC_STDAFX_H
index 5e35db3..5d1a5d6 100644 (file)
@@ -1,71 +1,71 @@
-//{{NO_DEPENDENCIES}}\r
-// Microsoft Developer Studio generated include file.\r
-// Used by GPGExch.rc\r
-//\r
-#define IDS_DECRYPT_MENU_ITEM           1\r
-#define IDS_DECRYPT_HELP                2\r
-#define IDS_APP_NAME                    3\r
-#define IDS_DECRYPT_STATUSBAR           4\r
-#define IDS_DECRYPT_TOOLTIP             5\r
-#define IDS_ENCRYPT_MENU_ITEM           6\r
-#define IDS_SIGN_MENU_ITEM              7\r
-#define IDS_ENCRYPT_HELP                8\r
-#define IDS_SIGN_HELP                   9\r
-#define IDS_SIGN_STATUSBAR              10\r
-#define IDS_SIGN_TOOLTIP                11\r
-#define IDS_ENCRYPT_STATUSBAR           12\r
-#define IDS_ENCRYPT_TOOLTIP             13\r
-#define IDS_ADD_KEYS_MENU_ITEM          14\r
-#define IDS_ADD_KEYS_HELP               15\r
-#define IDS_ADD_KEYS_STATUSBAR          16\r
-#define IDS_ADD_KEYS_TOOLTIP            17\r
-#define IDS_KEY_MANAGER                 18\r
-#define IDS_KEY_MANAGER_HELP            19\r
-#define IDS_KEY_MANAGER_STATUSBAR       20\r
-#define IDS_KEY_MANAGER_TOOLTIP         21\r
-#define IDS_ADD_STANDARD_KEY            22\r
-#define IDS_ADD_STANDARD_KEY_HELP       23\r
-#define IDS_ADD_STANDARD_KEY_STATUSBAR  24\r
-#define IDS_IMPORT_X_KEYS               25\r
-#define IDS_IMPORT_NO_NEW_OR_CHANGED_KEYS 26\r
-#define IDS_IMPORT_NO_KEYS              27\r
-#define IDS_ERR_REPLACE_TEXT            28\r
-#define IDS_ERR_EXPORT_KEY              29\r
-#define IDS_ATT_DECRYPT_AND_SAVE        30\r
-#define IDS_SAVE_ATT_TITLE              31\r
-#define IDS_SAVE_ATT_FILTER             32\r
-#define IDS_ERR_REPLACE_TEXT_ASK_SAVE   33\r
-#define IDS_ERR_ENCRYPT_ATTACHMENTS     34\r
-#define IDS_COPY_KEY_TO_CLIPBOARD       35\r
-#define IDS_ERR_ENCRYPT_EMBEDDED_OLE    36\r
-#define IDB_DECRYPT                     4000\r
-#define IDC_TIME_PHRASES                4000\r
-#define IDB_ENCRYPT                     4001\r
-#define IDD_GPG_OPTIONS                 4001\r
-#define IDC_ENCRYPT_DEFAULT             4001\r
-#define IDB_SIGN                        4002\r
-#define IDC_SIGN_DEFAULT                4002\r
-#define IDB_ADD_KEYS                    4003\r
-#define IDC_ENCRYPT_WITH_STANDARD_KEY   4003\r
-#define IDB_KEY_MANAGER                 4004\r
-#define IDC_SAVE_DECRYPTED              4004\r
-#define IDC_GPG_OPTIONS                 4006\r
-#define IDC_BITMAP                      4007\r
-#define IDC_DEBUG_LOGFILE               4008\r
-#define IDB_BANNER                      4009\r
-#define IDC_VERSION_INFO                4009\r
-#define IDB_BANNER_HI                   4010\r
-#define IDC_ENCRYPT_TO                  4010\r
-#define IDC_SIGN_ATTACHMENTS            4011\r
-#define IDD_GPG_OPTIONS_DE              4012\r
-\r
-// Next default values for new objects\r
-// \r
-#ifdef APSTUDIO_INVOKED\r
-#ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE        4013\r
-#define _APS_NEXT_COMMAND_VALUE         32771\r
-#define _APS_NEXT_CONTROL_VALUE         4012\r
-#define _APS_NEXT_SYMED_VALUE           4000\r
-#endif\r
-#endif\r
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by GPGExch.rc
+//
+#define IDS_DECRYPT_MENU_ITEM           1
+#define IDS_DECRYPT_HELP                2
+#define IDS_APP_NAME                    3
+#define IDS_DECRYPT_STATUSBAR           4
+#define IDS_DECRYPT_TOOLTIP             5
+#define IDS_ENCRYPT_MENU_ITEM           6
+#define IDS_SIGN_MENU_ITEM              7
+#define IDS_ENCRYPT_HELP                8
+#define IDS_SIGN_HELP                   9
+#define IDS_SIGN_STATUSBAR              10
+#define IDS_SIGN_TOOLTIP                11
+#define IDS_ENCRYPT_STATUSBAR           12
+#define IDS_ENCRYPT_TOOLTIP             13
+#define IDS_ADD_KEYS_MENU_ITEM          14
+#define IDS_ADD_KEYS_HELP               15
+#define IDS_ADD_KEYS_STATUSBAR          16
+#define IDS_ADD_KEYS_TOOLTIP            17
+#define IDS_KEY_MANAGER                 18
+#define IDS_KEY_MANAGER_HELP            19
+#define IDS_KEY_MANAGER_STATUSBAR       20
+#define IDS_KEY_MANAGER_TOOLTIP         21
+#define IDS_ADD_STANDARD_KEY            22
+#define IDS_ADD_STANDARD_KEY_HELP       23
+#define IDS_ADD_STANDARD_KEY_STATUSBAR  24
+#define IDS_IMPORT_X_KEYS               25
+#define IDS_IMPORT_NO_NEW_OR_CHANGED_KEYS 26
+#define IDS_IMPORT_NO_KEYS              27
+#define IDS_ERR_REPLACE_TEXT            28
+#define IDS_ERR_EXPORT_KEY              29
+#define IDS_ATT_DECRYPT_AND_SAVE        30
+#define IDS_SAVE_ATT_TITLE              31
+#define IDS_SAVE_ATT_FILTER             32
+#define IDS_ERR_REPLACE_TEXT_ASK_SAVE   33
+#define IDS_ERR_ENCRYPT_ATTACHMENTS     34
+#define IDS_COPY_KEY_TO_CLIPBOARD       35
+#define IDS_ERR_ENCRYPT_EMBEDDED_OLE    36
+#define IDB_DECRYPT                     4000
+#define IDC_TIME_PHRASES                4000
+#define IDB_ENCRYPT                     4001
+#define IDD_GPG_OPTIONS                 4001
+#define IDC_ENCRYPT_DEFAULT             4001
+#define IDB_SIGN                        4002
+#define IDC_SIGN_DEFAULT                4002
+#define IDB_ADD_KEYS                    4003
+#define IDC_ENCRYPT_WITH_STANDARD_KEY   4003
+#define IDB_KEY_MANAGER                 4004
+#define IDC_SAVE_DECRYPTED              4004
+#define IDC_GPG_OPTIONS                 4006
+#define IDC_BITMAP                      4007
+#define IDC_DEBUG_LOGFILE               4008
+#define IDB_BANNER                      4009
+#define IDC_VERSION_INFO                4009
+#define IDB_BANNER_HI                   4010
+#define IDC_ENCRYPT_TO                  4010
+#define IDC_SIGN_ATTACHMENTS            4011
+#define IDD_GPG_OPTIONS_DE              4012
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        4013
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         4012
+#define _APS_NEXT_SYMED_VALUE           4000
+#endif
+#endif