aboutsummaryrefslogtreecommitdiff
path: root/logic
diff options
context:
space:
mode:
Diffstat (limited to 'logic')
-rw-r--r--logic/MinecraftProcess.cpp4
-rw-r--r--logic/MinecraftProcess.h2
-rw-r--r--logic/OneSixAssets.cpp6
-rw-r--r--logic/OneSixAssets.h3
-rw-r--r--logic/net/DownloadJob.cpp3
-rw-r--r--logic/net/DownloadJob.h4
-rw-r--r--logic/net/LoginTask.cpp18
7 files changed, 27 insertions, 13 deletions
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp
index 06b7a1f1..ff122628 100644
--- a/logic/MinecraftProcess.cpp
+++ b/logic/MinecraftProcess.cpp
@@ -138,7 +138,7 @@ void MinecraftProcess::finish(int code, ExitStatus status)
}
}
m_instance->cleanupAfterRun();
- emit ended();
+ emit ended(m_instance);
}
void MinecraftProcess::killMinecraft()
@@ -193,4 +193,4 @@ MessageLevel::Enum MinecraftProcess::getLevel(const QString &line, MessageLevel:
if (line.contains("[DEBUG]"))
level = MessageLevel::Debug;
return level;
-} \ No newline at end of file
+}
diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h
index a1dfa23f..812559d5 100644
--- a/logic/MinecraftProcess.h
+++ b/logic/MinecraftProcess.h
@@ -67,7 +67,7 @@ signals:
/**
* @brief emitted when mc has finished and the PostLaunchCommand was run
*/
- void ended();
+ void ended(BaseInstance*);
/**
* @brief emitted when we want to log something
diff --git a/logic/OneSixAssets.cpp b/logic/OneSixAssets.cpp
index 6aa0a207..ff19a86b 100644
--- a/logic/OneSixAssets.cpp
+++ b/logic/OneSixAssets.cpp
@@ -67,6 +67,8 @@ void OneSixAssets::fetchXMLFinished()
QString fprefix ( "assets/" );
nuke_whitelist.clear();
+ emit filesStarted();
+
auto firstJob = index_job->first();
QByteArray ba = std::dynamic_pointer_cast<ByteArrayDownload>(firstJob)->m_data;
@@ -84,6 +86,7 @@ void OneSixAssets::fetchXMLFinished()
DownloadJob *job = new DownloadJob("Assets");
connect ( job, SIGNAL(succeeded()), SLOT(downloadFinished()) );
connect ( job, SIGNAL(failed()), SIGNAL(failed()) );
+ connect ( job, SIGNAL(filesProgress(int, int, int)), SIGNAL(filesProgress(int, int, int)) );
auto metacache = MMC->metacache();
@@ -130,14 +133,15 @@ void OneSixAssets::fetchXMLFinished()
emit finished();
}
}
+
void OneSixAssets::start()
{
auto job = new DownloadJob("Assets index");
job->addByteArrayDownload(QUrl ( "http://s3.amazonaws.com/Minecraft.Resources/" ));
connect ( job, SIGNAL(succeeded()), SLOT ( fetchXMLFinished() ) );
+ emit indexStarted();
index_job.reset ( job );
job->start();
}
-
#include "OneSixAssets.moc"
diff --git a/logic/OneSixAssets.h b/logic/OneSixAssets.h
index 58618c88..6c6f2c36 100644
--- a/logic/OneSixAssets.h
+++ b/logic/OneSixAssets.h
@@ -10,6 +10,9 @@ class OneSixAssets : public QObject
signals:
void failed();
void finished();
+ void indexStarted();
+ void filesStarted();
+ void filesProgress(int, int, int);
public slots:
void fetchXMLFinished();
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());
}
/*