-
Notifications
You must be signed in to change notification settings - Fork 4
/
testversion.cpp
44 lines (40 loc) · 1.14 KB
/
testversion.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "testversion.h"
#include <QNetworkRequest>
#include <QNetworkReply>
#include "muteen.h"
#include <QUrl>
#include <QThread>
#include <definitions.h>
TestVersion::TestVersion()
{
manager = new QNetworkAccessManager();
}
void TestVersion::doDownload()
{
QUrl url;
url.setUrl(tr(URL)+"version.muteen");
QNetworkRequest request(url);
reply = manager->get(request);
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(testVersion(QNetworkReply*)));
}
void TestVersion::testVersion(QNetworkReply * reply)
{
if(reply->error())
qDebug() << reply->errorString();
else
{
QFile file("version.muteen");
file.open(QIODevice::ReadWrite);
QByteArray clientVersion = file.readAll();
QByteArray versionPatch = reply->readAll();
qDebug() << "Server Version :" << versionPatch << " Client Version: " << clientVersion;
if(clientVersion != versionPatch)
{
isVersion = false;
}
else{
isVersion = true;
}
emit resultReady(isVersion,versionPatch.toInt());
}
}