SuperTuxKart
|
Class that represents an online profile. More...
#include <online_profile.hpp>
Classes | |
class | RelationInfo |
Public Types | |
enum | ConstructorType { C_DEFAULT = 1 , C_RELATION_INFO } |
typedef std::vector< uint32_t > | IDList |
Public Member Functions | |
OnlineProfile (const uint32_t &userid, const irr::core::stringw &username, bool is_current_user=false) | |
Constructor for a new profile. | |
OnlineProfile (const XMLNode *xml, ConstructorType type=C_DEFAULT) | |
Creates a new profile from an XML Node. | |
void | fetchFriends () |
Triggers an asynchronous request to download the friends for this user. | |
const IDList & | getFriends () |
Returns the list of all friend ids. | |
void | fetchAchievements () |
Triggers an asynchronous request to get the achievements for this user from the server. | |
void | removeFriend (const uint32_t id) |
Removed a friend with a given id. | |
void | addFriend (const uint32_t id) |
Adds a friend to the friend list. | |
void | deleteRelationalInfo () |
Deletes the relational info for this profile. | |
const IDList & | getAchievements () |
Returns the list of all achievement ids. | |
void | merge (OnlineProfile *profile) |
Merges the information from a given profile with this profile. | |
std::map< uint32_t, irr::core::stringw > & | getFriendServerMap () |
bool | hasFetchedAchievements () const |
Returns true if the achievements for this profile have been fetched. | |
void | unsetHasFetchedFriends () |
Unsets the flag that all friends of this profile are in cache. | |
bool | hasFetchedFriends () const |
Returns true if the friend list for this profile has been fetched. | |
bool | finishedFetchingFriends () const |
True if the profile has fetched friends. | |
bool | finishedFetchingAchievements () const |
True if the profile has fetched friends. | |
bool | isCurrentUser () const |
Returns true if this item is the current user. | |
bool | isFriend () const |
void | setFriend () |
RelationInfo * | getRelationInfo () |
void | setRelationInfo (RelationInfo *r) |
void | setCacheBit (bool cache_bit) |
Sets the cache bit of this profile. | |
bool | getCacheBit () const |
Returns the cache bit for this profile. | |
uint32_t | getID () const |
Returns the online id of this profile. | |
const irr::core::stringw & | getUserName () const |
Returns the user name of this profile. | |
Private Types | |
enum | State { S_FETCHING_ACHIEVEMENTS = 0x01 , S_FETCHING_FRIENDS = 0x02 } |
The profile can either be fetching data, or be ready. | |
Private Member Functions | |
void | storeFriends (const XMLNode *input) |
Stores the friends from an XML node into this profile. | |
void | storeAchievements (const XMLNode *input) |
Stores the achievement ids from an XML node into this profile. | |
Private Attributes | |
State | m_state |
bool | m_is_current_user |
uint32_t | m_id |
irr::core::stringw | m_username |
RelationInfo * | m_relation_info |
information about the relation with the current user | |
bool | m_is_friend |
Whether or not the user of this profile, is a friend of the current user. | |
std::atomic_bool | m_has_fetched_friends |
std::vector< uint32_t > | m_friends |
List of user id's that are friends with the user of this profile. | |
bool | m_has_fetched_achievements |
std::vector< uint32_t > | m_achievements |
std::map< uint32_t, irr::core::stringw > | m_friend_server_map |
bool | m_cache_bit |
Class that represents an online profile.
It manages the online profile for any user on this system, but also for users for which information is requested (e.g. to see the achievements of friends). All those profiles are managed by the ProfileManager.
Online::OnlineProfile::OnlineProfile | ( | const uint32_t & | userid, |
const irr::core::stringw & | username, | ||
bool | is_current_user = false |
||
) |
Constructor for a new profile.
It does only store the ID, a name, and if it is the current user.
Online::OnlineProfile::OnlineProfile | ( | const XMLNode * | xml, |
ConstructorType | type = C_DEFAULT |
||
) |
Creates a new profile from an XML Node.
Two different profiles can be created: either a simple one with no relation, or a profile with relation information, i.e. it contains how this profile is related to the current profile.
xml | The XML node with the data to use. |
type | Either C_DEFAULT (no relation), or C_RELATION_INFO if the XML node contains relation information. |
void Online::OnlineProfile::addFriend | ( | const uint32_t | id | ) |
Adds a friend to the friend list.
id | The id of the profile to add. |
void Online::OnlineProfile::fetchAchievements | ( | ) |
Triggers an asynchronous request to get the achievements for this user from the server.
The state of this profile is changed to be fetching, and will be reset to ready when the server request returns.
A simple class that receives the achievements, and calls the right Profile instance to store them.
void Online::OnlineProfile::fetchFriends | ( | ) |
Triggers an asynchronous request to download the friends for this user.
The state of this profile is changed to be fetching, and will be reset to ready when the server request returns.
|
inline |
Returns the cache bit for this profile.
Used by the cache eviction algorithm.
void Online::OnlineProfile::merge | ( | OnlineProfile * | profile | ) |
Merges the information from a given profile with this profile.
Any data that is in the given profile that's not available in this profile will be copied over, then the given profile will be deleted.
void Online::OnlineProfile::removeFriend | ( | const uint32_t | id | ) |
Removed a friend with a given id.
id | Friend id to remove. |
|
inline |
Sets the cache bit of this profile.
Used by the cache eviction algorithm.
|
private |
Stores the achievement ids from an XML node into this profile.
It also sets that achievements have been fetched, and changes the state to be READY again.
input | XML node with the achievements data. |
|
private |
Stores the friends from an XML node into this profile.
It also sets that friends have been fetched, and changes the state of the profile to be READY again.
input | XML node with the friends data. |
|
inline |
Unsets the flag that all friends of this profile are in cache.
Used when a profile is pushed out of cache.
|
private |
List of user id's that are friends with the user of this profile.
In case this profile is of the current user, this list also contains any id's of users that still have a friend request pending.