mapix.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef __M4L_MAPIX_H_
  18. #define __M4L_MAPIX_H_
  19. #define MAPIX_H
  20. #include <kopano/zcdefs.h>
  21. #include <kopano/platform.h>
  22. /* Include common MAPI header files if they haven't been already. */
  23. #include <mapidefs.h>
  24. #include <mapicode.h>
  25. #include <mapiguid.h>
  26. #include <mapitags.h>
  27. /* Forward interface declarations */
  28. class IProfAdmin;
  29. class IMsgServiceAdmin;
  30. class IMAPISession;
  31. typedef IProfAdmin* LPPROFADMIN;
  32. typedef IMsgServiceAdmin* LPSERVICEADMIN;
  33. typedef IMAPISession* LPMAPISESSION;
  34. /* uhhh... already in mapi.h ? */
  35. /* MAPILogon() flags. */
  36. //#define MAPI_LOGON_UI 0x00000001 /* Display logon UI */
  37. //#define MAPI_NEW_SESSION 0x00000002 /* Don't use shared session */
  38. #define MAPI_ALLOW_OTHERS 0x00000008 /* Make this a shared session */
  39. #define MAPI_EXPLICIT_PROFILE 0x00000010 /* Don't use default profile */
  40. //#define MAPI_EXTENDED 0x00000020 /* Extended MAPI Logon */
  41. //#define MAPI_FORCE_DOWNLOAD 0x00001000 /* Get new mail before return */
  42. #define MAPI_SERVICE_UI_ALWAYS 0x00002000 /* Do logon UI in all providers */
  43. #define MAPI_NO_MAIL 0x00008000 /* Do not activate transports */
  44. /* #define MAPI_NT_SERVICE 0x00010000 Allow logon from an NT service */
  45. /* #ifndef MAPI_PASSWORD_UI */
  46. /* #define MAPI_PASSWORD_UI 0x00020000 /\* Display password UI only *\/ */
  47. /* #endif */
  48. #define MAPI_TIMEOUT_SHORT 0x00100000 /* Minimal wait for logon resources */
  49. #define MAPI_SIMPLE_DEFAULT (MAPI_LOGON_UI | MAPI_FORCE_DOWNLOAD | MAPI_ALLOW_OTHERS)
  50. #define MAPI_SIMPLE_EXPLICIT (MAPI_NEW_SESSION | MAPI_FORCE_DOWNLOAD | MAPI_EXPLICIT_PROFILE)
  51. /* Structure passed to MAPIInitialize(), and its ulFlags values */
  52. struct MAPIINIT_0 {
  53. ULONG ulVersion;
  54. ULONG ulFlags;
  55. };
  56. typedef struct MAPIINIT_0 *LPMAPIINIT_0;
  57. typedef MAPIINIT_0 MAPIINIT;
  58. typedef MAPIINIT *LPMAPIINIT;
  59. #define MAPI_INIT_VERSION 0
  60. #define MAPI_MULTITHREAD_NOTIFICATIONS 0x00000001
  61. /* Reserved for MAPI 0x40000000 */
  62. #define MAPI_NT_SERVICE 0x00010000 /* Use from NT service */
  63. /* MAPI base functions */
  64. extern "C" {
  65. typedef HRESULT (MAPIINITIALIZE)(LPVOID lpMapiInit);
  66. typedef MAPIINITIALIZE* LPMAPIINITIALIZE;
  67. typedef void (MAPIUNINITIALIZE)(void);
  68. typedef MAPIUNINITIALIZE* LPMAPIUNINITIALIZE;
  69. extern _kc_export MAPIINITIALIZE MAPIInitialize;
  70. extern _kc_export MAPIUNINITIALIZE MAPIUninitialize;
  71. /* Extended MAPI Logon function */
  72. typedef HRESULT (MAPILOGONEX)(
  73. ULONG ulUIParam,
  74. LPTSTR lpszProfileName,
  75. LPTSTR lpszPassword,
  76. ULONG ulFlags,
  77. LPMAPISESSION* lppSession
  78. );
  79. typedef MAPILOGONEX* LPMAPILOGONEX;
  80. extern _kc_export MAPILOGONEX MAPILogonEx;
  81. typedef SCODE (MAPIALLOCATEBUFFER)(
  82. ULONG cbSize,
  83. LPVOID * lppBuffer
  84. );
  85. typedef SCODE (MAPIALLOCATEMORE)(
  86. ULONG cbSize,
  87. LPVOID lpObject,
  88. LPVOID * lppBuffer
  89. );
  90. typedef ULONG (MAPIFREEBUFFER)(
  91. LPVOID lpBuffer
  92. );
  93. typedef MAPIALLOCATEBUFFER *LPMAPIALLOCATEBUFFER;
  94. typedef MAPIALLOCATEMORE *LPMAPIALLOCATEMORE;
  95. typedef MAPIFREEBUFFER *LPMAPIFREEBUFFER;
  96. extern _kc_export MAPIALLOCATEBUFFER MAPIAllocateBuffer;
  97. extern _kc_export MAPIALLOCATEMORE MAPIAllocateMore;
  98. extern _kc_export MAPIFREEBUFFER MAPIFreeBuffer;
  99. typedef HRESULT (MAPIADMINPROFILES)(
  100. ULONG ulFlags,
  101. LPPROFADMIN *lppProfAdmin
  102. );
  103. typedef MAPIADMINPROFILES *LPMAPIADMINPROFILES;
  104. extern _kc_export MAPIADMINPROFILES MAPIAdminProfiles;
  105. } // EXTERN "C"
  106. /*
  107. * IMAPISession Interface
  108. */
  109. /* Flags for OpenEntry and others */
  110. /*#define MAPI_MODIFY ((ULONG) 0x00000001) */
  111. /* Flags for Logoff */
  112. #define MAPI_LOGOFF_SHARED 0x00000001 /* Close all shared sessions */
  113. #define MAPI_LOGOFF_UI 0x00000002 /* It's OK to present UI */
  114. /* Flags for SetDefaultStore. They are mutually exclusive. */
  115. #define MAPI_DEFAULT_STORE 0x00000001 /* for incoming messages */
  116. #define MAPI_SIMPLE_STORE_TEMPORARY 0x00000002 /* for simple MAPI and CMC */
  117. #define MAPI_SIMPLE_STORE_PERMANENT 0x00000003 /* for simple MAPI and CMC */
  118. #define MAPI_PRIMARY_STORE 0x00000004 /* Used by some clients */
  119. #define MAPI_SECONDARY_STORE 0x00000005 /* Used by some clients */
  120. /* Flags for ShowForm. */
  121. #define MAPI_POST_MESSAGE 0x00000001 /* Selects post/send semantics */
  122. #define MAPI_NEW_MESSAGE 0x00000002 /* Governs copying during submission */
  123. class IMAPISession : public virtual IUnknown {
  124. public:
  125. // virtual ~IMAPISession() = 0;
  126. virtual HRESULT GetLastError(HRESULT hResult, ULONG ulFlags, LPMAPIERROR* lppMAPIError) = 0;
  127. virtual HRESULT GetMsgStoresTable(ULONG ulFlags, LPMAPITABLE* lppTable) = 0;
  128. virtual HRESULT OpenMsgStore(ULONG ulUIParam, ULONG cbEntryID, LPENTRYID lpEntryID, LPCIID lpInterface, ULONG ulFlags, LPMDB* lppMDB) = 0;
  129. virtual HRESULT OpenAddressBook(ULONG ulUIParam, LPCIID lpInterface, ULONG ulFlags, LPADRBOOK* lppAdrBook) = 0;
  130. virtual HRESULT OpenProfileSection(LPMAPIUID lpUID, LPCIID lpInterface, ULONG ulFlags, LPPROFSECT* lppProfSect) = 0;
  131. virtual HRESULT GetStatusTable(ULONG ulFlags, LPMAPITABLE* lppTable) = 0;
  132. virtual HRESULT OpenEntry(ULONG cbEntryID, LPENTRYID lpEntryID, LPCIID lpInterface, ULONG ulFlags, ULONG* lpulObjType,
  133. LPUNKNOWN* lppUnk) = 0;
  134. virtual HRESULT CompareEntryIDs(ULONG cbEntryID1, LPENTRYID lpEntryID1, ULONG cbEntryID2, LPENTRYID lpEntryID2, ULONG ulFlags,
  135. ULONG* lpulResult) = 0;
  136. virtual HRESULT Advise(ULONG cbEntryID, LPENTRYID lpEntryID, ULONG ulEventMask, LPMAPIADVISESINK lpAdviseSink, ULONG* lpulConnection) = 0;
  137. virtual HRESULT Unadvise(ULONG ulConnection) = 0;
  138. virtual HRESULT MessageOptions(ULONG ulUIParam, ULONG ulFlags, LPTSTR lpszAdrType, LPMESSAGE lpMessage) = 0;
  139. virtual HRESULT QueryDefaultMessageOpt(LPTSTR lpszAdrType, ULONG ulFlags, ULONG* lpcValues, LPSPropValue* lppOptions) = 0;
  140. virtual HRESULT EnumAdrTypes(ULONG ulFlags, ULONG* lpcAdrTypes, LPTSTR** lpppszAdrTypes) = 0;
  141. virtual HRESULT QueryIdentity(ULONG* lpcbEntryID, LPENTRYID* lppEntryID) = 0;
  142. virtual HRESULT Logoff(ULONG ulUIParam, ULONG ulFlags, ULONG ulReserved) = 0;
  143. virtual HRESULT SetDefaultStore(ULONG ulFlags, ULONG cbEntryID, LPENTRYID lpEntryID) = 0;
  144. virtual HRESULT AdminServices(ULONG ulFlags, LPSERVICEADMIN* lppServiceAdmin) = 0;
  145. virtual HRESULT ShowForm(ULONG ulUIParam, LPMDB lpMsgStore, LPMAPIFOLDER lpParentFolder, LPCIID lpInterface, ULONG ulMessageToken,
  146. LPMESSAGE lpMessageSent, ULONG ulFlags, ULONG ulMessageStatus, ULONG ulMessageFlags, ULONG ulAccess,
  147. LPSTR lpszMessageClass) = 0;
  148. virtual HRESULT PrepareForm(LPCIID lpInterface, LPMESSAGE lpMessage, ULONG* lpulMessageToken) = 0;
  149. };
  150. /*DECLARE_MAPI_INTERFACE_PTR(IMAPISession, LPMAPISESSION);*/
  151. /* IAddrBook Interface ----------------------------------------------------- */
  152. class IAddrBook : public virtual IMAPIProp {
  153. public:
  154. // virtual ~IAddrBook() = 0;
  155. virtual HRESULT OpenEntry(ULONG cbEntryID, LPENTRYID lpEntryID, LPCIID lpInterface, ULONG ulFlags, ULONG * lpulObjType,
  156. LPUNKNOWN * lppUnk) = 0;
  157. virtual HRESULT CompareEntryIDs(ULONG cbEntryID1, LPENTRYID lpEntryID1, ULONG cbEntryID2, LPENTRYID lpEntryID2, ULONG ulFlags,
  158. ULONG* lpulResult) = 0;
  159. virtual HRESULT Advise(ULONG cbEntryID, LPENTRYID lpEntryID, ULONG ulEventMask, LPMAPIADVISESINK lpAdviseSink, ULONG* lpulConnection) = 0;
  160. virtual HRESULT Unadvise(ULONG ulConnection) = 0;
  161. virtual HRESULT CreateOneOff(LPTSTR lpszName, LPTSTR lpszAdrType, LPTSTR lpszAddress, ULONG ulFlags, ULONG* lpcbEntryID,
  162. LPENTRYID* lppEntryID) = 0;
  163. virtual HRESULT NewEntry(ULONG ulUIParam, ULONG ulFlags, ULONG cbEIDContainer, LPENTRYID lpEIDContainer, ULONG cbEIDNewEntryTpl,
  164. LPENTRYID lpEIDNewEntryTpl, ULONG* lpcbEIDNewEntry, LPENTRYID* lppEIDNewEntry) = 0;
  165. virtual HRESULT ResolveName(ULONG ulUIParam, ULONG ulFlags, LPTSTR lpszNewEntryTitle, LPADRLIST lpAdrList) = 0;
  166. virtual HRESULT Address(ULONG* lpulUIParam, LPADRPARM lpAdrParms, LPADRLIST* lppAdrList) = 0;
  167. virtual HRESULT Details(ULONG* lpulUIParam, LPFNDISMISS lpfnDismiss, LPVOID lpvDismissContext, ULONG cbEntryID, LPENTRYID lpEntryID,
  168. LPFNBUTTON lpfButtonCallback, LPVOID lpvButtonContext, LPTSTR lpszButtonText, ULONG ulFlags) = 0;
  169. virtual HRESULT RecipOptions(ULONG ulUIParam, ULONG ulFlags, LPADRENTRY lpRecip) = 0;
  170. virtual HRESULT QueryDefaultRecipOpt(LPTSTR lpszAdrType, ULONG ulFlags, ULONG* lpcValues, LPSPropValue* lppOptions) = 0;
  171. virtual HRESULT GetPAB(ULONG* lpcbEntryID, LPENTRYID* lppEntryID) = 0;
  172. virtual HRESULT SetPAB(ULONG cbEntryID, LPENTRYID lpEntryID) = 0;
  173. virtual HRESULT GetDefaultDir(ULONG* lpcbEntryID, LPENTRYID* lppEntryID) = 0;
  174. virtual HRESULT SetDefaultDir(ULONG cbEntryID, LPENTRYID lpEntryID) = 0;
  175. virtual HRESULT GetSearchPath(ULONG ulFlags, LPSRowSet* lppSearchPath) = 0;
  176. virtual HRESULT SetSearchPath(ULONG ulFlags, LPSRowSet lpSearchPath) = 0;
  177. virtual HRESULT PrepareRecips(ULONG ulFlags, const SPropTagArray *lpPropTagArray, LPADRLIST lpRecipList) = 0;
  178. };
  179. typedef IAddrBook* LPADRBOOK;
  180. /*
  181. * IProfAdmin Interface
  182. */
  183. #define MAPI_DEFAULT_SERVICES 0x00000001
  184. class IProfAdmin : public virtual IUnknown {
  185. public:
  186. // virtual ~IProfAdmin() = 0;
  187. virtual HRESULT GetLastError(HRESULT hResult, ULONG ulFlags, LPMAPIERROR* lppMAPIError) = 0;
  188. virtual HRESULT GetProfileTable(ULONG ulFlags, LPMAPITABLE* lppTable) = 0;
  189. virtual HRESULT CreateProfile(LPTSTR lpszProfileName, LPTSTR lpszPassword, ULONG ulUIParam, ULONG ulFlags) = 0;
  190. virtual HRESULT DeleteProfile(LPTSTR lpszProfileName, ULONG ulFlags) = 0;
  191. virtual HRESULT ChangeProfilePassword(LPTSTR lpszProfileName, LPTSTR lpszOldPassword, LPTSTR lpszNewPassword, ULONG ulFlags) = 0;
  192. virtual HRESULT CopyProfile(LPTSTR lpszOldProfileName, LPTSTR lpszOldPassword, LPTSTR lpszNewProfileName, ULONG ulUIParam,
  193. ULONG ulFlags) = 0;
  194. virtual HRESULT RenameProfile(LPTSTR lpszOldProfileName, LPTSTR lpszOldPassword, LPTSTR lpszNewProfileName, ULONG ulUIParam,
  195. ULONG ulFlags) = 0;
  196. virtual HRESULT SetDefaultProfile(LPTSTR lpszProfileName, ULONG ulFlags) = 0;
  197. virtual HRESULT AdminServices(LPTSTR lpszProfileName, LPTSTR lpszPassword, ULONG ulUIParam, ULONG ulFlags,
  198. LPSERVICEADMIN* lppServiceAdmin) = 0;
  199. };
  200. /*
  201. * IMsgServiceAdmin Interface
  202. */
  203. /* Values for PR_RESOURCE_FLAGS in message service table */
  204. #define SERVICE_DEFAULT_STORE 0x00000001
  205. #define SERVICE_SINGLE_COPY 0x00000002
  206. #define SERVICE_CREATE_WITH_STORE 0x00000004
  207. #define SERVICE_PRIMARY_IDENTITY 0x00000008
  208. #define SERVICE_NO_PRIMARY_IDENTITY 0x00000020
  209. class IMsgServiceAdmin : public virtual IUnknown {
  210. public:
  211. // virtual ~IMsgServiceAdmin() = 0;
  212. virtual HRESULT GetLastError(HRESULT hResult, ULONG ulFlags, LPMAPIERROR* lppMAPIError) = 0;
  213. virtual HRESULT GetMsgServiceTable(ULONG ulFlags, LPMAPITABLE* lppTable) = 0;
  214. virtual HRESULT CreateMsgService(LPTSTR lpszService, LPTSTR lpszDisplayName, ULONG ulUIParam, ULONG ulFlags) = 0;
  215. virtual HRESULT DeleteMsgService(LPMAPIUID lpUID) = 0;
  216. virtual HRESULT CopyMsgService(LPMAPIUID lpUID, LPTSTR lpszDisplayName, LPCIID lpInterfaceToCopy, LPCIID lpInterfaceDst,
  217. LPVOID lpObjectDst, ULONG ulUIParam, ULONG ulFlags) = 0;
  218. virtual HRESULT RenameMsgService(LPMAPIUID lpUID, ULONG ulFlags, LPTSTR lpszDisplayName) = 0;
  219. virtual HRESULT ConfigureMsgService(LPMAPIUID lpUID, ULONG ulUIParam, ULONG ulFlags, ULONG cValues, LPSPropValue lpProps) = 0;
  220. virtual HRESULT OpenProfileSection(LPMAPIUID lpUID, LPCIID lpInterface, ULONG ulFlags, LPPROFSECT* lppProfSect) = 0;
  221. virtual HRESULT MsgServiceTransportOrder(ULONG cUID, LPMAPIUID lpUIDList, ULONG ulFlags) = 0;
  222. virtual HRESULT AdminProviders(LPMAPIUID lpUID, ULONG ulFlags, LPPROVIDERADMIN* lppProviderAdmin) = 0;
  223. virtual HRESULT SetPrimaryIdentity(LPMAPIUID lpUID, ULONG ulFlags) = 0;
  224. virtual HRESULT GetProviderTable(ULONG ulFlags, LPMAPITABLE* lppTable) = 0;
  225. };
  226. #endif /* MAPIX_H */