WSMAPIPropStorage.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 WSMAPIPROPSTORAGE_H
  18. #define WSMAPIPROPSTORAGE_H
  19. #include <kopano/zcdefs.h>
  20. #include <mutex>
  21. #include <kopano/ECUnknown.h>
  22. #include "IECPropStorage.h"
  23. #include <kopano/kcodes.h>
  24. #include "soapKCmdProxy.h"
  25. #include "WSTransport.h"
  26. #include <mapi.h>
  27. #include <mapispi.h>
  28. namespace KC {
  29. class convert_context;
  30. }
  31. class WSMAPIPropStorage _kc_final : public ECUnknown {
  32. protected:
  33. WSMAPIPropStorage(ULONG cbParentEntryId, LPENTRYID lpParentEntryId, ULONG cbEntryId, LPENTRYID, ULONG ulFlags, KCmd *, std::recursive_mutex &, ECSESSIONID, unsigned int ulServerCapabilities, WSTransport *);
  34. virtual ~WSMAPIPropStorage();
  35. public:
  36. static HRESULT Create(ULONG cbParentEntryId, LPENTRYID lpParentEntryId, ULONG cbEntryId, LPENTRYID, ULONG ulFlags, KCmd * , std::recursive_mutex &, ECSESSIONID, unsigned int ulServerCapabilities, WSTransport *, WSMAPIPropStorage **);
  37. virtual HRESULT QueryInterface(REFIID refiid, void **lppInterface) _kc_override;
  38. // For ICS
  39. virtual HRESULT HrSetSyncId(ULONG ulSyncId);
  40. // Register advise on load object
  41. virtual HRESULT RegisterAdvise(ULONG ulEventMask, ULONG ulConnection);
  42. virtual HRESULT GetEntryIDByRef(ULONG *lpcbEntryID, LPENTRYID *lppEntryID);
  43. private:
  44. // Get a list of the properties
  45. virtual HRESULT HrReadProps(LPSPropTagArray *lppPropTags,ULONG *cValues, LPSPropValue *ppValues);
  46. // Get a single (large) property
  47. virtual HRESULT HrLoadProp(ULONG ulObjId, ULONG ulPropTag, LPSPropValue *lppsPropValue);
  48. // Write all properties to disk (overwrites a property if it already exists)
  49. virtual HRESULT HrWriteProps(ULONG cValues, LPSPropValue pValues, ULONG ulFlags = 0);
  50. // Delete properties from file
  51. virtual HRESULT HrDeleteProps(const SPropTagArray *lpsPropTagArray);
  52. // Save complete object to server
  53. virtual HRESULT HrSaveObject(ULONG ulFlags, MAPIOBJECT *lpsMapiObject);
  54. // Load complete object from server
  55. virtual HRESULT HrLoadObject(MAPIOBJECT **lppsMapiObject);
  56. virtual IECPropStorage* GetServerStorage();
  57. /* very private */
  58. virtual ECRESULT EcFillPropTags(struct saveObject *lpsSaveObj, MAPIOBJECT *lpsMapiObj);
  59. virtual ECRESULT EcFillPropValues(struct saveObject *lpsSaveObj, MAPIOBJECT *lpsMapiObj);
  60. virtual HRESULT HrMapiObjectToSoapObject(MAPIOBJECT *lpsMapiObject, struct saveObject *lpSaveObj, convert_context *lpConverter);
  61. virtual HRESULT HrUpdateSoapObject(MAPIOBJECT *lpsMapiObject, struct saveObject *lpsSaveObj, convert_context *lpConverter);
  62. virtual void DeleteSoapObject(struct saveObject *lpSaveObj);
  63. virtual HRESULT HrUpdateMapiObject(MAPIOBJECT *lpClientObj, struct saveObject *lpsServerObj);
  64. virtual ECRESULT ECSoapObjectToMapiObject(struct saveObject *lpsSaveObj, MAPIOBJECT *lpsMapiObject);
  65. virtual HRESULT LockSoap();
  66. virtual HRESULT UnLockSoap();
  67. static HRESULT Reload(void *lpParam, ECSESSIONID sessionId);
  68. /* ECParentStorage may access my functions (used to read PR_ATTACH_DATA_BIN chunks through HrLoadProp()) */
  69. friend class ECParentStorage;
  70. public:
  71. class xECPropStorage _kc_final : public IECPropStorage {
  72. #include <kopano/xclsfrag/IECUnknown.hpp>
  73. #include <kopano/xclsfrag/IECPropStorage.hpp>
  74. } m_xECPropStorage;
  75. private:
  76. entryId m_sEntryId;
  77. entryId m_sParentEntryId;
  78. KCmd* lpCmd;
  79. std::recursive_mutex &lpDataLock;
  80. ECSESSIONID ecSessionId;
  81. unsigned int ulServerCapabilities;
  82. ULONG m_ulSyncId = 0, m_ulConnection = 0, m_ulEventMask = 0;
  83. ULONG m_ulFlags;
  84. ULONG m_ulSessionReloadCallback;
  85. WSTransport *m_lpTransport;
  86. bool m_bSubscribed = false;
  87. };
  88. #endif