ManaPlus
Public Member Functions | Protected Member Functions
Ea::LoginHandler Class Referenceabstract

#include <loginhandler.h>

Inheritance diagram for Ea::LoginHandler:
Net::LoginHandler EAthena::LoginHandler TmwAthena::LoginHandler

Public Member Functions

 ~LoginHandler ()
 
bool isRegistrationEnabled () const
 
void getRegistrationDetails () const
 
unsigned int getMaxPasswordLength () const
 
void loginAccount (LoginData *const loginData) const
 
void chooseServer (const unsigned int server, const bool persistentIp) const
 
void registerAccount (const LoginData *const loginData) const
 
const WorldsgetWorlds () const A_CONST
 
void clearWorlds () const
 
virtual ServerInfogetCharServer () const =0
 
const TokengetToken () const A_CONST
 
void logout () const
 
void changeEmail (const std::string &email) const
 
void unregisterAccount (const std::string &username, const std::string &password) const
 
void loginOrRegister (LoginData *const data) const
 
- Public Member Functions inherited from Net::LoginHandler
void setServer (const ServerInfo &server)
 
const ServerInfogetServer () const
 
virtual void connect () const =0
 
virtual bool isConnected () const =0
 
virtual void disconnect () const =0
 
virtual unsigned int getMinUserNameLength () const
 
virtual unsigned int getMaxUserNameLength () const
 
virtual unsigned int getMinPasswordLength () const
 
virtual void changePassword (const std::string &oldPassword, const std::string &newPassword) const =0
 
virtual void sendVersion () const =0
 
virtual void ping () const =0
 
virtual void updatePacketVersion () const =0
 
virtual void sendMobileCode (const BeingId accountId, const std::string &code) const =0
 
virtual void sendOtpCode (const std::string &code) const =0
 

Protected Member Functions

 LoginHandler ()
 
virtual void sendLoginRegister (const std::string &username, const std::string &password, const std::string &email) const =0
 
- Protected Member Functions inherited from Net::LoginHandler
 LoginHandler ()
 

Additional Inherited Members

- Protected Attributes inherited from Net::LoginHandler
ServerInfo mServer
 

Detailed Description

Definition at line 36 of file loginhandler.h.

Constructor & Destructor Documentation

◆ ~LoginHandler()

Ea::LoginHandler::~LoginHandler ( )
virtual

Reimplemented from Net::LoginHandler.

Reimplemented in TmwAthena::LoginHandler, and EAthena::LoginHandler.

Definition at line 53 of file loginhandler.cpp.

54 {
56 }
void delete_all(Container &c)
Definition: dtor.h:56
Worlds mWorlds
Definition: loginrecv.cpp:45

References delete_all(), and Ea::LoginRecv::mWorlds.

◆ LoginHandler()

Ea::LoginHandler::LoginHandler ( )
protected

Member Function Documentation

◆ changeEmail()

void Ea::LoginHandler::changeEmail ( const std::string &  email) const
virtual

Implements Net::LoginHandler.

Definition at line 177 of file loginhandler.cpp.

178 {
179 }

◆ chooseServer()

void Ea::LoginHandler::chooseServer ( const unsigned int  server,
const bool  persistentIp 
) const
virtual

Implements Net::LoginHandler.

Definition at line 78 of file loginhandler.cpp.

80 {
81  if (CAST_SIZE(server) >= LoginRecv::mWorlds.size() ||
82  (LoginRecv::mWorlds[server] == nullptr))
83  {
84  return;
85  }
86 
88  if (charServer != nullptr)
89  {
90  if (config.getBoolValue("usePersistentIP") || persistentIp)
91  {
93  }
94  else
95  {
97  LoginRecv::mWorlds[server]->address);
98  }
99  charServer->port = LoginRecv::mWorlds[server]->port;
100  }
102 
104 }
#define CAST_SIZE
Definition: cast.h:34
void setState(const StateT state)
Definition: client.h:66
bool getBoolValue(const std::string &key) const
virtual ServerInfo * getCharServer() const =0
ServerInfo mServer
Definition: loginhandler.h:116
std::string hostname
Definition: serverinfo.h:45
std::string althostname
Definition: serverinfo.h:46
uint16_t port
Definition: serverinfo.h:58
std::string serverName
Definition: settings.h:114
Configuration config
Client * client
Definition: client.cpp:118
ServerInfo charServer
int size()
Definition: emotedb.cpp:306
@ UPDATE
Definition: state.h:44
Settings settings
Definition: settings.cpp:32
const char * ipToString(const uint32_t address)
Definition: stringutils.cpp:86

References ServerInfo::althostname, CAST_SIZE, EAthena::charServer, client, config, Configuration::getBoolValue(), getCharServer(), ServerInfo::hostname, ipToString(), Net::LoginHandler::mServer, Ea::LoginRecv::mWorlds, ServerInfo::port, Settings::serverName, Client::setState(), settings, EmoteDB::size(), and State::UPDATE.

◆ clearWorlds()

void Ea::LoginHandler::clearWorlds ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 133 of file loginhandler.cpp.

134 {
136  LoginRecv::mWorlds.clear();
137 }

References delete_all(), and Ea::LoginRecv::mWorlds.

◆ getCharServer()

virtual ServerInfo* Ea::LoginHandler::getCharServer ( ) const
pure virtual

Implemented in TmwAthena::LoginHandler, and EAthena::LoginHandler.

Referenced by chooseServer().

◆ getMaxPasswordLength()

unsigned int Ea::LoginHandler::getMaxPasswordLength ( ) const
inlinevirtual

Reimplemented from Net::LoginHandler.

Reimplemented in TmwAthena::LoginHandler, and EAthena::LoginHandler.

Definition at line 47 of file loginhandler.h.

48  { return 24; }

◆ getRegistrationDetails()

void Ea::LoginHandler::getRegistrationDetails ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 63 of file loginhandler.cpp.

64 {
65  // Not supported, so move on
67 }
@ REGISTER
Definition: state.h:54

References client, State::REGISTER, and Client::setState().

◆ getToken()

const Token & Ea::LoginHandler::getToken ( ) const

Definition at line 187 of file loginhandler.cpp.

188 {
189  return LoginRecv::mToken;
190 }

References Ea::LoginRecv::mToken.

◆ getWorlds()

const Worlds & Ea::LoginHandler::getWorlds ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 128 of file loginhandler.cpp.

129 {
130  return LoginRecv::mWorlds;
131 }

References Ea::LoginRecv::mWorlds.

◆ isRegistrationEnabled()

bool Ea::LoginHandler::isRegistrationEnabled ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 58 of file loginhandler.cpp.

59 {
61 }

References Ea::LoginRecv::mRegistrationEnabled.

◆ loginAccount()

void Ea::LoginHandler::loginAccount ( LoginData *const  loginData) const
virtual

Implements Net::LoginHandler.

Definition at line 69 of file loginhandler.cpp.

70 {
71  if (loginData1 != nullptr)
72  {
73  loginData1->resetCharacterSlots();
74  sendLoginRegister(loginData1->username, loginData1->password, "");
75  }
76 }
virtual void sendLoginRegister(const std::string &username, const std::string &password, const std::string &email) const =0

References LoginData::password, LoginData::resetCharacterSlots(), sendLoginRegister(), and LoginData::username.

Referenced by loginOrRegister().

◆ loginOrRegister()

void Ea::LoginHandler::loginOrRegister ( LoginData *const  data) const
virtual

Implements Net::LoginHandler.

Definition at line 139 of file loginhandler.cpp.

140 {
141  if (data == nullptr)
142  return;
143 
144  logger->log("Username is %s", data->username.c_str());
145 
146  // Send login infos
147  if (data->registerLogin)
149  else
151 
152  const bool remember = data->remember;
153  if (remember)
154  {
155  serverConfig.setValue("username", data->username);
156 #ifdef SAVE_PASSWORD
157  serverConfig.setValue("password", data->password);
158 #endif
159  }
160  else
161  {
162  serverConfig.setValue("username", "");
163 #ifdef SAVE_PASSWORD
164  serverConfig.setValue("password", "");
165 #endif
166  }
167  serverConfig.setValue("remember", remember);
168 
169  // Clear the password, avoids auto login when returning to login
170  data->password.clear();
171 }
void setValue(const std::string &key, const std::string &value)
void registerAccount(const LoginData *const loginData) const
void loginAccount(LoginData *const loginData) const
void log(const char *const log_text,...)
Definition: logger.cpp:269
Configuration serverConfig
Logger * logger
Definition: logger.cpp:89
uint32_t data

References data, Logger::log(), logger, loginAccount(), registerAccount(), serverConfig, and Configuration::setValue().

◆ logout()

void Ea::LoginHandler::logout ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 173 of file loginhandler.cpp.

174 {
175 }

◆ registerAccount()

void Ea::LoginHandler::registerAccount ( const LoginData *const  loginData) const
virtual

Implements Net::LoginHandler.

Definition at line 106 of file loginhandler.cpp.

107 {
108  if (loginData1 == nullptr)
109  return;
110 
111  std::string username = loginData1->username;
112  switch (loginData1->gender)
113  {
114  case Gender::FEMALE:
115  case Gender::UNSPECIFIED:
116  username.append("_F");
117  break;
118  case Gender::MALE:
119  username.append("_M");
120  break;
121  default:
122  break;
123  }
124 
125  sendLoginRegister(username, loginData1->password, loginData1->email);
126 }
@ UNSPECIFIED
Definition: gender.h:33
@ MALE
Definition: gender.h:31
@ FEMALE
Definition: gender.h:32

References LoginData::email, Gender::FEMALE, LoginData::gender, Gender::MALE, LoginData::password, sendLoginRegister(), Gender::UNSPECIFIED, and LoginData::username.

Referenced by loginOrRegister().

◆ sendLoginRegister()

virtual void Ea::LoginHandler::sendLoginRegister ( const std::string &  username,
const std::string &  password,
const std::string &  email 
) const
protectedpure virtual

◆ unregisterAccount()

void Ea::LoginHandler::unregisterAccount ( const std::string &  username,
const std::string &  password 
) const
virtual

Implements Net::LoginHandler.

Definition at line 181 of file loginhandler.cpp.

184 {
185 }

The documentation for this class was generated from the following files: