ECNotifyClient.h 3.3 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 ECNOTIFYCLIENT_H
  18. #define ECNOTIFYCLIENT_H
  19. #include <mutex>
  20. #include <kopano/zcdefs.h>
  21. #include <kopano/ECUnknown.h>
  22. #include <IECChangeAdviseSink.h>
  23. #include "ics_client.hpp"
  24. #include "ECNotifyMaster.h"
  25. #include <map>
  26. #include <list>
  27. #include <mapispi.h>
  28. struct ECADVISE;
  29. struct ECCHANGEADVISE;
  30. typedef std::map<int, ECADVISE*> ECMAPADVISE;
  31. typedef std::map<int, ECCHANGEADVISE*> ECMAPCHANGEADVISE;
  32. typedef std::list<std::pair<syncid_t,connection_t> > ECLISTCONNECTION;
  33. class SessionGroupData;
  34. class ECNotifyClient _kc_final : public ECUnknown {
  35. protected:
  36. ECNotifyClient(ULONG ulProviderType, void *lpProvider, ULONG ulFlags, LPMAPISUP lpSupport);
  37. virtual ~ECNotifyClient();
  38. public:
  39. static HRESULT Create(ULONG ulProviderType, void *lpProvider, ULONG ulFlags, LPMAPISUP lpSupport, ECNotifyClient**lppNotifyClient);
  40. virtual HRESULT QueryInterface(REFIID refiid, void **lppInterface) _kc_override;
  41. virtual HRESULT Advise(ULONG cbKey, LPBYTE lpKey, ULONG ulEventMask, LPMAPIADVISESINK lpAdviseSink, ULONG *lpulConnection);
  42. virtual HRESULT Advise(const ECLISTSYNCSTATE &lstSyncStates, IECChangeAdviseSink *lpChangeAdviseSink, ECLISTCONNECTION *lplstConnections);
  43. virtual HRESULT Unadvise(ULONG ulConnection);
  44. virtual HRESULT Unadvise(const ECLISTCONNECTION &lstConnections);
  45. // Re-request the connection from the server. You may pass an updated key if required.
  46. virtual HRESULT Reregister(ULONG ulConnection, ULONG cbKey = 0, LPBYTE lpKey = NULL);
  47. virtual HRESULT ReleaseAll();
  48. virtual HRESULT Notify(ULONG ulConnection, const NOTIFYLIST &lNotifications);
  49. virtual HRESULT NotifyChange(ULONG ulConnection, const NOTIFYLIST &lNotifications);
  50. virtual HRESULT NotifyReload(); // Called when all tables should be notified of RELOAD
  51. // Only register an advise client side
  52. virtual HRESULT RegisterAdvise(ULONG cbKey, LPBYTE lpKey, ULONG ulEventMask, bool bSynchronous, LPMAPIADVISESINK lpAdviseSink, ULONG *lpulConnection);
  53. virtual HRESULT RegisterChangeAdvise(ULONG ulSyncId, ULONG ulChangeId, IECChangeAdviseSink *lpChangeAdviseSink, ULONG *lpulConnection);
  54. virtual HRESULT UnRegisterAdvise(ULONG ulConnection);
  55. virtual HRESULT UpdateSyncStates(const ECLISTSYNCID &lstSyncID, ECLISTSYNCSTATE *lplstSyncState);
  56. private:
  57. ECMAPADVISE m_mapAdvise; // Map of all advise request from the client (outlook)
  58. ECMAPCHANGEADVISE m_mapChangeAdvise; // ExchangeChangeAdvise(s)
  59. SessionGroupData* m_lpSessionGroup;
  60. ECNotifyMaster* m_lpNotifyMaster;
  61. WSTransport* m_lpTransport;
  62. LPMAPISUP m_lpSupport;
  63. void* m_lpProvider;
  64. ULONG m_ulProviderType;
  65. std::recursive_mutex m_hMutex;
  66. ECSESSIONGROUPID m_ecSessionGroupId;
  67. };
  68. #endif // #ifndef ECNOTIFYCLIENT_H