StoreHelper.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 STOREHELPER_H_INCLUDED
  18. #define STOREHELPER_H_INCLUDED
  19. #include <memory>
  20. #include <kopano/zcdefs.h>
  21. #include "MAPIPropHelper.h"
  22. namespace KC {
  23. class ECRestriction;
  24. class ECAndRestriction;
  25. class ECOrRestriction;
  26. namespace helpers {
  27. class StoreHelper;
  28. typedef std::unique_ptr<StoreHelper> StoreHelperPtr;
  29. /**
  30. * The StoreHelper class provides some common utility functions that relate to IMsgStore
  31. * objects in the archiver context.
  32. */
  33. class _kc_export StoreHelper _kc_final : public MAPIPropHelper {
  34. public:
  35. static HRESULT Create(MsgStorePtr &ptrMsgStore, StoreHelperPtr *lpptrStoreHelper);
  36. _kc_hidden HRESULT GetFolder(const tstring &name, bool create, LPMAPIFOLDER *ret);
  37. _kc_hidden HRESULT UpdateSearchFolders(void);
  38. _kc_hidden HRESULT GetIpmSubtree(LPMAPIFOLDER *);
  39. HRESULT GetSearchFolders(LPMAPIFOLDER *lppSearchArchiveFolder, LPMAPIFOLDER *lppSearchDeleteFolder, LPMAPIFOLDER *lppSearchStubFolder);
  40. private:
  41. _kc_hidden StoreHelper(MsgStorePtr &);
  42. _kc_hidden HRESULT Init(void);
  43. _kc_hidden HRESULT GetSubFolder(MAPIFolderPtr &, const tstring &name, bool create, LPMAPIFOLDER *ret);
  44. enum eSearchFolder {esfArchive = 0, esfDelete, esfStub, esfMax};
  45. _kc_hidden HRESULT CheckAndUpdateSearchFolder(LPMAPIFOLDER folder, eSearchFolder which);
  46. _kc_hidden HRESULT CreateSearchFolder(eSearchFolder which, LPMAPIFOLDER *ret);
  47. _kc_hidden HRESULT CreateSearchFolders(LPMAPIFOLDER *archive_folder, LPMAPIFOLDER *delete_folder, LPMAPIFOLDER *stub_folder);
  48. _kc_hidden HRESULT DoCreateSearchFolder(LPMAPIFOLDER parent, eSearchFolder which, LPMAPIFOLDER *retsf);
  49. _kc_hidden HRESULT SetupSearchArchiveFolder(LPMAPIFOLDER folder, const ECRestriction *class_chk, const ECRestriction *arc_chk);
  50. _kc_hidden HRESULT SetupSearchDeleteFolder(LPMAPIFOLDER folder, const ECRestriction *class_chk, const ECRestriction *arc_chk);
  51. _kc_hidden HRESULT SetupSearchStubFolder(LPMAPIFOLDER folder, const ECRestriction *class_chk, const ECRestriction *arc_chk);
  52. _kc_hidden HRESULT GetClassCheckRestriction(ECOrRestriction *class_chk);
  53. _kc_hidden HRESULT GetArchiveCheckRestriction(ECAndRestriction *arc_chk);
  54. typedef HRESULT(StoreHelper::*fn_setup_t)(LPMAPIFOLDER, const ECRestriction *, const ECRestriction *);
  55. struct search_folder_info_t {
  56. LPCTSTR lpszName;
  57. LPCTSTR lpszDescription;
  58. fn_setup_t fnSetup;
  59. };
  60. static const search_folder_info_t s_infoSearchFolders[];
  61. MsgStorePtr m_ptrMsgStore;
  62. MAPIFolderPtr m_ptrIpmSubtree;
  63. PROPMAP_DECL()
  64. PROPMAP_DEF_NAMED_ID(ARCHIVE_STORE_ENTRYIDS)
  65. PROPMAP_DEF_NAMED_ID(ARCHIVE_ITEM_ENTRYIDS)
  66. PROPMAP_DEF_NAMED_ID(ORIGINAL_SOURCEKEY)
  67. PROPMAP_DEF_NAMED_ID(SEARCH_FOLDER_ENTRYIDS)
  68. PROPMAP_DEF_NAMED_ID(STUBBED)
  69. PROPMAP_DEF_NAMED_ID(DIRTY)
  70. PROPMAP_DEF_NAMED_ID(FLAGS)
  71. PROPMAP_DEF_NAMED_ID(VERSION)
  72. };
  73. }} /* namespace */
  74. #endif // !defined STOREHELPER_H_INCLUDED