Moved canceling of friend requests into UserInfoDialog.

This commit is contained in:
hiker 2014-04-04 08:15:48 +11:00
parent e8e4b7ad5f
commit dcba93aa7e
3 changed files with 37 additions and 48 deletions

View File

@ -335,45 +335,6 @@ namespace Online
return request;
} // requestUserSearch
// ------------------------------------------------------------------------
void CurrentUser::requestCancelFriend(const uint32_t friend_id) const
{
assert(m_state == US_SIGNED_IN);
CurrentUser::CancelFriendRequest * request =
new CurrentUser::CancelFriendRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "cancel-friend-request");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("friendid", friend_id);
request->queue();
} // requestCancelFriend
// ------------------------------------------------------------------------
/** Callback for the request to cancel a friend invitation. Shows a
* confirmation message and takes care of updating all the cached
* information.
*/
void CurrentUser::CancelFriendRequest::callback()
{
uint32_t id(0);
getXMLData()->get("friendid", &id);
core::stringw info_text("");
if(isSuccess())
{
CurrentUser::get()->getProfile()->removeFriend(id);
ProfileManager::get()->moveToCache(id);
ProfileManager::get()->getProfileByID(id)->deleteRelationalInfo();
OnlineProfileFriends::getInstance()->refreshFriendsList();
info_text = _("Friend request cancelled!");
}
else
info_text = getInfo();
UserInfoDialog *dia = new UserInfoDialog(id, info_text,!isSuccess(),
true);
GUIEngine::DialogQueue::get()->pushDialog(dia, true);
} // CancelFriendRequest::callback
// ------------------------------------------------------------------------
/** A request to the server, to change the password of the signed in user.
* \param current_password The active password of the currently signed in

View File

@ -87,13 +87,6 @@ namespace Online
SetAddonVoteRequest() : XMLRequest() {}
}; // SetAddonVoteRequest
// ----------------------------------------------------------------
class CancelFriendRequest : public XMLRequest {
virtual void callback ();
public:
CancelFriendRequest() : XMLRequest(true) {}
}; // CancelFriendRequest
// ----------------------------------------------------------------
class PollRequest : public XMLRequest {
virtual void callback ();
@ -140,7 +133,6 @@ namespace Online
const XMLRequest * requestGetAddonVote(const std::string & addon_id) const;
const SetAddonVoteRequest * requestSetAddonVote(const std::string & addon_id, float rating) const;
void requestFriendRequest(const uint32_t friend_id) const;
void requestCancelFriend(const uint32_t friend_id) const;
void requestPasswordChange( const irr::core::stringw &current_password,
const irr::core::stringw &new_password,
const irr::core::stringw &new_password_ver) const;

View File

@ -327,8 +327,44 @@ void UserInfoDialog::removeExistingFriend()
*/
void UserInfoDialog::removePendingFriend()
{
CurrentUser::get()->requestCancelFriend(m_profile->getID());
class CancelFriendRequest : public XMLRequest
{
// ------------------------------------------------------------------------
/** Callback for the request to cancel a friend invitation. Shows a
* confirmation message and takes care of updating all the cached
* information.
*/
virtual void callback()
{
uint32_t id(0);
getXMLData()->get("friendid", &id);
core::stringw info_text("");
if (isSuccess())
{
CurrentUser::get()->getProfile()->removeFriend(id);
ProfileManager *pm = ProfileManager::get();
pm->moveToCache(id);
pm->getProfileByID(id)->deleteRelationalInfo();
OnlineProfileFriends::getInstance()->refreshFriendsList();
info_text = _("Friend request cancelled!");
}
else
info_text = getInfo();
UserInfoDialog *dia = new UserInfoDialog(id, info_text,
!isSuccess(), true);
GUIEngine::DialogQueue::get()->pushDialog(dia, true);
} // callback
public:
CancelFriendRequest() : XMLRequest(true) {}
}; // CancelFriendRequest
// ------------------------------------------------------------------------
CancelFriendRequest * request = new CancelFriendRequest();
CurrentUser::get()->setUserDetails(request);
request->addParameter("action", "cancel-friend-request");
request->addParameter("friendid", m_profile->getID());
request->queue();
} // removePendingFriend
// -----------------------------------------------------------------------------