SessionGroupData.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 ECSESSIONGROUPDATA_H
  18. #define ECSESSIONGROUPDATA_H
  19. #include <kopano/zcdefs.h>
  20. #include <mutex>
  21. #include <mapispi.h>
  22. #include <kopano/kcodes.h>
  23. #include "ClientUtil.h"
  24. class ECNotifyMaster;
  25. class WSTransport;
  26. class ECSessionGroupInfo _kc_final {
  27. public:
  28. std::string strServer;
  29. std::string strProfile;
  30. ECSessionGroupInfo()
  31. : strServer(), strProfile()
  32. {
  33. }
  34. ECSessionGroupInfo(const std::string &strServer, const std::string &strProfile)
  35. : strServer(strServer), strProfile(strProfile)
  36. {
  37. }
  38. };
  39. static inline bool operator==(const ECSessionGroupInfo &a, const ECSessionGroupInfo &b)
  40. {
  41. return (a.strServer.compare(b.strServer) == 0) &&
  42. (a.strProfile.compare(b.strProfile) == 0);
  43. }
  44. static inline bool operator<(const ECSessionGroupInfo &a, const ECSessionGroupInfo &b)
  45. {
  46. return (a.strServer.compare(b.strServer) < 0) ||
  47. ((a.strServer.compare(b.strServer) == 0) && (a.strProfile.compare(b.strProfile) < 0));
  48. }
  49. class SessionGroupData _kc_final {
  50. private:
  51. /* SessionGroup ID to which this data belongs */
  52. ECSESSIONGROUPID m_ecSessionGroupId;
  53. ECSessionGroupInfo m_ecSessionGroupInfo;
  54. /* Notification information */
  55. ECNotifyMaster *m_lpNotifyMaster = nullptr;
  56. /* Mutex */
  57. std::recursive_mutex m_hMutex;
  58. sGlobalProfileProps m_sProfileProps;
  59. /* Refcounting */
  60. std::recursive_mutex m_hRefMutex;
  61. ULONG m_cRef = 0;
  62. public:
  63. SessionGroupData(ECSESSIONGROUPID ecSessionGroupId, ECSessionGroupInfo *lpInfo, const sGlobalProfileProps &sProfileProps);
  64. ~SessionGroupData(void);
  65. static HRESULT Create(ECSESSIONGROUPID ecSessionGroupId, ECSessionGroupInfo *lpInfo, const sGlobalProfileProps &sProfileProps, SessionGroupData **lppData);
  66. HRESULT GetOrCreateNotifyMaster(ECNotifyMaster **lppMaster);
  67. HRESULT GetTransport(WSTransport **lppTransport);
  68. ULONG AddRef();
  69. ULONG Release();
  70. BOOL IsOrphan();
  71. ECSESSIONGROUPID GetSessionGroupId();
  72. };
  73. #endif /* ECSESSIONGROUPDATA_H */