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: