kcore.hpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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 KC_KCORE_HPP
  18. #define KC_KCORE_HPP 1
  19. #include <mapi.h>
  20. #include <mapidefs.h>
  21. #include <kopano/ECTags.h>
  22. #include <kopano/Trace.h>
  23. // We have 2 types of entryids: those of objects, and those of stores.
  24. // Objects have a store-relative path, however they do have a GUID to make
  25. // sure that we can differentiate 2 entryids from different stores
  26. //
  27. // The ulType fields makes sure that we can read whether it is a store EID
  28. // or an object EID. This is used when opening a store's properties.
  29. // This is our EntryID struct. The first abFlags[] array is required
  30. // by MAPI, other fields in the struct can be anything you like
  31. // Version is our internal version so we can differentiate them in later
  32. // versions
  33. // The ulId field is simply the ID of the record in the database hierarchy
  34. // table. For stores, this is the ID of the msgstore record in the database
  35. // (also the hierarchy table). Each record in on the server has a different
  36. // ulId, even across different stores.
  37. //
  38. // We can differentiate two EntryIDs of 2 different servers with the same
  39. // ulId because the guid is different. (This guid is different per server)
  40. //
  41. // When this is a store EID, the szServer field is also set, and the ulId
  42. // points to the top-level object for the store. The other fields are the same.
  43. #pragma pack(push,1)
  44. // Entryid from version 6
  45. // Entryid version 1 (48 bytes)
  46. struct EID {
  47. BYTE abFlags[4];
  48. GUID guid; // StoreGuid
  49. ULONG ulVersion;
  50. USHORT usType;
  51. USHORT usFlags; // Before Zarafa 7.1, ulFlags did not exist, and ulType was ULONG
  52. GUID uniqueId; // Unique id
  53. CHAR szServer[1];
  54. CHAR szPadding[3];
  55. EID(USHORT usType, const GUID &guid, const GUID &uniqueId, USHORT usFlags = 0)
  56. {
  57. memset(this, 0, sizeof(EID));
  58. this->ulVersion = 1; //Always last version
  59. this->usType = usType;
  60. this->usFlags = usFlags;
  61. this->guid = guid;
  62. this->uniqueId = uniqueId;
  63. }
  64. EID(const EID *oldEID)
  65. {
  66. memset(this, 0, sizeof(EID));
  67. this->ulVersion = oldEID->ulVersion;
  68. this->usType = oldEID->usType;
  69. this->guid = oldEID->guid;
  70. this->uniqueId = oldEID->uniqueId;
  71. }
  72. EID() {
  73. memset(this, 0, sizeof(EID));
  74. this->ulVersion = 1;
  75. }
  76. };
  77. // The entryid from the begin of zarafa till 5.20
  78. // Entryid version is zero (36 bytes)
  79. struct EID_V0 {
  80. BYTE abFlags[4];
  81. GUID guid; // StoreGuid
  82. ULONG ulVersion;
  83. USHORT usType;
  84. USHORT usFlags; // Before Zarafa 7.1, ulFlags did not exist, and ulType was ULONG
  85. ULONG ulId;
  86. CHAR szServer[1];
  87. CHAR szPadding[3];
  88. EID_V0(USHORT usType, const GUID &guid, ULONG ulId)
  89. {
  90. memset(this, 0, sizeof(EID_V0));
  91. this->usType = usType;
  92. this->guid = guid;
  93. this->ulId = ulId;
  94. }
  95. EID_V0(const EID_V0 *oldEID)
  96. {
  97. memset(this, 0, sizeof(EID_V0));
  98. this->usType = oldEID->usType;
  99. this->guid = oldEID->guid;
  100. this->ulId = oldEID->ulId;
  101. }
  102. EID_V0() {
  103. memset(this, 0, sizeof(EID_V0));
  104. }
  105. };
  106. #pragma pack(pop)
  107. struct ABEID {
  108. BYTE abFlags[4];
  109. GUID guid;
  110. ULONG ulVersion;
  111. ULONG ulType;
  112. ULONG ulId;
  113. CHAR szExId[1];
  114. CHAR szPadding[3];
  115. ABEID(ULONG ulType, const GUID &guid, ULONG ulId) {
  116. memset(this, 0, sizeof(ABEID));
  117. this->ulType = ulType;
  118. this->guid = guid;
  119. this->ulId = ulId;
  120. }
  121. ABEID(const ABEID *oldEID)
  122. {
  123. memset(this, 0, sizeof(ABEID));
  124. this->ulType = oldEID->ulType;
  125. this->guid = oldEID->guid;
  126. this->ulId = oldEID->ulId;
  127. }
  128. ABEID() {
  129. memset(this, 0, sizeof(ABEID));
  130. }
  131. };
  132. typedef struct ABEID *PABEID;
  133. #define _CbABEID(p) ((sizeof(ABEID)+strlen((char*)(p)->szExId))&~3)
  134. #define CbABEID(p) (sizeof(ABEID)>_CbABEID((p))?sizeof(ABEID):_CbABEID((p)))
  135. #define _CbNewABEID(p) ((sizeof(ABEID)+strlen((char*)(p)))&~3)
  136. #define CbNewABEID(p) (sizeof(ABEID)>_CbNewABEID((p))?sizeof(ABEID):_CbNewABEID((p)))
  137. static inline ULONG ABEID_TYPE(const ABEID *p)
  138. {
  139. return p != nullptr ? p->ulType : -1;
  140. }
  141. template<typename T> static inline ULONG ABEID_ID(const T *p)
  142. {
  143. return p != nullptr ? reinterpret_cast<const ABEID *>(p)->ulId : 0;
  144. }
  145. struct SIEID {
  146. BYTE abFlags[4];
  147. GUID guid;
  148. ULONG ulVersion;
  149. ULONG ulType;
  150. ULONG ulId;
  151. CHAR szServerId[1];
  152. CHAR szPadding[3];
  153. SIEID(ULONG ulType, const GUID &guid, ULONG ulId)
  154. {
  155. memset(this, 0, sizeof(SIEID));
  156. this->ulType = ulType;
  157. this->guid = guid;
  158. this->ulId = ulId;
  159. }
  160. SIEID(const SIEID *oldEID)
  161. {
  162. memset(this, 0, sizeof(SIEID));
  163. this->ulType = oldEID->ulType;
  164. this->guid = oldEID->guid;
  165. this->ulId = oldEID->ulId;
  166. }
  167. SIEID() {
  168. memset(this, 0, sizeof(SIEID));
  169. }
  170. };
  171. typedef struct SIEID *LPSIEID;
  172. /* Bit definitions for abFlags[3] of ENTRYID */
  173. #define KOPANO_FAVORITE 0x01 // Entryid from the favorits folder
  174. // Indexes of the identity property array
  175. enum
  176. {
  177. XPID_NAME, // Array Indexes
  178. XPID_EID,
  179. XPID_SEARCH_KEY,
  180. XPID_STORE_EID,
  181. XPID_ADDRESS,
  182. XPID_ADDRTYPE,
  183. NUM_IDENTITY_PROPS // Array size
  184. };
  185. #define TRANSPORT_ADDRESS_TYPE_SMTP _T("SMTP")
  186. #define TRANSPORT_ADDRESS_TYPE_ZARAFA _T("ZARAFA")
  187. #define TRANSPORT_ADDRESS_TYPE_FAX _T("FAX")
  188. typedef EID * PEID;
  189. #define CbEID(p) (sizeof(EID)+strlen((char*)(p)->szServer))
  190. #define CbNewEID(p) (sizeof(EID)+strlen(((char*)p)))
  191. #define EID_TYPE_STORE 1
  192. #define EID_TYPE_OBJECT 2
  193. #ifndef STORE_HTML_OK
  194. #define STORE_HTML_OK 0x00010000
  195. #endif
  196. //The message store supports properties containing ANSI (8-bit) characters
  197. #ifndef STORE_ANSI_OK
  198. #define STORE_ANSI_OK 0x00020000
  199. #endif
  200. //This flag is reserved and should not be used
  201. #ifndef STORE_LOCALSTORE
  202. #define STORE_LOCALSTORE 0x00080000
  203. #endif
  204. #ifndef STORE_UNICODE_OK
  205. #define STORE_UNICODE_OK 0x00040000L
  206. #endif
  207. #ifndef STORE_PUSHER_OK
  208. #define STORE_PUSHER_OK ((ULONG) 0x00800000)
  209. #endif
  210. // This is what we support for private store
  211. #define EC_SUPPORTMASK_PRIVATE \
  212. STORE_ENTRYID_UNIQUE | \
  213. STORE_SEARCH_OK | \
  214. STORE_MODIFY_OK | \
  215. STORE_CREATE_OK | \
  216. STORE_ATTACH_OK | \
  217. STORE_OLE_OK | \
  218. STORE_NOTIFY_OK | \
  219. STORE_MV_PROPS_OK | \
  220. STORE_CATEGORIZE_OK | \
  221. STORE_RTF_OK | \
  222. STORE_RESTRICTION_OK | \
  223. STORE_SORT_OK | \
  224. STORE_HTML_OK | \
  225. STORE_UNICODE_OK | \
  226. STORE_SUBMIT_OK
  227. // This is what we support for archive store
  228. #define EC_SUPPORTMASK_ARCHIVE \
  229. STORE_ENTRYID_UNIQUE | \
  230. STORE_SEARCH_OK | \
  231. STORE_MODIFY_OK | \
  232. STORE_CREATE_OK | \
  233. STORE_ATTACH_OK | \
  234. STORE_OLE_OK | \
  235. STORE_NOTIFY_OK | \
  236. STORE_MV_PROPS_OK | \
  237. STORE_CATEGORIZE_OK | \
  238. STORE_RTF_OK | \
  239. STORE_RESTRICTION_OK | \
  240. STORE_SORT_OK | \
  241. STORE_HTML_OK | \
  242. STORE_UNICODE_OK
  243. // This is what we support for delegate store
  244. #define EC_SUPPORTMASK_DELEGATE \
  245. STORE_ENTRYID_UNIQUE | \
  246. STORE_SEARCH_OK | \
  247. STORE_MODIFY_OK | \
  248. STORE_CREATE_OK | \
  249. STORE_ATTACH_OK | \
  250. STORE_OLE_OK | \
  251. STORE_NOTIFY_OK | \
  252. STORE_MV_PROPS_OK | \
  253. STORE_CATEGORIZE_OK | \
  254. STORE_RTF_OK | \
  255. STORE_RESTRICTION_OK | \
  256. STORE_SORT_OK | \
  257. STORE_HTML_OK | \
  258. STORE_UNICODE_OK | \
  259. STORE_SUBMIT_OK
  260. // This is what we support for public store
  261. #define EC_SUPPORTMASK_PUBLIC \
  262. STORE_ENTRYID_UNIQUE | \
  263. STORE_SEARCH_OK | \
  264. STORE_MODIFY_OK | \
  265. STORE_CREATE_OK | \
  266. STORE_ATTACH_OK | \
  267. STORE_OLE_OK | \
  268. STORE_NOTIFY_OK | \
  269. STORE_MV_PROPS_OK | \
  270. STORE_CATEGORIZE_OK | \
  271. STORE_RTF_OK | \
  272. STORE_RESTRICTION_OK | \
  273. STORE_SORT_OK | \
  274. STORE_HTML_OK | \
  275. STORE_UNICODE_OK | \
  276. STORE_PUBLIC_FOLDERS
  277. // This is the DLL name given to WrapStoreEntryID so MAPI can
  278. // figure out which DLL to open for a given EntryID
  279. // Note that the '32' is added by MAPI
  280. #define WCLIENT_DLL_NAME "zarafa6client.dll"
  281. // Default freebusy publish months
  282. #define ECFREEBUSY_DEFAULT_PUBLISH_MONTHS 6
  283. #define TABLE_CAP_STRING 255
  284. #define TABLE_CAP_BINARY 511
  285. //
  286. // Capabilities bitmask, sent with ns__logon()
  287. //
  288. // test SOAP flag
  289. #ifdef WITH_GZIP
  290. #define KOPANO_CAP_COMPRESSION 0x0001
  291. #else
  292. // no compression in soap
  293. #define KOPANO_CAP_COMPRESSION 0x0000
  294. #endif
  295. // Client has PR_MAILBOX_OWNER_* properties
  296. #define KOPANO_CAP_MAILBOX_OWNER 0x0002
  297. // Server sends Mod. time and Create time in readProps() call
  298. //#define KOPANO_CAP_TIMES_IN_READPROPS 0x0004 //not needed since saveObject is introduced
  299. #define KOPANO_CAP_CRYPT 0x0008
  300. // 64 bit session IDs
  301. #define KOPANO_CAP_LARGE_SESSIONID 0x0010
  302. // Includes license server
  303. #define KOPANO_CAP_LICENSE_SERVER 0x0020
  304. // Client/Server understands ABEID (longer than 36 bytes)
  305. #define KOPANO_CAP_MULTI_SERVER 0x0040
  306. // Server supports enhanced ICS operations
  307. #define KOPANO_CAP_ENHANCED_ICS 0x0100
  308. // Support 'entryid' field in loadProp
  309. #define KOPANO_CAP_LOADPROP_ENTRYID 0x0080
  310. // Client supports unicode
  311. #define KOPANO_CAP_UNICODE 0x0200
  312. // Server side message locking
  313. #define KOPANO_CAP_MSGLOCK 0x0400
  314. // ExportMessageChangeAsStream supports ulPropTag parameter
  315. #define KOPANO_CAP_EXPORT_PROPTAG 0x0800
  316. // Support impersonation
  317. #define KOPANO_CAP_IMPERSONATION 0x1000
  318. // Client stores the max ab changeid obtained from the server
  319. #define KOPANO_CAP_MAX_ABCHANGEID 0x2000
  320. // Client can read and write binary anonymous ab properties
  321. #define KOPANO_CAP_EXTENDED_ANON 0x4000
  322. // Do *not* use this from a client. This is just what the latest server supports.
  323. #define KOPANO_LATEST_CAPABILITIES KOPANO_CAP_CRYPT | KOPANO_CAP_LICENSE_SERVER | KOPANO_CAP_LOADPROP_ENTRYID | KOPANO_CAP_EXPORT_PROPTAG | KOPANO_CAP_IMPERSONATION
  324. //
  325. // Logon flags, sent with ns__logon()
  326. //
  327. // Don't allow uid based authentication (Unix socket only)
  328. #define KOPANO_LOGON_NO_UID_AUTH 0x0001
  329. // MTOM IDs
  330. #define MTOM_ID_EXPORTMESSAGES "idExportMessages"
  331. #endif /* KC_KCORE_H */