1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'pr2828'

This commit is contained in:
tux3 2016-01-21 01:15:34 +01:00
commit 286cea1629
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -38,15 +38,18 @@ QByteArray Toxme::makeJsonRequest(QString url, QString json, QNetworkReply::Netw
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkReply* reply = netman.post(request,json.toUtf8());
while (reply->isRunning()) {
error = reply->error();
if (error)
break;
reply->waitForReadyRead(100);
while (!reply->isFinished())
{
qApp->processEvents();
}
error = reply->error();
if (error)
{
qWarning() << "makeJsonRequest: A network error occured:" << reply->errorString();
return QByteArray();
}
return reply->readAll();
}
@ -61,15 +64,18 @@ QByteArray Toxme::getServerPubkey(QString url, QNetworkReply::NetworkError &erro
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkReply* reply = netman.get(request);
while (reply->isRunning()) {
error = reply->error();
if (error)
break;
reply->waitForReadyRead(100);
while (!reply->isFinished())
{
qApp->processEvents();
}
error = reply->error();
if (error)
{
qWarning() << "getServerPubkey: A network error occured:" << reply->errorString();
return QByteArray();
}
// Extract key
static const QByteArray pattern{"key\":\""};
@ -277,8 +283,6 @@ int Toxme::deleteAddress(QString server, ToxId id)
QString apiUrl = server + "/api";
QNetworkReply::NetworkError error = QNetworkReply::NoError;
QByteArray response = makeJsonRequest(apiUrl, prepareEncryptedJson(pubkeyUrl, 2, payload), error);
if (error != QNetworkReply::NoError)
return error;
return extractError(response);
}