fsck.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 KOPANO_FSCK
  18. #define KOPANO_FSCK
  19. #include <kopano/platform.h>
  20. #include <string>
  21. #include <list>
  22. #include <set>
  23. using namespace std;
  24. #include <kopano/zcdefs.h>
  25. #include <mapidefs.h>
  26. /*
  27. * Global configuration
  28. */
  29. extern string auto_fix;
  30. extern string auto_del;
  31. class Fsck {
  32. private:
  33. ULONG ulFolders = 0, ulEntries = 0, ulProblems = 0;
  34. ULONG ulFixed = 0, ulDeleted = 0;
  35. virtual HRESULT ValidateItem(LPMESSAGE lpMessage, const std::string &strClass) = 0;
  36. public:
  37. virtual ~Fsck(void) _kc_impdtor;
  38. HRESULT ValidateMessage(LPMESSAGE lpMessage, const std::string &strName, const std::string &strClass);
  39. HRESULT ValidateFolder(LPMAPIFOLDER lpFolder, const std::string &strName);
  40. HRESULT AddMissingProperty(LPMESSAGE lpMessage, const std::string &strName, ULONG ulTag, __UPV Value);
  41. HRESULT ReplaceProperty(LPMESSAGE lpMessage, const std::string &strName, ULONG ulTag, const std::string &strError, __UPV Value);
  42. HRESULT DeleteRecipientList(LPMESSAGE lpMessage, std::list<unsigned int> &mapiReciptDel, bool &bChanged);
  43. HRESULT DeleteMessage(LPMAPIFOLDER folder, const SPropValue *prop);
  44. HRESULT ValidateRecursiveDuplicateRecipients(LPMESSAGE lpMessage, bool &bChanged);
  45. HRESULT ValidateDuplicateRecipients(LPMESSAGE lpMessage, bool &bChanged);
  46. void PrintStatistics(const std::string &title);
  47. };
  48. class FsckCalendar _kc_final : public Fsck {
  49. private:
  50. HRESULT ValidateItem(LPMESSAGE lpMessage, const std::string &strClass) _kc_override;
  51. HRESULT ValidateMinimalNamedFields(LPMESSAGE lpMessage);
  52. HRESULT ValidateTimestamps(LPMESSAGE lpMessage);
  53. HRESULT ValidateRecurrence(LPMESSAGE lpMessage);
  54. };
  55. class FsckContact _kc_final : public Fsck {
  56. private:
  57. HRESULT ValidateItem(LPMESSAGE lpMessage, const std::string &strClass) _kc_override;
  58. HRESULT ValidateContactNames(LPMESSAGE lpMessage);
  59. };
  60. class FsckTask _kc_final : public Fsck {
  61. private:
  62. HRESULT ValidateItem(LPMESSAGE lpMessage, const std::string &strClass) _kc_override;
  63. HRESULT ValidateMinimalNamedFields(LPMESSAGE lpMessage);
  64. HRESULT ValidateTimestamps(LPMESSAGE lpMessage);
  65. HRESULT ValidateCompletion(LPMESSAGE lpMessage);
  66. };
  67. /*
  68. * Helper functions.
  69. */
  70. HRESULT allocNamedIdList(ULONG ulSize, LPMAPINAMEID **lpppNameArray);
  71. HRESULT ReadProperties(IMessage *, ULONG count, const ULONG *tags, SPropValue **out);
  72. HRESULT ReadNamedProperties(LPMESSAGE lpMessage, ULONG ulCount,
  73. LPMAPINAMEID *lppTag,
  74. LPSPropTagArray *lppPropertyTagArray,
  75. LPSPropValue *lppPropertyArray);
  76. #endif /* KOPANO_FSCK */