Remove friend and cancel request added in the client. Server-side still need to be implemented.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13553 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
ed7b4b875a
commit
bfc32bdd14
@ -21,6 +21,8 @@
|
||||
<spacer height="20" width="50">
|
||||
|
||||
<buttonbar id="options" width="90%" height="20%" align="center">
|
||||
<icon-button id="remove" width="64" height="64" icon="gui/package-uninstall.png"
|
||||
I18N="User info dialog" text="Remove" label_location="bottom"/>
|
||||
<icon-button id="friend" width="64" height="64" icon="gui/main_help.png"
|
||||
I18N="User info dialog" text="Add Friend" label_location="bottom"/>
|
||||
<icon-button id="accept" width="64" height="64" icon="gui/green_check.png"
|
||||
|
@ -405,6 +405,72 @@ namespace Online{
|
||||
info_text = m_info;
|
||||
GUIEngine::DialogQueue::get()->pushDialog( new UserInfoDialog(id, info_text,!m_success, true), true);
|
||||
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
void CurrentUser::requestCancelFriend(const uint32_t friend_id) const
|
||||
{
|
||||
assert(isRegisteredUser());
|
||||
CurrentUser::CancelFriendRequest * request = new CurrentUser::CancelFriendRequest();
|
||||
request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
|
||||
request->setParameter("action", std::string("cancel-friend-request"));
|
||||
request->setParameter("token", getToken());
|
||||
request->setParameter("userid", getID());
|
||||
request->setParameter("friendid", friend_id);
|
||||
HTTPManager::get()->addRequest(request);
|
||||
}
|
||||
|
||||
void CurrentUser::CancelFriendRequest::callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
m_result->get("friendid", &id);
|
||||
irr::core::stringw info_text("");
|
||||
if(m_success)
|
||||
{
|
||||
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 = m_info;
|
||||
GUIEngine::DialogQueue::get()->pushDialog( new UserInfoDialog(id, info_text,!m_success, true), true);
|
||||
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
void CurrentUser::requestRemoveFriend(const uint32_t friend_id) const
|
||||
{
|
||||
assert(isRegisteredUser());
|
||||
CurrentUser::RemoveFriendRequest * request = new CurrentUser::RemoveFriendRequest();
|
||||
request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
|
||||
request->setParameter("action", std::string("remove-friend-request"));
|
||||
request->setParameter("token", getToken());
|
||||
request->setParameter("userid", getID());
|
||||
request->setParameter("friendid", friend_id);
|
||||
HTTPManager::get()->addRequest(request);
|
||||
}
|
||||
|
||||
void CurrentUser::RemoveFriendRequest::callback()
|
||||
{
|
||||
uint32_t id(0);
|
||||
m_result->get("friendid", &id);
|
||||
irr::core::stringw info_text("");
|
||||
if(m_success)
|
||||
{
|
||||
CurrentUser::get()->getProfile()->removeFriend(id);
|
||||
ProfileManager::get()->moveToCache(id);
|
||||
ProfileManager::get()->getProfileByID(id)->deleteRelationalInfo();
|
||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||
info_text = _("Friend removed!");
|
||||
}
|
||||
else
|
||||
info_text = m_info;
|
||||
GUIEngine::DialogQueue::get()->pushDialog( new UserInfoDialog(id, info_text,!m_success, true), true);
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
void CurrentUser::requestPoll()
|
||||
|
@ -102,6 +102,18 @@ namespace Online{
|
||||
DeclineFriendRequest() : XMLRequest(true) {}
|
||||
};
|
||||
|
||||
class RemoveFriendRequest : public XMLRequest {
|
||||
virtual void callback ();
|
||||
public:
|
||||
RemoveFriendRequest() : XMLRequest(true) {}
|
||||
};
|
||||
|
||||
class CancelFriendRequest : public XMLRequest {
|
||||
virtual void callback ();
|
||||
public:
|
||||
CancelFriendRequest() : XMLRequest(true) {}
|
||||
};
|
||||
|
||||
class PollRequest : public XMLRequest {
|
||||
virtual void callback ();
|
||||
public:
|
||||
@ -156,6 +168,8 @@ namespace Online{
|
||||
void requestFriendRequest(const uint32_t friend_id) const;
|
||||
void requestAcceptFriend(const uint32_t friend_id) const;
|
||||
void requestDeclineFriend(const uint32_t friend_id) const;
|
||||
void requestRemoveFriend(const uint32_t friend_id) const;
|
||||
void requestCancelFriend(const uint32_t friend_id) const;
|
||||
|
||||
const XMLRequest * requestUserSearch(const irr::core::stringw & search_string) const;
|
||||
|
||||
|
@ -47,6 +47,8 @@ void UserInfoDialog::load()
|
||||
loadFromFile("online/user_info_dialog.stkgui");
|
||||
if(m_error)
|
||||
m_info_widget->setErrorColor();
|
||||
m_name_widget->setText(m_profile->getUserName(),false);
|
||||
m_info_widget->setText(m_info, false);
|
||||
}
|
||||
|
||||
void UserInfoDialog::beforeAddingWidgets()
|
||||
@ -57,12 +59,13 @@ void UserInfoDialog::beforeAddingWidgets()
|
||||
m_processing = false;
|
||||
m_name_widget = getWidget<LabelWidget>("name");
|
||||
assert(m_name_widget != NULL);
|
||||
m_name_widget->setText(m_profile->getUserName(),false);
|
||||
m_info_widget = getWidget<LabelWidget>("info");
|
||||
assert(m_info_widget != NULL);
|
||||
m_info_widget->setText(m_info, false);
|
||||
|
||||
m_options_widget = getWidget<RibbonWidget>("options");
|
||||
assert(m_options_widget != NULL);
|
||||
m_remove_widget = getWidget<IconButtonWidget>("remove");
|
||||
assert(m_remove_widget != NULL);
|
||||
m_friend_widget = getWidget<IconButtonWidget>("friend");
|
||||
assert(m_friend_widget != NULL);
|
||||
m_accept_widget = getWidget<IconButtonWidget>("accept");
|
||||
@ -77,20 +80,35 @@ void UserInfoDialog::beforeAddingWidgets()
|
||||
|
||||
m_accept_widget->setVisible(false);
|
||||
m_decline_widget->setVisible(false);
|
||||
if(m_profile->isFriend() || m_profile->isCurrentUser())
|
||||
m_remove_widget->setVisible(false);
|
||||
if(m_profile->isCurrentUser())
|
||||
{
|
||||
m_friend_widget->setVisible(false);
|
||||
}
|
||||
if(m_profile->isFriend())
|
||||
{
|
||||
m_friend_widget->setVisible(false);
|
||||
m_remove_widget->setVisible(true);
|
||||
}
|
||||
|
||||
Profile::RelationInfo * relation_info = m_profile->getRelationInfo();
|
||||
if(relation_info != NULL)
|
||||
{
|
||||
if(relation_info->isPending() && relation_info->isAsker())
|
||||
{
|
||||
m_accept_widget->setVisible(true);
|
||||
m_decline_widget->setVisible(true);
|
||||
}
|
||||
|
||||
if(relation_info->isPending())
|
||||
{
|
||||
m_friend_widget->setVisible(false);
|
||||
if(relation_info->isAsker())
|
||||
{
|
||||
m_accept_widget->setVisible(true);
|
||||
m_decline_widget->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_remove_widget->setVisible(true);
|
||||
m_remove_widget->setLabel("Cancel");
|
||||
//FIXME set text to cancel?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -126,6 +144,15 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
|
||||
m_processing = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(selection == m_remove_widget->m_properties[PROP_ID])
|
||||
{
|
||||
if(m_profile->getRelationInfo()->isPending())
|
||||
CurrentUser::get()->requestCancelFriend(m_profile->getID());
|
||||
else
|
||||
CurrentUser::get()->requestRemoveFriend(m_profile->getID());
|
||||
m_processing = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(selection == m_accept_widget->m_properties[PROP_ID])
|
||||
{
|
||||
CurrentUser::get()->requestAcceptFriend(m_profile->getID());
|
||||
|
@ -51,6 +51,7 @@ private:
|
||||
GUIEngine::LabelWidget * m_info_widget;
|
||||
|
||||
GUIEngine::RibbonWidget * m_options_widget;
|
||||
GUIEngine::IconButtonWidget * m_remove_widget;
|
||||
GUIEngine::IconButtonWidget * m_friend_widget;
|
||||
GUIEngine::IconButtonWidget * m_accept_widget;
|
||||
GUIEngine::IconButtonWidget * m_decline_widget;
|
||||
|
Loading…
Reference in New Issue
Block a user