[GsoC Uni_] Small commit to ask a question concerning stringw

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@12906 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-06-20 22:49:46 +00:00
parent ffb23fbc6d
commit 2e35f293df
2 changed files with 14 additions and 8 deletions

View File

@ -52,18 +52,19 @@ CurrentOnlineUser::CurrentOnlineUser(){
bool CurrentOnlineUser::signIn(const stringw &username, const stringw &password)
{
assert(m_is_signed_in == false);
/*
HTTPConnector * connector = new HTTPConnector((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
HTTPConnector::Parameters parameters;
parameters["action"] = "signin";
parameters["action"] = "connect";
parameters["user"] = username;
const XMLNode * result = connector->getXMLFromPage(parameters);*/
//Sign in
if(/*succes*/true)
parameters["password"] = password;
const XMLNode * result = connector->getXMLFromPage(parameters);
std::string token;
//const XMLNode * connection = result->getNode("connection");
bool succes = result->get("token", &token);
if(succes)
{
m_user = new OnlineUser(username);
m_token = "0000"; //of course this should come from the server eventualy.
m_token = token;
m_is_signed_in = true;
}
else

View File

@ -22,6 +22,7 @@
#include <stdio.h>
#include <memory.h>
#include "io/file_manager.hpp"
#include "utils/string_utils.hpp"
HTTPConnector::HTTPConnector(const std::string &url){
@ -69,7 +70,9 @@ std::string HTTPConnector::getPage(Parameters & post_parameters)
postString.append("=");
postString.append(iter->second);
}
curl_easy_setopt(this->curl, CURLOPT_POSTFIELDS, postString.c_str());
core::stringc postString2 = postString.c_str();
printf("Sending: %s\n", postString2.c_str());
curl_easy_setopt(this->curl, CURLOPT_POSTFIELDS, postString2.c_str());
std::string readBuffer;
curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(this->curl, CURLOPT_FILE, &readBuffer);
@ -78,6 +81,8 @@ std::string HTTPConnector::getPage(Parameters & post_parameters)
{
Log::error("online/http_functions", "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
printf("curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}else{
printf("Retrieved: %s\n", readBuffer.c_str());
}
return readBuffer;
}