Renamed Profile to OnlineProfile to better distinguish the various profiles we use.
This commit is contained in:
parent
d19b5a2732
commit
7cb7651c07
@ -194,7 +194,7 @@ src/network/types.cpp
|
||||
src/online/current_user.cpp
|
||||
src/online/http_request.cpp
|
||||
src/online/messages.cpp
|
||||
src/online/profile.cpp
|
||||
src/online/online_profile.cpp
|
||||
src/online/profile_manager.cpp
|
||||
src/online/request.cpp
|
||||
src/online/request_manager.cpp
|
||||
@ -527,7 +527,7 @@ src/network/types.hpp
|
||||
src/online/current_user.hpp
|
||||
src/online/http_request.hpp
|
||||
src/online/messages.hpp
|
||||
src/online/profile.hpp
|
||||
src/online/online_profile.hpp
|
||||
src/online/profile_manager.hpp
|
||||
src/online/request.hpp
|
||||
src/online/request_manager.hpp
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
|
@ -22,12 +22,14 @@
|
||||
#ifndef GAME_SETUP_HPP
|
||||
#define GAME_SETUP_HPP
|
||||
|
||||
#include "online/profile.hpp"
|
||||
#include "network/race_config.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace Online { class OnlineProfile; }
|
||||
|
||||
|
||||
/*! \class PlayerProfile
|
||||
* \brief Contains the profile of a player.
|
||||
*/
|
||||
@ -39,7 +41,7 @@ class NetworkPlayerProfile
|
||||
|
||||
uint8_t race_id; //!< The id of the player for the race
|
||||
std::string kart_name; //!< The selected kart.
|
||||
Online::Profile* user_profile; //!< Pointer to the lobby profile
|
||||
Online::OnlineProfile* user_profile; //!< Pointer to the lobby profile
|
||||
uint8_t world_kart_id; //!< the kart id in the World class (pointer to AbstractKart)
|
||||
};
|
||||
|
||||
|
@ -18,14 +18,14 @@
|
||||
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
|
||||
#include "network/network_manager.hpp"
|
||||
#include "network/protocols/start_game_protocol.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
|
||||
#include "modes/world_with_rank.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
#include "network/protocols/start_game_protocol.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "states_screens/network_kart_selection.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
ClientLobbyRoomProtocol::ClientLobbyRoomProtocol(const TransportAddress& server_address)
|
||||
@ -305,7 +305,7 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
|
||||
NetworkPlayerProfile* profile = new NetworkPlayerProfile();
|
||||
profile->kart_name = "";
|
||||
profile->race_id = race_id;
|
||||
profile->user_profile = new Online::Profile(global_id, "");
|
||||
profile->user_profile = new Online::OnlineProfile(global_id, "");
|
||||
m_setup->addPlayer(profile);
|
||||
}
|
||||
else
|
||||
@ -396,7 +396,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
|
||||
uint8_t race_id = data[1];
|
||||
uint32_t global_id = data.gui32(3);
|
||||
Online::Profile* new_user = new Online::Profile(global_id, "");
|
||||
Online::OnlineProfile* new_user = new Online::OnlineProfile(global_id, "");
|
||||
|
||||
NetworkPlayerProfile* profile2 = new NetworkPlayerProfile();
|
||||
profile2->race_id = race_id;
|
||||
|
@ -20,7 +20,8 @@
|
||||
#define GET_PEER_ADDRESS_HPP
|
||||
|
||||
#include "network/protocol.hpp"
|
||||
#include "online/request.hpp"
|
||||
|
||||
namespace Online { class XMLRequest; }
|
||||
|
||||
class GetPeerAddress : public Protocol
|
||||
{
|
||||
|
@ -20,9 +20,11 @@
|
||||
#define HIDE_PUBLIC_ADDRESS_HPP
|
||||
|
||||
#include "network/protocol.hpp"
|
||||
#include "online/request.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Online { class XMLRequest; }
|
||||
|
||||
class HidePublicAddress : public Protocol
|
||||
{
|
||||
public:
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "modes/world.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
#include "utils/time.hpp"
|
||||
|
||||
KartUpdateProtocol::KartUpdateProtocol()
|
||||
: Protocol(NULL, PROTOCOL_KART_UPDATE)
|
||||
|
@ -2,7 +2,8 @@
|
||||
#define QUICK_JOIN_PROTOCOL_HPP
|
||||
|
||||
#include "network/protocol.hpp"
|
||||
#include "online/request.hpp"
|
||||
|
||||
namespace Online { class XMLRequest; }
|
||||
|
||||
class QuickJoinProtocol : public Protocol
|
||||
{
|
||||
|
@ -18,21 +18,21 @@
|
||||
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
|
||||
#include "network/server_network_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
#include "network/protocols/get_public_address.hpp"
|
||||
#include "network/protocols/show_public_address.hpp"
|
||||
#include "network/protocols/connect_to_peer.hpp"
|
||||
#include "network/protocols/start_server.hpp"
|
||||
#include "network/protocols/start_game_protocol.hpp"
|
||||
|
||||
#include "network/server_network_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/random_generator.hpp"
|
||||
#include "utils/time.hpp"
|
||||
|
||||
|
||||
ServerLobbyRoomProtocol::ServerLobbyRoomProtocol() : LobbyRoomProtocol(NULL)
|
||||
@ -386,7 +386,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
NetworkPlayerProfile* profile = new NetworkPlayerProfile();
|
||||
profile->race_id = m_next_id;
|
||||
profile->kart_name = "";
|
||||
profile->user_profile = new Online::Profile(player_id, "");
|
||||
profile->user_profile = new Online::OnlineProfile(player_id, "");
|
||||
m_setup->addPlayer(profile);
|
||||
peer->setPlayerProfile(profile);
|
||||
Log::verbose("ServerLobbyRoomProtocol", "New player.");
|
||||
|
@ -20,9 +20,11 @@
|
||||
#define SHOW_PUBLIC_ADDRESS_HPP
|
||||
|
||||
#include "network/protocol.hpp"
|
||||
#include "online/request.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Online { class XMLRequest; }
|
||||
|
||||
class ShowPublicAddress : public Protocol
|
||||
{
|
||||
public:
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "network/network_world.hpp"
|
||||
#include "network/protocols/synchronization_protocol.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
|
@ -2,7 +2,8 @@
|
||||
#define START_SERVER_HPP
|
||||
|
||||
#include "network/protocol.hpp"
|
||||
#include "online/request.hpp"
|
||||
|
||||
namespace Online { class XMLRequest; }
|
||||
|
||||
/*!
|
||||
* This protocol tells to the database that the server is up and running,
|
||||
|
@ -2,7 +2,8 @@
|
||||
#define STOP_SERVER_HPP
|
||||
|
||||
#include "network/protocol.hpp"
|
||||
#include "online/request.hpp"
|
||||
|
||||
namespace Online { class XMLRequest; }
|
||||
|
||||
/*! \brief Removes the server info from the database
|
||||
*/
|
||||
|
@ -18,16 +18,16 @@
|
||||
|
||||
#include "network/server_network_manager.hpp"
|
||||
|
||||
#include "main_loop.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
#include "network/protocols/get_peer_address.hpp"
|
||||
#include "network/protocols/get_public_address.hpp"
|
||||
#include "network/protocols/hide_public_address.hpp"
|
||||
#include "network/protocols/show_public_address.hpp"
|
||||
#include "network/protocols/get_peer_address.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
#include "network/protocols/stop_server.hpp"
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
|
||||
#include "main_loop.hpp"
|
||||
#include "network/protocols/show_public_address.hpp"
|
||||
#include "network/protocols/stop_server.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/time.hpp"
|
||||
|
||||
#include <enet/enet.h>
|
||||
#include <pthread.h>
|
||||
|
@ -26,8 +26,9 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "guiengine/dialog_queue.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
#include "states_screens/login_screen.hpp"
|
||||
#include "states_screens/dialogs/change_password_dialog.hpp"
|
||||
#include "states_screens/dialogs/user_info_dialog.hpp"
|
||||
@ -188,7 +189,7 @@ namespace Online
|
||||
int username_fetched = input->get("username", &username);
|
||||
uint32_t userid(0);
|
||||
int userid_fetched = input->get("userid", &userid);
|
||||
m_profile = new Profile(userid, username, true);
|
||||
m_profile = new OnlineProfile(userid, username, true);
|
||||
assert(token_fetched && username_fetched && userid_fetched);
|
||||
m_state = US_SIGNED_IN;
|
||||
if(saveSession())
|
||||
@ -409,8 +410,8 @@ namespace Online
|
||||
if(isSuccess())
|
||||
{
|
||||
CurrentUser::get()->getProfile()->addFriend(id);
|
||||
Profile::RelationInfo *info =
|
||||
new Profile::RelationInfo(_("Today"), false, true, false);
|
||||
OnlineProfile::RelationInfo *info =
|
||||
new OnlineProfile::RelationInfo(_("Today"), false, true, false);
|
||||
ProfileManager::get()->getProfileByID(id)->setRelationInfo(info);
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request send!");
|
||||
@ -452,10 +453,10 @@ namespace Online
|
||||
core::stringw info_text("");
|
||||
if(isSuccess())
|
||||
{
|
||||
Profile * profile = ProfileManager::get()->getProfileByID(id);
|
||||
OnlineProfile * profile = ProfileManager::get()->getProfileByID(id);
|
||||
profile->setFriend();
|
||||
Profile::RelationInfo *info =
|
||||
new Profile::RelationInfo(_("Today"), false, false, true);
|
||||
OnlineProfile::RelationInfo *info =
|
||||
new OnlineProfile::RelationInfo(_("Today"), false, false, true);
|
||||
profile->setRelationInfo(info);
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend request accepted!");
|
||||
@ -683,9 +684,9 @@ namespace Online
|
||||
now_online = true;
|
||||
online_friends.erase(iter);
|
||||
}
|
||||
Profile * profile =
|
||||
OnlineProfile * profile =
|
||||
ProfileManager::get()->getProfileByID(friends[i]);
|
||||
Profile::RelationInfo * relation_info =
|
||||
OnlineProfile::RelationInfo * relation_info =
|
||||
profile->getRelationInfo();
|
||||
if( relation_info->isOnline() )
|
||||
{
|
||||
@ -755,9 +756,9 @@ namespace Online
|
||||
const XMLNode * node = getXMLData()->getNode(i);
|
||||
if(node->getName() == "new_friend_request")
|
||||
{
|
||||
Profile::RelationInfo * ri =
|
||||
new Profile::RelationInfo("New", false, true, true);
|
||||
Profile * p = new Profile(node);
|
||||
OnlineProfile::RelationInfo * ri =
|
||||
new OnlineProfile::RelationInfo("New", false, true, true);
|
||||
OnlineProfile * p = new OnlineProfile(node);
|
||||
p->setRelationInfo(ri);
|
||||
ProfileManager::get()->addPersistent(p);
|
||||
friend_request_count++;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "online/request_manager.hpp"
|
||||
#include "online/server.hpp"
|
||||
#include "online/profile.hpp"
|
||||
#include "online/xml_request.hpp"
|
||||
#include "utils/types.hpp"
|
||||
#include "utils/synchronised.hpp"
|
||||
@ -34,6 +33,8 @@
|
||||
namespace Online
|
||||
{
|
||||
|
||||
class OnlineProfile;
|
||||
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
@ -152,7 +153,7 @@ namespace Online
|
||||
std::string m_token;
|
||||
bool m_save_session;
|
||||
UserState m_state;
|
||||
Profile * m_profile;
|
||||
OnlineProfile *m_profile;
|
||||
|
||||
bool saveSession() const { return m_save_session; }
|
||||
|
||||
@ -211,7 +212,7 @@ namespace Online
|
||||
/** Returns the session token of the signed in user. */
|
||||
const std::string & getToken() const { return m_token; }
|
||||
/** Returns a pointer to the profile associated with the current user. */
|
||||
Profile * getProfile() const { return m_profile; }
|
||||
OnlineProfile * getProfile() const { return m_profile; }
|
||||
|
||||
}; // class CurrentUser
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
#include "online/profile.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
@ -35,7 +35,7 @@ using namespace Online;
|
||||
namespace Online
|
||||
{
|
||||
|
||||
Profile::RelationInfo::RelationInfo(const irr::core::stringw & date,
|
||||
OnlineProfile::RelationInfo::RelationInfo(const irr::core::stringw & date,
|
||||
bool is_online, bool is_pending,
|
||||
bool is_asker)
|
||||
{
|
||||
@ -46,7 +46,7 @@ Profile::RelationInfo::RelationInfo(const irr::core::stringw & date,
|
||||
} // RelationInfo::RelationInfo
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void Profile::RelationInfo::setOnline(bool online)
|
||||
void OnlineProfile::RelationInfo::setOnline(bool online)
|
||||
{
|
||||
m_is_online = online;
|
||||
if (m_is_online)
|
||||
@ -57,7 +57,7 @@ void Profile::RelationInfo::setOnline(bool online)
|
||||
/** Constructor for a new profile. It does only store the ID, a name, and
|
||||
* if it is the current user.
|
||||
*/
|
||||
Profile::Profile(const uint32_t & userid,
|
||||
OnlineProfile::OnlineProfile(const uint32_t & userid,
|
||||
const irr::core::stringw & username,
|
||||
bool is_current_user)
|
||||
{
|
||||
@ -81,7 +81,7 @@ Profile::Profile(const uint32_t & userid,
|
||||
* \param type Either C_DEFAULT (no relation), or C_RELATION_INFO
|
||||
* if the XML node contains relation information.
|
||||
*/
|
||||
Profile::Profile(const XMLNode * xml, ConstructorType type)
|
||||
OnlineProfile::OnlineProfile(const XMLNode * xml, ConstructorType type)
|
||||
{
|
||||
m_relation_info = NULL;
|
||||
m_is_friend = false;
|
||||
@ -115,20 +115,20 @@ Profile::Profile(const XMLNode * xml, ConstructorType type)
|
||||
xml->get("user_name", &m_username);
|
||||
m_is_current_user = (m_id == CurrentUser::get()->getID());
|
||||
m_state = S_READY;
|
||||
} // Profile(XMLNode)
|
||||
} // OnlineProfile(XMLNode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
Profile::~Profile()
|
||||
OnlineProfile::~OnlineProfile()
|
||||
{
|
||||
delete m_relation_info;
|
||||
} // ~Profile
|
||||
} // ~OnlineProfile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** 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.
|
||||
*/
|
||||
void Profile::fetchAchievements()
|
||||
void OnlineProfile::fetchAchievements()
|
||||
{
|
||||
assert(CurrentUser::get()->isRegisteredUser());
|
||||
if (m_has_fetched_achievements || m_is_current_user)
|
||||
@ -146,7 +146,7 @@ void Profile::fetchAchievements()
|
||||
{
|
||||
uint32_t user_id = 0;
|
||||
getXMLData()->get("visitingid", &user_id);
|
||||
Profile *profile = ProfileManager::get()->getProfileByID(user_id);
|
||||
OnlineProfile *profile = ProfileManager::get()->getProfileByID(user_id);
|
||||
if (profile)
|
||||
profile->storeAchievements(getXMLData());
|
||||
} // AchievementsRequest::callback
|
||||
@ -168,7 +168,7 @@ void Profile::fetchAchievements()
|
||||
* READY again.
|
||||
* \param input XML node with the achievements data.
|
||||
*/
|
||||
void Profile::storeAchievements(const XMLNode * input)
|
||||
void OnlineProfile::storeAchievements(const XMLNode * input)
|
||||
{
|
||||
m_achievements.clear();
|
||||
std::string achieved_string("");
|
||||
@ -185,7 +185,7 @@ void Profile::storeAchievements(const XMLNode * input)
|
||||
* The state of this profile is changed to be fetching,
|
||||
* and will be reset to ready when the server request returns.
|
||||
*/
|
||||
void Profile::fetchFriends()
|
||||
void OnlineProfile::fetchFriends()
|
||||
{
|
||||
assert(CurrentUser::get()->isRegisteredUser());
|
||||
if (m_has_fetched_friends)
|
||||
@ -201,7 +201,7 @@ void Profile::fetchFriends()
|
||||
{
|
||||
uint32_t user_id = 0;
|
||||
getXMLData()->get("visitingid", &user_id);
|
||||
Profile *profile = ProfileManager::get()->getProfileByID(user_id);
|
||||
OnlineProfile *profile = ProfileManager::get()->getProfileByID(user_id);
|
||||
if (profile)
|
||||
profile->storeFriends(getXMLData());
|
||||
} // callback
|
||||
@ -223,22 +223,23 @@ void Profile::fetchFriends()
|
||||
* to be READY again.
|
||||
* \param input XML node with the friends data.
|
||||
*/
|
||||
void Profile::storeFriends(const XMLNode * input)
|
||||
void OnlineProfile::storeFriends(const XMLNode * input)
|
||||
{
|
||||
const XMLNode * friends_xml = input->getNode("friends");
|
||||
m_friends.clear();
|
||||
for (unsigned int i = 0; i < friends_xml->getNumNodes(); i++)
|
||||
{
|
||||
Profile * profile;
|
||||
OnlineProfile * profile;
|
||||
if (m_is_current_user)
|
||||
{
|
||||
profile = new Profile(friends_xml->getNode(i), C_RELATION_INFO);
|
||||
profile = new OnlineProfile(friends_xml->getNode(i), C_RELATION_INFO);
|
||||
m_friends.push_back(profile->getID());
|
||||
ProfileManager::get()->addPersistent(profile);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile = new Profile(friends_xml->getNode(i)->getNode("user"), C_DEFAULT);
|
||||
profile = new OnlineProfile(friends_xml->getNode(i)->getNode("user"),
|
||||
C_DEFAULT);
|
||||
m_friends.push_back(profile->getID());
|
||||
ProfileManager::get()->addToCache(profile);
|
||||
}
|
||||
@ -251,7 +252,7 @@ void Profile::storeFriends(const XMLNode * input)
|
||||
/** Removed a friend with a given id.
|
||||
* \param id Friend id to remove.
|
||||
*/
|
||||
void Profile::removeFriend(const uint32_t id)
|
||||
void OnlineProfile::removeFriend(const uint32_t id)
|
||||
{
|
||||
assert(m_has_fetched_friends);
|
||||
IDList::iterator iter;
|
||||
@ -271,7 +272,7 @@ void Profile::removeFriend(const uint32_t id)
|
||||
/** Adds a friend to the friend list.
|
||||
* \param id The id of the profile to add.
|
||||
*/
|
||||
void Profile::addFriend(const uint32_t id)
|
||||
void OnlineProfile::addFriend(const uint32_t id)
|
||||
{
|
||||
assert(m_has_fetched_friends);
|
||||
for (unsigned int i = 0; i < m_friends.size(); i++)
|
||||
@ -283,7 +284,7 @@ void Profile::addFriend(const uint32_t id)
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Deletes the relational info for this profile.
|
||||
*/
|
||||
void Profile::deleteRelationalInfo()
|
||||
void OnlineProfile::deleteRelationalInfo()
|
||||
{
|
||||
delete m_relation_info;
|
||||
m_relation_info = NULL;
|
||||
@ -292,7 +293,7 @@ void Profile::deleteRelationalInfo()
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Returns the list of all friend ids.
|
||||
*/
|
||||
const Profile::IDList& Profile::getFriends()
|
||||
const OnlineProfile::IDList& OnlineProfile::getFriends()
|
||||
{
|
||||
assert(m_has_fetched_friends && m_state == S_READY);
|
||||
return m_friends;
|
||||
@ -301,7 +302,7 @@ const Profile::IDList& Profile::getFriends()
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Returns the list of all achievement ids.
|
||||
*/
|
||||
const Profile::IDList& Profile::getAchievements()
|
||||
const OnlineProfile::IDList& OnlineProfile::getAchievements()
|
||||
{
|
||||
assert(m_has_fetched_achievements && m_state == S_READY && !m_is_current_user);
|
||||
return m_achievements;
|
||||
@ -312,7 +313,7 @@ const Profile::IDList& Profile::getAchievements()
|
||||
* 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 Profile::merge(Profile * profile)
|
||||
void OnlineProfile::merge(OnlineProfile *profile)
|
||||
{
|
||||
assert(profile != NULL);
|
||||
if (!this->m_has_fetched_friends && profile->m_has_fetched_friends)
|
@ -37,7 +37,7 @@ namespace Online
|
||||
* are managed by the ProfileManager.
|
||||
* \ingroup online
|
||||
*/
|
||||
class Profile
|
||||
class OnlineProfile
|
||||
{
|
||||
public:
|
||||
enum ConstructorType
|
||||
@ -104,12 +104,12 @@ private:
|
||||
void storeAchievements(const XMLNode * input);
|
||||
|
||||
public:
|
||||
Profile(const uint32_t & userid,
|
||||
OnlineProfile(const uint32_t & userid,
|
||||
const irr::core::stringw & username,
|
||||
bool is_current_user = false );
|
||||
Profile(const XMLNode * xml,
|
||||
OnlineProfile(const XMLNode * xml,
|
||||
ConstructorType type = C_DEFAULT);
|
||||
~Profile();
|
||||
~OnlineProfile();
|
||||
void fetchFriends();
|
||||
const IDList& getFriends();
|
||||
void fetchAchievements();
|
||||
@ -117,7 +117,7 @@ public:
|
||||
void addFriend(const uint32_t id);
|
||||
void deleteRelationalInfo();
|
||||
const IDList& getAchievements();
|
||||
void merge(Profile * profile);
|
||||
void merge(OnlineProfile * profile);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the achievements for this profile have been fetched. */
|
||||
bool hasFetchedAchievements() const { return m_has_fetched_achievements; }
|
||||
@ -157,7 +157,7 @@ public:
|
||||
const irr::core::stringw& getUserName() const { return m_username; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
}; // class Profile
|
||||
}; // class OnlineProfile
|
||||
|
||||
} // namespace Online
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "online/profile_manager.hpp"
|
||||
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -82,7 +83,7 @@ int ProfileManager::guaranteeCacheSize(unsigned int min_num)
|
||||
* FIXME: This should be improved to download the profile is necessary.
|
||||
* \param id The id of the profile to find.
|
||||
*/
|
||||
Profile * ProfileManager::getProfileByID(const uint32_t id)
|
||||
OnlineProfile* ProfileManager::getProfileByID(const uint32_t id)
|
||||
{
|
||||
if (inPersistent(id))
|
||||
return m_profiles_persistent[id];
|
||||
@ -100,7 +101,7 @@ Profile * ProfileManager::getProfileByID(const uint32_t id)
|
||||
* with any new information from the given profile. Otherwise, the profile
|
||||
* is just added to the cache.
|
||||
*/
|
||||
void ProfileManager::addToCache(Profile * profile)
|
||||
void ProfileManager::addToCache(OnlineProfile * profile)
|
||||
{
|
||||
if (inPersistent(profile->getID()))
|
||||
m_profiles_persistent[profile->getID()]->merge(profile);
|
||||
@ -118,7 +119,7 @@ void ProfileManager::addToCache(Profile * profile)
|
||||
* the RaceResultGUI to leave the race running (for the end animation) while
|
||||
* the results are being shown.
|
||||
*/
|
||||
void ProfileManager::addDirectToCache(Profile* profile)
|
||||
void ProfileManager::addDirectToCache(OnlineProfile* profile)
|
||||
{
|
||||
assert(profile != NULL);
|
||||
if (m_profiles_cache.size() == m_max_cache_size)
|
||||
@ -168,7 +169,7 @@ bool ProfileManager::isInCache(const uint32_t id)
|
||||
* probability that most often used entries will remain in the cache,
|
||||
* without adding much overhead.
|
||||
*/
|
||||
void ProfileManager::updateCacheBits(Profile * profile)
|
||||
void ProfileManager::updateCacheBits(OnlineProfile * profile)
|
||||
{
|
||||
profile->setCacheBit(true);
|
||||
if (m_profiles_cache.size() == m_max_cache_size)
|
||||
@ -208,7 +209,7 @@ bool ProfileManager::inPersistent(const uint32_t id)
|
||||
* the friends, while the other could have fetched the achievements.)
|
||||
* \param profile The profile to make persistent.
|
||||
*/
|
||||
void ProfileManager::addPersistent(Profile * profile)
|
||||
void ProfileManager::addPersistent(OnlineProfile * profile)
|
||||
{
|
||||
if (inPersistent(profile->getID()))
|
||||
{
|
||||
@ -260,7 +261,7 @@ void ProfileManager::moveToCache(const uint32_t id)
|
||||
{
|
||||
if (inPersistent(id))
|
||||
{
|
||||
Profile * profile = getProfileByID(id);
|
||||
OnlineProfile * profile = getProfileByID(id);
|
||||
m_profiles_persistent.erase(id);
|
||||
addToCache(profile);
|
||||
}
|
||||
|
@ -20,16 +20,18 @@
|
||||
#define HEADER_ONLINE_PROFILE_MANAGER_HPP
|
||||
|
||||
#include "utils/types.hpp"
|
||||
#include "online/profile.hpp"
|
||||
|
||||
|
||||
#include <irrString.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace Online
|
||||
{
|
||||
|
||||
class OnlineProfile;
|
||||
|
||||
/** Class that manages all online profiles. Profiles are used for storing
|
||||
* online information from local users, but also to store information about
|
||||
* remote users (e.g. if you want to see the achievements of another user
|
||||
@ -48,7 +50,7 @@ private:
|
||||
~ProfileManager();
|
||||
|
||||
/** The mapping of ids to profile. */
|
||||
typedef std::map<uint32_t, Profile*> ProfilesMap;
|
||||
typedef std::map<uint32_t, OnlineProfile*> ProfilesMap;
|
||||
|
||||
/** A map of profiles that is persistent. (i.e. no automatic
|
||||
* removing happens) Normally used for the current user's profile
|
||||
@ -62,15 +64,15 @@ private:
|
||||
|
||||
/** A temporary profile that is currently being 'visited',
|
||||
* e.g. its data is shown in a gui. */
|
||||
Profile* m_currently_visiting;
|
||||
OnlineProfile* m_currently_visiting;
|
||||
|
||||
/** The max size of the m_profiles cache. Its default size can be
|
||||
* inrceased when necessary (e.g. when too many search results are
|
||||
* loaded, to make sure they can be all stored). */
|
||||
unsigned int m_max_cache_size;
|
||||
|
||||
void updateCacheBits(Profile * profile);
|
||||
void addDirectToCache(Profile * profile);
|
||||
void updateCacheBits(OnlineProfile * profile);
|
||||
void addDirectToCache(OnlineProfile * profile);
|
||||
|
||||
public:
|
||||
/** Create the singleton instance. */
|
||||
@ -98,15 +100,15 @@ public:
|
||||
} // destroy
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
void addToCache(Profile * profile);
|
||||
void addPersistent(Profile * profile);
|
||||
void addToCache(OnlineProfile *profile);
|
||||
void addPersistent(OnlineProfile *profile);
|
||||
void deleteFromPersistent(const uint32_t id);
|
||||
void clearPersistent();
|
||||
void moveToCache(const uint32_t id);
|
||||
int guaranteeCacheSize(unsigned int max_num);
|
||||
bool isInCache(const uint32_t id);
|
||||
bool inPersistent(const uint32_t id);
|
||||
Profile* getProfileByID(const uint32_t id);
|
||||
OnlineProfile* getProfileByID(const uint32_t id);
|
||||
// ----------------------------------------------------------------
|
||||
/** Marks a given profile to be the currently visited one. This
|
||||
* is used to mark the profiles that ave its data display (e.g.
|
||||
@ -118,7 +120,7 @@ public:
|
||||
// ----------------------------------------------------------------
|
||||
/** \return the instance of the profile that's currently being
|
||||
* visited */
|
||||
Profile* getVisitingProfile() { return m_currently_visiting; }
|
||||
OnlineProfile* getVisitingProfile() { return m_currently_visiting; }
|
||||
|
||||
}; // class CurrentUser
|
||||
|
||||
|
@ -17,15 +17,15 @@
|
||||
|
||||
#include "states_screens/dialogs/user_info_dialog.hpp"
|
||||
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/online_profile_overview.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "online/messages.hpp"
|
||||
#include "states_screens/online_profile_overview.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
using namespace GUIEngine;
|
||||
using namespace irr;
|
||||
@ -93,7 +93,7 @@ void UserInfoDialog::beforeAddingWidgets()
|
||||
m_remove_widget->setVisible(true);
|
||||
}
|
||||
|
||||
Profile::RelationInfo * relation_info = m_profile->getRelationInfo();
|
||||
OnlineProfile::RelationInfo * relation_info = m_profile->getRelationInfo();
|
||||
if(relation_info != NULL)
|
||||
{
|
||||
if(relation_info->isPending())
|
||||
|
@ -19,14 +19,13 @@
|
||||
#ifndef HEADER_USER_INFO_DIALOG_HPP
|
||||
#define HEADER_USER_INFO_DIALOG_HPP
|
||||
|
||||
#include <irrString.h>
|
||||
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/widgets.hpp"
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/profile_manager.hpp"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <irrString.h>
|
||||
|
||||
/**
|
||||
* \brief Dialog that allows a user to sign in
|
||||
@ -45,7 +44,7 @@ private:
|
||||
irr::core::stringw m_info;
|
||||
|
||||
const uint32_t m_showing_id;
|
||||
Online::Profile * m_profile;
|
||||
Online::OnlineProfile * m_profile;
|
||||
|
||||
GUIEngine::LabelWidget * m_name_widget;
|
||||
GUIEngine::LabelWidget * m_info_widget;
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "modes/overworld.hpp"
|
||||
#include "online/profile.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "states_screens/race_setup_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@ -191,7 +191,7 @@ void PlayerNameSpinner::markAsCorrect()
|
||||
|
||||
PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
StateManager::ActivePlayer* associated_player,
|
||||
Online::Profile* associated_user,
|
||||
Online::OnlineProfile* associated_user,
|
||||
core::recti area, const int player_id,
|
||||
std::string kart_group,
|
||||
const int irrlicht_widget_id) : Widget(WTYPE_DIV)
|
||||
|
@ -19,15 +19,17 @@
|
||||
#ifndef KART_SELECTION_INCLUDED
|
||||
#define KART_SELECTION_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/model_view_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
#include <IGUIImage.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
class Widget;
|
||||
@ -38,7 +40,9 @@ namespace GUIEngine
|
||||
namespace Online
|
||||
{
|
||||
class User;
|
||||
class OnlineProfile;
|
||||
}
|
||||
|
||||
class InputDevice;
|
||||
class PlayerKartWidget;
|
||||
class KartHoverListener;
|
||||
@ -247,7 +251,7 @@ class PlayerKartWidget : public GUIEngine::Widget,
|
||||
int m_player_id;
|
||||
|
||||
/** Network info about the user. */
|
||||
Online::Profile* m_associated_user;
|
||||
Online::OnlineProfile* m_associated_user;
|
||||
|
||||
/** Internal name of the spinner; useful to interpret spinner events,
|
||||
* which contain the name of the activated object */
|
||||
@ -278,7 +282,7 @@ public:
|
||||
|
||||
PlayerKartWidget(KartSelectionScreen* parent,
|
||||
StateManager::ActivePlayer* associated_player,
|
||||
Online::Profile* associated_user,
|
||||
Online::OnlineProfile* associated_user,
|
||||
core::recti area, const int player_id,
|
||||
std::string kart_group,
|
||||
const int irrlicht_idget_id=-1);
|
||||
|
@ -24,11 +24,12 @@
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "online/messages.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "states_screens/dialogs/message_dialog.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/dialogs/user_info_dialog.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "online/messages.hpp"
|
||||
|
||||
#include <IGUIButton.h>
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "states_screens/online_profile_overview.hpp"
|
||||
|
@ -48,7 +48,7 @@ protected:
|
||||
GUIEngine::IconButtonWidget * m_settings_tab;
|
||||
|
||||
/** The profile that should be shown. */
|
||||
Online::Profile *m_visiting_profile;
|
||||
Online::OnlineProfile *m_visiting_profile;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -115,11 +115,11 @@ void OnlineProfileFriends::eventCallback(Widget* widget,
|
||||
void OnlineProfileFriends::displayResults()
|
||||
{
|
||||
m_friends_list_widget->clear();
|
||||
const Profile::IDList &friends = m_visiting_profile->getFriends();
|
||||
const OnlineProfile::IDList &friends = m_visiting_profile->getFriends();
|
||||
for (unsigned int i = 0; i < friends.size(); i++)
|
||||
{
|
||||
std::vector<ListWidget::ListCell> row;
|
||||
Profile* friend_profile =
|
||||
OnlineProfile* friend_profile =
|
||||
ProfileManager::get()->getProfileByID(friends[i]);
|
||||
|
||||
// When looking at friends of a friend those profiles are not
|
||||
@ -134,7 +134,7 @@ void OnlineProfileFriends::displayResults()
|
||||
-1, 2) );
|
||||
if (m_visiting_profile->isCurrentUser())
|
||||
{
|
||||
Profile::RelationInfo * relation_info =
|
||||
OnlineProfile::RelationInfo * relation_info =
|
||||
friend_profile->getRelationInfo();
|
||||
row.push_back(ListWidget::ListCell(relation_info->getDate(),
|
||||
-1, 1, true) );
|
||||
|
@ -152,7 +152,7 @@ void OnlineUserSearch::parseResult(const XMLNode * input)
|
||||
}
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
{
|
||||
Profile * profile = new Profile(users_xml->getNode(i));
|
||||
OnlineProfile * profile = new OnlineProfile(users_xml->getNode(i));
|
||||
// The id must be pushed before adding it to the cache, since
|
||||
// the cache might merge the new data with an existing entry
|
||||
m_users.push_back(profile->getID());
|
||||
@ -169,7 +169,7 @@ void OnlineUserSearch::showList()
|
||||
for (unsigned int i=0; i < m_users.size(); i++)
|
||||
{
|
||||
std::vector<GUIEngine::ListWidget::ListCell> row;
|
||||
Profile * profile = ProfileManager::get()->getProfileByID(m_users[i]);
|
||||
OnlineProfile * profile = ProfileManager::get()->getProfileByID(m_users[i]);
|
||||
// This could still happen if something pushed results out of the cache.
|
||||
if (!profile)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets.hpp"
|
||||
#include "online/profile.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "online/request.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
@ -57,7 +57,7 @@ private:
|
||||
irr::core::stringw m_last_search_string;
|
||||
|
||||
/** The list of all IDs found. */
|
||||
Online::Profile::IDList m_users;
|
||||
Online::OnlineProfile::IDList m_users;
|
||||
|
||||
/** The online request to search for users. */
|
||||
Online::XMLRequest *m_search_request;
|
||||
|
@ -101,7 +101,9 @@ void StateManager::updateActivePlayerIDs()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int StateManager::createActivePlayer(PlayerProfile *profile, InputDevice *device, Online::Profile* user)
|
||||
int StateManager::createActivePlayer(PlayerProfile *profile,
|
||||
InputDevice *device,
|
||||
Online::OnlineProfile* user)
|
||||
{
|
||||
ActivePlayer *p;
|
||||
int i;
|
||||
@ -253,7 +255,7 @@ void StateManager::onStackEmptied()
|
||||
|
||||
StateManager::ActivePlayer::ActivePlayer(PlayerProfile* player,
|
||||
InputDevice *device,
|
||||
Online::Profile* user)
|
||||
Online::OnlineProfile* user)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xAC1EF1AE;
|
||||
|
@ -36,7 +36,7 @@ class InputDevice;
|
||||
struct Input;
|
||||
namespace Online
|
||||
{
|
||||
class Profile;
|
||||
class OnlineProfile;
|
||||
}
|
||||
|
||||
namespace GUIEngine
|
||||
@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
friend class StateManager;
|
||||
|
||||
Online::Profile *m_online_user;
|
||||
Online::OnlineProfile *m_online_user;
|
||||
PlayerProfile *m_player;
|
||||
InputDevice *m_device;
|
||||
|
||||
@ -86,7 +86,8 @@ public:
|
||||
/** ID of this player within the list of active players */
|
||||
int m_id;
|
||||
|
||||
ActivePlayer(PlayerProfile* player, InputDevice* device, Online::Profile* user);
|
||||
ActivePlayer(PlayerProfile* player, InputDevice* device,
|
||||
Online::OnlineProfile* user);
|
||||
|
||||
#ifdef DEBUG
|
||||
unsigned int m_magic_number;
|
||||
@ -128,14 +129,17 @@ public:
|
||||
void setPlayerProfile(PlayerProfile* player);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
Online::Profile* getOnlineUser()
|
||||
Online::OnlineProfile* getOnlineUser()
|
||||
{
|
||||
return m_online_user;
|
||||
}
|
||||
} // getOnlineUser
|
||||
// --------------------------------------------------------------------
|
||||
/** Call to change the identity of this player (useful when player is
|
||||
* selecting his identity) */
|
||||
void setOnlineUser(Online::Profile* user) { m_online_user = user; }
|
||||
void setOnlineUser(Online::OnlineProfile* user)
|
||||
{
|
||||
m_online_user = user;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/** ID of this player within the list of active players */
|
||||
@ -193,7 +197,8 @@ public:
|
||||
*/
|
||||
const PlayerProfile* getActivePlayerProfile(const int id);
|
||||
|
||||
int createActivePlayer(PlayerProfile *profile, InputDevice *device, Online::Profile* use);
|
||||
int createActivePlayer(PlayerProfile *profile, InputDevice *device,
|
||||
Online::OnlineProfile* use);
|
||||
void removeActivePlayer(int id);
|
||||
|
||||
unsigned int activePlayerCount();
|
||||
|
Loading…
Reference in New Issue
Block a user