ManaPlus
loginhandler.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef NET_LOGINHANDLER_H
25 #define NET_LOGINHANDLER_H
26 
27 #include "net/serverinfo.h"
28 
30 
31 #include "net/worldinfo.h"
32 
33 class LoginData;
34 
35 namespace Net
36 {
37 
39 {
40  public:
42 
43  void setServer(const ServerInfo &server)
44  { mServer = server; }
45 
47  { return mServer; }
48 
49  virtual void connect() const = 0;
50 
51  virtual bool isConnected() const A_WARN_UNUSED = 0;
52 
53  virtual void disconnect() const = 0;
54 
55  virtual bool isRegistrationEnabled() const A_WARN_UNUSED = 0;
56 
57  virtual void getRegistrationDetails() const = 0;
58 
59  virtual unsigned int getMinUserNameLength() const A_WARN_UNUSED
60  { return 4; }
61 
62  virtual unsigned int getMaxUserNameLength() const A_WARN_UNUSED
63  { return 25; }
64 
65  virtual unsigned int getMinPasswordLength() const A_WARN_UNUSED
66  { return 4; }
67 
68  virtual unsigned int getMaxPasswordLength() const A_WARN_UNUSED
69  { return 255; }
70 
71  virtual void loginAccount(LoginData *const loginData) const = 0;
72 
73  virtual void logout() const = 0;
74 
75  virtual void changeEmail(const std::string &email) const = 0;
76 
77  virtual void changePassword(const std::string &restrict oldPassword,
78  const std::string &restrict newPassword)
79  const = 0;
80 
81  virtual void chooseServer(unsigned int server,
82  const bool persistentIp) const = 0;
83 
84  virtual void registerAccount(const LoginData *const loginData)
85  const = 0;
86 
87  virtual void unregisterAccount(const std::string &username,
88  const std::string &password) const = 0;
89 
90  virtual const Worlds &getWorlds() const A_WARN_UNUSED = 0;
91 
92  virtual void clearWorlds() const = 0;
93 
94  virtual void loginOrRegister(LoginData *const data) const = 0;
95 
96  virtual void sendVersion() const = 0;
97 
98  virtual void ping() const = 0;
99 
100  virtual void updatePacketVersion() const = 0;
101 
102  virtual void sendMobileCode(const BeingId accountId,
103  const std::string &code) const = 0;
104 
105  virtual void sendOtpCode(const std::string &code) const = 0;
106 
107  virtual ~LoginHandler()
108  { }
109 
110  protected:
112  mServer()
113  {
114  }
115 
117 };
118 
119 } // namespace Net
120 
122 
123 #endif // NET_LOGINHANDLER_H
int BeingId
Definition: beingid.h:30
virtual void chooseServer(unsigned int server, const bool persistentIp) const =0
virtual unsigned int getMinUserNameLength() const
Definition: loginhandler.h:59
virtual void logout() const =0
virtual void updatePacketVersion() const =0
ServerInfo mServer
Definition: loginhandler.h:116
virtual void getRegistrationDetails() const =0
virtual void loginOrRegister(LoginData *const data) const =0
void setServer(const ServerInfo &server)
Definition: loginhandler.h:43
virtual unsigned int getMaxPasswordLength() const
Definition: loginhandler.h:68
virtual void sendOtpCode(const std::string &code) const =0
virtual void connect() const =0
virtual void disconnect() const =0
virtual void clearWorlds() const =0
virtual void ping() const =0
virtual bool isConnected() const =0
virtual const Worlds & getWorlds() const =0
virtual void changeEmail(const std::string &email) const =0
virtual unsigned int getMaxUserNameLength() const
Definition: loginhandler.h:62
virtual bool isRegistrationEnabled() const =0
virtual unsigned int getMinPasswordLength() const
Definition: loginhandler.h:65
virtual void changePassword(const std::string &oldPassword, const std::string &newPassword) const =0
virtual void loginAccount(LoginData *const loginData) const =0
virtual void sendMobileCode(const BeingId accountId, const std::string &code) const =0
virtual void sendVersion() const =0
virtual void unregisterAccount(const std::string &username, const std::string &password) const =0
const ServerInfo & getServer() const
Definition: loginhandler.h:46
virtual void registerAccount(const LoginData *const loginData) const =0
#define restrict
Definition: localconsts.h:165
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
Net::LoginHandler * loginHandler
Definition: net.cpp:90
LoginData loginData
Definition: client.cpp:185
uint32_t data
std::vector< WorldInfo * > Worlds
Definition: worldinfo.h:59