SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Online::OnlinePlayerProfile Class Reference

Class that represents an online registered user. More...

#include <online_player_profile.hpp>

Inheritance diagram for Online::OnlinePlayerProfile:
Inheritance graph
[legend]

Public Member Functions

 OnlinePlayerProfile (const XMLNode *player)
 
 OnlinePlayerProfile (const core::stringw &name, bool is_guest=false)
 
OnlineProfilegetProfile () const
 Returns a pointer to the profile associated with the current user.
 
- Public Member Functions inherited from PlayerProfile
 PlayerProfile (const core::stringw &name, bool is_guest=false)
 Constructor to create a new player that didn't exist before.
 
 PlayerProfile (const XMLNode *node)
 Constructor to deserialize player data that was saved to a XML file.
 
void save (UTFWriter &out)
 Writes the data for this player to the specified UTFWriter.
 
void loadRemainingData (const XMLNode *node)
 This function loads the achievement and story mode data.
 
void initRemainingData ()
 Initialises the story- and achievement data structure in case of the first start of STK.
 
void incrementUseFrequency ()
 Increments how often that account was used.
 
int getUseFrequency () const
 
bool operator< (const PlayerProfile &other)
 Comparison used to sort players.
 
void raceFinished ()
 Notification of a finished race, which can trigger fulfilling challenges.
 
void saveSession (int user_id, const std::string &token)
 Saves the online data, so that it will automatically re-connect next time this profile is loaded.
 
void clearSession (bool save=true)
 Unsets any saved session data.
 
void addIcon ()
 Creates an icon for a player if non exist so far.
 
virtual void setUserDetails (std::shared_ptr< Online::HTTPRequest > request, const std::string &action, const std::string &url_path="") const =0
 Abstract virtual classes, to be implemented by the OnlinePlayer.
 
virtual uint32_t getOnlineId () const =0
 
virtual PlayerProfile::OnlineState getOnlineState () const =0
 
virtual Online::OnlineProfilegetProfile () const =0
 
virtual void requestPoll () const =0
 
virtual void requestSavedSession ()=0
 
virtual void requestSignIn (const irr::core::stringw &username, const irr::core::stringw &password)=0
 
virtual void signIn (bool success, const XMLNode *input)=0
 
virtual void signOut (bool success, const XMLNode *input, const irr::core::stringw &info)=0
 
virtual void requestSignOut ()=0
 
virtual bool isLoggedIn () const
 
const std::string getIconFilename () const
 Returns the name of the icon file for this player.
 
void setName (const core::stringw &name)
 Sets the name of this player.
 
const core::stringw & getName () const
 Returns the name of this player.
 
bool isGuestAccount () const
 Returns true if this player is a guest account.
 
const core::stringw & getLastOnlineName () const
 Returns the last used online name.
 
void setLastOnlineName (const core::stringw &name)
 Sets the last used online name.
 
unsigned int getUniqueID () const
 Returns the unique id of this player.
 
bool isLocked (const std::string &feature) const
 Returnes if the feature (kart, track) is locked.
 
void computeActive ()
 Returns all active challenges.
 
std::vector< const ChallengeData * > getRecentlyCompletedChallenges ()
 Returns the list of recently completed challenges.
 
void setCurrentChallenge (const std::string &name)
 Sets the currently active challenge.
 
void grandPrixFinished ()
 Callback when a GP is finished (to test if a challenge was fulfilled).
 
unsigned int getNumCompletedChallenges () const
 
unsigned int getPoints () const
 
unsigned int getPointsBefore () const
 
unsigned int getNextUnlockPoints () const
 
void setFirstTime (bool b)
 
bool isFirstTime () const
 
void setFinished ()
 
bool isFinished () const
 
void setSpeedrunFinished ()
 
bool isSpeedrunFinished ()
 
void setStoryModeTimer (int ms)
 
int getStoryModeTimer ()
 
void setSpeedrunTimer (int ms)
 
int getSpeedrunTimer ()
 
void clearUnlocked ()
 
const ChallengeStatusgetCurrentChallengeStatus () const
 Returns the current challenge for this player.
 
const ChallengeStatusgetChallengeStatus (const std::string &id)
 
unsigned int getNumEasyTrophies () const
 
unsigned int getNumMediumTrophies () const
 
unsigned int getNumHardTrophies () const
 
unsigned int getNumBestTrophies () const
 
AchievementsStatusgetAchievementsStatus ()
 
bool hasSavedSession () const
 Returns true if a session was saved for this player.
 
StoryModeStatusgetStoryModeStatus ()
 
int getSavedUserId () const
 If a session was saved, return the id of the saved user.
 
const std::string & getSavedToken () const
 If a session was saved, return the token to use.
 
bool wasOnlineLastTime () const
 Returns if the last time this player was used it was used online or offline.
 
void setWasOnlineLastTime (bool b)
 Sets if this player was logged in last time it was used.
 
bool rememberPassword () const
 Returns if the last time this player was used it was used online or offline.
 
void setRememberPassword (bool b)
 Sets if this player was logged in last time it was used.
 
void setDefaultKartColor (float c)
 
float getDefaultKartColor () const
 

Private Member Functions

virtual void signIn (bool success, const XMLNode *input)
 Checks the server respond after a login attempt.
 
virtual void signOut (bool success, const XMLNode *input, const irr::core::stringw &info)
 Callback once the logout event has been processed.
 
virtual uint32_t getOnlineId () const
 
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.
 
virtual void requestPoll () const
 Sends a request to the server to see if any new information is available.
 
virtual bool isLoggedIn () const
 Returns if this user is logged in.
 
PlayerProfile::OnlineState getOnlineState () const
 The online state of the player (i.e.
 
const std::string & getToken () const
 Returns the session token of the signed in user.
 
virtual void requestSavedSession ()
 Request a login using the saved credentials of the user.
 
virtual void requestSignOut ()
 Requests a sign out from the server.
 
virtual void requestSignIn (const irr::core::stringw &username, const irr::core::stringw &password)
 Create a signin request.
 

Private Attributes

std::string m_token
 
OnlineProfilem_profile
 
PlayerProfile::OnlineState m_online_state
 The state of the player (logged in, logging in, ...)
 

Additional Inherited Members

- Public Types inherited from PlayerProfile
enum  OnlineState {
  OS_SIGNED_OUT = 0 , OS_SIGNED_IN , OS_GUEST , OS_SIGNING_IN ,
  OS_SIGNING_OUT
}
 The online state a player can be in.
 

Detailed Description

Class that represents an online registered user.

Member Function Documentation

◆ getOnlineId()

uint32_t Online::OnlinePlayerProfile::getOnlineId ( ) const
privatevirtual
Returns
the online id, or 0 if the user is not signed in.

Implements PlayerProfile.

◆ getOnlineState()

PlayerProfile::OnlineState Online::OnlinePlayerProfile::getOnlineState ( ) const
inlineprivatevirtual

The online state of the player (i.e.

logged out, logging in, logged in, ...).

Implements PlayerProfile.

◆ getProfile()

OnlineProfile * Online::OnlinePlayerProfile::getProfile ( ) const
inlinevirtual

Returns a pointer to the profile associated with the current user.

Implements PlayerProfile.

◆ isLoggedIn()

virtual bool Online::OnlinePlayerProfile::isLoggedIn ( ) const
inlineprivatevirtual

Returns if this user is logged in.

Reimplemented from PlayerProfile.

◆ requestPoll()

void Online::OnlinePlayerProfile::requestPoll ( ) const
privatevirtual

Sends a request to the server to see if any new information is available.

(online friends, notifications, etc.).

Implements PlayerProfile.

◆ requestSavedSession()

void Online::OnlinePlayerProfile::requestSavedSession ( )
privatevirtual

Request a login using the saved credentials of the user.

Implements PlayerProfile.

◆ requestSignIn()

void Online::OnlinePlayerProfile::requestSignIn ( const irr::core::stringw &  username,
const irr::core::stringw &  password 
)
privatevirtual

Create a signin request.

Parameters
usernameName of user.
passwordPassword.

Implements PlayerProfile.

◆ requestSignOut()

void Online::OnlinePlayerProfile::requestSignOut ( )
privatevirtual

Requests a sign out from the server.

If the user should be remembered, a 'client-quit' request is sent (which will log the user out, but remember the token), otherwise a 'disconnect' is sent.

Sign out request, which have the highest priority (same as quit-stk request). This allows the final logout request at the end of STK to be handled, even if a quit request gets added (otherwise if quit has higher priority, the quit can be executed before signout, resulting in players not being logged out properly). It also guarantees that the logout happens before a following logout.

Implements PlayerProfile.

◆ setUserDetails()

void Online::OnlinePlayerProfile::setUserDetails ( std::shared_ptr< HTTPRequest request,
const std::string &  action,
const std::string &  url_path = "" 
) const
privatevirtual

Adds the login credential to a http request.

It sets the name of the script to invokce, token, and user id.

Parameters
requestThe http request.
actionthe action performed

Implements PlayerProfile.

◆ signIn()

void Online::OnlinePlayerProfile::signIn ( bool  success,
const XMLNode input 
)
privatevirtual

Checks the server respond after a login attempt.

If the login was successful, it marks the user as logged in, and (if requested) saves data to be able to login next time.

Parameters
successIf the answer from the server indicated a successful login attemp.
inputXml tree with the complete server response.

Implements PlayerProfile.

◆ signOut()

void Online::OnlinePlayerProfile::signOut ( bool  success,
const XMLNode input,
const irr::core::stringw &  info 
)
privatevirtual

Callback once the logout event has been processed.

Parameters
successIf the request was successful.
input

Implements PlayerProfile.


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