ECResyncSet.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 ECResyncSet_INCLUDED
  18. #define ECResyncSet_INCLUDED
  19. #include <map>
  20. #include <vector>
  21. #include <kopano/zcdefs.h>
  22. #include <mapidefs.h>
  23. #include <edkmdb.h>
  24. namespace KC {
  25. class ECResyncSetIterator;
  26. class ECResyncSet _kc_final {
  27. public:
  28. typedef std::vector<BYTE> array_type;
  29. struct storage_type {
  30. storage_type(const array_type& _entryId, const FILETIME& _lastModTime)
  31. : entryId(_entryId), lastModTime(_lastModTime), flags(SYNC_NEW_MESSAGE)
  32. { }
  33. array_type entryId;
  34. FILETIME lastModTime;
  35. ULONG flags;
  36. };
  37. typedef std::map<array_type, storage_type> map_type;
  38. typedef map_type::size_type size_type;
  39. void Append(const SBinary &sbinSourceKey, const SBinary &sbinEntryID, const FILETIME &lastModTime);
  40. bool Remove(const SBinary &sbinSourceKey);
  41. ECResyncSetIterator Find(const SBinary &sBinSourceKey);
  42. bool IsEmpty() const { return m_map.empty(); }
  43. size_type Size() const { return m_map.size(); }
  44. private:
  45. map_type m_map;
  46. friend class ECResyncSetIterator;
  47. };
  48. class ECResyncSetIterator _kc_final {
  49. public:
  50. ECResyncSetIterator(ECResyncSet &resyncSet);
  51. ECResyncSetIterator(ECResyncSet &resyncSet, const SBinary &sBinSourceKey);
  52. bool IsValid() const;
  53. LPENTRYID GetEntryID() const;
  54. ULONG GetEntryIDSize() const;
  55. const FILETIME& GetLastModTime() const;
  56. ULONG GetFlags() const;
  57. void SetFlags(ULONG flags);
  58. void Next();
  59. private:
  60. typedef ECResyncSet::map_type::iterator iterator_type;
  61. ECResyncSet *m_lpResyncSet;
  62. iterator_type m_iterator;
  63. const static FILETIME s_nullTime;
  64. };
  65. } /* namespace */
  66. #endif // ndef ECResyncSet_INCLUDED