home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / remote.xp / comwinds.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-11  |  25.6 KB  |  531 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  File Name 
  4. //      COMWINDS.H
  5. //
  6. //  Description
  7. //      Common remote call and client-side utility functions for provider
  8. //      communicating with the WINDS messaging host.
  9. //
  10. //  Author
  11. //      Irving De la Cruz
  12. //
  13. //  Revision: 1.7
  14. //
  15. // Written for Microsoft Windows Developer Support
  16. // Copyright (c) 1995-1996 Microsoft Corporation. All rights reserved.
  17. //
  18. #ifndef _COMWINDS_H
  19. #define _COMWINDS_H
  20.  
  21. #define STRICT
  22. #include <WINDOWS.H>
  23. #include <WINDOWSX.H>
  24. #include <CTL3D.H>
  25. #include <MAPIWIN.H>
  26. #include <MAPISPI.H>
  27. #include <MAPIUTIL.H>
  28. #include <MAPICODE.H>
  29. #include <MAPIVAL.H>
  30. #include <MAPIWZ.H>
  31.  
  32. // Constants for communicating with the WINDS Server Messaging Host
  33. #include "WINDSGBL.H"
  34.  
  35. // Header file for the trace and logging functions.
  36. #include "TRACES.H"
  37.  
  38. // This header file is generated by the MIDL compiler
  39. #include "WINDS.H"
  40.  
  41. #include "UISRVCS.H"
  42.  
  43. #ifdef UNICODE
  44. #define RemoteChangePassword            RemoteChangePasswordW
  45. #define RemoteLogonMailBox              RemoteLogonMailBoxW
  46. #define RemoteLogonMailBoxAndSetNotif   RemoteLogonMailBoxAndSetNotifW
  47. #define RemoteTerminateNotif            RemoteTerminateNotifW
  48. #define RemoteValidateNotif             RemoteValidateNotifW
  49. #define RemoteOpenMsgUploadPipe         RemoteOpenMsgUploadPipeW
  50. #define RemoteSendMsgToAccount          RemoteSendMsgToAccountW
  51. #define RemoteOpenMsgDownloadPipe       RemoteOpenMsgDownloadPipeW
  52. #define RemoteOpenHeaderDownloadPipe    RemoteOpenHeaderDownloadPipeW
  53. #define RemoteCheckNewMail              RemoteCheckNewMailW
  54. #define RemoteOpenOneMsgDownloadPipe    RemoteOpenOneMsgDownloadPipeW
  55. #define RemoteGetRecipientProps         RemoteGetRecipientPropsW
  56. #define RemoteGetDistListProps          RemoteGetDistListPropsW
  57. #else
  58. #define RemoteChangePassword            RemoteChangePasswordA
  59. #define RemoteLogonMailBox              RemoteLogonMailBoxA
  60. #define RemoteLogonMailBoxAndSetNotif   RemoteLogonMailBoxAndSetNotifA
  61. #define RemoteTerminateNotif            RemoteTerminateNotifA
  62. #define RemoteValidateNotif             RemoteValidateNotifA
  63. #define RemoteOpenMsgUploadPipe         RemoteOpenMsgUploadPipeA
  64. #define RemoteSendMsgToAccount          RemoteSendMsgToAccountA
  65. #define RemoteOpenMsgDownloadPipe       RemoteOpenMsgDownloadPipeA
  66. #define RemoteOpenHeaderDownloadPipe    RemoteOpenHeaderDownloadPipeA
  67. #define RemoteCheckNewMail              RemoteCheckNewMailA
  68. #define RemoteOpenOneMsgDownloadPipe    RemoteOpenOneMsgDownloadPipeA
  69. #define RemoteGetRecipientProps         RemoteGetRecipientPropsA
  70. #define RemoteGetDistListProps          RemoteGetDistListPropsA
  71. #endif // UNICODE
  72.  
  73. // Custom properties used by this service provider. These properties are
  74. // non-transmittable and only used in the configuration and private
  75. // profile section of this provider/service.
  76. #define BASE_PROVIDER_ID                    0x6600  // Look at the comments in MAPITAGS.H
  77.  
  78. // Common Custom Properties for all WINDS service providers
  79. #define PR_SMP_REMOTE_SERVER            PROP_TAG (PT_TSTRING,    (BASE_PROVIDER_ID + 0x0000))
  80. #define PR_SMP_USER_NAME                PROP_TAG (PT_TSTRING,    (BASE_PROVIDER_ID + 0x0001))
  81. #define PR_SMP_BROWSE_MB                PROP_TAG (PT_OBJECT,     (BASE_PROVIDER_ID + 0x0002))
  82. #define PR_SMP_CHANGE_PASSWORD          PROP_TAG (PT_OBJECT,     (BASE_PROVIDER_ID + 0x0003))
  83. #define PR_SMP_SESSION_UID              PROP_TAG (PT_BINARY,     (BASE_PROVIDER_ID + 0x0004))
  84. #define PR_SMP_CONNECTION_TYPE          PROP_TAG (PT_LONG,       (BASE_PROVIDER_ID + 0x0005))
  85.  
  86. // Secured properties that users should not see by looking at the registry.
  87. // On Windows NT the registry is secured by the system. On Windows 95, this
  88. // properties are stored encrypted, along with the system's list of passwords
  89. #define PR_SMP_MAILBOX_NAME         PROP_TAG (PT_TSTRING,    (PROP_ID_SECURE_MIN + 0x0001))
  90. #define PR_SMP_MAILBOX_ID           PROP_TAG (PT_LONG,       (PROP_ID_SECURE_MIN + 0x0002))
  91. #define PR_SMP_MAILBOX_PASSWORD     PROP_TAG (PT_TSTRING,    (PROP_ID_SECURE_MIN + 0x0003))
  92.                                                              
  93. // Address books                                             
  94. #define PR_SMP_LUL_LAST_UPDATE      PROP_TAG (PT_TSTRING,    (BASE_PROVIDER_ID + 0x0020))
  95. #define PR_SMP_LUL_FILENAME         PROP_TAG (PT_TSTRING,    (BASE_PROVIDER_ID + 0x0021))
  96. #define PR_SMP_LUL_DOWNLOAD         PROP_TAG (PT_OBJECT,     (BASE_PROVIDER_ID + 0x0022))
  97. #define PR_SMP_MANAGER_NAME_TBL     PROP_TAG (PT_OBJECT,     (BASE_PROVIDER_ID + 0x0023))
  98. // Custom properties for IMailUser and IDistList objects. This properties are in the named
  99. // property range so that PAB address books and other writeable address books may copy them.
  100. // Address book service providers should not use the 0x6600-0x67FF property ID range for
  101. // custom properties in the recipient objects. Instead user NAMED properties
  102. #define PR_WINDS_AB_MANAGER_NAME        PROP_TAG (PT_TSTRING, 0x8000)
  103. #define PR_WINDS_AB_MANAGER_ENTRYID     PROP_TAG (PT_BINARY,  0x8001)
  104. #define PR_WINDS_AB_DL_OWNER_ACCT       PROP_TAG (PT_TSTRING, 0x8002)
  105. #define PR_WINDS_AB_DL_OWNER_NAME       PROP_TAG (PT_TSTRING, 0x8003)
  106. // Address entry named property names. They have to be UNICODE strings
  107. #define WINDS_AB_MANAGER_NAME       L"WINDS AB - Manager Name"
  108. #define WINDS_AB_MANAGER_EID        L"WINDS AB - Manager Entry ID"
  109. #define WINDS_AB_DL_OWNER_ACCT      L"WINDS AB - DL Owner Account"
  110. #define WINDS_AB_DL_OWNER_NAME      L"WINDS AB - DL Owner Name"
  111.  
  112. // Transports                                                
  113. #define PR_SMP_UPLOAD_TIME          PROP_TAG (PT_SYSTIME,    (BASE_PROVIDER_ID + 0x0040))
  114. #define PR_SMP_HEADERS_FILENAME     PROP_TAG (PT_TSTRING,    (BASE_PROVIDER_ID + 0x0041))
  115. #define PR_TMP_UPLOAD_TIME          PROP_TAG (PT_TSTRING,    (BASE_PROVIDER_ID + 0x0042))
  116. #define PR_SMP_GET_HEADERS          PROP_TAG (PT_BOOLEAN,    (BASE_PROVIDER_ID + 0x0043))
  117.  
  118. // Values available for PR_SMP_CONNECTION_TYPE
  119. typedef enum _CONNECTION_TYPE
  120. {
  121.     // Don't change the order of these unless the string resources ID's are modified accordingly
  122.     LAN_CONNECT         = 1,    
  123.     OFFLINE_CONNECT     = 2,
  124.     CONNECTION_BROKEN   = 3,
  125.     NOT_AVAIL_NO_ABD    = 4
  126. } CONNECTION_TYPE;
  127.  
  128. // Index properties into the logon property array of ALL providers using the WINDS server
  129. enum
  130. {
  131.     SERVER_NAME             = 0,
  132.     MAILBOX_NAME            = 1,
  133.     MAILBOX_ID              = 2,
  134.     USER_NAME               = 3, 
  135.     PASSWORD                = 4,
  136.     NET_CON                 = 5,
  137.     // Number of properties the WIZARD setup pages collect for the configuration of the WINDS providers
  138.     WIZARD_PROPERTIES       = 5
  139. };
  140.  
  141. // Number of controls in the configuration page of ALL WINDS Providers
  142. #define NUM_CFG_USERINFO_PAGE_CTLS     13
  143.  
  144. // Structure passed to the configuration dialog.
  145. typedef struct _CFGDLG
  146. {
  147.     HINSTANCE      hInst;      // Instance of provider's DLL for loading resources for the UI
  148.     HWND           hWnd;       // Handle of parent window or NULL is not UI should be used
  149.     LPSPropValue * ppProps;    // Property array with the configuration properties
  150.     LPMAPISUP      pSupObj;    // IMAPISupport object for creating the UI property sheets
  151.     ULONG          ulFlags;    // 0 or UI_READONLY for access control to the configuration values
  152.     HANDLE         hUIMutex;   // Handle to the MUTEX to control exclusive access to the configuration UI
  153. } CFGDLG, *PCFGDLG;
  154.  
  155. // This code is to protect on reentrancy in the function
  156. // that display the configuration UI for the WINDS services
  157. #define CONFIG_UI_MUTEX     TEXT("WINDS_SERVICE_CONFIG_UI_MUTEX")
  158.  
  159. // PR_AB_PROVIDER_ID is the GUID that represents this Address Book Provider.
  160. // This GUID is available as a property in the hierarchy. The UID is hard coded.
  161. // This number is generated only once per provider during the developement
  162. // of it using the standard tools (GUIDGEN or UUIDGEN) in VC++ or the Win32 SDK.
  163. // With this number you could identify your provider across multiple platforms.
  164. // GUIDGEN: 0xe33c67a0, 0xc81f, 0x11ce, 0xb2, 0xe4, 0x0, 0xaa, 0x0, 0x51, 0xe, 0x3b
  165. // This is the UID of the entry ID of objects in the WINDS address book provider.
  166. #define AB_UID_PROVIDER { 0xe3, 0x3c, 0x67, 0xa0, \
  167.                           0xc8, 0x1f, 0x11, 0xce, \
  168.                           0xb2, 0xe4, 0x0,  0xaa, \
  169.                           0x0,  0x51, 0xe,  0x3b }
  170.  
  171.  
  172. // This is the UID in the entry ID's the a WINDS transport uses to open entries in
  173. // the WINDS address book, through the support object.
  174. // This UID is hard coded because we only allow one instance of our provider
  175. // to be installed in a single profile at any time.
  176. // GUIDGEN: 0x8B43A160, 0xDFAC, 0x11ce, 0xB2, 0xEC, 0x00, 0xAA, 0x00, 0x51, 0x0E, 0x3B
  177. #define XP_WINDS_AB_ENTRIES { 0x8b, 0x43, 0xa1, 0x60, \
  178.                               0xdf, 0xac, 0x11, 0xce, \
  179.                               0xb2, 0xec, 0x0,  0xaa, \
  180.                               0x0,  0x51, 0xe,  0x3b }
  181.  
  182.  
  183. // This is the private entry ID structure for entries that a WINDS transport
  184. // would like to open in the WINDS address book
  185. typedef struct _PRIVATE_XP_ENTRYID
  186. {
  187.     // MAPI-required fields
  188.     BYTE        abFlags[4];         // 4 bytes      // MAPI Flags
  189.     MAPIUID     uidGlobal;          // 16 bytes     // UID Unique for XP entries
  190.     // Provider-defined fields
  191.     MAPIUID     uidWINDSEntries;    // 16 bytes     // UID Unique for WINDS entries in the WINDS address book
  192.     char        szObjectAlias[34];  // 34 bytes
  193.                                     // 70 Bytes Total
  194. } PRIVATE_XP_ENTRYID;
  195. #define     CB_PRIVATE_XP_EID       70      // Size of the structure above
  196.  
  197.  
  198. // This is the subdirectory in the TEMP directoy where WINDS service
  199. // providers create temporary data files
  200. #define WINDS_DATA_DIRECTORY                TEXT("WINDS Messaging Services Data Files")
  201. // This is the directory where the temporary files for downloaded messages are stored
  202. #define WINDS_DOWNLOAD_DIR_NAME_FORMAT      TEXT("%s\\Pending Downloads - %s")
  203. #define XP_MSG_FILE_PREFIX                  TEXT("XRM")
  204. #define XP_MSG_FILE_SUFFIX                  TEXT("TMP")
  205.  
  206. // Variables and static data structure used by all WINDS providers 
  207. extern "C"
  208. {
  209.     extern HINSTANCE    ghInstance;
  210.     extern TCHAR        szBlank[];
  211.     extern TCHAR        szFilter[];
  212.     extern TCHAR        szPhoneFilter[];
  213.     extern TCHAR        szTimeFilter[];
  214.     extern DTBLLABEL    DtLabel;
  215.     extern DTBLGROUPBOX DtGroupBox;
  216.     extern DTBLPAGE     DtPage;
  217.     extern DTBLEDIT     DtObjAlias;
  218.     extern DTBLEDIT     DtObjFullName;
  219.     extern DTBLEDIT     DtUserName;
  220.     extern DTBLEDIT     DtServer;
  221.     extern DTBLEDIT     DtComment;
  222.     extern DTCTL        UserConfigPage[];
  223. };
  224.  
  225. int WINAPI PrivateMessageBox
  226.                     (UINT                       ids, 
  227.                      HWND                       hOwnerWnd = NULL,
  228.                      UINT                       uFlags = MB_OK | MB_ICONSTOP,
  229.                      HINSTANCE                  hInst = NULL);
  230. extern "C"
  231. {
  232.     HRESULT WINAPI BindToServer
  233.                     (LPTSTR                     szServer);
  234.     BOOL WINAPI IsWINDSServerAvailable
  235.                     (LPTSTR                     szServerName);
  236.     BOOL WINAPI PingRemoteServer
  237.                     (HWND                       hOwnerWnd,
  238.                      LPSPropValue               pProps);
  239.     BOOL WINAPI IsValidServerName
  240.                     (LPTSTR                     szServerName);
  241.     HRESULT WINAPI DoServerLogon
  242.                     (PMAILBOX_INFO              pMBInfo,
  243.                      LPSPropValue               pProps,
  244.                      LPPROFSECT                 pProfileObj,
  245.                      BOOL                       fUIAllowed,
  246.                      HWND                       hOwnerWnd,
  247.                      BOOL                       fSetNotification,
  248.                      DWORD                      dwNotifMask,
  249.                      DWORD *                    pdwConnectID,
  250.                      BOOL                       fOffLineOK);
  251.     HRESULT WINAPI ChangeMBServerPassword
  252.                     (LPTSTR                     szServerName,
  253.                      LPTSTR                     szMailboxName,
  254.                      LPTSTR                     szOldPassword,
  255.                      LPTSTR                     szNewPassword);
  256.     HRESULT WINAPI TerminateServerNotifications
  257.                     (LPTSTR                     szServerName,
  258.                      DWORD                      dwConnectionID);
  259.     HRESULT WINAPI ResetServerNotifications
  260.                     (LPTSTR                     szServerName,
  261.                      LPTSTR                     szMailboxName,
  262.                      DWORD                      dwNotifMask,
  263.                      DWORD *                    pdwConnectionID);
  264.     void WINAPI TerminateRemoteConnections
  265.                     ();
  266.     HRESULT WINAPI MergeConfigProps
  267.                     (ULONG                      ulCfgProps,
  268.                      LPSPropValue               pCfgProps,
  269.                      LPSPropValue               pLogonProps);
  270.     HRESULT WINAPI OpenServiceProfileSection
  271.                     (LPMAPISUP                  pSupObj,
  272.                      LPPROFSECT *               ppProfSectObj,
  273.                      LPFREEBUFFER               pfnFreeBuffer);
  274.     // Transport Providers
  275.     HRESULT WINAPI OpenServerUploadPipe
  276.                     (LPTSTR                     szServerName,
  277.                      LPTSTR                     szSenderMailbox,
  278.                      HANDLE                     hMsgFile,
  279.                      LPTSTR                     szConnectionInfo,
  280.                      BOOL *                     pfErrorInTheServer);
  281.     HRESULT WINAPI SendMsgToAccount
  282.                     (LPTSTR                     szServerName,
  283.                      LPTSTR                     szRecipMailbox,
  284.                      LPTSTR                     szHeader,
  285.                      LPTSTR                     szConnectionInfo,
  286.                      BOOL *                     pfErrorInTheServer);
  287.     HRESULT WINAPI FinishUploadConnection
  288.                     (LPTSTR                     szServerName,
  289.                      LPTSTR                     szConnectionInfo);
  290.     HRESULT WINAPI GetHeadersFromServer
  291.                     (LPTSTR                     szServerName,
  292.                      LPTSTR                     szMailbox,
  293.                      LPTSTR                     szHeaderFile);
  294.     HRESULT WINAPI OpenRemoteServerDownLoadPipe
  295.                     (LPTSTR                     szServer,
  296.                      LPTSTR                     szMBox,
  297.                      HANDLE *                   phPipe);
  298.     HRESULT WINAPI GetNextMailboxMsg
  299.                     (LPTSTR                     szServer,
  300.                      LPTSTR                     szMailbox,
  301.                      LPTSTR                     szLocalMsgFile);
  302.     HRESULT WINAPI CheckForPendingMessages
  303.                     (LPTSTR                     szServerName,
  304.                      LPTSTR                     szMailboxName,
  305.                      ULONG *                    pulMsgWaiting);
  306. };
  307.  
  308. // CTL3D Dynamic Loading Support
  309. void WINAPI PrivInitialize3DCtl
  310.                     (HINSTANCE                  hInstance);
  311. void WINAPI PrivUninitialize3DCtl
  312.                     (HINSTANCE                  hInstance);
  313.  
  314. // Forward declarations
  315. class CUIMAPIProp;
  316.  
  317. // Custom callback function prototype for the implementation
  318. // and activation of IMAPIControl on display tables on property sheets.
  319. typedef void (STDAPICALLTYPE BUTTONCALLBACK) (CUIMAPIProp * pObj, HWND hOwnerWnd, HINSTANCE hInstance);
  320. typedef BUTTONCALLBACK *LPBUTTONCALLBACK;
  321.  
  322. class CUIMAPIProp : public IMAPIProp
  323. {
  324. public:
  325.     inline STDMETHODIMP QueryInterface
  326.                     (REFIID                     riid,
  327.                      LPVOID *                   ppvObj)
  328.                     { *ppvObj = NULL;
  329.                       HRESULT hResult = S_OK;
  330.                       EnterCriticalSection (&m_csObj);
  331.                       if (riid == IID_IMAPIProp || riid == IID_IUnknown)
  332.                       {
  333.                           *ppvObj = (LPVOID)this;
  334.                           AddRef();
  335.                       }
  336.                       else
  337.                       {
  338.                           hResult = E_NOINTERFACE;
  339.                       }
  340.                       LeaveCriticalSection (&m_csObj);
  341.                       return hResult; }
  342.     inline STDMETHODIMP_(ULONG) AddRef
  343.                     () { EnterCriticalSection (&m_csObj);
  344.                          ++m_cRef; ULONG ulCount = m_cRef;
  345.                          LeaveCriticalSection (&m_csObj);
  346.                          return ulCount; }
  347.     inline STDMETHODIMP_(ULONG) Release
  348.                     () { EnterCriticalSection (&m_csObj);
  349.                          ULONG ulCount = --m_cRef;
  350.                          LeaveCriticalSection (&m_csObj);
  351.                          if (!ulCount) { delete this; }
  352.                          return ulCount;}
  353.     inline STDMETHODIMP GetLastError
  354.                     (HRESULT                    hResult,
  355.                      ULONG                      ulFlags,
  356.                      LPMAPIERROR *              ppMAPIError)
  357.                     { return m_pImpObj->GetLastError (hResult, ulFlags, ppMAPIError); }
  358.     inline STDMETHODIMP SaveChanges
  359.                     (ULONG                      ulFlags)
  360.                     { return S_OK; }
  361.     inline STDMETHODIMP GetProps
  362.                     (LPSPropTagArray            pPropTagArray,
  363.                      ULONG                      ulFlags,
  364.                      ULONG *                    pcValues,
  365.                      LPSPropValue *             ppPropArray)
  366.                     { return m_pImpObj->GetProps (pPropTagArray, ulFlags, pcValues, ppPropArray); }
  367.     inline STDMETHODIMP GetPropList
  368.                     (ULONG                      ulFlags,
  369.                      LPSPropTagArray *          ppAllTags)
  370.                     { return m_pImpObj->GetPropList (ulFlags, ppAllTags); }
  371.     STDMETHODIMP OpenProperty
  372.                     (ULONG                      ulPropTag,
  373.                      LPCIID                     piid,
  374.                      ULONG                      ulInterfaceOptions,
  375.                      ULONG                      ulFlags,
  376.                      LPUNKNOWN *                ppUnk);
  377.     inline STDMETHODIMP SetProps
  378.                     (ULONG                      cValues,
  379.                      LPSPropValue               pPropArray,
  380.                      LPSPropProblemArray *      ppProblems)
  381.                     { return m_pImpObj->SetProps (cValues, pPropArray, ppProblems); }
  382.     inline STDMETHODIMP DeleteProps
  383.                     (LPSPropTagArray            pPropTagArray,
  384.                      LPSPropProblemArray *      ppProblems)
  385.                     { return m_pImpObj->DeleteProps (pPropTagArray, ppProblems); }
  386.     inline STDMETHODIMP CopyTo
  387.                     (ULONG                      ciidExclude,
  388.                      LPCIID                     rgiidExclude,
  389.                      LPSPropTagArray            pExcludeProps,
  390.                      ULONG                      ulUIParam,
  391.                      LPMAPIPROGRESS             pProgress,
  392.                      LPCIID                     pInterface,
  393.                      LPVOID                     pDestObj,
  394.                      ULONG                      ulFlags,
  395.                      LPSPropProblemArray *      ppProblems)
  396.                     { return m_pImpObj->CopyTo (ciidExclude, rgiidExclude, pExcludeProps, ulUIParam, pProgress, pInterface, pDestObj, ulFlags, ppProblems); }
  397.     inline STDMETHODIMP CopyProps
  398.                     (LPSPropTagArray            pIncludeProps,
  399.                      ULONG                      ulUIParam,
  400.                      LPMAPIPROGRESS             pProgress,
  401.                      LPCIID                     pInterface,
  402.                      LPVOID                     pDestObj,
  403.                      ULONG                      ulFlags,
  404.                      LPSPropProblemArray *      ppProblems)
  405.                     { return m_pImpObj->CopyProps (pIncludeProps, ulUIParam, pProgress, pInterface, pDestObj, ulFlags, ppProblems); }
  406.     inline STDMETHODIMP GetNamesFromIDs
  407.                     (LPSPropTagArray *          ppPropTags,
  408.                      LPGUID                     pPropSetGuid,
  409.                      ULONG                      ulFlags,
  410.                      ULONG *                    pcPropNames,
  411.                      LPMAPINAMEID **            pppPropNames)
  412.                     { return MAPI_E_NO_SUPPORT; }
  413.     inline STDMETHODIMP GetIDsFromNames
  414.                     (ULONG                      cPropNames,
  415.                      LPMAPINAMEID *             ppPropNames,
  416.                      ULONG                      ulFlags,
  417.                      LPSPropTagArray *          ppPropTags)
  418.                     { return MAPI_E_NO_SUPPORT; }
  419.  
  420. ///////////////////////////////////////////////////////////////////////////////
  421. // Other methods private to this class
  422. //
  423.     inline void WINAPI SetTableData
  424.                     (LPTABLEDATA                pTable)
  425.                     { m_pTableData = pTable; m_pTableData->AddRef(); }
  426.     inline void WINAPI SetPropCallBack
  427.                     (ULONG                      ulPropTag,
  428.                      LPBUTTONCALLBACK           pfnCallBack)
  429.                     { m_ulCustomPropTag = ulPropTag; m_pfnCallBack = pfnCallBack; }
  430.  
  431. ///////////////////////////////////////////////////////////////////////////////
  432. // Constructors and destructors
  433. //
  434. public :
  435.     CUIMAPIProp     (HINSTANCE                  hInstance,
  436.                      LPALLOCATEBUFFER           pfnAllocateBuffer,
  437.                      LPALLOCATEMORE             pfnAllocateMore,
  438.                      LPFREEBUFFER               pfnFreeBuffer,
  439.                      BOOL                       fReadOnly);
  440.     ~CUIMAPIProp    () { m_pImpObj->Release(); m_pImpObj = NULL;
  441.                          if (m_pTableData) { m_pTableData->Release(); }
  442.                          DeleteCriticalSection (&m_csObj);}
  443.  
  444. ///////////////////////////////////////////////////////////////////////////////
  445. // Data members
  446. //
  447. private :
  448.     ULONG               m_cRef;
  449.     BOOL                m_fReadOnly;
  450.     LPPROPDATA          m_pImpObj;
  451.     ULONG               m_ulCustomPropTag;
  452.     LPBUTTONCALLBACK    m_pfnCallBack;
  453.     CRITICAL_SECTION    m_csObj;
  454. public :
  455.     LPTABLEDATA         m_pTableData;
  456.     HINSTANCE           m_hInstance;
  457. };
  458.  
  459. class CMAPIControl : public IMAPIControl
  460. {
  461.     inline STDMETHODIMP QueryInterface
  462.                     (REFIID                     riid,
  463.                      LPVOID *                   ppvObj)
  464.                     { *ppvObj = NULL;
  465.                       HRESULT hResult = S_OK;
  466.                       EnterCriticalSection (&m_csObj);
  467.                       if (riid == IID_IMAPIControl || riid == IID_IUnknown)
  468.                       {
  469.                           *ppvObj = (LPVOID)this;
  470.                           // Increase usage count of this object
  471.                           AddRef();
  472.                       }
  473.                       else
  474.                       {
  475.                           hResult = E_NOINTERFACE;
  476.                       }
  477.                       LeaveCriticalSection (&m_csObj);
  478.                       return hResult; }
  479.     inline STDMETHODIMP_(ULONG) AddRef
  480.                     () { EnterCriticalSection (&m_csObj);
  481.                          ++m_cRef; ULONG ulCount = m_cRef;
  482.                          LeaveCriticalSection (&m_csObj);
  483.                          return ulCount; }
  484.     inline STDMETHODIMP_(ULONG) Release
  485.                     () { EnterCriticalSection (&m_csObj);
  486.                          ULONG ulCount = --m_cRef;
  487.                          LeaveCriticalSection (&m_csObj);
  488.                          if (!ulCount) { delete this; }
  489.                          return ulCount;}
  490.     inline STDMETHODIMP GetLastError
  491.                     (HRESULT                    hResult,
  492.                      ULONG                      ulFlags,
  493.                      LPMAPIERROR *              ppMAPIError)
  494.                     { return MAPI_E_NO_SUPPORT; }
  495.     inline STDMETHODIMP GetState
  496.                     (ULONG                      ulFlags,
  497.                      ULONG *                    pulState)
  498.                     { *pulState = (m_fReadOnly ? MAPI_DISABLED : MAPI_ENABLED); return S_OK; }
  499.     inline STDMETHODIMP Activate
  500.                     (ULONG                      ulFlags,
  501.                      ULONG                      ulUIParam)
  502.                     { (*m_pfnCallBack)(m_pProp, (HWND)ulUIParam, m_pProp->m_hInstance); return S_OK; }
  503.  
  504. ///////////////////////////////////////////////////////////////////////////////
  505. // Constructors and destructors
  506. //
  507. public :
  508.     CMAPIControl    (CUIMAPIProp *              pProp,
  509.                      LPBUTTONCALLBACK           pfnCallBack,
  510.                      BOOL                       fReadOnly)
  511.                     { m_cRef = 1; m_pfnCallBack = pfnCallBack; m_fReadOnly = fReadOnly;
  512.                       m_pProp = pProp; m_pProp->AddRef();
  513.                       InitializeCriticalSection (&m_csObj); }
  514.     ~CMAPIControl   ()
  515.                     { m_pProp->Release();
  516.                       DeleteCriticalSection (&m_csObj);}
  517. ///////////////////////////////////////////////////////////////////////////////
  518. // Data members
  519. //
  520. private :
  521.     ULONG               m_cRef;
  522.     LPBUTTONCALLBACK    m_pfnCallBack;
  523.     BOOL                m_fReadOnly;
  524.     CUIMAPIProp *       m_pProp;
  525.     CRITICAL_SECTION    m_csObj;
  526. };
  527.  
  528. #endif // _COMWINDS_H
  529.  
  530. // End of file for COMWINDS.H
  531.