nesca/vercheckerthread.cpp

39 lines
1.1 KiB
C++
Raw Normal View History

2015-02-24 14:00:19 +00:00
#include "vercheckerthread.h"
#include "externData.h"
#include "mainResources.h"
2015-03-05 14:29:05 +00:00
#include "Connector.h"
#include "Utils.h"
2015-02-24 14:00:19 +00:00
void _checkVer()
{
2015-03-05 14:29:05 +00:00
while(true) {
2015-03-24 14:29:27 +00:00
const char request[64] = {"http://nesca.d3w.org/version"};
2015-03-05 14:29:05 +00:00
std::string buffer;
std::vector<std::string> headerVector {"X-Nescav3: True"};
Connector::nConnect(request, 80, &buffer, NULL, &headerVector);
2015-02-24 14:00:19 +00:00
2015-03-05 14:29:05 +00:00
char *ptr1 = NULL;
if(buffer.size() > 0)
{
if(Utils::ci_find_substr(buffer, std::string("\r\n\r\n")) != -1)
{
ptr1 = strstr((char*)buffer.c_str(), "\r\n\r\n");
if(strcmp(gVER, ptr1 + 4) != 0)
{
2015-03-24 14:29:27 +00:00
stt->doEmitionFoundData("<br><font color=\"Pink\">======Update required======<br>Latest version: " + QString(ptr1 + 4) +
"<br>Your version: " + QString(gVER) + "<br>=======================</font>");
2015-03-05 14:29:05 +00:00
stt->doEmitionShowRedVersion();
};
};
};
2015-02-24 14:00:19 +00:00
2015-03-05 14:29:05 +00:00
vct->sleep(600000); //10 min
};
//vct->terminate();
}
2015-02-24 14:00:19 +00:00
void VerCheckerThread::run()
{
_checkVer();
2015-03-05 14:29:05 +00:00
}