summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--depends/pack200/anti200.cpp43
-rw-r--r--depends/pack200/include/unpack200.h2
-rw-r--r--depends/pack200/src/unpack200.cpp13
-rw-r--r--gui/dialogs/AccountListDialog.cpp9
-rw-r--r--logic/JavaChecker.cpp2
-rw-r--r--logic/auth/MojangAccount.cpp26
-rw-r--r--logic/auth/MojangAccount.h2
-rw-r--r--logic/lists/JavaVersionList.cpp11
-rw-r--r--logic/lists/JavaVersionList.h1
-rw-r--r--logic/net/ForgeXzDownload.cpp45
-rw-r--r--mmc_updater/src/Platform.h4
-rwxr-xr-xpackage/linux/MultiMC2
12 files changed, 106 insertions, 54 deletions
diff --git a/depends/pack200/anti200.cpp b/depends/pack200/anti200.cpp
index 3dfdb5dc..1e1ec0c8 100644
--- a/depends/pack200/anti200.cpp
+++ b/depends/pack200/anti200.cpp
@@ -8,21 +8,36 @@
int main(int argc, char **argv)
{
- if (argc == 3)
+ if (argc != 3)
{
- try
- {
- unpack_200(argv[1], argv[2]);
- }
- catch (std::runtime_error &e)
- {
- std::cerr << "Bad things happened: " << e.what() << std::endl;
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
- else
std::cerr << "Simple pack200 unpacker!" << std::endl << "Run like this:" << std::endl
<< " " << argv[0] << " input.jar.lzma output.jar" << std::endl;
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
+ }
+
+ FILE *input = fopen(argv[1], "rb");
+ FILE *output = fopen(argv[2], "wb");
+ if (!input)
+ {
+ std::cerr << "Can't open input file";
+ return EXIT_FAILURE;
+ }
+ if (!output)
+ {
+ fclose(output);
+ std::cerr << "Can't open output file";
+ return EXIT_FAILURE;
+ }
+ try
+ {
+ unpack_200(input, output);
+ }
+ catch (std::runtime_error &e)
+ {
+ std::cerr << "Bad things happened: " << e.what() << std::endl;
+ fclose(input);
+ fclose(output);
+ return EXIT_FAILURE;
+ }
+ return EXIT_SUCCESS;
}
diff --git a/depends/pack200/include/unpack200.h b/depends/pack200/include/unpack200.h
index bcee8009..f9239488 100644
--- a/depends/pack200/include/unpack200.h
+++ b/depends/pack200/include/unpack200.h
@@ -34,4 +34,4 @@
* @return void
* @throw std::runtime_error for any error encountered
*/
-void unpack_200(std::string input_path, std::string output_path);
+void unpack_200(FILE * input, FILE * output);
diff --git a/depends/pack200/src/unpack200.cpp b/depends/pack200/src/unpack200.cpp
index 0a9d2714..22b7f3b0 100644
--- a/depends/pack200/src/unpack200.cpp
+++ b/depends/pack200/src/unpack200.cpp
@@ -94,20 +94,9 @@ static int read_magic(unpacker *u, char peek[], int peeklen)
return magic;
}
-void unpack_200(std::string input_path, std::string output_path)
+void unpack_200(FILE *input, FILE *output)
{
unpacker u;
- FILE *input = fopen(input_path.c_str(), "rb");
- if (!input)
- {
- throw std::runtime_error("Can't open input file" + input_path);
- }
- FILE *output = fopen(output_path.c_str(), "wb");
- if (!output)
- {
- fclose(output);
- throw std::runtime_error("Can't open output file" + output_path);
- }
u.init(read_input_via_stdio);
// initialize jar output
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp
index 242590fb..1712e352 100644
--- a/gui/dialogs/AccountListDialog.cpp
+++ b/gui/dialogs/AccountListDialog.cpp
@@ -26,7 +26,9 @@
#include <gui/dialogs/EditAccountDialog.h>
#include <gui/dialogs/ProgressDialog.h>
#include <gui/dialogs/AccountSelectDialog.h>
+#include "CustomMessageBox.h"
#include <logic/tasks/Task.h>
+#include <logic/auth/YggdrasilTask.h>
#include <MultiMC.h>
@@ -147,5 +149,12 @@ void AccountListDialog::addAccount(const QString& errMsg)
job->start();
}
+ else
+ {
+ auto reason = task->failReason();
+ auto dlg = CustomMessageBox::selectable(this, tr("Login error."), reason, QMessageBox::Critical);
+ dlg->exec();
+ delete dlg;
+ }
}
}
diff --git a/logic/JavaChecker.cpp b/logic/JavaChecker.cpp
index 2b94fbb6..113974ff 100644
--- a/logic/JavaChecker.cpp
+++ b/logic/JavaChecker.cpp
@@ -99,6 +99,7 @@ void JavaChecker::error(QProcess::ProcessError err)
if(err == QProcess::FailedToStart)
{
killTimer.stop();
+ checkerJar.remove();
JavaCheckResult result;
{
@@ -116,6 +117,5 @@ void JavaChecker::timeout()
if(process)
{
process->kill();
- process.reset();
}
}
diff --git a/logic/auth/MojangAccount.cpp b/logic/auth/MojangAccount.cpp
index bc6af98f..a462eda5 100644
--- a/logic/auth/MojangAccount.cpp
+++ b/logic/auth/MojangAccount.cpp
@@ -32,7 +32,8 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
// The JSON object must at least have a username for it to be valid.
if (!object.value("username").isString())
{
- QLOG_ERROR() << "Can't load Mojang account info from JSON object. Username field is missing or of the wrong type.";
+ QLOG_ERROR() << "Can't load Mojang account info from JSON object. Username field is "
+ "missing or of the wrong type.";
return nullptr;
}
@@ -43,7 +44,8 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
QJsonArray profileArray = object.value("profiles").toArray();
if (profileArray.size() < 1)
{
- QLOG_ERROR() << "Can't load Mojang account with username \"" << username << "\". No profiles found.";
+ QLOG_ERROR() << "Can't load Mojang account with username \"" << username
+ << "\". No profiles found.";
return nullptr;
}
@@ -63,7 +65,7 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
}
MojangAccountPtr account(new MojangAccount());
- if(object.value("user").isObject())
+ if (object.value("user").isObject())
{
User u;
QJsonObject userStructure = object.value("user").toObject();
@@ -92,7 +94,7 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
return account;
}
-MojangAccountPtr MojangAccount::createFromUsername(const QString& username)
+MojangAccountPtr MojangAccount::createFromUsername(const QString &username)
{
MojangAccountPtr account(new MojangAccount());
account->m_clientToken = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
@@ -152,27 +154,27 @@ bool MojangAccount::setCurrentProfile(const QString &profileId)
return false;
}
-const AccountProfile* MojangAccount::currentProfile() const
+const AccountProfile *MojangAccount::currentProfile() const
{
- if(m_currentProfile == -1)
+ if (m_currentProfile == -1)
return nullptr;
return &m_profiles[m_currentProfile];
}
AccountStatus MojangAccount::accountStatus() const
{
- if(m_accessToken.isEmpty())
+ if (m_accessToken.isEmpty())
return NotVerified;
- if(!m_online)
+ if (!m_online)
return Verified;
return Online;
}
-std::shared_ptr<Task> MojangAccount::login(QString password)
+std::shared_ptr<YggdrasilTask> MojangAccount::login(QString password)
{
- if(m_currentTask)
+ if (m_currentTask)
return m_currentTask;
- if(password.isEmpty())
+ if (password.isEmpty())
{
m_currentTask.reset(new RefreshTask(this));
}
@@ -196,7 +198,7 @@ void MojangAccount::authFailed(QString reason)
{
// This is emitted when the yggdrasil tasks time out or are cancelled.
// -> we treat the error as no-op
- if(reason != "Yggdrasil task cancelled.")
+ if (reason != "Yggdrasil task cancelled.")
{
m_online = false;
m_accessToken = QString();
diff --git a/logic/auth/MojangAccount.h b/logic/auth/MojangAccount.h
index 325aa826..dd5d54ae 100644
--- a/logic/auth/MojangAccount.h
+++ b/logic/auth/MojangAccount.h
@@ -95,7 +95,7 @@ public: /* manipulation */
* Attempt to login. Empty password means we use the token.
* If the attempt fails because we already are performing some task, it returns false.
*/
- std::shared_ptr<Task> login(QString password = QString());
+ std::shared_ptr<YggdrasilTask> login(QString password = QString());
void downgrade()
{
diff --git a/logic/lists/JavaVersionList.cpp b/logic/lists/JavaVersionList.cpp
index d2f0972c..c2886c67 100644
--- a/logic/lists/JavaVersionList.cpp
+++ b/logic/lists/JavaVersionList.cpp
@@ -177,9 +177,9 @@ void JavaListLoadTask::executeTask()
JavaUtils ju;
QList<QString> candidate_paths = ju.FindJavaPaths();
- auto job = new JavaCheckerJob("Java detection");
- connect(job, SIGNAL(finished(QList<JavaCheckResult>)), this, SLOT(javaCheckerFinished(QList<JavaCheckResult>)));
- connect(job, SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int)));
+ m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection"));
+ connect(m_job.get(), SIGNAL(finished(QList<JavaCheckResult>)), this, SLOT(javaCheckerFinished(QList<JavaCheckResult>)));
+ connect(m_job.get(), SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int)));
QLOG_DEBUG() << "Probing the following Java paths: ";
for(QString candidate : candidate_paths)
@@ -188,10 +188,10 @@ void JavaListLoadTask::executeTask()
auto candidate_checker = new JavaChecker();
candidate_checker->path = candidate;
- job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker));
+ m_job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker));
}
- job->start();
+ m_job->start();
}
void JavaListLoadTask::checkerProgress(int current, int total)
@@ -203,6 +203,7 @@ void JavaListLoadTask::checkerProgress(int current, int total)
void JavaListLoadTask::javaCheckerFinished(QList<JavaCheckResult> results)
{
QList<JavaVersionPtr> candidates;
+ m_job.reset();
QLOG_DEBUG() << "Found the following valid Java installations:";
for(JavaCheckResult result : results)
diff --git a/logic/lists/JavaVersionList.h b/logic/lists/JavaVersionList.h
index 879b2480..e6cc8e5f 100644
--- a/logic/lists/JavaVersionList.h
+++ b/logic/lists/JavaVersionList.h
@@ -90,6 +90,7 @@ public slots:
void checkerProgress(int current, int total);
protected:
+ std::shared_ptr<JavaCheckerJob> m_job;
JavaVersionList *m_list;
JavaVersion *m_currentRecommended;
};
diff --git a/logic/net/ForgeXzDownload.cpp b/logic/net/ForgeXzDownload.cpp
index 83cbabd0..359ad858 100644
--- a/logic/net/ForgeXzDownload.cpp
+++ b/logic/net/ForgeXzDownload.cpp
@@ -311,18 +311,51 @@ void ForgeXzDownload::decompressAndInstall()
m_pack200_xz_file.remove();
// revert pack200
- pack200_file.close();
- QString pack_name = pack200_file.fileName();
- QString source_native = QDir::toNativeSeparators(pack_name);
- QString target_native = QDir::toNativeSeparators(m_target_path);
+ pack200_file.seek(0);
+ int handle_in = pack200_file.handle();
+ // FIXME: dispose of file handles, pointers and the like. Ideally wrap in objects.
+ if(handle_in == -1)
+ {
+ QLOG_ERROR() << "Error reopening " << pack200_file.fileName();
+ failAndTryNextMirror();
+ return;
+ }
+ FILE * file_in = fdopen(handle_in,"r");
+ if(!file_in)
+ {
+ QLOG_ERROR() << "Error reopening " << pack200_file.fileName();
+ failAndTryNextMirror();
+ return;
+ }
+ QFile qfile_out(m_target_path);
+ if(!qfile_out.open(QIODevice::WriteOnly))
+ {
+ QLOG_ERROR() << "Error opening " << qfile_out.fileName();
+ failAndTryNextMirror();
+ return;
+ }
+ int handle_out = qfile_out.handle();
+ if(handle_out == -1)
+ {
+ QLOG_ERROR() << "Error opening " << qfile_out.fileName();
+ failAndTryNextMirror();
+ return;
+ }
+ FILE * file_out = fdopen(handle_out,"w");
+ if(!file_out)
+ {
+ QLOG_ERROR() << "Error opening " << qfile_out.fileName();
+ failAndTryNextMirror();
+ return;
+ }
try
{
- unpack_200(source_native.toStdString(), target_native.toStdString());
+ unpack_200(file_in, file_out);
}
catch (std::runtime_error &err)
{
m_status = Job_Failed;
- QLOG_ERROR() << "Error unpacking " << pack_name.toUtf8() << " : " << err.what();
+ QLOG_ERROR() << "Error unpacking " << pack200_file.fileName() << " : " << err.what();
QFile f(m_target_path);
if (f.exists())
f.remove();
diff --git a/mmc_updater/src/Platform.h b/mmc_updater/src/Platform.h
index 6d9afdfb..97867d6a 100644
--- a/mmc_updater/src/Platform.h
+++ b/mmc_updater/src/Platform.h
@@ -13,7 +13,9 @@
// disable warnings about exception specifications,
// which are not implemented in Visual C++
- #pragma warning(disable:4290)
+ #ifdef MSVC
+ #pragma warning(disable:4290)
+ #endif
#endif
#ifdef __APPLE__
diff --git a/package/linux/MultiMC b/package/linux/MultiMC
index fb2c28f6..7ccc2bac 100755
--- a/package/linux/MultiMC
+++ b/package/linux/MultiMC
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Basic start script for running MultiMC with the libs packaged with it.
function printerror {