ECCacheManager.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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 ECCACHEMANAGER
  18. #define ECCACHEMANAGER
  19. #include <kopano/zcdefs.h>
  20. #include <map>
  21. #include <memory>
  22. #include <mutex>
  23. #include "ECDatabaseFactory.h"
  24. #include "ECDatabaseUtils.h"
  25. #include "ECGenericObjectTable.h" // ECListInt
  26. #include <kopano/ECConfig.h>
  27. #include <kopano/ECLogger.h>
  28. #include "SOAPUtils.h"
  29. #include "cmdutil.hpp"
  30. #include <mapidefs.h>
  31. #include <ECCache.h>
  32. #include <kopano/ECKeyTable.h>
  33. struct soap;
  34. #include <unordered_map>
  35. template<typename Key, typename T>
  36. struct hash_map {
  37. typedef std::unordered_map<Key, T, std::hash<Key>, std::equal_to<Key>> Type;
  38. };
  39. namespace KC {
  40. class ECSessionManager;
  41. class ECsStores _kc_final : public ECsCacheEntry {
  42. public:
  43. unsigned int ulStore;
  44. GUID guidStore;
  45. unsigned int ulType;
  46. };
  47. class ECsUserObject _kc_final : public ECsCacheEntry {
  48. public:
  49. objectclass_t ulClass;
  50. std::string strExternId;
  51. unsigned int ulCompanyId;
  52. std::string strSignature;
  53. };
  54. /* same as objectid_t, join? */
  55. struct ECsUEIdKey {
  56. objectclass_t ulClass;
  57. std::string strExternId;
  58. };
  59. inline bool operator <(const ECsUEIdKey &a, const ECsUEIdKey &b)
  60. {
  61. if (a.ulClass < b.ulClass)
  62. return true;
  63. if ((a.ulClass == b.ulClass) && a.strExternId < b.strExternId)
  64. return true;
  65. return false;
  66. }
  67. /* Intern Id cache */
  68. class ECsUEIdObject _kc_final : public ECsCacheEntry {
  69. public:
  70. unsigned int ulCompanyId;
  71. unsigned int ulUserId;
  72. std::string strSignature;
  73. };
  74. class ECsUserObjectDetails _kc_final : public ECsCacheEntry {
  75. public:
  76. objectdetails_t sDetails;
  77. };
  78. class ECsServerDetails _kc_final : public ECsCacheEntry {
  79. public:
  80. serverdetails_t sDetails;
  81. };
  82. class ECsObjects _kc_final : public ECsCacheEntry {
  83. public:
  84. unsigned int ulParent;
  85. unsigned int ulOwner;
  86. unsigned int ulFlags;
  87. unsigned int ulType;
  88. };
  89. class ECsQuota _kc_final : public ECsCacheEntry {
  90. public:
  91. quotadetails_t quota;
  92. };
  93. class ECsIndexObject _kc_final : public ECsCacheEntry {
  94. public:
  95. inline bool operator==(const ECsIndexObject &other) const
  96. {
  97. if (ulObjId == other.ulObjId && ulTag == other.ulTag)
  98. return true;
  99. return false;
  100. }
  101. inline bool operator<(const ECsIndexObject &other) const
  102. {
  103. if(ulObjId < other.ulObjId)
  104. return true;
  105. else if(ulObjId == other.ulObjId && ulTag < other.ulTag)
  106. return true;
  107. return false;
  108. }
  109. unsigned int ulObjId;
  110. unsigned int ulTag;
  111. };
  112. class ECsIndexProp _kc_final : public ECsCacheEntry {
  113. public:
  114. ECsIndexProp(void) = default;
  115. ~ECsIndexProp() {
  116. delete[] lpData;
  117. }
  118. ECsIndexProp(const ECsIndexProp &src) {
  119. if(this == &src)
  120. return;
  121. Copy(&src, this);
  122. }
  123. ECsIndexProp(ECsIndexProp &&o) :
  124. ulTag(o.ulTag), lpData(o.lpData), cbData(o.cbData)
  125. {
  126. o.lpData = nullptr;
  127. o.cbData = 0;
  128. }
  129. ECsIndexProp(unsigned int tag, const unsigned char *d, unsigned int z)
  130. {
  131. SetValue(tag, d, z);
  132. }
  133. ECsIndexProp& operator=(const ECsIndexProp &src) {
  134. if (this == &src)
  135. return *this;
  136. Free();
  137. Copy(&src, this);
  138. return *this;
  139. }
  140. // @todo check this function, is this really ok?
  141. inline bool operator<(const ECsIndexProp &other) const
  142. {
  143. if(cbData < other.cbData)
  144. return true;
  145. if (cbData != other.cbData)
  146. return false;
  147. if (lpData == NULL && other.lpData)
  148. return true;
  149. else if (lpData != NULL && other.lpData == NULL)
  150. return false;
  151. else if (lpData == NULL && other.lpData == NULL)
  152. return false;
  153. int c = memcmp(lpData, other.lpData, cbData);
  154. if (c < 0)
  155. return true;
  156. else if (c == 0 && ulTag < other.ulTag)
  157. return true;
  158. return false;
  159. }
  160. inline bool operator==(const ECsIndexProp &other) const
  161. {
  162. if(cbData != other.cbData || ulTag != other.ulTag)
  163. return false;
  164. if (lpData == other.lpData)
  165. return true;
  166. if (lpData == NULL || other.lpData == NULL)
  167. return false;
  168. if(memcmp(lpData, other.lpData, cbData) == 0)
  169. return true;
  170. return false;
  171. }
  172. void SetValue(unsigned int ulTag, const unsigned char *lpData, unsigned int cbData)
  173. {
  174. if(lpData == NULL|| cbData == 0)
  175. return;
  176. Free();
  177. this->lpData = new unsigned char[cbData];
  178. this->cbData = cbData;
  179. this->ulTag = ulTag;
  180. memcpy(this->lpData, lpData, (size_t)cbData);
  181. }
  182. protected:
  183. void Free() {
  184. delete[] lpData;
  185. ulTag = 0;
  186. cbData = 0;
  187. lpData = NULL;
  188. }
  189. void Copy(const ECsIndexProp* src, ECsIndexProp* dst) {
  190. if(src->lpData != NULL && src->cbData>0) {
  191. dst->lpData = new unsigned char[src->cbData];
  192. memcpy(dst->lpData, src->lpData, (size_t)src->cbData);
  193. dst->cbData = src->cbData;
  194. } else {
  195. dst->lpData = NULL;
  196. dst->cbData = 0;
  197. }
  198. dst->ulTag = src->ulTag;
  199. }
  200. public:
  201. unsigned int ulTag = 0;
  202. unsigned char *lpData = nullptr;
  203. unsigned int cbData = 0;
  204. };
  205. class ECsCells _kc_final : public ECsCacheEntry {
  206. public:
  207. ECsCells(void) = default;
  208. ~ECsCells() {
  209. for (auto &p : mapPropVals)
  210. FreePropVal(&p.second, false);
  211. };
  212. ECsCells(const ECsCells &src) {
  213. struct propVal val;
  214. for (const auto &p : src.mapPropVals) {
  215. CopyPropVal(const_cast<struct propVal *>(&p.second), &val);
  216. mapPropVals[p.first] = val;
  217. }
  218. m_bComplete = src.m_bComplete;
  219. }
  220. ECsCells& operator=(const ECsCells &src) {
  221. struct propVal val;
  222. for (auto &p : mapPropVals)
  223. FreePropVal(&p.second, false);
  224. mapPropVals.clear();
  225. for (const auto &p : src.mapPropVals) {
  226. CopyPropVal(const_cast<struct propVal *>(&p.second), &val);
  227. mapPropVals[p.first] = val;
  228. }
  229. m_bComplete = src.m_bComplete;
  230. return *this;
  231. }
  232. // Add a property value for this object
  233. void AddPropVal(unsigned int ulPropTag, const struct propVal *lpPropVal) {
  234. struct propVal val;
  235. ulPropTag = NormalizeDBPropTag(ulPropTag); // Only cache PT_STRING8
  236. CopyPropVal(lpPropVal, &val, NULL, true);
  237. val.ulPropTag = NormalizeDBPropTag(val.ulPropTag);
  238. auto res = mapPropVals.insert(std::make_pair(ulPropTag, val));
  239. if (res.second == false) {
  240. FreePropVal(&res.first->second, false);
  241. res.first->second = val; // reassign
  242. }
  243. }
  244. // get a property value for this object
  245. bool GetPropVal(unsigned int ulPropTag, struct propVal *lpPropVal, struct soap *soap) {
  246. auto i = mapPropVals.find(NormalizeDBPropTag(ulPropTag));
  247. if (i == mapPropVals.cend())
  248. return false;
  249. CopyPropVal(&i->second, lpPropVal, soap);
  250. if(NormalizeDBPropTag(ulPropTag) == lpPropVal->ulPropTag)
  251. lpPropVal->ulPropTag = ulPropTag; // Switch back to requested type (not on PT_ERROR of course)
  252. return true;
  253. }
  254. // Updates a LONG type property
  255. void UpdatePropVal(unsigned int ulPropTag, int lDelta) {
  256. if(PROP_TYPE(ulPropTag) != PT_LONG)
  257. return;
  258. auto i = mapPropVals.find(ulPropTag);
  259. if (i == mapPropVals.cend() ||
  260. PROP_TYPE(i->second.ulPropTag) != PT_LONG)
  261. return;
  262. i->second.Value.ul += lDelta;
  263. }
  264. // Updates a LONG type property
  265. void UpdatePropVal(unsigned int ulPropTag, unsigned int ulMask, unsigned int ulValue) {
  266. if(PROP_TYPE(ulPropTag) != PT_LONG)
  267. return;
  268. auto i = mapPropVals.find(ulPropTag);
  269. if (i == mapPropVals.cend() ||
  270. PROP_TYPE(i->second.ulPropTag) != PT_LONG)
  271. return;
  272. i->second.Value.ul &= ~ulMask;
  273. i->second.Value.ul |= ulValue & ulMask;
  274. }
  275. void SetComplete(bool bComplete) {
  276. this->m_bComplete = bComplete;
  277. }
  278. bool GetComplete() {
  279. return this->m_bComplete;
  280. }
  281. // Gets the amount of memory used by this object
  282. size_t GetSize() const {
  283. size_t ulSize = 0;
  284. for (const auto &p : mapPropVals) {
  285. switch (p.second.__union) {
  286. case SOAP_UNION_propValData_lpszA:
  287. ulSize += p.second.Value.lpszA != NULL ?
  288. strlen(p.second.Value.lpszA) : 0;
  289. break;
  290. case SOAP_UNION_propValData_bin:
  291. ulSize += p.second.Value.bin != NULL ?
  292. p.second.Value.bin->__size +
  293. sizeof(p.second.Value.bin[0]) : 0;
  294. break;
  295. case SOAP_UNION_propValData_hilo:
  296. ulSize += sizeof(p.second.Value.hilo[0]);
  297. break;
  298. default:
  299. break;
  300. }
  301. ulSize += sizeof(std::map<unsigned int, struct propVal>::value_type);
  302. }
  303. ulSize += sizeof(*this);
  304. return ulSize;
  305. }
  306. // All properties for this object; propTag => propVal
  307. std::map<unsigned int, struct propVal> mapPropVals;
  308. bool m_bComplete = false;
  309. };
  310. class ECsACLs _kc_final : public ECsCacheEntry {
  311. public:
  312. ECsACLs(void) = default;
  313. ECsACLs(const ECsACLs &src) : ulACLs(src.ulACLs)
  314. {
  315. aACL.reset(new ACL[ulACLs]);
  316. memcpy(aACL.get(), src.aACL.get(), sizeof(ACL) * ulACLs);
  317. }
  318. ECsACLs& operator=(const ECsACLs &src) {
  319. if (this != &src) {
  320. ulACLs = src.ulACLs;
  321. aACL.reset(new ACL[ulACLs]);
  322. memcpy(aACL.get(), src.aACL.get(), sizeof(ACL) * ulACLs);
  323. }
  324. return *this;
  325. };
  326. unsigned int ulACLs = 0;
  327. struct ACL {
  328. unsigned int ulType;
  329. unsigned int ulMask;
  330. unsigned int ulUserId;
  331. };
  332. std::unique_ptr<ACL[]> aACL;
  333. };
  334. struct ECsSortKeyKey {
  335. sObjectTableKey sKey;
  336. unsigned int ulPropTag;
  337. };
  338. struct lessindexobjectkey {
  339. bool operator()(const ECsIndexObject& a, const ECsIndexObject& b) const
  340. {
  341. if(a.ulObjId < b.ulObjId)
  342. return true;
  343. else if(a.ulObjId == b.ulObjId && a.ulTag < b.ulTag)
  344. return true;
  345. return false;
  346. }
  347. };
  348. inline unsigned int IPRSHash(const ECsIndexProp& _Keyval1)
  349. {
  350. unsigned int b = 378551;
  351. unsigned int a = 63689;
  352. unsigned int hash = 0;
  353. for (std::size_t i = 0; i < _Keyval1.cbData; ++i) {
  354. hash = hash * a + _Keyval1.lpData[i];
  355. a *= b;
  356. }
  357. return hash;
  358. }
  359. } /* namespace KC */
  360. namespace std {
  361. // hash function for type ECsIndexProp
  362. template<>
  363. struct hash<ECsIndexProp> {
  364. public:
  365. size_t operator() (const ECsIndexProp &value) const { return IPRSHash(value); }
  366. };
  367. // hash function for type ECsIndexObject
  368. template<>
  369. struct hash<ECsIndexObject> {
  370. public:
  371. size_t operator() (const ECsIndexObject &value) const {
  372. hash<unsigned int> hasher;
  373. // @TODO check the hash function!
  374. return hasher(value.ulObjId * value.ulTag ) ;
  375. }
  376. };
  377. }
  378. namespace KC {
  379. typedef hash_map<unsigned int, ECsObjects>::Type ECMapObjects;
  380. typedef hash_map<unsigned int, ECsStores>::Type ECMapStores;
  381. typedef hash_map<unsigned int, ECsACLs>::Type ECMapACLs;
  382. typedef hash_map<unsigned int, ECsQuota>::Type ECMapQuota;
  383. typedef hash_map<unsigned int, ECsUserObject>::Type ECMapUserObject; // userid to user object
  384. typedef std::map<ECsUEIdKey, ECsUEIdObject> ECMapUEIdObject; // user type + externid to user object
  385. typedef hash_map<unsigned int, ECsUserObjectDetails>::Type ECMapUserObjectDetails; // userid to user object data
  386. typedef std::map<std::string, ECsServerDetails> ECMapServerDetails;
  387. typedef hash_map<unsigned int, ECsCells>::Type ECMapCells;
  388. // Index properties
  389. typedef std::map<ECsIndexObject, ECsIndexProp, lessindexobjectkey > ECMapObjectToProp;
  390. typedef hash_map<ECsIndexProp, ECsIndexObject>::Type ECMapPropToObject;
  391. #define CACHE_NO_PARENT 0xFFFFFFFF
  392. class ECCacheManager _kc_final {
  393. public:
  394. ECCacheManager(ECConfig *lpConfig, ECDatabaseFactory *lpDatabase);
  395. virtual ~ECCacheManager();
  396. ECRESULT PurgeCache(unsigned int ulFlags);
  397. // These are read-through (ie they access the DB if they can't find the data)
  398. ECRESULT GetParent(unsigned int ulObjId, unsigned int *ulParent);
  399. ECRESULT GetOwner(unsigned int ulObjId, unsigned int *ulOwner);
  400. ECRESULT GetObject(unsigned int ulObjId, unsigned int *ulParent, unsigned int *ulOwner, unsigned int *ulFlags, unsigned int *ulType = NULL);
  401. ECRESULT SetObject(unsigned int ulObjId, unsigned int ulParent, unsigned int ulOwner, unsigned int ulFlags, unsigned int ulType);
  402. // Query cache only
  403. ECRESULT QueryParent(unsigned int ulObjId, unsigned int *ulParent);
  404. ECRESULT GetObjects(const std::list<sObjectTableKey> &lstObjects, std::map<sObjectTableKey, ECsObjects> &mapObjects);
  405. ECRESULT GetObjectsFromProp(unsigned int ulTag, const std::vector<unsigned int> &cbdata, const std::vector<unsigned char *> &lpdata, std::map<ECsIndexProp, unsigned int> &mapObjects);
  406. ECRESULT GetStore(unsigned int ulObjId, unsigned int *ulStore, GUID *lpGuid, unsigned int maxdepth = 100);
  407. ECRESULT GetStoreAndType(unsigned int ulObjId, unsigned int *ulStore, GUID *lpGuid, unsigned int *ulType, unsigned int maxdepth = 100);
  408. ECRESULT GetObjectFlags(unsigned int ulObjId, unsigned int *ulFlags);
  409. ECRESULT SetStore(unsigned int ulObjId, unsigned int ulStore, const GUID *, unsigned int ulType);
  410. ECRESULT GetServerDetails(const std::string &strServerId, serverdetails_t *lpsDetails);
  411. ECRESULT SetServerDetails(const std::string &strServerId, const serverdetails_t &sDetails);
  412. // Cache user table
  413. /* hmm, externid is in the signature as well, optimize? */
  414. ECRESULT GetUserObject(unsigned int ulUserId, objectid_t *lpExternId, unsigned int *lpulCompanyId, std::string *lpstrSignature);
  415. ECRESULT GetUserObject(const objectid_t &sExternId, unsigned int *lpulUserId, unsigned int *lpulCompanyId, std::string *lpstrSignature);
  416. ECRESULT GetUserObjects(const std::list<objectid_t> &lstExternObjIds, std::map<objectid_t, unsigned int> *lpmapLocalObjIds);
  417. // Cache user information
  418. ECRESULT GetUserDetails(unsigned int ulUserId, objectdetails_t *details);
  419. ECRESULT SetUserDetails(unsigned int, const objectdetails_t *);
  420. ECRESULT GetACLs(unsigned int ulObjId, struct rightsArray **lppRights);
  421. ECRESULT SetACLs(unsigned int ulObjId, const struct rightsArray *);
  422. ECRESULT GetQuota(unsigned int ulUserId, bool bIsDefaultQuota, quotadetails_t *quota);
  423. ECRESULT SetQuota(unsigned int ulUserId, bool bIsDefaultQuota, const quotadetails_t &);
  424. ECRESULT Update(unsigned int ulType, unsigned int ulObjId);
  425. ECRESULT UpdateUser(unsigned int ulUserId);
  426. ECRESULT GetEntryIdFromObject(unsigned int ulObjId, struct soap *soap, unsigned int ulFlags, entryId* lpEntrId);
  427. ECRESULT GetEntryIdFromObject(unsigned int ulObjId, struct soap *soap, unsigned int ulFlags, entryId** lppEntryId);
  428. ECRESULT GetObjectFromEntryId(const entryId *id, unsigned int *obj);
  429. ECRESULT SetObjectEntryId(const entryId *, unsigned int ulObjId);
  430. ECRESULT GetEntryListToObjectList(struct entryList *lpEntryList, ECListInt* lplObjectList);
  431. ECRESULT GetEntryListFromObjectList(ECListInt* lplObjectList, struct soap *soap, struct entryList **lppEntryList);
  432. // Table data functions (pure cache functions, they will never access the DB themselves. Data must be provided through Set functions)
  433. ECRESULT GetCell(const sObjectTableKey *, unsigned int tag, struct propVal *, struct soap *, bool computed);
  434. ECRESULT SetCell(const sObjectTableKey *, unsigned int tag, const struct propVal *);
  435. ECRESULT UpdateCell(unsigned int ulObjId, unsigned int ulPropTag, int lDelta);
  436. ECRESULT UpdateCell(unsigned int ulObjId, unsigned int ulPropTag, unsigned int ulMask, unsigned int ulValue);
  437. ECRESULT SetComplete(unsigned int ulObjId);
  438. // Cache Index properties
  439. // Read-through
  440. ECRESULT GetPropFromObject(unsigned int ulTag, unsigned int ulObjId, struct soap *soap, unsigned int* lpcbData, unsigned char** lppData);
  441. ECRESULT GetObjectFromProp(unsigned int ulTag, unsigned int cbData, unsigned char* lpData, unsigned int* lpulObjId);
  442. ECRESULT RemoveIndexData(unsigned int ulObjId);
  443. ECRESULT RemoveIndexData(unsigned int ulPropTag, unsigned int cbData, unsigned char *lpData);
  444. ECRESULT RemoveIndexData(unsigned int ulPropTag, unsigned int ulObjId);
  445. // Read cache only
  446. ECRESULT QueryObjectFromProp(unsigned int ulTag, unsigned int cbData, unsigned char* lpData, unsigned int* lpulObjId);
  447. ECRESULT SetObjectProp(unsigned int ulTag, unsigned int cbData, unsigned char* lpData, unsigned int ulObjId);
  448. void ForEachCacheItem(void(callback)(const std::string &, const std::string &, const std::string &, void*), void *obj);
  449. ECRESULT DumpStats();
  450. // Cache list of properties indexed by kopano-search
  451. ECRESULT GetExcludedIndexProperties(std::set<unsigned int>& set);
  452. ECRESULT SetExcludedIndexProperties(const std::set<unsigned int> &);
  453. // Test
  454. void DisableCellCache();
  455. void EnableCellCache();
  456. private:
  457. // cache functions
  458. ECRESULT _GetACLs(unsigned int ulObjId, struct rightsArray **lppRights);
  459. ECRESULT _DelACLs(unsigned int ulObjId);
  460. ECRESULT _GetObject(unsigned int ulObjId, unsigned int *ulParent, unsigned int *ulOwner, unsigned int *ulFlags, unsigned int *ulType);
  461. ECRESULT _DelObject(unsigned int ulObjId);
  462. ECRESULT _GetStore(unsigned int ulObjId, unsigned int *ulStore, GUID *lpGuid, unsigned int *ulType);
  463. ECRESULT _DelStore(unsigned int ulObjId);
  464. ECRESULT _AddUserObject(unsigned int ulUserId, const objectclass_t &ulClass, unsigned int ulCompanyId, const std::string &strExternId, const std::string &strSignature);
  465. ECRESULT _GetUserObject(unsigned int ulUserId, objectclass_t* lpulClass, unsigned int *lpulCompanyId,
  466. std::string* lpstrExternId, std::string* lpstrSignature);
  467. ECRESULT _DelUserObject(unsigned int ulUserId);
  468. ECRESULT _AddUEIdObject(const std::string &strExternId, const objectclass_t &ulClass, unsigned int ulCompanyId, unsigned int ulUserId, const std::string &strSignature);
  469. ECRESULT _GetUEIdObject(const std::string &strExternId, objectclass_t ulClass, unsigned int *lpulCompanyId, unsigned int* lpulUserId, std::string* lpstrSignature);
  470. ECRESULT _DelUEIdObject(const std::string &strExternId, objectclass_t ulClass);
  471. ECRESULT _AddUserObjectDetails(unsigned int, const objectdetails_t *);
  472. ECRESULT _GetUserObjectDetails(unsigned int ulUserId, objectdetails_t *details);
  473. ECRESULT _DelUserObjectDetails(unsigned int ulUserId);
  474. ECRESULT _DelCell(unsigned int ulObjId);
  475. ECRESULT _GetQuota(unsigned int ulUserId, bool bIsDefaultQuota, quotadetails_t *quota);
  476. ECRESULT _DelQuota(unsigned int ulUserId, bool bIsDefaultQuota);
  477. // Cache Index properties
  478. ECRESULT _AddIndexData(const ECsIndexObject *lpObject, const ECsIndexProp *lpProp);
  479. ECDatabaseFactory* m_lpDatabaseFactory;
  480. std::recursive_mutex m_hCacheMutex; /* Store, Object, User, ACL, server cache */
  481. std::recursive_mutex m_hCacheCellsMutex; /* Cell cache */
  482. std::recursive_mutex m_hCacheIndPropMutex; /* Indexed properties cache */
  483. // Quota cache, to reduce the impact of the user plugin
  484. // m_mapQuota contains user and company cache, except when it's the company user default quota
  485. // m_mapQuotaUserDefault contains company user default quota
  486. // this can't be in the same map, since the id is the same for "company" and "company user default"
  487. ECCache<ECMapQuota> m_QuotaCache;
  488. ECCache<ECMapQuota> m_QuotaUserDefaultCache;
  489. // Object cache, (hierarchy table)
  490. ECCache<ECMapObjects> m_ObjectsCache;
  491. // Store cache
  492. ECCache<ECMapStores> m_StoresCache;
  493. // User cache
  494. ECCache<ECMapUserObject> m_UserObjectCache;
  495. ECCache<ECMapUEIdObject> m_UEIdObjectCache;
  496. ECCache<ECMapUserObjectDetails> m_UserObjectDetailsCache;
  497. // ACL cache
  498. ECCache<ECMapACLs> m_AclCache;
  499. // Cell cache, include the column data of a loaded table
  500. ECCache<ECMapCells> m_CellCache;
  501. // Server cache
  502. ECCache<ECMapServerDetails> m_ServerDetailsCache;
  503. //Index properties
  504. ECCache<ECMapPropToObject> m_PropToObjectCache;
  505. ECCache<ECMapObjectToProp> m_ObjectToPropCache;
  506. // Properties from kopano-search
  507. std::set<unsigned int> m_setExcludedIndexProperties;
  508. std::mutex m_hExcludedIndexPropertiesMutex;
  509. // Testing
  510. bool m_bCellCacheDisabled = false;
  511. };
  512. } /* namespace */
  513. #endif