Redirection system to use another addons server

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5666 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
xapantu 2010-07-07 19:31:54 +00:00
parent ad6785a2b2
commit 1f7d07a3ae

View File

@ -38,14 +38,18 @@ void * NetworkHttp::checkNewServer(void * obj)
{
NetworkHttp * pthis = (NetworkHttp *)obj;
std::string newserver = pthis->downloadToStr("redirect");
std::cout << newserver << std::endl;
if(newserver != "")
{
std::cout << "new server !" << std::endl;
newserver.replace(newserver.find("\n"), 1, "");
std::cout << "Current server: " << UserConfigParams::m_server_addons.toString() << std::endl;
UserConfigParams::m_server_addons = newserver;
std::cout << "New server: " << newserver << std::endl;
user_config->saveConfig();
}
else
{
std::cout << "no new server :(" << std::endl;
std::cout << "No new server." << std::endl;
}
return NULL;
}
@ -53,13 +57,13 @@ size_t NetworkHttp::writeStr(char ptr [], size_t size, size_t nb_char, std::stri
{
static std::string str = std::string(ptr);
*stream = str;
//std::cout << *stream << std::endl;
//needed, otherwise, the download failed
return nb_char;
}
std::string NetworkHttp::downloadToStr(std::string url)
{
for(int i =0; i < 10; i++) std::cout << "stream---------------------------------------" << std::endl;
CURL *session = curl_easy_init();
curl_easy_setopt(session, CURLOPT_URL, std::string(UserConfigParams::m_server_addons.toString() + "/" + url).c_str());