Merge branch 'master' of https://github.com/supertuxkart/stk-code
This commit is contained in:
commit
06a3d770e5
@ -66,15 +66,20 @@ namespace Online
|
||||
* to allow for shorter request creation code. It sets the name of
|
||||
* the script to invokce, token, and user id.
|
||||
* \param request The http request.
|
||||
* \param action If not empty, the action to be set.
|
||||
*/
|
||||
void CurrentUser::setUserDetails(HTTPRequest *request)
|
||||
void CurrentUser::setUserDetails(HTTPRequest *request,
|
||||
const std::string &action)
|
||||
{
|
||||
CurrentUser *cu = CurrentUser::get();
|
||||
assert(cu && cu->m_state == US_SIGNED_IN);
|
||||
assert(cu->m_profile);
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("token", cu->m_token);
|
||||
request->addParameter("userid", cu->m_profile->getID());
|
||||
|
||||
if (cu && cu->m_profile)
|
||||
request->addParameter("userid", cu->m_profile->getID());
|
||||
if(cu->m_state == US_SIGNED_IN)
|
||||
request->addParameter("token", cu->m_token);
|
||||
if (action.size() > 0)
|
||||
request->addParameter("action", action);
|
||||
} // setUserDetails
|
||||
|
||||
// ========================================================================
|
||||
|
@ -104,7 +104,8 @@ namespace Online
|
||||
/**Singleton */
|
||||
static CurrentUser * get();
|
||||
static void deallocate();
|
||||
static void setUserDetails(HTTPRequest *request);
|
||||
static void setUserDetails(HTTPRequest *request,
|
||||
const std::string &action);
|
||||
|
||||
void requestSavedSession();
|
||||
SignInRequest * requestSignIn( const irr::core::stringw &username,
|
||||
|
@ -201,21 +201,26 @@ namespace Online
|
||||
{
|
||||
// Avoid printing the password or token, just replace them with *s
|
||||
std::string param = m_parameters;
|
||||
for (unsigned int j = 0; j < 2; j++)
|
||||
// List of strings whose values should not be printed. "" is the
|
||||
// end indicator.
|
||||
static std::string dont_print[] = { "&password=", "&token=", "¤t=",
|
||||
"&new1=", "&new2=", ""};
|
||||
unsigned int j = 0;
|
||||
while (dont_print[j].size()>0)
|
||||
{
|
||||
// Get the string that should be replaced.
|
||||
std::string s = (j == 0 ? "&password=" : "&token=");
|
||||
std::size_t pos = param.find(s);
|
||||
std::size_t pos = param.find(dont_print[j]);
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
pos += s.size();
|
||||
pos += dont_print[j].size();
|
||||
while (pos < param.size() && param[pos] != '&')
|
||||
{
|
||||
param[pos] = '*';
|
||||
pos++;
|
||||
} // while not end
|
||||
} // if string found
|
||||
} // for j < 2
|
||||
j++;
|
||||
} // while dont_print[j].size()>0
|
||||
Log::info("HTTPRequest", "Sending %s to %s",
|
||||
param.c_str(), m_url.c_str());
|
||||
}
|
||||
|
@ -154,8 +154,7 @@ void OnlineProfile::fetchAchievements()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AchievementsRequest * request = new AchievementsRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "get-achievements");
|
||||
CurrentUser::setUserDetails(request, "get-achievements");
|
||||
request->addParameter("visitingid", m_id);
|
||||
RequestManager::get()->addRequest(request);
|
||||
} // fetchAchievements
|
||||
@ -207,8 +206,7 @@ void OnlineProfile::fetchFriends()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
FriendsListRequest * request = new FriendsListRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "get-friends-list");
|
||||
CurrentUser::setUserDetails(request, "get-friends-list");
|
||||
request->addParameter("visitingid", m_id);
|
||||
RequestManager::get()->addRequest(request);
|
||||
} // fetchFriends
|
||||
|
@ -138,8 +138,7 @@ void CreateServerScreen::serverCreationRequest()
|
||||
{
|
||||
|
||||
m_server_creation_request = new ServerCreationRequest();
|
||||
CurrentUser::setUserDetails(m_server_creation_request);
|
||||
m_server_creation_request->addParameter("action", "create_server");
|
||||
CurrentUser::setUserDetails(m_server_creation_request,"create_server");
|
||||
m_server_creation_request->addParameter("name", name);
|
||||
m_server_creation_request->addParameter("max_players", max_players);
|
||||
m_server_creation_request->queue();
|
||||
|
@ -110,9 +110,7 @@ void ChangePasswordDialog::changePassword(const stringw ¤t_password,
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ChangePasswordRequest * request = new ChangePasswordRequest();
|
||||
CurrentUser::get()->setUserDetails(request);
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "change_password");
|
||||
CurrentUser::setUserDetails(request, "change_password");
|
||||
request->addParameter("userid", CurrentUser::get()->getID());
|
||||
request->addParameter("current", current_password);
|
||||
// The server code expects two passwords (and verifies again that they
|
||||
|
@ -34,12 +34,11 @@ using namespace Online;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NotificationDialog::NotificationDialog(Type type, const core::stringw info, bool from_queue)
|
||||
NotificationDialog::NotificationDialog(Type type, const core::stringw info)
|
||||
: ModalDialog(0.8f,0.5f)
|
||||
{
|
||||
m_info = info;
|
||||
m_type = type;
|
||||
if(!from_queue) load();
|
||||
}
|
||||
|
||||
void NotificationDialog::load()
|
||||
|
@ -53,7 +53,7 @@ private:
|
||||
GUIEngine::IconButtonWidget * m_cancel_widget;
|
||||
|
||||
public:
|
||||
NotificationDialog(Type type, const core::stringw info, bool from_queue = true);
|
||||
NotificationDialog(Type type, const core::stringw info);
|
||||
~NotificationDialog();
|
||||
|
||||
virtual void beforeAddingWidgets();
|
||||
|
@ -126,10 +126,10 @@ void RecoveryDialog::processInput()
|
||||
m_info_widget->setDefaultColor();
|
||||
m_options_widget->setDeactivated();
|
||||
m_recovery_request = new XMLRequest();
|
||||
m_recovery_request->setServerURL("client-user.php");
|
||||
m_recovery_request->addParameter("action", "recovery");
|
||||
// This function also works when the current user is not logged in
|
||||
CurrentUser::setUserDetails(m_recovery_request, "recovery");
|
||||
m_recovery_request->addParameter("username", username);
|
||||
m_recovery_request->addParameter("email", email);
|
||||
m_recovery_request->addParameter("email", email );
|
||||
m_recovery_request->queue();
|
||||
}
|
||||
} // processInput
|
||||
|
@ -169,8 +169,7 @@ void UserInfoDialog::sendFriendRequest()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
FriendRequest *request = new FriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "friend-request");
|
||||
CurrentUser::setUserDetails(request, "friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
@ -221,8 +220,7 @@ void UserInfoDialog::acceptFriendRequest()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AcceptFriendRequest *request = new AcceptFriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "accept-friend-request");
|
||||
CurrentUser::setUserDetails(request, "accept-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
m_processing = true;
|
||||
@ -268,8 +266,7 @@ void UserInfoDialog::declineFriendRequest()
|
||||
}; // DeclineFriendRequest
|
||||
// ----------------------------------------------------------------
|
||||
DeclineFriendRequest *request = new DeclineFriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "decline-friend-request");
|
||||
CurrentUser::setUserDetails(request, "decline-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
@ -316,8 +313,7 @@ void UserInfoDialog::removeExistingFriend()
|
||||
|
||||
int friend_id = m_profile->getID();
|
||||
RemoveFriendRequest * request = new RemoveFriendRequest(friend_id);
|
||||
CurrentUser::get()->setUserDetails(request);
|
||||
request->addParameter("action", "remove-friend");
|
||||
CurrentUser::setUserDetails(request, "remove-friend");
|
||||
request->addParameter("friendid", friend_id);
|
||||
request->queue();
|
||||
} // removeExistingFriend
|
||||
@ -361,8 +357,7 @@ void UserInfoDialog::removePendingFriend()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
CancelFriendRequest * request = new CancelFriendRequest();
|
||||
CurrentUser::get()->setUserDetails(request);
|
||||
request->addParameter("action", "cancel-friend-request");
|
||||
CurrentUser::setUserDetails(request, "cancel-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
} // removePendingFriend
|
||||
|
@ -60,8 +60,7 @@ VoteDialog::VoteDialog(const std::string & addon_id)
|
||||
|
||||
|
||||
m_fetch_vote_request = new XMLRequest();
|
||||
CurrentUser::get()->setUserDetails(m_fetch_vote_request);
|
||||
m_fetch_vote_request->addParameter("action", "get-addon-vote");
|
||||
CurrentUser::setUserDetails(m_fetch_vote_request, "get-addon-vote");
|
||||
m_fetch_vote_request->addParameter("addonid", addon_id.substr(6));
|
||||
m_fetch_vote_request->queue();
|
||||
|
||||
@ -120,8 +119,7 @@ void VoteDialog::sendVote()
|
||||
|
||||
|
||||
m_perform_vote_request = new SetAddonVoteRequest();
|
||||
CurrentUser::get()->setUserDetails(m_perform_vote_request);
|
||||
m_perform_vote_request->addParameter("action", "set-addon-vote");
|
||||
CurrentUser::setUserDetails(m_perform_vote_request, "set-addon-vote");
|
||||
m_perform_vote_request->addParameter("addonid", m_addon_id.substr(6));
|
||||
m_perform_vote_request->addParameter("rating", m_rating_widget->getRating());
|
||||
m_perform_vote_request->queue();
|
||||
|
@ -192,8 +192,7 @@ void OnlineUserSearch::search()
|
||||
if (m_search_string != "" && m_last_search_string != m_search_string)
|
||||
{
|
||||
m_search_request = new XMLRequest();
|
||||
CurrentUser::get()->setUserDetails(m_search_request);
|
||||
m_search_request->addParameter("action", "user-search");
|
||||
CurrentUser::setUserDetails(m_search_request, "user-search");
|
||||
m_search_request->addParameter("search-string", m_search_string);
|
||||
m_search_request->queue();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user