ArchiveHelper.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 ARCHIVEHELPER_H_INCLUDED
  18. #define ARCHIVEHELPER_H_INCLUDED
  19. #include <memory>
  20. #include <kopano/zcdefs.h>
  21. #include <kopano/archiver-common.h>
  22. #include <kopano/mapi_ptr.h>
  23. #include <kopano/CommonUtil.h>
  24. #include "ArchiverSessionPtr.h" // For ArchiverSessionPtr
  25. namespace KC {
  26. class ECLogger;
  27. namespace helpers {
  28. class ArchiveHelper;
  29. typedef std::shared_ptr<ArchiveHelper> ArchiveHelperPtr;
  30. enum ArchiveType {
  31. UndefArchive = 0,
  32. SingleArchive = 1,
  33. MultiArchive = 2
  34. };
  35. enum AttachType {
  36. ExplicitAttach = 0,
  37. ImplicitAttach = 1,
  38. UnknownAttach = 42
  39. };
  40. /**
  41. * The ArchiveHelper class is a utility class that operates on a message store that's used as
  42. * an archive.
  43. */
  44. class _kc_export ArchiveHelper _kc_final {
  45. public:
  46. _kc_hidden static HRESULT Create(LPMDB arc_store, const tstring &folder, const char *server_path, ArchiveHelperPtr *);
  47. _kc_hidden static HRESULT Create(LPMDB arc_store, LPMAPIFOLDER arc_folder, const char *server_path, ArchiveHelperPtr *);
  48. static HRESULT Create(ArchiverSessionPtr ptrSession, const SObjectEntry &archiveEntry, ECLogger *lpLogger, ArchiveHelperPtr *lpptrArchiveHelper);
  49. _kc_hidden HRESULT GetAttachedUser(abentryid_t *user_eid);
  50. _kc_hidden HRESULT SetAttachedUser(const abentryid_t &user_eid);
  51. _kc_hidden HRESULT GetArchiveEntry(bool create, SObjectEntry *obj_entry);
  52. _kc_hidden HRESULT GetArchiveType(ArchiveType *arc_type, AttachType *att_type);
  53. _kc_hidden HRESULT SetArchiveType(ArchiveType arc_type, AttachType att_type);
  54. _kc_hidden HRESULT SetPermissions(const abentryid_t &user_eid, bool writable);
  55. HRESULT GetArchiveFolderFor(MAPIFolderPtr &ptrSourceFolder, ArchiverSessionPtr ptrSession, LPMAPIFOLDER *lppDestinationFolder);
  56. HRESULT GetHistoryFolder(LPMAPIFOLDER *lppHistoryFolder);
  57. HRESULT GetOutgoingFolder(LPMAPIFOLDER *lppOutgoingFolder);
  58. HRESULT GetDeletedItemsFolder(LPMAPIFOLDER *lppOutgoingFolder);
  59. HRESULT GetSpecialsRootFolder(LPMAPIFOLDER *lppSpecialsRootFolder);
  60. HRESULT GetArchiveFolder(bool bCreate, LPMAPIFOLDER *lppArchiveFolder);
  61. _kc_hidden HRESULT IsArchiveFolder(LPMAPIFOLDER, bool *res);
  62. _kc_hidden MsgStorePtr GetMsgStore(void) const { return m_ptrArchiveStore; }
  63. _kc_hidden HRESULT PrepareForFirstUse(ECLogger * = nullptr);
  64. private:
  65. _kc_hidden ArchiveHelper(LPMDB arc_store, const tstring &folder, const std::string &server_path);
  66. _kc_hidden ArchiveHelper(LPMDB arc_store, LPMAPIFOLDER arc_folder, const std::string &server_path);
  67. _kc_hidden HRESULT Init(void);
  68. enum eSpecFolder {
  69. sfBase = 0, //< The root of the special folders, which is a child of the archive root
  70. sfHistory = 1, //< The history folder, which is a child of the special root
  71. sfOutgoing = 2, //< The outgoing folder, which is a child of the special root
  72. sfDeleted = 3 //< The deleted items folder, which is a child of the special root
  73. };
  74. _kc_hidden HRESULT GetSpecialFolderEntryID(eSpecFolder sf_which, ULONG *eid_size, LPENTRYID *eid);
  75. _kc_hidden HRESULT SetSpecialFolderEntryID(eSpecFolder sf_which, ULONG eid_size, LPENTRYID eid);
  76. _kc_hidden HRESULT GetSpecialFolder(eSpecFolder sf_which, bool create, LPMAPIFOLDER *spc_folder);
  77. _kc_hidden HRESULT CreateSpecialFolder(eSpecFolder sf_which, LPMAPIFOLDER *spc_folder);
  78. _kc_hidden HRESULT IsSpecialFolder(eSpecFolder sf_which, LPMAPIFOLDER, bool *res);
  79. MsgStorePtr m_ptrArchiveStore;
  80. MAPIFolderPtr m_ptrArchiveFolder;
  81. tstring m_strFolder;
  82. const std::string m_strServerPath;
  83. PROPMAP_DECL()
  84. PROPMAP_DEF_NAMED_ID(ATTACHED_USER_ENTRYID)
  85. PROPMAP_DEF_NAMED_ID(ARCHIVE_TYPE)
  86. PROPMAP_DEF_NAMED_ID(ATTACH_TYPE)
  87. PROPMAP_DEF_NAMED_ID(SPECIAL_FOLDER_ENTRYIDS)
  88. };
  89. }} /* namespace */
  90. #endif // !defined ARCHIVEHELPER_INCLUDED