WOLChatMgr.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /******************************************************************************
  19. *
  20. * FILE
  21. * $Archive: /Commando/Code/Commando/WOLChatMgr.h $
  22. *
  23. * DESCRIPTION
  24. *
  25. * PROGRAMMER
  26. * Denzil E. Long, Jr.
  27. * $Author: Denzil_l $
  28. *
  29. * VERSION INFO
  30. * $Revision: 18 $
  31. * $Modtime: 11/08/01 2:31p $
  32. *
  33. ******************************************************************************/
  34. #ifndef __WOLCHATMGR_H__
  35. #define __WOLCHATMGR_H__
  36. #include <WWLib\RefCount.h>
  37. #include <WWLib\Notify.h>
  38. #include <WWLib\WideString.h>
  39. #include <WWOnline\RefPtr.h>
  40. #include <WWOnline\WOLSession.h>
  41. #include <WWOnline\WOLChatMsg.h>
  42. typedef std::vector< RefPtr<WWOnline::ChannelData> > LobbyList;
  43. enum WOLChatMgrEvent
  44. {
  45. LobbyListChanged = 1,
  46. LobbyChanged,
  47. UserInListChanged,
  48. UserOutListChanged,
  49. MessageListChanged,
  50. KickedFromChannel,
  51. BannedFromChannel
  52. };
  53. class WOLChatMgr :
  54. public RefCountClass,
  55. public Notifier<WOLChatMgrEvent>,
  56. public Observer<WWOnline::ServerError>,
  57. public Observer<WWOnline::ChannelListEvent>,
  58. public Observer<WWOnline::ChannelEvent>,
  59. public Observer<WWOnline::UserEvent>,
  60. public Observer<WWOnline::UserList>,
  61. public Observer<WWOnline::ChatMessage>
  62. {
  63. public:
  64. static WOLChatMgr* GetInstance(bool createOK);
  65. void Start(void);
  66. void Stop(void);
  67. // Lobby Methods
  68. void RefreshLobbyList(void);
  69. const LobbyList& GetLobbyList(void);
  70. const RefPtr<WWOnline::ChannelData>& GetCurrentLobby(void);
  71. const RefPtr<WWOnline::ChannelData> FindLobby(const wchar_t* name);
  72. void CreateLobby(const wchar_t* name, const wchar_t* password);
  73. void JoinLobby(const RefPtr<WWOnline::ChannelData>& channel);
  74. void LeaveLobby(void);
  75. void GetLobbyDisplayName(const RefPtr<WWOnline::ChannelData>& lobby, WideStringClass& outName);
  76. // User Methods
  77. const RefPtr<WWOnline::UserData> FindUser(const wchar_t* name);
  78. inline const WWOnline::UserList& GetUserInList(void)
  79. {return mUserInList;}
  80. void ClearUserInList(void);
  81. inline const WWOnline::UserList& GetUserOutList(void)
  82. {return mUserOutList;}
  83. void ClearUserOutList(void);
  84. bool SquelchUser(const RefPtr<WWOnline::UserData>& user, bool onoff);
  85. void LocateUser(const wchar_t* name);
  86. // Message Methods
  87. inline const WWOnline::ChatMessageList& GetMessageList(void)
  88. {return mMessageList;}
  89. void ClearMessageList(void);
  90. void SendPublicMessage(const wchar_t* message, bool isAction);
  91. void SendPrivateMessage(const RefPtr<WWOnline::UserData>& user, const wchar_t* message, bool isAction);
  92. void SendPrivateMessage(WWOnline::UserList& users, const wchar_t* message, bool isAction);
  93. protected:
  94. WOLChatMgr();
  95. ~WOLChatMgr();
  96. // Delcare here to prevent copy and assignment
  97. WOLChatMgr(const WOLChatMgr&);
  98. const WOLChatMgr& operator=(const WOLChatMgr&);
  99. bool FinalizeCreate(void);
  100. bool IsLobbyValid(const RefPtr<WWOnline::ChannelData>& lobby);
  101. void AddMessage(const wchar_t* sender, const wchar_t* message, bool isPrivate, bool isAction);
  102. bool PassesFilters(const WWOnline::ChatMessage& msg);
  103. void HandleNotification(WWOnline::ServerError&);
  104. void HandleNotification(WWOnline::ChannelListEvent&);
  105. void HandleNotification(WWOnline::ChannelEvent&);
  106. void HandleNotification(WWOnline::UserEvent&);
  107. void HandleNotification(WWOnline::UserList&);
  108. void HandleNotification(WWOnline::ChatMessage&);
  109. bool ProcessCommand(const wchar_t* message);
  110. private:
  111. static WOLChatMgr* _mInstance;
  112. RefPtr<WWOnline::Session> mWOLSession;
  113. WideStringClass mLobbyPrefix;
  114. LobbyList mLobbyList;
  115. WWOnline::UserList mUserInList;
  116. WWOnline::UserList mUserOutList;
  117. WideStringClass mLocatingUserName;
  118. WWOnline::ChatMessageList mMessageList;
  119. };
  120. #endif __WOLCHATMGR_H__