MAPINotifSink.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 MAPINOTIFSINK_H
  18. #define MAPINOTIFSINK_H
  19. #include <kopano/zcdefs.h>
  20. #include <condition_variable>
  21. #include <list>
  22. #include <mutex>
  23. #include <mapi.h>
  24. #include <mapix.h>
  25. #include <mapidefs.h>
  26. #include <kopano/ECUnknown.h>
  27. namespace KC {
  28. class _kc_export MAPINotifSink _kc_final : public IMAPIAdviseSink {
  29. public:
  30. static HRESULT Create(MAPINotifSink **lppSink);
  31. _kc_hidden virtual ULONG __stdcall AddRef(void) _kc_override;
  32. virtual ULONG __stdcall Release(void) _kc_override;
  33. _kc_hidden virtual HRESULT __stdcall QueryInterface(REFIID iid, void **iface) _kc_override;
  34. _kc_hidden virtual ULONG __stdcall OnNotify(ULONG n, LPNOTIFICATION notif) _kc_override;
  35. virtual HRESULT __stdcall GetNotifications(ULONG *n, LPNOTIFICATION *notif, BOOL fNonBlock, ULONG timeout);
  36. private:
  37. _kc_hidden MAPINotifSink(void) = default;
  38. _kc_hidden virtual ~MAPINotifSink(void);
  39. std::mutex m_hMutex;
  40. std::condition_variable m_hCond;
  41. std::list<NOTIFICATION *> m_lstNotifs;
  42. bool m_bExit = false;
  43. unsigned int m_cRef = 0;
  44. };
  45. HRESULT MAPICopyUnicode(WCHAR *lpSrc, void *lpBase, WCHAR **lpDst);
  46. HRESULT MAPICopyString(char *lpSrc, void *lpBase, char **lpDst);
  47. } /* namespace */
  48. #endif