SuperTuxKart
Loading...
Searching...
No Matches
online_player_profile.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2013-2015 Glenn De Jonghe
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (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, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_CURRENT_ONLINE_USER_HPP
20#define HEADER_CURRENT_ONLINE_USER_HPP
21
22#include "config/player_profile.hpp"
23#include "utils/synchronised.hpp"
24#include "utils/types.hpp"
25
26#include <irrString.h>
27
28#include <string>
29#include <assert.h>
30
31class PlayerManager;
32
33namespace Online
34{
35 class OnlineProfile;
36
42 {
43 private:
44 std::string m_token;
45 OnlineProfile *m_profile;
46
49
50 virtual void signIn(bool success, const XMLNode * input);
51 virtual void signOut(bool success, const XMLNode * input,
52 const irr::core::stringw &info);
53 virtual uint32_t getOnlineId() const;
54 virtual void setUserDetails(std::shared_ptr<HTTPRequest> request,
55 const std::string &action,
56 const std::string &url_path = "") const;
57
58 virtual void requestPoll() const;
59
60 // ----------------------------------------------------------------
62 virtual bool isLoggedIn() const
63 {
64 return m_online_state == PlayerProfile::OS_SIGNED_IN;
65 } // isLoggedIn
66
67 // ----------------------------------------------------------------
71 {
72 return m_online_state;
73 } // getOnlineState
74
75 // ----------------------------------------------------------------
77 const std::string& getToken() const { return m_token; }
78 virtual void requestSavedSession();
79 virtual void requestSignOut();
80 virtual void requestSignIn(const irr::core::stringw &username,
81 const irr::core::stringw &password);
82
83 public:
84 OnlinePlayerProfile(const XMLNode *player);
85 OnlinePlayerProfile(const core::stringw &name, bool is_guest = false);
86 virtual ~OnlinePlayerProfile() {}
87 // ----------------------------------------------------------------
89 OnlineProfile* getProfile() const { return m_profile; }
90 // ----------------------------------------------------------------
91 }; // class OnlinePlayerProfile
92} // namespace Online
93#endif // HEADER_CURRENT_ONLINE_USER_HPP
Class that represents an online registered user.
Definition: online_player_profile.hpp:42
virtual void signOut(bool success, const XMLNode *input, const irr::core::stringw &info)
Callback once the logout event has been processed.
Definition: online_player_profile.cpp:322
OnlineProfile * getProfile() const
Returns a pointer to the profile associated with the current user.
Definition: online_player_profile.hpp:89
virtual void signIn(bool success, const XMLNode *input)
Checks the server respond after a login attempt.
Definition: online_player_profile.cpp:223
virtual void requestPoll() const
Sends a request to the server to see if any new information is available.
Definition: online_player_profile.cpp:359
PlayerProfile::OnlineState getOnlineState() const
The online state of the player (i.e.
Definition: online_player_profile.hpp:70
virtual void requestSavedSession()
Request a login using the saved credentials of the user.
Definition: online_player_profile.cpp:114
const std::string & getToken() const
Returns the session token of the signed in user.
Definition: online_player_profile.hpp:77
virtual void setUserDetails(std::shared_ptr< HTTPRequest > request, const std::string &action, const std::string &url_path="") const
Adds the login credential to a http request.
Definition: online_player_profile.cpp:74
virtual void requestSignIn(const irr::core::stringw &username, const irr::core::stringw &password)
Create a signin request.
Definition: online_player_profile.cpp:135
virtual uint32_t getOnlineId() const
Definition: online_player_profile.cpp:569
virtual bool isLoggedIn() const
Returns if this user is logged in.
Definition: online_player_profile.hpp:62
virtual void requestSignOut()
Requests a sign out from the server.
Definition: online_player_profile.cpp:280
PlayerProfile::OnlineState m_online_state
The state of the player (logged in, logging in, ...)
Definition: online_player_profile.hpp:48
Class that represents an online profile.
Definition: online_profile.hpp:42
A special class that manages all local player accounts.
Definition: player_manager.hpp:56
Class for managing player profiles (name, usage frequency, etc.).
Definition: player_profile.hpp:54
OnlineState
The online state a player can be in.
Definition: player_profile.hpp:58
utility class used to parse XML files
Definition: xml_node.hpp:48
Declares the general types that are used by the network.