ManaPlus
Public Member Functions | Private Member Functions
EAthena::LoginHandler Class Reference

#include <loginhandler.h>

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

Public Member Functions

 LoginHandler ()
 
 ~LoginHandler ()
 
void connect () const
 
bool isConnected () const
 
void disconnect () const
 
unsigned int getMaxPasswordLength () const
 
void changePassword (const std::string &oldPassword, const std::string &newPassword) const
 
void sendVersion () const
 
ServerInfogetCharServer () const
 
void ping () const
 
void updatePacketVersion () const
 
void sendMobileCode (const BeingId accountId, const std::string &code) const
 
void sendOtpCode (const std::string &code) const
 
- Public Member Functions inherited from Ea::LoginHandler
bool isRegistrationEnabled () const
 
void getRegistrationDetails () 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
 
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 unsigned int getMinUserNameLength () const
 
virtual unsigned int getMaxUserNameLength () const
 
virtual unsigned int getMinPasswordLength () const
 

Private Member Functions

void sendLoginRegister (const std::string &username, const std::string &password, const std::string &email) const
 

Additional Inherited Members

- Protected Member Functions inherited from Ea::LoginHandler
 LoginHandler ()
 
- Protected Member Functions inherited from Net::LoginHandler
 LoginHandler ()
 
- Protected Attributes inherited from Net::LoginHandler
ServerInfo mServer
 

Detailed Description

Definition at line 32 of file loginhandler.h.

Constructor & Destructor Documentation

◆ LoginHandler()

EAthena::LoginHandler::LoginHandler ( )

Definition at line 48 of file loginhandler.cpp.

48  :
50 {
51  loginHandler = this;
52 }
Net::LoginHandler * loginHandler
Definition: net.cpp:90

References loginHandler.

◆ ~LoginHandler()

EAthena::LoginHandler::~LoginHandler ( )
virtual

Reimplemented from Ea::LoginHandler.

Definition at line 54 of file loginhandler.cpp.

55 {
56  loginHandler = nullptr;
57 }

References loginHandler.

Member Function Documentation

◆ changePassword()

void EAthena::LoginHandler::changePassword ( const std::string &  oldPassword,
const std::string &  newPassword 
) const
virtual

Implements Net::LoginHandler.

Definition at line 93 of file loginhandler.cpp.

96 {
97  if (serverVersion == 0)
98  return;
99  createOutPacket(CMSG_CHAR_PASSWORD_CHANGE);
100  outMsg.writeStringNoLog(oldPassword, 24, "old password");
101  outMsg.writeStringNoLog(newPassword, 24, "new password");
102 }
int serverVersion
Definition: client.cpp:124
#define createOutPacket(name)
Definition: messageout.h:37

References createOutPacket, and serverVersion.

◆ connect()

void EAthena::LoginHandler::connect ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 59 of file loginhandler.cpp.

60 {
61  if (Network::mInstance == nullptr)
62  return;
63 
66  {
67  sendVersion();
68  }
69  else
70  {
71  if (client->getState() != State::LOGIN)
73  }
74 }
void setState(const StateT state)
Definition: client.h:66
StateT getState() const
Definition: client.h:69
void sendVersion() const
static Network * mInstance
Definition: network.h:57
bool connect(const ServerInfo &server)
Definition: network.cpp:101
ServerInfo mServer
Definition: loginhandler.h:116
virtual bool haveServerVersion() const =0
Client * client
Definition: client.cpp:118
@ LOGIN
Definition: state.h:40
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101

References client, Ea::Network::connect(), Client::getState(), Net::ServerFeatures::haveServerVersion(), State::LOGIN, EAthena::Network::mInstance, Net::LoginHandler::mServer, sendVersion(), serverFeatures, and Client::setState().

◆ disconnect()

void EAthena::LoginHandler::disconnect ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 84 of file loginhandler.cpp.

85 {
86  if (Network::mInstance != nullptr &&
88  {
90  }
91 }
void disconnect()
Definition: network.cpp:139
const ServerInfo & getServer() const
Definition: loginhandler.h:46

References Ea::Network::disconnect(), Net::LoginHandler::getServer(), EAthena::Network::mInstance, and Net::LoginHandler::mServer.

◆ getCharServer()

ServerInfo * EAthena::LoginHandler::getCharServer ( ) const
virtual

Implements Ea::LoginHandler.

Definition at line 140 of file loginhandler.cpp.

141 {
142  return &charServer;
143 }
ServerInfo charServer

References EAthena::charServer.

◆ getMaxPasswordLength()

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

Reimplemented from Ea::LoginHandler.

Definition at line 47 of file loginhandler.h.

48  { return 24; }

◆ isConnected()

bool EAthena::LoginHandler::isConnected ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 76 of file loginhandler.cpp.

77 {
78  if (Network::mInstance == nullptr)
79  return false;
80 
82 }
bool isConnected() const
Definition: network.h:61

References Ea::Network::isConnected(), and EAthena::Network::mInstance.

◆ ping()

void EAthena::LoginHandler::ping ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 156 of file loginhandler.cpp.

157 {
158  createOutPacket(CMSG_LOGIN_PING);
159  outMsg.writeInt32(0, "unused");
160  outMsg.writeInt32(0, "unused");
161  outMsg.writeInt32(0, "unused");
162  outMsg.writeInt32(0, "unused");
163  outMsg.writeInt32(0, "unused");
164  outMsg.writeInt32(0, "unused");
165 }

References createOutPacket.

◆ sendLoginRegister()

void EAthena::LoginHandler::sendLoginRegister ( const std::string &  username,
const std::string &  password,
const std::string &  email 
) const
privatevirtual

Implements Ea::LoginHandler.

Definition at line 104 of file loginhandler.cpp.

107 {
108  if (email.empty())
109  {
111  {
112  createOutPacket(CMSG_LOGIN_REGISTER_HAN);
113  outMsg.writeInt32(20, "client version");
114  outMsg.writeString(username, 24, "login");
115  outMsg.writeStringNoLog(password, 24, "password");
116  outMsg.writeInt8(0x03, "client type");
117  outMsg.writeString("127.0.0.1", 16, "ip address");
118  outMsg.writeString("001122334455", 13, "mac address");
119  outMsg.writeInt8(0, "is gravity id");
120  }
121  else
122  {
123  createOutPacket(CMSG_LOGIN_REGISTER);
124  outMsg.writeInt32(20, "client version");
125  outMsg.writeString(username, 24, "login");
126  outMsg.writeStringNoLog(password, 24, "password");
127  outMsg.writeInt8(0x03, "client type");
128  }
129  }
130  else
131  {
132  createOutPacket(CMSG_LOGIN_REGISTER4);
133  outMsg.writeString(username, 24, "login");
134  outMsg.writeStringNoLog(password, 24, "password");
135  outMsg.writeInt8(0x03, "client type");
136  outMsg.writeString(email, 40, "email");
137  }
138 }
ServerTypeT getNetworkType()
Definition: net.cpp:189

References createOutPacket, ServerType::EATHENA, and Net::getNetworkType().

◆ sendMobileCode()

void EAthena::LoginHandler::sendMobileCode ( const BeingId  accountId,
const std::string &  code 
) const
virtual

Implements Net::LoginHandler.

Definition at line 172 of file loginhandler.cpp.

174 {
175  if (packetVersionMain < 20181114 &&
176  packetVersionRe < 20181114)
177  {
178  return;
179  }
180  createOutPacket(CMSG_LOGIN_MOBILE_OTP);
181  outMsg.writeInt16(14, "len");
182  outMsg.writeBeingId(accountId, "account id");
183  outMsg.writeStringNoLog(code, 6, "code");
184 }
int packetVersionRe
Definition: client.cpp:127
int packetVersionMain
Definition: client.cpp:126

References createOutPacket, packetVersionMain, and packetVersionRe.

◆ sendOtpCode()

void EAthena::LoginHandler::sendOtpCode ( const std::string &  code) const
virtual

Implements Net::LoginHandler.

Definition at line 186 of file loginhandler.cpp.

187 {
188  if (packetVersionMain < 20181114 &&
189  packetVersionRe < 20181114 &&
190  packets_zero == false)
191  {
192  return;
193  }
194  createOutPacket(CMSG_LOGIN_OTP_CODE);
195  outMsg.writeStringNoLog(code, 9, "code");
196 }
bool packets_zero
Definition: client.cpp:133

References createOutPacket, packets_zero, packetVersionMain, and packetVersionRe.

◆ sendVersion()

void EAthena::LoginHandler::sendVersion ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 145 of file loginhandler.cpp.

146 {
147  createOutPacket(CMSG_SERVER_VERSION_REQUEST);
148  outMsg.writeInt32(CLIENT_PROTOCOL_VERSION, "protocol version");
149  outMsg.writeInt32(0, "unused");
150  outMsg.writeInt32(0, "unused");
151  outMsg.writeInt32(0, "unused");
152  outMsg.writeInt32(0, "unused");
154 }
virtual void flushSend() const =0
#define CLIENT_PROTOCOL_VERSION
Definition: network.h:33
Net::GeneralHandler * generalHandler
Definition: net.cpp:88

References CLIENT_PROTOCOL_VERSION, createOutPacket, Net::GeneralHandler::flushSend(), and generalHandler.

Referenced by connect().

◆ updatePacketVersion()

void EAthena::LoginHandler::updatePacketVersion ( ) const
virtual

Implements Net::LoginHandler.

Definition at line 167 of file loginhandler.cpp.

168 {
169  updateProtocol();
170 }
void updateProtocol()

References EAthena::updateProtocol().


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