MAPIPropHelper.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 MAPIPROPHELPER_INCLUDED
  18. #define MAPIPROPHELPER_INCLUDED
  19. #include <memory>
  20. #include <kopano/zcdefs.h>
  21. #include <mapix.h>
  22. #include <kopano/mapi_ptr.h>
  23. #include <kopano/CommonUtil.h>
  24. #include <kopano/archiver-common.h>
  25. #include "ArchiverSessionPtr.h" // For ArchiverSessionPtr
  26. namespace KC { namespace helpers {
  27. class MAPIPropHelper;
  28. typedef std::unique_ptr<MAPIPropHelper> MAPIPropHelperPtr;
  29. class MessageState;
  30. /**
  31. * The MAPIPropHelper class provides some common utility functions that relate to IMAPIProp
  32. * objects in the archiver context.
  33. */
  34. class _kc_export MAPIPropHelper {
  35. public:
  36. static HRESULT Create(MAPIPropPtr ptrMapiProp, MAPIPropHelperPtr *lpptrMAPIPropHelper);
  37. _kc_hidden virtual ~MAPIPropHelper(void) _kc_impdtor;
  38. HRESULT GetMessageState(ArchiverSessionPtr ptrSession, MessageState *lpState);
  39. HRESULT GetArchiveList(ObjectEntryList *lplstArchives, bool bIgnoreSourceKey = false);
  40. HRESULT SetArchiveList(const ObjectEntryList &lstArchives, bool bExplicitCommit = false);
  41. HRESULT SetReference(const SObjectEntry &sEntry, bool bExplicitCommit = false);
  42. _kc_hidden HRESULT GetReference(SObjectEntry *entry);
  43. HRESULT ClearReference(bool bExplicitCommit = false);
  44. HRESULT ReferencePrevious(const SObjectEntry &sEntry);
  45. HRESULT OpenPrevious(ArchiverSessionPtr ptrSession, LPMESSAGE *lppMessage);
  46. _kc_hidden HRESULT RemoveStub(void);
  47. HRESULT SetClean();
  48. HRESULT DetachFromArchives();
  49. virtual HRESULT GetParentFolder(ArchiverSessionPtr ptrSession, LPMAPIFOLDER *lppFolder);
  50. _kc_hidden static HRESULT GetArchiveList(MAPIPropPtr, LPSPropValue props, ULONG nprop, ObjectEntryList *archives);
  51. protected:
  52. _kc_hidden MAPIPropHelper(MAPIPropPtr);
  53. _kc_hidden HRESULT Init(void);
  54. private:
  55. MAPIPropPtr m_ptrMapiProp;
  56. PROPMAP_DECL()
  57. PROPMAP_DEF_NAMED_ID(ARCHIVE_STORE_ENTRYIDS)
  58. PROPMAP_DEF_NAMED_ID(ARCHIVE_ITEM_ENTRYIDS)
  59. PROPMAP_DEF_NAMED_ID(ORIGINAL_SOURCEKEY)
  60. PROPMAP_DEF_NAMED_ID(STUBBED)
  61. PROPMAP_DEF_NAMED_ID(DIRTY)
  62. PROPMAP_DEF_NAMED_ID(REF_STORE_ENTRYID)
  63. PROPMAP_DEF_NAMED_ID(REF_ITEM_ENTRYID)
  64. PROPMAP_DEF_NAMED_ID(REF_PREV_ENTRYID)
  65. };
  66. class MessageState _kc_final {
  67. public:
  68. bool isStubbed() const { return m_ulState & msStubbed; }
  69. bool isDirty() const { return m_ulState & msDirty; }
  70. bool isCopy() const { return m_ulState & msCopy; }
  71. bool isMove() const { return m_ulState & msMove; }
  72. private:
  73. enum msFlags {
  74. msStubbed = 0x01, //< The message is stubbed, mutual exlusive with msDirty
  75. msDirty = 0x02, //< The message is dirty, mutual exclusive with msStubbed
  76. msCopy = 0x04, //< The message is copied, mutual exclusive with msMove
  77. msMove = 0x08 //< The message is moved, mutual exclusive with msCopy
  78. };
  79. ULONG m_ulState = 0;
  80. friend class MAPIPropHelper;
  81. };
  82. }} /* namespace */
  83. #endif // !defined MAPIPROPHELPER_INCLUDED