Fix windows-specific compilation error

This commit is contained in:
Rasmus Karlsson 2018-05-12 19:50:22 +02:00 committed by fourtf
parent 937fffc34b
commit 88e97325f8
2 changed files with 50 additions and 97 deletions

View file

@ -176,7 +176,7 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe
}); });
req.execute(); req.execute();
} } // namespace twitch
void TwitchAccount::unignore(const QString &targetName, void TwitchAccount::unignore(const QString &targetName,
std::function<void(UnignoreResult, const QString &message)> onFinished) std::function<void(UnignoreResult, const QString &message)> onFinished)

View file

@ -151,26 +151,15 @@ public:
} }
void setRawHeader(const char *headerName, const char *value) void setRawHeader(const char *headerName, const char *value)
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
=======
{ {
this->data.request.setRawHeader(headerName, value); this->data.request.setRawHeader(headerName, value);
} }
void setRawHeader(const char *headerName, const QByteArray &value) void setRawHeader(const char *headerName, const QByteArray &value)
>>>>>>> Implement /ignore and /unignore commands
{ {
this->data.request.setRawHeader(headerName, value); this->data.request.setRawHeader(headerName, value);
} }
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
void setRawHeader(const char *headerName, const QByteArray &value)
{
this->data.request.setRawHeader(headerName, value);
}
=======
>>>>>>> Implement /ignore and /unignore commands
void setRawHeader(const char *headerName, const QString &value) void setRawHeader(const char *headerName, const QString &value)
{ {
this->data.request.setRawHeader(headerName, value.toUtf8()); this->data.request.setRawHeader(headerName, value.toUtf8());
@ -313,28 +302,17 @@ public:
void execute() void execute()
{ {
switch (this->data.requestType) { switch (this->data.requestType) {
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
case GetRequest: { case GetRequest: {
debug::Log("Call GET request!");
this->executeGet(); this->executeGet();
} break; } break;
case PutRequest: { case PutRequest: {
=======
case GET: {
this->executeGet();
} break;
case PUT: {
>>>>>>> Implement /ignore and /unignore commands
debug::Log("Call PUT request!"); debug::Log("Call PUT request!");
this->executePut(); this->executePut();
} break; } break;
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
case DeleteRequest: { case DeleteRequest: {
=======
case DELETE: {
>>>>>>> Implement /ignore and /unignore commands
debug::Log("Call DELETE request!"); debug::Log("Call DELETE request!");
this->executeDelete(); this->executeDelete();
} break; } break;
@ -343,7 +321,7 @@ public:
debug::Log("Unhandled request type {}", (int)this->data.requestType); debug::Log("Unhandled request type {}", (int)this->data.requestType);
} break; } break;
} }
} } // namespace util
private: private:
void useCache() void useCache()
@ -392,7 +370,6 @@ private:
worker->moveToThread(&NetworkManager::workerThread); worker->moveToThread(&NetworkManager::workerThread);
if (this->data.caller != nullptr) { if (this->data.caller != nullptr) {
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
QObject::connect(worker, &NetworkWorker::doneUrl, QObject::connect(worker, &NetworkWorker::doneUrl,
this->data.caller, [data = this->data](auto reply) mutable { this->data.caller, [data = this->data](auto reply) mutable {
auto &dat = data; auto &dat = data;
@ -401,12 +378,6 @@ private:
if (data.onError) { if (data.onError) {
data.onError(reply->error()); data.onError(reply->error());
} }
=======
QObject::connect(worker, &NetworkWorker::doneUrl,
this->data.caller, [data = this->data](auto reply) mutable {
if (reply->error() != QNetworkReply::NetworkError::NoError) {
// TODO: We might want to call an onError callback here
>>>>>>> Implement /ignore and /unignore commands
return; return;
} }
@ -418,85 +389,67 @@ private:
reply->deleteLater(); reply->deleteLater();
}); });
} } // namespace chatterino
if (timer != nullptr) { if (timer != nullptr) {
timer->start(this->data.timeoutMS); timer->start(this->data.timeoutMS);
} }
QObject::connect(&requester, &NetworkRequester::requestUrl, worker, QObject::connect(
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df &requester, &NetworkRequester::requestUrl, worker,
[ timer, data = std::move(this->data), worker ]() { [ timer, data = std::move(this->data), worker ]() {
QNetworkReply *reply; QNetworkReply *reply;
switch (data.requestType) { switch (data.requestType) {
case GetRequest: { case GetRequest: {
reply = NetworkManager::NaM.get(data.request); reply = NetworkManager::NaM.get(data.request);
} break; } break;
case PutRequest: { case PutRequest: {
reply = NetworkManager::NaM.put(data.request, data.payload); reply = NetworkManager::NaM.put(data.request, data.payload);
} break; } break;
case DeleteRequest: { case DeleteRequest: {
======= reply = NetworkManager::NaM.deleteResource(data.request);
[ timer, data = std::move(this->data), worker ]() { } break;
QNetworkReply *reply; } // namespace chatterino
switch (data.requestType) {
case GET: {
reply = NetworkManager::NaM.get(data.request);
} break;
case PUT: { if (reply == nullptr) {
reply = NetworkManager::NaM.put(data.request, data.payload); debug::Log("Unhandled request type {}", (int)data.requestType);
} break; return;
}
case DELETE: { if (timer != nullptr) {
>>>>>>> Implement /ignore and /unignore commands QObject::connect(timer, &QTimer::timeout, worker, [reply, timer, data]() {
reply = NetworkManager::NaM.deleteResource(data.request); debug::Log("Aborted!");
} break; reply->abort();
} timer->deleteLater();
data.onError(-2);
});
}
if (reply == nullptr) { if (data.onReplyCreated) {
debug::Log("Unhandled request type {}", (int)data.requestType); data.onReplyCreated(reply);
return; }
}
if (timer != nullptr) { QObject::connect(reply, &QNetworkReply::finished, worker,
QObject::connect(timer, &QTimer::timeout, worker, [ data = std::move(data), worker, reply ]() mutable {
[reply, timer, data]() { if (data.caller == nullptr) {
debug::Log("Aborted!"); QByteArray bytes = reply->readAll();
reply->abort(); data.writeToCache(bytes);
timer->deleteLater(); data.onSuccess(parseJSONFromData2(bytes));
data.onError(-2);
});
}
if (data.onReplyCreated) { reply->deleteLater();
data.onReplyCreated(reply); } else {
} emit worker->doneUrl(reply);
}
QObject::connect(reply, &QNetworkReply::finished, worker, delete worker;
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df });
[ data = std::move(data), worker, reply ]() mutable { } // namespace util
======= );
[ data = std::move(data), worker, reply ]() mutable {
>>>>>>> Implement /ignore and /unignore commands
if (data.caller == nullptr) {
QByteArray bytes = reply->readAll();
data.writeToCache(bytes);
data.onSuccess(parseJSONFromData2(bytes));
reply->deleteLater();
} else {
emit worker->doneUrl(reply);
}
delete worker;
});
});
emit requester.requestUrl(); emit requester.requestUrl();
} } // namespace chatterino
void executeGet() void executeGet()
{ {
@ -514,7 +467,7 @@ private:
{ {
this->doRequest(); this->doRequest();
} }
}; }; // namespace util
} // namespace util } // namespace util
} // namespace chatterino } // namespace chatterino