ECExchangeExportChanges.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 ECEXCHANGEEXPORTCHANGES_H
  18. #define ECEXCHANGEEXPORTCHANGES_H
  19. #include <kopano/zcdefs.h>
  20. #include <mapidefs.h>
  21. #include <vector>
  22. #include <set>
  23. #include <string>
  24. #include "ics_client.hpp"
  25. #include "ECMAPIProp.h"
  26. #include <kopano/ECLogger.h>
  27. #include <kopano/ECUnknown.h>
  28. #include <IECExportChanges.h>
  29. #include <IECImportContentsChanges.h>
  30. #include "WSMessageStreamExporter.h"
  31. class ECExchangeExportChanges _kc_final : public ECUnknown {
  32. protected:
  33. ECExchangeExportChanges(ECMsgStore *lpStore, const std::string& strSK, const wchar_t *szDisplay, unsigned int ulSyncType);
  34. virtual ~ECExchangeExportChanges();
  35. public:
  36. static HRESULT Create(ECMsgStore *lpStore, REFIID iid, const std::string& strSK, const wchar_t *szDisplay, unsigned int ulSyncType, LPEXCHANGEEXPORTCHANGES* lppExchangeExportChanges);
  37. virtual HRESULT QueryInterface(REFIID refiid, void **lppInterface) _kc_override;
  38. virtual HRESULT GetLastError(HRESULT hResult, ULONG ulFlags, LPMAPIERROR *lppMAPIError);
  39. virtual HRESULT Config(LPSTREAM lpStream, ULONG ulFlags, LPUNKNOWN lpCollector, LPSRestriction lpRestriction, LPSPropTagArray lpIncludeProps, LPSPropTagArray lpExcludeProps, ULONG ulBufferSize);
  40. virtual HRESULT ConfigSelective(ULONG ulPropTag, LPENTRYLIST lpEntries, LPENTRYLIST lpParents, ULONG ulFlags, LPUNKNOWN lpCollector, LPSPropTagArray lpIncludeProps, LPSPropTagArray lpExcludeProps, ULONG ulBufferSize);
  41. virtual HRESULT Synchronize(ULONG *pulSteps, ULONG *pulProgress);
  42. virtual HRESULT UpdateState(LPSTREAM lpStream);
  43. virtual HRESULT GetChangeCount(ULONG *lpcChanges);
  44. virtual HRESULT SetMessageInterface(REFIID refiid);
  45. virtual HRESULT SetLogger(ECLogger *lpLogger);
  46. private:
  47. void LogMessageProps(int loglevel, ULONG cValues, LPSPropValue lpPropArray);
  48. class xECExportChanges _kc_final : public IECExportChanges {
  49. #include <kopano/xclsfrag/IUnknown.hpp>
  50. // <kopano/xclsfrag/IExchangeExportChanges.hpp>
  51. virtual HRESULT __stdcall GetLastError(HRESULT, ULONG flags, LPMAPIERROR *err) _kc_override;
  52. virtual HRESULT __stdcall Config(LPSTREAM, ULONG flags, LPUNKNOWN collector, LPSRestriction, LPSPropTagArray inclprop, LPSPropTagArray exclprop, ULONG bufsize) _kc_override;
  53. virtual HRESULT __stdcall Synchronize(ULONG *steps, ULONG *progress) _kc_override;
  54. virtual HRESULT __stdcall UpdateState(LPSTREAM) _kc_override;
  55. virtual HRESULT __stdcall ConfigSelective(ULONG proptag, LPENTRYLIST entries, LPENTRYLIST parents, ULONG flags, LPUNKNOWN collector, LPSPropTagArray inclprop, LPSPropTagArray exclprop, ULONG bufsize) _kc_override;
  56. virtual HRESULT __stdcall GetChangeCount(ULONG *changes) _kc_override;
  57. virtual HRESULT __stdcall SetMessageInterface(REFIID refiid) _kc_override;
  58. virtual HRESULT __stdcall SetLogger(ECLogger *) _kc_override;
  59. } m_xECExportChanges;
  60. HRESULT ExportMessageChanges();
  61. HRESULT ExportMessageChangesSlow();
  62. HRESULT ExportMessageChangesFast();
  63. HRESULT ExportMessageFlags();
  64. HRESULT ExportMessageDeletes();
  65. HRESULT ExportFolderChanges();
  66. HRESULT ExportFolderDeletes();
  67. HRESULT UpdateStream(LPSTREAM lpStream);
  68. HRESULT ChangesToEntrylist(std::list<ICSCHANGE> * lpLstChanges, LPENTRYLIST * lppEntryList);
  69. unsigned long m_ulSyncType;
  70. bool m_bConfiged = false;
  71. ECMsgStore* m_lpStore;
  72. std::string m_sourcekey;
  73. std::wstring m_strDisplay;
  74. IStream *m_lpStream = nullptr;
  75. ULONG m_ulFlags = 0;
  76. ULONG m_ulSyncId = 0, m_ulChangeId = 0;
  77. ULONG m_ulStep = 0, m_ulBatchSize;
  78. ULONG m_ulBufferSize = 0;
  79. ULONG m_ulEntryPropTag = PR_SOURCE_KEY; // This is normally the tag that is sent to exportMessageChangeAsStream()
  80. IID m_iidMessage;
  81. IExchangeImportContentsChanges *m_lpImportContents = nullptr;
  82. IECImportContentsChanges *m_lpImportStreamedContents = nullptr;
  83. IExchangeImportHierarchyChanges *m_lpImportHierarchy = nullptr;
  84. WSMessageStreamExporterPtr m_ptrStreamExporter;
  85. std::vector<ICSCHANGE> m_lstChange;
  86. typedef std::list<ICSCHANGE> ChangeList;
  87. typedef ChangeList::iterator ChangeListIter;
  88. ChangeList m_lstFlag;
  89. ChangeList m_lstSoftDelete;
  90. ChangeList m_lstHardDelete;
  91. typedef std::set<std::pair<unsigned int, std::string> > PROCESSEDCHANGESSET;
  92. PROCESSEDCHANGESSET m_setProcessedChanges;
  93. ICSCHANGE *m_lpChanges = nullptr;
  94. ULONG m_ulChanges = 0, m_ulMaxChangeId = 0;
  95. SRestriction *m_lpRestrict = nullptr;
  96. ECLogger *m_lpLogger;
  97. clock_t m_clkStart = 0;
  98. struct tms m_tmsStart;
  99. HRESULT AddProcessedChanges(ChangeList &lstChanges);
  100. ALLOC_WRAP_FRIEND;
  101. };
  102. #endif // ECEXCHANGEEXPORTCHANGES_H