mirror of
https://github.com/ChronosX88/nesca.git
synced 2024-11-23 18:52:19 +00:00
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#include "msgcheckerthread.h"
|
|
#include "externData.h"
|
|
#include "mainResources.h"
|
|
#include "Utils.h"
|
|
#include "Connector.h"
|
|
|
|
void MSGCheckerThread::doEmitionShowNewMsg(QString str)
|
|
{
|
|
emit mct->showNewMsg(str);
|
|
}
|
|
|
|
void _getNewMsg()
|
|
{
|
|
char request[256] = {0};
|
|
sprintf(request, "http://nesca.d3w.org/mailbox?key=%s", trcPersKey);
|
|
|
|
std::string buffer;
|
|
std::vector<std::string> headerVector {"X-Nescav3: True"};
|
|
Connector::nConnect(request, 80, &buffer, NULL, &headerVector);
|
|
|
|
char *ptr1 = NULL;
|
|
if(buffer.size() > 0)
|
|
{
|
|
if(Utils::ustrstr(buffer, std::string("\r\n\r\n")) != -1
|
|
&& Utils::ustrstr(buffer, std::string("404 Not Found")) == -1
|
|
&& Utils::ustrstr(buffer, std::string("502 Bad Gateway")) == -1
|
|
&& Utils::ustrstr(buffer, std::string("400 Bad Request")) == -1
|
|
&& Utils::ustrstr(buffer, std::string("\r\n\r\nEmpty")) == -1
|
|
)
|
|
{
|
|
ptr1 = strstr((char*)buffer.c_str(), "\r\n\r\n");
|
|
if(strlen(ptr1 + 4) != 0)
|
|
{
|
|
mct->doEmitionShowNewMsg(QString(ptr1 + 4));
|
|
};
|
|
}
|
|
};
|
|
}
|
|
|
|
void MSGCheckerThread::run()
|
|
{
|
|
for(;;)
|
|
{
|
|
Sleep(60000);
|
|
if(strlen(trcPersKey) != 0) _getNewMsg();
|
|
};
|
|
}
|