postsaveiidupdater.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 postsaveiidupdater_INCLUDED
  18. #define postsaveiidupdater_INCLUDED
  19. #include <memory>
  20. #include <kopano/zcdefs.h>
  21. #include "postsaveaction.h"
  22. #include <kopano/mapi_ptr.h>
  23. #include "instanceidmapper_fwd.h"
  24. #include <kopano/archiver-common.h>
  25. #include <list>
  26. namespace KC { namespace operations {
  27. class TaskBase {
  28. public:
  29. TaskBase(const AttachPtr &ptrSourceAttach, const MessagePtr &ptrDestMsg, ULONG ulDestAttachIdx);
  30. HRESULT Execute(ULONG ulPropTag, const InstanceIdMapperPtr &ptrMapper);
  31. private:
  32. HRESULT GetUniqueIDs(IAttach *lpAttach, LPSPropValue *lppServerUID, ULONG *lpcbInstanceID, LPENTRYID *lppInstanceID);
  33. virtual HRESULT DoExecute(ULONG ulPropTag, const InstanceIdMapperPtr &ptrMapper, const SBinary &sourceServerUID, ULONG cbSourceInstanceID, LPENTRYID lpSourceInstanceID, const SBinary &destServerUID, ULONG cbDestInstanceID, LPENTRYID lpDestInstanceID) = 0;
  34. AttachPtr m_ptrSourceAttach;
  35. MessagePtr m_ptrDestMsg;
  36. ULONG m_ulDestAttachIdx;
  37. };
  38. typedef std::shared_ptr<TaskBase> TaskPtr;
  39. typedef std::list<TaskPtr> TaskList;
  40. class TaskMapInstanceId _kc_final : public TaskBase {
  41. public:
  42. TaskMapInstanceId(const AttachPtr &ptrSourceAttach, const MessagePtr &ptrDestMsg, ULONG ulDestAttachNum);
  43. HRESULT DoExecute(ULONG ulPropTag, const InstanceIdMapperPtr &ptrMapper, const SBinary &sourceServerUID, ULONG cbSourceInstanceID, LPENTRYID lpSourceInstanceID, const SBinary &destServerUID, ULONG cbDestInstanceID, LPENTRYID lpDestInstanceID) _kc_override;
  44. };
  45. class TaskVerifyAndUpdateInstanceId _kc_final : public TaskBase {
  46. public:
  47. TaskVerifyAndUpdateInstanceId(const AttachPtr &ptrSourceAttach, const MessagePtr &ptrDestMsg, ULONG ulDestAttachNum, ULONG cbDestInstanceID, LPENTRYID lpDestInstanceID);
  48. HRESULT DoExecute(ULONG ulPropTag, const InstanceIdMapperPtr &ptrMapper, const SBinary &sourceServerUID, ULONG cbSourceInstanceID, LPENTRYID lpSourceInstanceID, const SBinary &destServerUID, ULONG cbDestInstanceID, LPENTRYID lpDestInstanceID) _kc_override;
  49. private:
  50. entryid_t m_destInstanceID;
  51. };
  52. class PostSaveInstanceIdUpdater _kc_final : public IPostSaveAction {
  53. public:
  54. PostSaveInstanceIdUpdater(ULONG ulPropTag, const InstanceIdMapperPtr &ptrMapper, const TaskList &lstDeferred);
  55. HRESULT Execute(void) _kc_override;
  56. private:
  57. ULONG m_ulPropTag;
  58. InstanceIdMapperPtr m_ptrMapper;
  59. TaskList m_lstDeferred;
  60. };
  61. }} /* namespace */
  62. #endif // ndef postsaveiidupdater_INCLUDED