diff options
Diffstat (limited to 'logic/net')
-rw-r--r-- | logic/net/DownloadJob.cpp | 3 | ||||
-rw-r--r-- | logic/net/DownloadJob.h | 4 | ||||
-rw-r--r-- | logic/net/LoginTask.cpp | 18 |
3 files changed, 16 insertions, 9 deletions
diff --git a/logic/net/DownloadJob.cpp b/logic/net/DownloadJob.cpp index fa3e655e..38716a02 100644 --- a/logic/net/DownloadJob.cpp +++ b/logic/net/DownloadJob.cpp @@ -56,6 +56,8 @@ void DownloadJob::partSucceeded(int index) num_succeeded++; QLOG_INFO() << m_job_name.toLocal8Bit() << "progress:" << num_succeeded << "/" << downloads.size(); + emit filesProgress(num_succeeded, num_failed, downloads.size()); + if (num_failed + num_succeeded == downloads.size()) { if (num_failed) @@ -78,6 +80,7 @@ void DownloadJob::partFailed(int index) { QLOG_ERROR() << "Part" << index << "failed 3 times (" << downloads[index]->m_url << ")"; num_failed++; + emit filesProgress(num_succeeded, num_failed, downloads.size()); if (num_failed + num_succeeded == downloads.size()) { QLOG_ERROR() << m_job_name.toLocal8Bit() << "failed."; diff --git a/logic/net/DownloadJob.h b/logic/net/DownloadJob.h index 91b014ad..cc2a1d59 100644 --- a/logic/net/DownloadJob.h +++ b/logic/net/DownloadJob.h @@ -1,5 +1,6 @@ #pragma once #include <QtNetwork> +#include <QLabel> #include "Download.h" #include "ByteArrayDownload.h" #include "FileDownload.h" @@ -57,12 +58,13 @@ public: signals: void started(); void progress(qint64 current, qint64 total); + void filesProgress(int, int, int); void succeeded(); void failed(); public slots: virtual void start(); private slots: - void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal);; + void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal); void partSucceeded(int index); void partFailed(int index); private: diff --git a/logic/net/LoginTask.cpp b/logic/net/LoginTask.cpp index 4098783b..5717aa9f 100644 --- a/logic/net/LoginTask.cpp +++ b/logic/net/LoginTask.cpp @@ -213,14 +213,16 @@ void LoginTask::yggdrasilLogin() clientToken.remove('{'); clientToken.remove('}'); // create the request - QString requestConstent; - requestConstent += "{"; - requestConstent += " \"agent\":{\"name\":\"Minecraft\",\"version\":1},\n"; - requestConstent += " \"username\":\"" + uInfo.username + "\",\n"; - requestConstent += " \"password\":\"" + uInfo.password + "\",\n"; - requestConstent += " \"clientToken\":\"" + clientToken + "\"\n"; - requestConstent += "}"; - netReply = worker->post(netRequest, requestConstent.toUtf8()); + QJsonObject root; + QJsonObject agent; + agent.insert("name", QString("Minecraft")); + agent.insert("version", QJsonValue(1)); + root.insert("agent", agent); + root.insert("username", uInfo.username); + root.insert("password", uInfo.password); + root.insert("clientToken", clientToken); + QJsonDocument requestDoc(root); + netReply = worker->post(netRequest, requestDoc.toJson()); } /* |