From c687151d11bb374d37ea9d5b5c00e43913d4378d Mon Sep 17 00:00:00 2001 From: unitraxx Date: Sun, 11 Aug 2013 19:47:25 +0000 Subject: [PATCH] Stable version of profile where your friends are actually showed with their username in a small list. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13459 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/gui/online/profile_friends.stkgui | 4 ++-- data/gui/online/profile_overview.stkgui | 4 ++-- src/online/current_user.cpp | 13 ------------- src/online/current_user.hpp | 3 --- src/online/profile.cpp | 21 ++++++++++++++++++--- src/online/profile.hpp | 1 + 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/data/gui/online/profile_friends.stkgui b/data/gui/online/profile_friends.stkgui index cf7755b6f..5f3fb1423 100644 --- a/data/gui/online/profile_friends.stkgui +++ b/data/gui/online/profile_friends.stkgui @@ -7,8 +7,8 @@ - - + + diff --git a/data/gui/online/profile_overview.stkgui b/data/gui/online/profile_overview.stkgui index 1b9d1ab14..f01d76f54 100644 --- a/data/gui/online/profile_overview.stkgui +++ b/data/gui/online/profile_overview.stkgui @@ -7,8 +7,8 @@ - - + + diff --git a/src/online/current_user.cpp b/src/online/current_user.cpp index 5829ede7b..36802d206 100644 --- a/src/online/current_user.cpp +++ b/src/online/current_user.cpp @@ -218,19 +218,6 @@ namespace Online{ CurrentUser::get()->signOut(m_success, m_result); } - // ============================================================================ - const Profile::FriendsListRequest * CurrentUser::requestFriendsOf(const uint32_t visiting_id){ - assert(isRegisteredUser()); - Profile::FriendsListRequest * request = new Profile::FriendsListRequest(); - request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php"); - request->setParameter("action",std::string("get-friends-list")); - request->setParameter("token", getToken()); - request->setParameter("userid", getUserID()); - request->setParameter("visitingid", visiting_id); - HTTPManager::get()->addRequest(request); - return request; - } - // ============================================================================ CurrentUser::ServerJoinRequest * CurrentUser::requestServerJoin(uint32_t server_id, diff --git a/src/online/current_user.hpp b/src/online/current_user.hpp index d51dda35e..48b9e9cee 100644 --- a/src/online/current_user.hpp +++ b/src/online/current_user.hpp @@ -139,9 +139,6 @@ namespace Online{ const XMLRequest * requestGetAddonVote(const std::string & addon_id) const; const setAddonVoteRequest * requestSetAddonVote(const std::string & addon_id, float rating) const; - - const Profile::FriendsListRequest * requestFriendsOf(const uint32_t visiting_id); - /** Returns the username if signed in. */ const irr::core::stringw getUserName() const; const UserState getUserState() const { return m_state.getAtomic(); } diff --git a/src/online/profile.cpp b/src/online/profile.cpp index f45ddc077..1439ff92d 100644 --- a/src/online/profile.cpp +++ b/src/online/profile.cpp @@ -20,6 +20,8 @@ #include "online/profile.hpp" #include "online/profile_manager.hpp" +#include "online/http_manager.hpp" +#include "config/user_config.hpp" #include "online/current_user.hpp" #include "utils/log.hpp" #include "utils/translation.hpp" @@ -55,20 +57,21 @@ namespace Online{ if(m_has_fetched_friends) return; setState (S_FETCHING); - m_friends_list_request = CurrentUser::get()->requestFriendsOf(m_id); + m_friends_list_request = requestFriendsList(); } // ============================================================================ void Profile::friendsListCallback(const XMLNode * input) { - uint32_t friendid(0); - irr::core::stringw username("check"); const XMLNode * friends_xml = input->getNode("friends"); m_friends.clearAndDeleteAll(); + uint32_t friendid(0); + irr::core::stringw username(""); for (unsigned int i = 0; i < friends_xml->getNumNodes(); i++) { friends_xml->getNode(i)->get("friend_id", &friendid); + friends_xml->getNode(i)->get("friend_name", &username); m_friends.push_back(new User(username, friendid)); } m_has_fetched_friends = true; @@ -78,6 +81,18 @@ namespace Online{ // ============================================================================ + const Profile::FriendsListRequest * Profile::requestFriendsList() + { + FriendsListRequest * request = new FriendsListRequest(); + request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php"); + request->setParameter("action",std::string("get-friends-list")); + request->setParameter("token", CurrentUser::get()->getToken()); + request->setParameter("userid", CurrentUser::get()->getUserID()); + request->setParameter("visitingid", m_id); + HTTPManager::get()->addRequest(request); + return request; + } + void Profile::FriendsListRequest::callback() { uint32_t user_id(0); diff --git a/src/online/profile.hpp b/src/online/profile.hpp index 2e4b581af..0a3f6b539 100644 --- a/src/online/profile.hpp +++ b/src/online/profile.hpp @@ -71,6 +71,7 @@ namespace Online{ void setState(State state) { m_state.setAtomic(state); } const State getState() const { return m_state.getAtomic(); } + const FriendsListRequest * requestFriendsList(); void friendsListCallback(const XMLNode * input); public: