WOLLogonMgr.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/WOLLogonMgr.h $
  22. *
  23. * DESCRIPTION
  24. *
  25. * PROGRAMMER
  26. * Denzil E. Long, Jr.
  27. * $Author: Denzil_l $
  28. *
  29. * VERSION INFO
  30. * $Revision: 25 $
  31. * $Modtime: 1/14/02 2:04p $
  32. *
  33. ******************************************************************************/
  34. #ifndef __WOLLOGONMGR_H__
  35. #define __WOLLOGONMGR_H__
  36. #include "DlgWOLLogon.h"
  37. #include <WWLib\RefCount.h>
  38. #include <WWLib\Notify.h>
  39. #include <WWOnline\RefPtr.h>
  40. #include <WWOnline\WOLSession.h>
  41. class DlgWOLWaitEvent;
  42. class DlgMsgBoxEvent;
  43. typedef enum
  44. {
  45. WOLLOGON_FAILED = 0,
  46. WOLLOGON_SUCCESS,
  47. WOLLOGON_CANCEL,
  48. WOLLOGON_PATCHREQUIRED
  49. } WOLLogonAction;
  50. class WOLLogonMgr :
  51. public RefCountClass,
  52. public Notifier<WOLLogonAction>,
  53. public Observer<DlgWOLLogonEvent>,
  54. public Observer<DlgWOLWaitEvent>,
  55. public Observer<DlgMsgBoxEvent>,
  56. public Observer<WWOnline::ServerError>,
  57. public Observer<WWOnline::ConnectionStatus>,
  58. public Observer<WWOnline::MessageOfTheDayEvent>
  59. {
  60. public:
  61. // Log onto Westwood Online
  62. static void Logon(Observer<WOLLogonAction>* observer);
  63. // Log the current user off of Westwood Online.
  64. static void Logoff(void);
  65. // Get the name of the logged in user.
  66. static bool GetLoginName(WideStringClass& name);
  67. // Get the name of the server logged onto.
  68. static bool GetServerName(WideStringClass& name);
  69. static RefPtr<WWOnline::IRCServerData> GetDefaultServer(void);
  70. static void ConfigureSession(void);
  71. static void Set_Quiet_Mode(bool mode) {mQuietMode = mode;}
  72. protected:
  73. typedef enum {DISCONNECTED = 0, DETECTING_BANDWIDTH, FETCHING_SERVERLIST, WAITING_PINGS, WAITING_BANDWIDTH_DIALOG_OKAY, CONNECTING, CONNECTED} LogonState;
  74. WOLLogonMgr();
  75. ~WOLLogonMgr();
  76. WOLLogonMgr(const WOLLogonMgr&);
  77. const WOLLogonMgr& operator=(const WOLLogonMgr&);
  78. RefPtr<WWOnline::IRCServerData> GetPreferredServer(const wchar_t* loginname);
  79. // Check if the user is connected to a server.
  80. bool IsConnectedToServer(const wchar_t* loginname, RefPtr<WWOnline::IRCServerData>& server);
  81. bool IsUserLoggedIn(const wchar_t* loginname);
  82. bool IsAutoLogin(const wchar_t* loginname);
  83. bool HasServerList(void);
  84. bool HasValidPings(void);
  85. void InitiateLogon(bool forced);
  86. void RememberLogin(void);
  87. DECLARE_NOTIFIER(WOLLogonAction)
  88. void HandleNotification(DlgWOLLogonEvent&);
  89. void HandleNotification(DlgWOLWaitEvent&);
  90. void HandleNotification(DlgMsgBoxEvent&);
  91. void HandleNotification(WWOnline::ServerError&);
  92. void HandleNotification(WWOnline::ConnectionStatus&);
  93. void HandleNotification(WWOnline::MessageOfTheDayEvent&);
  94. private:
  95. static bool mQuietMode;
  96. RefPtr<WWOnline::Session> mWOLSession;
  97. LogonState mState;
  98. WideStringClass mLoginName;
  99. WideStringClass mPassword;
  100. bool mPasswordEncrypted;
  101. bool mRememberLogin;
  102. };
  103. #endif // __WOLLOGONMGR_H__