ECICSHelpers.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 ECICSHELPERS_H
  18. #define ECICSHELPERS_H
  19. #include <kopano/zcdefs.h>
  20. #include "ECICS.h"
  21. #include "ECDatabase.h"
  22. struct soap;
  23. namespace KC {
  24. // Indexes into the database rows.
  25. enum {
  26. icsID = 0,
  27. icsSourceKey = 1,
  28. icsParentSourceKey = 2,
  29. icsChangeType = 3,
  30. icsFlags = 4,
  31. icsMsgFlags = 5,
  32. icsSourceSync = 6
  33. };
  34. // Auxiliary Message Data (ParentSourceKey, Last ChangeId)
  35. struct SAuxMessageData {
  36. SAuxMessageData(const SOURCEKEY &ps, unsigned int ct, unsigned int flags): sParentSourceKey(ps), ulChangeTypes(ct), ulFlags(flags) {}
  37. SOURCEKEY sParentSourceKey;
  38. unsigned int ulChangeTypes;
  39. unsigned int ulFlags; // For readstate change
  40. };
  41. typedef std::map<SOURCEKEY,SAuxMessageData> MESSAGESET, *LPMESSAGESET;
  42. // Forward declarations of interfaces used by ECGetContentChangesHelper
  43. class IDbQueryCreator;
  44. class IMessageProcessor;
  45. class ECGetContentChangesHelper _kc_final {
  46. public:
  47. static ECRESULT Create(struct soap *soap, ECSession *lpSession, ECDatabase *lpDatabase, const SOURCEKEY &sFolderSourceKey, unsigned int ulSyncId, unsigned int ulChangeId, unsigned int ulFlags, struct restrictTable *lpsRestrict, ECGetContentChangesHelper **lppHelper);
  48. ~ECGetContentChangesHelper();
  49. ECRESULT QueryDatabase(DB_RESULT *lppDBResult);
  50. ECRESULT ProcessRows(const std::vector<DB_ROW> &db_rows, const std::vector<DB_LENGTHS> &db_lengths);
  51. ECRESULT ProcessResidualMessages();
  52. ECRESULT Finalize(unsigned int *lpulMaxChange, icsChangesArray **lppChanges);
  53. private:
  54. ECGetContentChangesHelper(struct soap *soap, ECSession *lpSession, ECDatabase *lpDatabase, const SOURCEKEY &sFolderSourceKey, unsigned int ulSyncId, unsigned int ulChangeId, unsigned int ulFlags, struct restrictTable *lpsRestrict);
  55. ECRESULT Init();
  56. ECRESULT MatchRestrictions(const std::vector<DB_ROW> &db_rows, const std::vector<DB_LENGTHS> &db_lengths, struct restrictTable *lpsRestrict, std::set<SOURCEKEY> *matches);
  57. ECRESULT GetSyncedMessages(unsigned int ulSyncId, unsigned int ulChangeId, LPMESSAGESET lpsetMessages);
  58. static bool CompareMessageEntry(const MESSAGESET::value_type &lhs, const MESSAGESET::value_type &rhs);
  59. bool MessageSetsDiffer() const;
  60. // Interfaces for delegated processing
  61. IDbQueryCreator *m_lpQueryCreator = nullptr;
  62. IMessageProcessor *m_lpMsgProcessor = nullptr;
  63. // Internal variables
  64. soap *m_soap;
  65. ECSession *m_lpSession;
  66. ECDatabase *m_lpDatabase;
  67. restrictTable *m_lpsRestrict;
  68. icsChangesArray *m_lpChanges = nullptr;
  69. const SOURCEKEY &m_sFolderSourceKey;
  70. unsigned int m_ulSyncId;
  71. unsigned int m_ulChangeId;
  72. unsigned int m_ulChangeCnt = 0, m_ulMaxFolderChange = 0;
  73. unsigned int m_ulFlags;
  74. MESSAGESET m_setLegacyMessages;
  75. MESSAGESET m_setNewMessages;
  76. };
  77. } /* namespace */
  78. #endif // ndef ECICSHELPERS_H