mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Remove unused functions in NetworkManager
This commit is contained in:
parent
b12c4e1d45
commit
1f2968934c
|
@ -25,66 +25,6 @@ public:
|
|||
static void init();
|
||||
static void deinit();
|
||||
|
||||
template <typename FinishedCallback>
|
||||
static void urlFetch(QNetworkRequest request, FinishedCallback onFinished)
|
||||
{
|
||||
NetworkRequester requester;
|
||||
NetworkWorker *worker = new NetworkWorker;
|
||||
|
||||
worker->moveToThread(&NetworkManager::workerThread);
|
||||
QObject::connect(
|
||||
&requester, &NetworkRequester::requestUrl, worker,
|
||||
[ worker, onFinished = std::move(onFinished), request = std::move(request) ]() {
|
||||
QNetworkReply *reply = NetworkManager::NaM.get(request);
|
||||
|
||||
reply->connect(reply, &QNetworkReply::finished,
|
||||
[ worker, reply, onFinished = std::move(onFinished) ]() {
|
||||
onFinished(reply);
|
||||
delete worker;
|
||||
});
|
||||
});
|
||||
|
||||
emit requester.requestUrl();
|
||||
}
|
||||
|
||||
template <typename FinishedCallback>
|
||||
static void urlFetch(const QUrl &url, FinishedCallback onFinished)
|
||||
{
|
||||
urlFetch(QNetworkRequest(url), std::move(onFinished));
|
||||
}
|
||||
|
||||
template <typename Callback, typename ReplyCreatedCallback = void (*)(QNetworkReply *)>
|
||||
static void urlFetch(QNetworkRequest request, const QObject *caller, Callback callback,
|
||||
ReplyCreatedCallback onReplyCreated = [](QNetworkReply *) { return; })
|
||||
{
|
||||
NetworkRequester requester;
|
||||
NetworkWorker *worker = new NetworkWorker;
|
||||
|
||||
worker->moveToThread(&NetworkManager::workerThread);
|
||||
|
||||
QObject::connect(&requester, &NetworkRequester::requestUrl, worker, [=]() {
|
||||
QNetworkReply *reply = NetworkManager::NaM.get(request);
|
||||
|
||||
onReplyCreated(reply);
|
||||
|
||||
reply->connect(reply, &QNetworkReply::finished, worker,
|
||||
[=]() { emit worker->doneUrl(reply); });
|
||||
});
|
||||
|
||||
QObject::connect(worker, &NetworkWorker::doneUrl, caller, [=](QNetworkReply *reply) {
|
||||
callback(reply);
|
||||
delete worker;
|
||||
});
|
||||
emit requester.requestUrl();
|
||||
}
|
||||
|
||||
template <typename Callback, typename ReplyCreatedCallback = void (*)(QNetworkReply *)>
|
||||
static void urlFetch(const QUrl &url, const QObject *caller, Callback callback,
|
||||
ReplyCreatedCallback onReplyCreated = [](QNetworkReply *) { return; })
|
||||
{
|
||||
urlFetch(QNetworkRequest(url), caller, callback, onReplyCreated);
|
||||
}
|
||||
|
||||
template <typename FinishedCallback>
|
||||
static void urlPut(QNetworkRequest request, FinishedCallback onFinished, QByteArray *data)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue