SuperTuxKart
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. More...
 
- 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. More...
 
 PlayerProfile (const XMLNode *node)
 Constructor to deserialize player data that was saved to a XML file. More...
 
void save (UTFWriter &out)
 Writes the data for this player to the specified UTFWriter. More...
 
void loadRemainingData (const XMLNode *node)
 This function loads the achievement and story mode data. More...
 
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. More...
 
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. More...
 
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. More...
 
void clearSession (bool save=true)
 Unsets any saved session data. More...
 
void addIcon ()
 Creates an icon for a player if non exist so far. More...
 
const std::string getIconFilename () const
 Returns the name of the icon file for this player. More...
 
void setName (const core::stringw &name)
 Sets the name of this player. More...
 
const core::stringw & getName () const
 Returns the name of this player. More...
 
bool isGuestAccount () const
 Returns true if this player is a guest account. More...
 
const core::stringw & getLastOnlineName () const
 Returns the last used online name. More...
 
void setLastOnlineName (const core::stringw &name)
 Sets the last used online name. More...
 
unsigned int getUniqueID () const
 Returns the unique id of this player. More...
 
bool isLocked (const std::string &feature) const
 Returnes if the feature (kart, track) is locked. More...
 
void computeActive ()
 Returns all active challenges. More...
 
std::vector< const ChallengeData * > getRecentlyCompletedChallenges ()
 Returns the list of recently completed challenges. More...
 
void setCurrentChallenge (const std::string &name)
 Sets the currently active challenge. More...
 
void grandPrixFinished ()
 Callback when a GP is finished (to test if a challenge was fulfilled). More...
 
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. More...
 
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. More...
 
StoryModeStatusgetStoryModeStatus ()
 
int getSavedUserId () const
 If a session was saved, return the id of the saved user. More...
 
const std::string & getSavedToken () const
 If a session was saved, return the token to use. More...
 
bool wasOnlineLastTime () const
 Returns if the last time this player was used it was used online or offline. More...
 
void setWasOnlineLastTime (bool b)
 Sets if this player was logged in last time it was used. More...
 
bool rememberPassword () const
 Returns if the last time this player was used it was used online or offline. More...
 
void setRememberPassword (bool b)
 Sets if this player was logged in last time it was used. More...
 
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. More...
 
virtual void signOut (bool success, const XMLNode *input, const irr::core::stringw &info)
 Callback once the logout event has been processed. More...
 
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. More...
 
virtual void requestPoll () const
 Sends a request to the server to see if any new information is available. More...
 
virtual bool isLoggedIn () const
 Returns if this user is logged in. More...
 
PlayerProfile::OnlineState getOnlineState () const
 The online state of the player (i.e. More...
 
const std::string & getToken () const
 Returns the session token of the signed in user. More...
 
virtual void requestSavedSession ()
 Request a login using the saved credentials of the user. More...
 
virtual void requestSignOut ()
 Requests a sign out from the server. More...
 
virtual void requestSignIn (const irr::core::stringw &username, const irr::core::stringw &password)
 Create a signin request. More...
 

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. More...
 

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.

◆ getToken()

const std::string& Online::OnlinePlayerProfile::getToken ( ) const
inlineprivate

Returns the session token of the signed in user.

◆ 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: