ECStoreObjectTable.h 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 ECSTORE_OBJECTTABLE_H
  18. #define ECSTORE_OBJECTTABLE_H
  19. #include "soapH.h"
  20. #include "ECDatabase.h"
  21. #include "ECGenericObjectTable.h"
  22. struct soap;
  23. namespace KC {
  24. /*
  25. * This object is an actual table, with a cursor in-memory. We also keep the complete
  26. * keyset of the table in memory, so seeks and queries can be really fast. Also, we
  27. * sort the table once on loading, and simply use that keyset when the rows are actually
  28. * required. The actual data is always loaded directly from the database.
  29. */
  30. class ECSession;
  31. // Objectdata for a store
  32. struct ECODStore {
  33. unsigned int ulStoreId; // The Store ID this table is watching (0 == multi-store)
  34. unsigned int ulFolderId; // The Folder ID this table is watching (0 == multi-folder)
  35. unsigned int ulObjType;
  36. unsigned int ulFlags;
  37. unsigned int ulTableFlags;
  38. GUID* lpGuid; // The GUID of the store
  39. };
  40. // For ulTableFlags
  41. #define TABLE_FLAG_OVERRIDE_HOME_MDB 0x00000001
  42. class ECStoreObjectTable : public ECGenericObjectTable {
  43. protected:
  44. ECStoreObjectTable(ECSession *lpSession, unsigned int ulStoreId, GUID *lpGuid, unsigned int ulFolderId, unsigned int ulObjType, unsigned int ulFlags, unsigned int ulTableFlags, const ECLocale &locale);
  45. virtual ~ECStoreObjectTable();
  46. public:
  47. static ECRESULT Create(ECSession *lpSession, unsigned int ulStoreId, GUID *lpGuid, unsigned int ulFolderId, unsigned int ulObjType, unsigned int ulFlags, unsigned int ulTableFlags, const ECLocale &locale, ECStoreObjectTable **lppTable);
  48. virtual ECRESULT Load();
  49. //Overrides
  50. virtual ECRESULT GetColumnsAll(ECListInt* lplstProps);
  51. // Static database row functions, can be used externally aswell .. Obviously these are *not* threadsafe, make sure that
  52. // you either lock the passed arguments or all arguments are from the local stack.
  53. static ECRESULT CopyEmptyCellToSOAPPropVal(struct soap *soap, unsigned int ulPropTag, struct propVal *lpPropVal);
  54. static ECRESULT QueryRowData(ECGenericObjectTable *lpThis, struct soap *soap, ECSession *lpSession, ECObjectTableList* lpRowList, struct propTagArray *lpsPropTagArray, void* lpObjectData, struct rowSet **lppRowSet, bool bCacheTableData, bool bTableLimit);
  55. static ECRESULT QueryRowData(ECGenericObjectTable *lpThis, struct soap *soap, ECSession *lpSession, ECObjectTableList* lpRowList, struct propTagArray *lpsPropTagArray, void* lpObjectData, struct rowSet **lppRowSet, bool bCacheTableData, bool bTableLimit, bool bSubObjects);
  56. protected:
  57. virtual ECRESULT AddRowKey(ECObjectTableList* lpRows, unsigned int *lpulLoaded, unsigned int ulFlags, bool bInitialLoad, bool bOverride, struct restrictTable *lpOverride);
  58. static ECRESULT QueryRowDataByColumn(ECGenericObjectTable *lpThis, struct soap *soap, ECSession *lpSesion, const std::multimap<unsigned int, unsigned int> &mapColumns, unsigned int ulFolderId, const std::map<sObjectTableKey, unsigned int> &mapObjIds, struct rowSet *lpRowSet);
  59. static ECRESULT QueryRowDataByRow(ECGenericObjectTable *lpThis, struct soap *soap, ECSession *lpSession, const sObjectTableKey &sKey, unsigned int ulRowNum, std::multimap<unsigned int, unsigned int> &mapColumns, bool bTableLimit, struct rowSet *lpsRowSet);
  60. private:
  61. virtual ECRESULT GetMVRowCount(unsigned int ulObjId, unsigned int *lpulCount);
  62. virtual ECRESULT ReloadTableMVData(ECObjectTableList* lplistRows, ECListInt* lplistMVPropTag);
  63. virtual ECRESULT CheckPermissions(unsigned int ulObjId);
  64. unsigned int ulPermission = 0;
  65. bool fPermissionRead = false;
  66. };
  67. ECRESULT GetDeferredTableUpdates(ECDatabase *lpDatabase, unsigned int ulFolderId, std::list<unsigned int> *lpDeferred);
  68. ECRESULT GetDeferredTableUpdates(ECDatabase *lpDatabase, ECObjectTableList* lpRowList, std::list<unsigned int> *lpDeferred);
  69. } /* namespace */
  70. #endif // OBJECTTABLE_H