ECResyncSet.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include <kopano/platform.h>
  18. #include "ECResyncSet.h"
  19. void ECResyncSet::Append(const SBinary &sbinSourceKey, const SBinary &sbinEntryID, const FILETIME &lastModTime)
  20. {
  21. m_map.insert(map_type::value_type(
  22. array_type(sbinSourceKey.lpb, sbinSourceKey.lpb + sbinSourceKey.cb),
  23. storage_type(array_type(sbinEntryID.lpb, sbinEntryID.lpb + sbinEntryID.cb), lastModTime)));
  24. }
  25. bool ECResyncSet::Remove(const SBinary &sbinSourceKey)
  26. {
  27. return m_map.erase(array_type(sbinSourceKey.lpb, sbinSourceKey.lpb + sbinSourceKey.cb)) == 1;
  28. }
  29. ECResyncSetIterator::ECResyncSetIterator(ECResyncSet &resyncSet)
  30. : m_lpResyncSet(&resyncSet)
  31. , m_iterator(m_lpResyncSet->m_map.begin())
  32. { }
  33. ECResyncSetIterator::ECResyncSetIterator(ECResyncSet &resyncSet, const SBinary &sbinSourceKey)
  34. : m_lpResyncSet(&resyncSet)
  35. , m_iterator(m_lpResyncSet->m_map.find(ECResyncSet::array_type(sbinSourceKey.lpb, sbinSourceKey.lpb + sbinSourceKey.cb)))
  36. { }
  37. bool ECResyncSetIterator::IsValid() const
  38. {
  39. return m_lpResyncSet && m_iterator != m_lpResyncSet->m_map.end();
  40. }
  41. LPENTRYID ECResyncSetIterator::GetEntryID() const
  42. {
  43. return IsValid() ? (LPENTRYID)&m_iterator->second.entryId.front() : NULL;
  44. }
  45. ULONG ECResyncSetIterator::GetEntryIDSize() const
  46. {
  47. return IsValid() ? m_iterator->second.entryId.size() : 0;
  48. }
  49. const FILETIME& ECResyncSetIterator::GetLastModTime() const
  50. {
  51. return IsValid() ? m_iterator->second.lastModTime : s_nullTime;
  52. }
  53. ULONG ECResyncSetIterator::GetFlags() const
  54. {
  55. return IsValid() ? m_iterator->second.flags : 0;
  56. }
  57. void ECResyncSetIterator::SetFlags(ULONG flags)
  58. {
  59. if (IsValid())
  60. m_iterator->second.flags = flags;
  61. }
  62. void ECResyncSetIterator::Next()
  63. {
  64. if (IsValid())
  65. ++m_iterator;
  66. }
  67. const FILETIME ECResyncSetIterator::s_nullTime = {0, 0};