[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:
parent
ffb23fbc6d
commit
2e35f293df
@ -52,18 +52,19 @@ CurrentOnlineUser::CurrentOnlineUser(){
|
|||||||
bool CurrentOnlineUser::signIn(const stringw &username, const stringw &password)
|
bool CurrentOnlineUser::signIn(const stringw &username, const stringw &password)
|
||||||
{
|
{
|
||||||
assert(m_is_signed_in == false);
|
assert(m_is_signed_in == false);
|
||||||
/*
|
|
||||||
HTTPConnector * connector = new HTTPConnector((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
|
HTTPConnector * connector = new HTTPConnector((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
|
||||||
HTTPConnector::Parameters parameters;
|
HTTPConnector::Parameters parameters;
|
||||||
parameters["action"] = "signin";
|
parameters["action"] = "connect";
|
||||||
parameters["user"] = username;
|
parameters["user"] = username;
|
||||||
const XMLNode * result = connector->getXMLFromPage(parameters);*/
|
parameters["password"] = password;
|
||||||
|
const XMLNode * result = connector->getXMLFromPage(parameters);
|
||||||
//Sign in
|
std::string token;
|
||||||
if(/*succes*/true)
|
//const XMLNode * connection = result->getNode("connection");
|
||||||
|
bool succes = result->get("token", &token);
|
||||||
|
if(succes)
|
||||||
{
|
{
|
||||||
m_user = new OnlineUser(username);
|
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;
|
m_is_signed_in = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
|
|
||||||
HTTPConnector::HTTPConnector(const std::string &url){
|
HTTPConnector::HTTPConnector(const std::string &url){
|
||||||
@ -69,7 +70,9 @@ std::string HTTPConnector::getPage(Parameters & post_parameters)
|
|||||||
postString.append("=");
|
postString.append("=");
|
||||||
postString.append(iter->second);
|
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;
|
std::string readBuffer;
|
||||||
curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_FILE, &readBuffer);
|
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));
|
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));
|
printf("curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
||||||
|
}else{
|
||||||
|
printf("Retrieved: %s\n", readBuffer.c_str());
|
||||||
}
|
}
|
||||||
return readBuffer;
|
return readBuffer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user