WOLConnect.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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/WWOnline/WOLConnect.h $
  22. *
  23. * DESCRIPTION
  24. * Westwood Online wait conditions.
  25. *
  26. * PROGRAMMER
  27. * $Author: Denzil_l $
  28. *
  29. * VERSION INFO
  30. * $Revision: 14 $
  31. * $Modtime: 1/29/02 1:44p $
  32. *
  33. ******************************************************************************/
  34. #ifndef __WOLCONNECT_H__
  35. #define __WOLCONNECT_H__
  36. #include "WOLSession.h"
  37. #include "WaitCondition.h"
  38. #include "WOLChatMsg.h"
  39. #include <WWLib\Notify.h>
  40. #include <WWLib\WideString.h>
  41. #include "RefPtr.h"
  42. namespace WWOnline {
  43. const wchar_t* const DefaultPassword = L"zotclot9";
  44. //-----------------------------------------------------------------------------
  45. // Retrieve serverlist wait condition
  46. //-----------------------------------------------------------------------------
  47. class ServerListWait :
  48. public SingleWait,
  49. public Observer<ServerError>,
  50. public Observer<IRCServerList>
  51. {
  52. public:
  53. static RefPtr<ServerListWait> Create(const RefPtr<Session>& session);
  54. void WaitBeginning(void);
  55. protected:
  56. ServerListWait(const RefPtr<Session>&);
  57. virtual ~ServerListWait();
  58. ServerListWait(const ServerListWait&);
  59. const ServerListWait& operator=(const ServerListWait&);
  60. void HandleNotification(ServerError& serverError);
  61. void HandleNotification(IRCServerList& serverList);
  62. RefPtr<Session> mSession;
  63. };
  64. //-----------------------------------------------------------------------------
  65. // Disconnect from WWOnline wait condition
  66. //-----------------------------------------------------------------------------
  67. class DisconnectWait :
  68. public SingleWait,
  69. public Observer<ServerError>,
  70. public Observer<ConnectionStatus>
  71. {
  72. public:
  73. static RefPtr<DisconnectWait> Create(const RefPtr<Session>& session);
  74. void WaitBeginning(void);
  75. void EndWait(WaitResult, const wchar_t*);
  76. protected:
  77. DisconnectWait(const RefPtr<Session>& session);
  78. virtual ~DisconnectWait();
  79. DisconnectWait(const DisconnectWait&);
  80. const DisconnectWait& operator=(const DisconnectWait&);
  81. void HandleNotification(ServerError& serverError);
  82. void HandleNotification(ConnectionStatus& status);
  83. RefPtr<Session> mSession;
  84. };
  85. //-----------------------------------------------------------------------------
  86. // Connect to WWOnline wait condition
  87. //-----------------------------------------------------------------------------
  88. class ConnectWait :
  89. public SingleWait,
  90. public Observer<ServerError>,
  91. public Observer<ConnectionStatus>
  92. {
  93. public:
  94. static RefPtr<ConnectWait> Create(const RefPtr<Session>& session,
  95. const RefPtr<ServerData>& server, const RefPtr<LoginInfo>& login);
  96. void WaitBeginning(void);
  97. void EndWait(WaitResult, const wchar_t*);
  98. protected:
  99. ConnectWait(const RefPtr<Session>& session, const RefPtr<ServerData>& server,
  100. const RefPtr<LoginInfo>& login);
  101. virtual ~ConnectWait();
  102. ConnectWait(const ConnectWait&);
  103. const ConnectWait& operator=(const ConnectWait&);
  104. void HandleNotification(ServerError& serverError);
  105. void HandleNotification(ConnectionStatus& status);
  106. RefPtr<Session> mSession;
  107. RefPtr<ServerData> mServer;
  108. RefPtr<LoginInfo> mLogin;
  109. };
  110. //-----------------------------------------------------------------------------
  111. // Request for chat channel list wait condition
  112. //-----------------------------------------------------------------------------
  113. class ChannelListWait :
  114. public SingleWait,
  115. public Observer<ServerError>,
  116. public Observer<ConnectionStatus>,
  117. public Observer<ChannelListEvent>
  118. {
  119. public:
  120. static RefPtr<ChannelListWait> Create(const RefPtr<Session>& session, int type);
  121. void WaitBeginning(void);
  122. protected:
  123. ChannelListWait(const RefPtr<Session>& session, int type);
  124. virtual ~ChannelListWait();
  125. ChannelListWait(const ChannelListWait&);
  126. const ChannelListWait& operator=(const ChannelListWait&);
  127. void HandleNotification(ServerError& serverError);
  128. void HandleNotification(ConnectionStatus& status);
  129. void HandleNotification(ChannelListEvent& event);
  130. RefPtr<Session> mSession;
  131. int mType;
  132. };
  133. //-----------------------------------------------------------------------------
  134. // Request to leave a channel wait condition
  135. //-----------------------------------------------------------------------------
  136. class LeaveChannelWait :
  137. public SingleWait,
  138. public Observer<ServerError>,
  139. public Observer<ConnectionStatus>,
  140. public Observer<ChannelEvent>
  141. {
  142. public:
  143. static RefPtr<LeaveChannelWait> Create(const RefPtr<Session>& session);
  144. void WaitBeginning(void);
  145. protected:
  146. LeaveChannelWait(const RefPtr<Session>& session);
  147. virtual ~LeaveChannelWait();
  148. LeaveChannelWait(const LeaveChannelWait&);
  149. const LeaveChannelWait& operator=(const LeaveChannelWait&);
  150. void HandleNotification(ServerError& serverError);
  151. void HandleNotification(ConnectionStatus& status);
  152. void HandleNotification(ChannelEvent& status);
  153. RefPtr<Session> mSession;
  154. };
  155. //-----------------------------------------------------------------------------
  156. // Request to join a channel wait condition
  157. //-----------------------------------------------------------------------------
  158. class JoinChannelWait :
  159. public SingleWait,
  160. public Observer<ServerError>,
  161. public Observer<ConnectionStatus>,
  162. public Observer<ChannelEvent>
  163. {
  164. public:
  165. static RefPtr<JoinChannelWait> Create(const RefPtr<Session>& session,
  166. const RefPtr<ChannelData>& channel, const wchar_t* password);
  167. static RefPtr<JoinChannelWait> Create(const RefPtr<Session>& session,
  168. const wchar_t* channelName, const wchar_t* password, int type);
  169. void WaitBeginning(void);
  170. protected:
  171. JoinChannelWait(const RefPtr<Session>& session, const RefPtr<ChannelData>& channel,
  172. const wchar_t* password);
  173. JoinChannelWait(const RefPtr<Session>& session, const wchar_t* channelName,
  174. const wchar_t* password, int type);
  175. virtual ~JoinChannelWait();
  176. JoinChannelWait(const JoinChannelWait&);
  177. const JoinChannelWait& operator=(const JoinChannelWait&);
  178. void HandleNotification(ServerError& serverError);
  179. void HandleNotification(ConnectionStatus& status);
  180. void HandleNotification(ChannelEvent& status);
  181. RefPtr<Session> mSession;
  182. RefPtr<ChannelData> mChannel;
  183. WideStringClass mChannelName;
  184. WideStringClass mPassword;
  185. int mType;
  186. };
  187. //-----------------------------------------------------------------------------
  188. // Request to create a new channel wait condition
  189. //-----------------------------------------------------------------------------
  190. class CreateChannelWait :
  191. public SingleWait,
  192. public Observer<ServerError>,
  193. public Observer<ConnectionStatus>,
  194. public Observer<ChannelEvent>
  195. {
  196. public:
  197. static RefPtr<CreateChannelWait> Create(const RefPtr<Session>& session,
  198. const RefPtr<ChannelData>& channel, const wchar_t* password);
  199. void WaitBeginning(void);
  200. protected:
  201. CreateChannelWait(const RefPtr<Session>& session, const RefPtr<ChannelData>& channel,
  202. const wchar_t* password);
  203. virtual ~CreateChannelWait();
  204. CreateChannelWait(const CreateChannelWait&);
  205. const CreateChannelWait& operator=(const CreateChannelWait&);
  206. void HandleNotification(ServerError& serverError);
  207. void HandleNotification(ConnectionStatus& status);
  208. void HandleNotification(ChannelEvent& status);
  209. RefPtr<Session> mSession;
  210. RefPtr<ChannelData> mChannel;
  211. WideStringClass mPassword;
  212. };
  213. //-----------------------------------------------------------------------------
  214. // Request a new user list wait condition
  215. //-----------------------------------------------------------------------------
  216. class UserListWait :
  217. public SerialWait,
  218. public Observer<ServerError>,
  219. public Observer<UserList>
  220. {
  221. public:
  222. static RefPtr<UserListWait> Create(const RefPtr<Session>& session);
  223. void WaitBeginning(void);
  224. protected:
  225. UserListWait(const RefPtr<Session>& session);
  226. virtual ~UserListWait();
  227. UserListWait(const UserListWait&);
  228. const UserListWait& operator=(const UserListWait&);
  229. void HandleNotification(ServerError&);
  230. void HandleNotification(UserList&);
  231. RefPtr<Session> mSession;
  232. };
  233. //-----------------------------------------------------------------------------
  234. // Request to find a user wait condition
  235. //-----------------------------------------------------------------------------
  236. class GetUserWait :
  237. public SerialWait
  238. {
  239. public:
  240. static RefPtr<GetUserWait> Create(const RefPtr<Session>& session, const wchar_t* userName);
  241. void WaitBeginning(void);
  242. WaitResult GetResult(void);
  243. protected:
  244. GetUserWait(const RefPtr<Session>& session, const wchar_t* userName);
  245. virtual ~GetUserWait();
  246. GetUserWait(const GetUserWait&);
  247. const GetUserWait& operator=(const GetUserWait&);
  248. RefPtr<Session> mSession;
  249. WideStringClass mUserName;
  250. };
  251. //-----------------------------------------------------------------------------
  252. // Request to locate a user wait condition
  253. //-----------------------------------------------------------------------------
  254. class LocateUserWait :
  255. public SingleWait,
  256. public Observer<ServerError>,
  257. public Observer<UserEvent>
  258. {
  259. public:
  260. static RefPtr<LocateUserWait> Create(const RefPtr<Session>& session, const wchar_t* userName);
  261. void WaitBeginning(void);
  262. protected:
  263. LocateUserWait(const RefPtr<Session>& session, const wchar_t* userName);
  264. virtual ~LocateUserWait();
  265. LocateUserWait(const LocateUserWait&);
  266. const LocateUserWait& operator=(const LocateUserWait&);
  267. void HandleNotification(ServerError&);
  268. void HandleNotification(UserEvent&);
  269. RefPtr<Session> mSession;
  270. WideStringClass mUserName;
  271. };
  272. //-----------------------------------------------------------------------------
  273. // Request to send a private message to a user wait condition
  274. //-----------------------------------------------------------------------------
  275. class SendMsgWait :
  276. public SingleWait
  277. {
  278. public:
  279. static RefPtr<SendMsgWait> Create(const RefPtr<Session>& session, ChatMessage& message);
  280. void WaitBeginning(void);
  281. protected:
  282. SendMsgWait(const RefPtr<Session>& session, ChatMessage& message);
  283. virtual ~SendMsgWait();
  284. SendMsgWait(const SendMsgWait&);
  285. const SendMsgWait& operator=(const SendMsgWait&);
  286. RefPtr<Session> mSession;
  287. ChatMessage mMessage;
  288. };
  289. }
  290. #endif // __WOLCONNECT_H__