From 41d52dc34717aa2cad0537abb255a5a475bd4bca Mon Sep 17 00:00:00 2001
From: Trial97
Date: Thu, 29 Feb 2024 00:06:28 +0200
Subject: [PATCH 01/38] Remove dependencies if review mods is rejected
Signed-off-by: Trial97
---
launcher/ui/dialogs/ResourceDownloadDialog.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp
index 1431ea92c..11833c438 100644
--- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp
+++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp
@@ -133,6 +133,7 @@ void ResourceDownloadDialog::confirm()
confirm_dialog->retranslateUi(resourcesString());
QHash getRequiredBy;
+ QStringList depNames;
if (auto task = getModDependenciesTask(); task) {
connect(task.get(), &Task::failed, this,
[&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
@@ -155,8 +156,10 @@ void ResourceDownloadDialog::confirm()
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
return;
} else {
- for (auto dep : task->getDependecies())
+ for (auto dep : task->getDependecies()) {
addResource(dep->pack, dep->version);
+ depNames << dep->pack->name;
+ }
getRequiredBy = task->getRequiredBy();
}
}
@@ -180,6 +183,9 @@ void ResourceDownloadDialog::confirm()
}
this->accept();
+ } else {
+ for (auto name : depNames)
+ removeResource(name);
}
}
From 6078a771c18fd749f38d7c1a2f80ed3c7ec7ad28 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sat, 18 May 2024 21:46:05 +0300
Subject: [PATCH 02/38] add config for transfer timeout
Signed-off-by: Trial97
---
launcher/Application.cpp | 10 ++++-----
launcher/net/NetRequest.cpp | 4 ++++
launcher/ui/pages/global/LauncherPage.cpp | 2 ++
launcher/ui/pages/global/LauncherPage.ui | 27 ++++++++++++++++++-----
4 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 96a50f2ba..ffa49ee11 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -559,6 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_settings->registerSetting("NumberOfConcurrentTasks", 10);
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
+ m_settings->registerSetting("DownlodTransferTimeout", 60);
QString defaultMonospace;
int defaultSize = 11;
@@ -949,8 +950,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
[[fallthrough]];
default: {
qDebug() << "Exiting because update lockfile is present";
- QMetaObject::invokeMethod(
- this, []() { exit(1); }, Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection);
return;
}
}
@@ -982,8 +982,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
[[fallthrough]];
default: {
qDebug() << "Exiting because update lockfile is present";
- QMetaObject::invokeMethod(
- this, []() { exit(1); }, Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection);
return;
}
}
@@ -1671,8 +1670,7 @@ QString Application::getJarPath(QString jarFile)
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME),
#endif
- FS::PathCombine(m_rootPath, "jars"),
- FS::PathCombine(applicationDirPath(), "jars"),
+ FS::PathCombine(m_rootPath, "jars"), FS::PathCombine(applicationDirPath(), "jars"),
FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging
};
for (QString p : potentialPaths) {
diff --git a/launcher/net/NetRequest.cpp b/launcher/net/NetRequest.cpp
index abecc0cf3..6ce6a9bfc 100644
--- a/launcher/net/NetRequest.cpp
+++ b/launcher/net/NetRequest.cpp
@@ -106,7 +106,11 @@ void NetRequest::executeTask()
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+#if defined(LAUNCHER_APPLICATION)
+ request.setTransferTimeout(APPLICATION->settings()->get("DownlodTransferTimeout").toInt() * 1000);
+#else
request.setTransferTimeout();
+#endif
#endif
m_last_progress_time = m_clock.now();
diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp
index 78c44380a..4b550a0fd 100644
--- a/launcher/ui/pages/global/LauncherPage.cpp
+++ b/launcher/ui/pages/global/LauncherPage.cpp
@@ -191,6 +191,7 @@ void LauncherPage::applySettings()
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
+ s->set("DownlodTransferTimeout", ui->timeoutSecondsSpinBox->value());
// Console settings
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
@@ -245,6 +246,7 @@ void LauncherPage::loadSettings()
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
+ ui->timeoutSecondsSpinBox->setValue(s->get("DownlodTransferTimeout").toInt());
// Console settings
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui
index 928ec8103..20c9d0269 100644
--- a/launcher/ui/pages/global/LauncherPage.ui
+++ b/launcher/ui/pages/global/LauncherPage.ui
@@ -7,7 +7,7 @@
0
0
511
- 629
+ 691
@@ -205,6 +205,13 @@
Miscellaneous
+ -
+
+
+ 1
+
+
+
-
@@ -226,10 +233,20 @@
- -
-
-
- 1
+ -
+
+
+ Seconds to wait until the requests are terminated
+
+
+ Transfer timeout
+
+
+
+ -
+
+
+ s
From d9e2badf71dc5b70e2cdaeac0ddde3a45891f953 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sun, 19 May 2024 08:54:19 +0300
Subject: [PATCH 03/38] Rename timeout option
Signed-off-by: Trial97
---
launcher/Application.cpp | 2 +-
launcher/net/NetRequest.cpp | 2 +-
launcher/ui/pages/global/LauncherPage.cpp | 4 ++--
launcher/ui/pages/global/LauncherPage.ui | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index ffa49ee11..da25f3e3f 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -559,7 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_settings->registerSetting("NumberOfConcurrentTasks", 10);
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
- m_settings->registerSetting("DownlodTransferTimeout", 60);
+ m_settings->registerSetting("RequestTimeout", 60);
QString defaultMonospace;
int defaultSize = 11;
diff --git a/launcher/net/NetRequest.cpp b/launcher/net/NetRequest.cpp
index 6ce6a9bfc..dc9bf3b68 100644
--- a/launcher/net/NetRequest.cpp
+++ b/launcher/net/NetRequest.cpp
@@ -107,7 +107,7 @@ void NetRequest::executeTask()
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#if defined(LAUNCHER_APPLICATION)
- request.setTransferTimeout(APPLICATION->settings()->get("DownlodTransferTimeout").toInt() * 1000);
+ request.setTransferTimeout(APPLICATION->settings()->get("RequestTimeout").toInt() * 1000);
#else
request.setTransferTimeout();
#endif
diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp
index 4b550a0fd..085c78420 100644
--- a/launcher/ui/pages/global/LauncherPage.cpp
+++ b/launcher/ui/pages/global/LauncherPage.cpp
@@ -191,7 +191,7 @@ void LauncherPage::applySettings()
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
- s->set("DownlodTransferTimeout", ui->timeoutSecondsSpinBox->value());
+ s->set("RequestTimeout", ui->timeoutSecondsSpinBox->value());
// Console settings
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
@@ -246,7 +246,7 @@ void LauncherPage::loadSettings()
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
- ui->timeoutSecondsSpinBox->setValue(s->get("DownlodTransferTimeout").toInt());
+ ui->timeoutSecondsSpinBox->setValue(s->get("RequestTimeout").toInt());
// Console settings
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui
index 20c9d0269..62335b467 100644
--- a/launcher/ui/pages/global/LauncherPage.ui
+++ b/launcher/ui/pages/global/LauncherPage.ui
@@ -239,7 +239,7 @@
Seconds to wait until the requests are terminated
- Transfer timeout
+ Timeout for HTTP requests
From 425a6e09191eda8f732a6e1a6ca2b663d6e6d939 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sun, 19 May 2024 10:09:34 +0300
Subject: [PATCH 04/38] Fix code format
Signed-off-by: Trial97
---
launcher/Application.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index da25f3e3f..1781729a1 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -950,7 +950,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
[[fallthrough]];
default: {
qDebug() << "Exiting because update lockfile is present";
- QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection);
+ QMetaObject::invokeMethod(
+ this, []() { exit(1); }, Qt::QueuedConnection);
return;
}
}
@@ -982,7 +983,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
[[fallthrough]];
default: {
qDebug() << "Exiting because update lockfile is present";
- QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection);
+ QMetaObject::invokeMethod(
+ this, []() { exit(1); }, Qt::QueuedConnection);
return;
}
}
@@ -1670,7 +1672,8 @@ QString Application::getJarPath(QString jarFile)
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME),
#endif
- FS::PathCombine(m_rootPath, "jars"), FS::PathCombine(applicationDirPath(), "jars"),
+ FS::PathCombine(m_rootPath, "jars"),
+ FS::PathCombine(applicationDirPath(), "jars"),
FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging
};
for (QString p : potentialPaths) {
From c4a65dd861f0704f09f258c5cc9c5530e5db981a Mon Sep 17 00:00:00 2001
From: Trial97
Date: Wed, 12 Jun 2024 00:34:39 +0300
Subject: [PATCH 05/38] update login flow
Signed-off-by: Trial97
---
launcher/Application.h | 3 +-
launcher/minecraft/auth/AuthFlow.cpp | 10 +
launcher/minecraft/auth/AuthFlow.h | 3 +
launcher/minecraft/auth/AuthStep.h | 1 +
.../minecraft/auth/steps/MSADeviceCodeStep.h | 2 +-
launcher/minecraft/auth/steps/MSAStep.cpp | 29 +-
launcher/resources/documents/documents.qrc | 1 +
launcher/resources/documents/login-qr.png | Bin 0 -> 7616 bytes
launcher/ui/MainWindow.cpp | 8 +
launcher/ui/dialogs/MSALoginDialog.cpp | 123 +++---
launcher/ui/dialogs/MSALoginDialog.h | 13 +-
launcher/ui/dialogs/MSALoginDialog.ui | 383 ++++++++++++++----
launcher/ui/pages/global/AccountListPage.cpp | 5 +-
...org.prismlauncher.PrismLauncher.desktop.in | 2 +-
program_info/win_install.nsi.in | 4 +
15 files changed, 421 insertions(+), 166 deletions(-)
create mode 100644 launcher/resources/documents/login-qr.png
diff --git a/launcher/Application.h b/launcher/Application.h
index 7669e08ec..8303c7475 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -48,7 +48,6 @@
#include
#include "minecraft/launch/MinecraftServerTarget.h"
-#include "ui/themes/CatPack.h"
class LaunchController;
class LocalPeer;
@@ -193,6 +192,8 @@ class Application : public QApplication {
void globalSettingsClosed();
int currentCatChanged(int index);
+ void oauthReplyRecieved(QVariantMap);
+
#ifdef Q_OS_MACOS
void clickedOnDock();
#endif
diff --git a/launcher/minecraft/auth/AuthFlow.cpp b/launcher/minecraft/auth/AuthFlow.cpp
index 5648fe9f6..45926206c 100644
--- a/launcher/minecraft/auth/AuthFlow.cpp
+++ b/launcher/minecraft/auth/AuthFlow.cpp
@@ -59,6 +59,9 @@ void AuthFlow::executeTask()
void AuthFlow::nextStep()
{
+ if (!Task::isRunning()) {
+ return;
+ }
if (m_steps.size() == 0) {
// we got to the end without an incident... assume this is all.
m_currentStep.reset();
@@ -143,4 +146,11 @@ bool AuthFlow::changeState(AccountTaskState newState, QString reason)
return false;
}
}
+}
+bool AuthFlow::abort()
+{
+ emitAborted();
+ if (m_currentStep)
+ m_currentStep->abort();
+ return true;
}
\ No newline at end of file
diff --git a/launcher/minecraft/auth/AuthFlow.h b/launcher/minecraft/auth/AuthFlow.h
index d99deec3c..4d18ac845 100644
--- a/launcher/minecraft/auth/AuthFlow.h
+++ b/launcher/minecraft/auth/AuthFlow.h
@@ -24,6 +24,9 @@ class AuthFlow : public Task {
AccountTaskState taskState() { return m_taskState; }
+ public slots:
+ bool abort() override;
+
signals:
void authorizeWithBrowser(const QUrl& url);
void authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn);
diff --git a/launcher/minecraft/auth/AuthStep.h b/launcher/minecraft/auth/AuthStep.h
index 4d2cf69c1..a2b2cf9e5 100644
--- a/launcher/minecraft/auth/AuthStep.h
+++ b/launcher/minecraft/auth/AuthStep.h
@@ -34,6 +34,7 @@ class AuthStep : public QObject {
public slots:
virtual void perform() = 0;
+ virtual void abort() {}
signals:
void finished(AccountTaskState resultingState, QString message);
diff --git a/launcher/minecraft/auth/steps/MSADeviceCodeStep.h b/launcher/minecraft/auth/steps/MSADeviceCodeStep.h
index e53eebc62..024927b31 100644
--- a/launcher/minecraft/auth/steps/MSADeviceCodeStep.h
+++ b/launcher/minecraft/auth/steps/MSADeviceCodeStep.h
@@ -51,7 +51,7 @@ class MSADeviceCodeStep : public AuthStep {
QString describe() override;
public slots:
- void abort();
+ void abort() override;
signals:
void authorizeWithBrowser(QString url, QString code, int expiresIn);
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 3f31cdc16..c1eb3a33c 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -35,22 +35,35 @@
#include "MSAStep.h"
-#include
#include
#include
+#include
#include "Application.h"
+#include "BuildConfig.h"
+
+class CustomOAuthOobReplyHandler : public QOAuthOobReplyHandler {
+ Q_OBJECT
+
+ public:
+ explicit CustomOAuthOobReplyHandler(QObject* parent = nullptr) : QOAuthOobReplyHandler(parent)
+ {
+ connect(APPLICATION, &Application::oauthReplyRecieved, this, &QOAuthOobReplyHandler::callbackReceived);
+ }
+ ~CustomOAuthOobReplyHandler() override
+ {
+ disconnect(APPLICATION, &Application::oauthReplyRecieved, this, &QOAuthOobReplyHandler::callbackReceived);
+ }
+ QString callback() const override { return BuildConfig.LAUNCHER_APP_BINARY_NAME + "://oauth"; }
+};
MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(silent)
{
m_clientId = APPLICATION->getMSAClientID();
- auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this);
- replyHandler->setCallbackText(
- " ");
- oauth2.setReplyHandler(replyHandler);
+ auto bv = new CustomOAuthOobReplyHandler();
+
+ oauth2.setReplyHandler(bv);
oauth2.setAuthorizationUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize"));
oauth2.setAccessTokenUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/token"));
oauth2.setScope("XboxLive.SignIn XboxLive.offline_access");
@@ -106,3 +119,5 @@ void MSAStep::perform()
oauth2.grant();
}
}
+
+#include "MSAStep.moc"
\ No newline at end of file
diff --git a/launcher/resources/documents/documents.qrc b/launcher/resources/documents/documents.qrc
index 007efcde3..a5ff84390 100644
--- a/launcher/resources/documents/documents.qrc
+++ b/launcher/resources/documents/documents.qrc
@@ -2,6 +2,7 @@
../../../COPYING.md
+ login-qr.png
diff --git a/launcher/resources/documents/login-qr.png b/launcher/resources/documents/login-qr.png
new file mode 100644
index 0000000000000000000000000000000000000000..9bed0a73e2e456fd810cdc997dbf0db24dcafc1c
GIT binary patch
literal 7616
zcmeHMdrVVT7(ZAChJgf^DBYxU5?^tY4a7R2fR52QCg?ync`3|_3Rno(+FrCGNaiGv
zg<4WxB|&5+6tG%QXr&AkwJlX}od{g&bcL>zf)#tUJa%r)k|kz;En9MvrD^X;d(-CY
z_nqJCoZT7CaCd#z6#(GA{qu;g09agrKbI_m?=TM^s)ZNl)F?&-Sim2(iiR=(ypL^<
z*cx}dYGSA>b2xli_u_JRkNOI@-BIg$LB9#*zKib`OKCKMW(k{9@p9Z
z8b#JPhn;m1b_u-be!H=)26~HQhy`=LV%w7;a+0B#niE;B3HH&uO!El?HE-Zy0%92m
z0Bu(w&-`?bX@T&|MfPoGDaJ0N%1$MXxSUUq_L$<~I}+!YK{7M3-JVlQ%`s9{)TCSf
ziJL9O2H$SE3mdJst{f4w2;RZjxOB;YkNlffx54@==+p@-dQ8Oi+wG-h6{%*MI@H8(
zJV4*qdd#0ENJkcX5|i7a-~VI!Tf1YNu)KZIeUvB*{TnSJB)iR~(BRC#tOwuwb1@~l2W
z#5MVTjj{^T-XfJ0>0u7?w8;Ky&%9B2XN$GQr@7W%XtBLroti%SEzKs9l6%N^#Kra
z5JWrFu9nXj{8>e?jmo~E_F|%QSDlsUO@LLk%>f-rNtgT01kL~0x
zw$V_%>lO(SNjf^YDo{Y=3T3uXdUuQrdgP~+k$tUhq6||Aqg>$q_Yx|exj3fD61fOtAY~9+)F@37SQX%_@a!fp1>LxQD5!i=3d6eK
zIxaLBA+SPKmWaSGid0d+egV#eGF=NP8|Oeyq-df)n=gDk55qXQLO~a62V%4O?RI-_
zZ?AC!09eZ3q;z1a8w(?tuY_h&`HL>Tfq`AZqaN&%G%8JD(dOjx2XhXPsn#ZlKYXm}
z{v44J2+E#Q!SN3N@dDN4L$O-ziOW~0$)P$ZOKRuZ4xwa1qtKs;^MDT&1$%N&2cmkv!{guEH
z;a@qvnr)s7S`Lp)fY(zN{ag~$6DT!!EPoW=16ct$4^`r)55r%=BNhEYJO-rUgK$j*
d57Yk1tqImvWx8DuF2sL)`)AP+P22XL{sR(L{Sp8G
literal 0
HcmV?d00001
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 50074f1da..f55e35a8f 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -996,6 +996,14 @@ void MainWindow::processURLs(QList urls)
dlUrlDialod.execWithTask(job.get());
}
+ } else if (url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME) {
+ QVariantMap receivedData;
+ const QUrlQuery query(url.query());
+ const auto items = query.queryItems();
+ for (auto it = items.begin(), end = items.end(); it != end; ++it)
+ receivedData.insert(it->first, it->second);
+ emit APPLICATION->oauthReplyRecieved(receivedData);
+ continue;
} else {
dl_url = url;
}
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index a654c1d29..5f311e625 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -34,6 +34,8 @@
*/
#include "MSALoginDialog.h"
+#include "Application.h"
+
#include "ui_MSALoginDialog.h"
#include "DesktopServices.h"
@@ -41,6 +43,7 @@
#include
#include
+#include
#include
#include
@@ -48,13 +51,18 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
{
ui->setupUi(this);
- ui->cancel->setEnabled(false);
- ui->link->setVisible(false);
- ui->copy->setVisible(false);
- ui->progressBar->setVisible(false);
+ // make font monospace
+ QFont font;
+ font.setPixelSize(ui->code->fontInfo().pixelSize());
+ font.setFamily(APPLICATION->settings()->get("ConsoleFont").toString());
+ font.setStyleHint(QFont::Monospace);
+ font.setFixedPitch(true);
+ ui->code->setFont(font);
- connect(ui->cancel, &QPushButton::pressed, this, &QDialog::reject);
- connect(ui->copy, &QPushButton::pressed, this, &MSALoginDialog::copyUrl);
+ ui->buttonBox->button(QDialogButtonBox::Help)->setDefault(false);
+
+ connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); });
+ ui->qr->setPixmap(QPixmap(":/documents/login-qr.png"));
}
int MSALoginDialog::exec()
@@ -63,12 +71,12 @@ int MSALoginDialog::exec()
m_account = MinecraftAccount::createBlankMSA();
m_task = m_account->login(m_using_device_code);
connect(m_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
- connect(m_task.get(), &Task::succeeded, this, &MSALoginDialog::onTaskSucceeded);
+ connect(m_task.get(), &Task::succeeded, this, &QDialog::accept);
+ connect(m_task.get(), &Task::aborted, this, &MSALoginDialog::reject);
connect(m_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus);
connect(m_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser);
connect(m_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
- connect(ui->cancel, &QPushButton::pressed, m_task.get(), &Task::abort);
- connect(&m_external_timer, &QTimer::timeout, this, &MSALoginDialog::externalLoginTick);
+ connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_task.get(), &Task::abort);
m_task->start();
return QDialog::exec();
@@ -79,9 +87,10 @@ MSALoginDialog::~MSALoginDialog()
delete ui;
}
-void MSALoginDialog::onTaskFailed(const QString& reason)
+void MSALoginDialog::onTaskFailed(QString reason)
{
// Set message
+ ui->stackedWidget->setCurrentIndex(0);
auto lines = reason.split('\n');
QString processed;
for (auto line : lines) {
@@ -91,91 +100,55 @@ void MSALoginDialog::onTaskFailed(const QString& reason)
processed += " ";
}
}
- ui->message->setText(processed);
-}
-
-void MSALoginDialog::onTaskSucceeded()
-{
- QDialog::accept();
-}
-
-void MSALoginDialog::onTaskStatus(const QString& status)
-{
- ui->message->setText(status);
- ui->cancel->setEnabled(false);
- ui->link->setVisible(false);
- ui->copy->setVisible(false);
- ui->progressBar->setVisible(false);
-}
-
-// Public interface
-MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent, QString msg, bool usingDeviceCode)
-{
- MSALoginDialog dlg(parent);
- dlg.m_using_device_code = usingDeviceCode;
- dlg.ui->message->setText(msg);
- if (dlg.exec() == QDialog::Accepted) {
- return dlg.m_account;
- }
- return nullptr;
+ ui->status->setText(processed);
+ ui->loadingLabel->setText(m_task->getStatus());
+ disconnect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_task.get(), &Task::abort);
+ connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &MSALoginDialog::reject);
}
void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
{
- ui->cancel->setEnabled(true);
- ui->link->setVisible(true);
- ui->copy->setVisible(true);
+ ui->stackedWidget->setCurrentIndex(2);
DesktopServices::openUrl(url);
- ui->link->setText(url.toDisplayString());
- ui->message->setText(
+ const auto uri = url.toString();
+ const auto linkString = QString("%2 ").arg(uri, uri);
+ ui->urlInfo->setText(
tr("Browser opened to complete the login process."
" "
- "If your browser hasn't opened, please manually open the below link in your browser:"));
-}
-
-void MSALoginDialog::copyUrl()
-{
- QClipboard* cb = QApplication::clipboard();
- cb->setText(ui->link->text());
+ "If your browser hasn't opened, please manually open the following link and choose your account:
"));
+ ui->url->setText(linkString);
}
void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn)
{
- m_external_elapsed = 0;
- m_external_timeout = expiresIn;
+ ui->stackedWidget->setCurrentIndex(1);
- m_external_timer.setInterval(1000);
- m_external_timer.setSingleShot(false);
- m_external_timer.start();
+ const auto linkString = QString("%2 ").arg(url, url);
+ ui->code->setText(code);
+ ui->codeInfo->setText(tr("Enter this code into %1 and choose your account.
").arg(linkString));
- ui->progressBar->setMaximum(expiresIn);
- ui->progressBar->setValue(m_external_elapsed);
+ const auto isDefaultUrl = url == "https://www.microsoft.com/link";
- QString linkString = QString("%2 ").arg(url, url);
- if (url == "https://www.microsoft.com/link" && !code.isEmpty()) {
+ ui->qr->setVisible(isDefaultUrl);
+ if (isDefaultUrl && !code.isEmpty()) {
url += QString("?otc=%1").arg(code);
- ui->message->setText(tr("Please login in the opened browser. If no browser was opened, please open up %1 in "
- "a browser and put in the code %2 to proceed with login.
")
- .arg(linkString, code));
- } else {
- ui->message->setText(
- tr("Please open up %1 in a browser and put in the code %2 to proceed with login.
").arg(linkString, code));
}
- ui->cancel->setEnabled(true);
- ui->link->setVisible(true);
- ui->copy->setVisible(true);
- ui->progressBar->setVisible(true);
DesktopServices::openUrl(url);
- ui->link->setText(code);
}
-void MSALoginDialog::externalLoginTick()
+void MSALoginDialog::onTaskStatus(QString status)
{
- m_external_elapsed++;
- ui->progressBar->setValue(m_external_elapsed);
- ui->progressBar->repaint();
+ ui->stackedWidget->setCurrentIndex(0);
+ ui->status->setText(status);
+}
- if (m_external_elapsed >= m_external_timeout) {
- m_external_timer.stop();
+// Public interface
+MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent, bool usingDeviceCode)
+{
+ MSALoginDialog dlg(parent);
+ dlg.m_using_device_code = usingDeviceCode;
+ if (dlg.exec() == QDialog::Accepted) {
+ return dlg.m_account;
}
+ return nullptr;
}
\ No newline at end of file
diff --git a/launcher/ui/dialogs/MSALoginDialog.h b/launcher/ui/dialogs/MSALoginDialog.h
index cef647ee4..cf806d88b 100644
--- a/launcher/ui/dialogs/MSALoginDialog.h
+++ b/launcher/ui/dialogs/MSALoginDialog.h
@@ -32,29 +32,22 @@ class MSALoginDialog : public QDialog {
public:
~MSALoginDialog();
- static MinecraftAccountPtr newAccount(QWidget* parent, QString message, bool usingDeviceCode = false);
+ static MinecraftAccountPtr newAccount(QWidget* parent, bool usingDeviceCode = false);
int exec() override;
private:
explicit MSALoginDialog(QWidget* parent = 0);
protected slots:
- void onTaskFailed(const QString& reason);
- void onTaskSucceeded();
- void onTaskStatus(const QString& status);
+ void onTaskFailed(QString reason);
+ void onTaskStatus(QString status);
void authorizeWithBrowser(const QUrl& url);
void authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn);
- void copyUrl();
- void externalLoginTick();
private:
Ui::MSALoginDialog* ui;
MinecraftAccountPtr m_account;
shared_qobject_ptr m_task;
- int m_external_elapsed;
- int m_external_timeout;
- QTimer m_external_timer;
-
bool m_using_device_code = false;
};
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index df1b32044..afd97e348 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -6,90 +6,337 @@
0
0
- 491
- 208
+ 500
+ 300
-
-
- 0
- 0
-
-
Add Microsoft Account
-
-
-
-
- 0
- 0
-
-
-
-
- 500
- 500
-
-
-
-
-
-
- Qt::RichText
-
-
- true
-
-
- true
-
-
- Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
+
+
+ 2
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+
+ 16
+ 75
+ true
+
+
+
+ Please wait...
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Status
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 40
+ 75
+ true
+
+
+
+ IBeamCursor
+
+
+ CODE
+
+
+ Qt::AlignCenter
+
+
+ Qt::TextBrowserInteraction
+
+
+
+ -
+
+
+ Copy code to clipboard
+
+
+
+
+
+
+ . .
+
+
+
+ 22
+ 22
+
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+
+ false
+
+
+
+ Information
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+ Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse
+
+
+
+ -
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 100
+ 100
+
+
+
+
+
+
+ :/assets/login-qr.png
+
+
+ true
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+
+ false
+
+
+
+ Information
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+ true
+
+
+ Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse
+
+
+
+ -
+
+
+ url
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+ Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
-
-
- -
-
-
- false
-
-
-
- -
-
-
-
-
-
-
- . .
-
-
-
-
-
- -
-
-
- 24
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Help
-
+
false
- -
-
-
- Cancel
-
-
-
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index 8d0b66004..3c77cb97a 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -134,15 +134,14 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
box.setWindowTitle(tr("Add account"));
box.setText(tr("How do you want to login?"));
box.setIcon(QMessageBox::Question);
- auto deviceCode = box.addButton(tr("Legacy"), QMessageBox::ButtonRole::YesRole);
+ auto deviceCode = box.addButton(tr("Remote"), QMessageBox::ButtonRole::YesRole);
auto authCode = box.addButton(tr("Recommended"), QMessageBox::ButtonRole::NoRole);
auto cancel = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole);
box.setDefaultButton(authCode);
box.exec();
if ((box.clickedButton() != deviceCode && box.clickedButton() != authCode) || box.clickedButton() == cancel)
return;
- MinecraftAccountPtr account = MSALoginDialog::newAccount(
- this, tr("Please enter your Mojang account email and password to add your account."), box.clickedButton() == deviceCode);
+ MinecraftAccountPtr account = MSALoginDialog::newAccount(this, box.clickedButton() == deviceCode);
if (account) {
m_accounts->addAccount(account);
diff --git a/program_info/org.prismlauncher.PrismLauncher.desktop.in b/program_info/org.prismlauncher.PrismLauncher.desktop.in
index a2846b06e..7d186a2e7 100644
--- a/program_info/org.prismlauncher.PrismLauncher.desktop.in
+++ b/program_info/org.prismlauncher.PrismLauncher.desktop.in
@@ -10,4 +10,4 @@ Icon=org.prismlauncher.PrismLauncher
Categories=Game;ActionGame;AdventureGame;Simulation;
Keywords=game;minecraft;mc;
StartupWMClass=PrismLauncher
-MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;
+MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;x-scheme-handler/prismlauncher;
diff --git a/program_info/win_install.nsi.in b/program_info/win_install.nsi.in
index eda85821b..cc56b9bd5 100644
--- a/program_info/win_install.nsi.in
+++ b/program_info/win_install.nsi.in
@@ -368,6 +368,10 @@ Section "@Launcher_DisplayName@"
WriteRegStr HKCU Software\Classes\curseforge "URL Protocol" ""
WriteRegStr HKCU Software\Classes\curseforge\shell\open\command "" '"$INSTDIR\@Launcher_APP_BINARY_NAME@.exe" "%1"'
+; Write the URL Handler into registry for prismlauncher
+ WriteRegStr HKCU Software\Classes\prismlauncher "URL Protocol" ""
+ WriteRegStr HKCU Software\Classes\prismlauncher\shell\open\command "" '"$INSTDIR\@Launcher_APP_BINARY_NAME@.exe" "%1"'
+
; Write the uninstall keys for Windows
${GetParameters} $R0
${GetOptions} $R0 "/NoUninstaller" $R1
From df142550fef0a53e6152f7e0710b7ec86a3049de Mon Sep 17 00:00:00 2001
From: Trial97
Date: Wed, 12 Jun 2024 11:55:56 +0300
Subject: [PATCH 06/38] update Add account question
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.cpp | 9 +--------
launcher/ui/pages/global/AccountListPage.cpp | 6 +++---
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 5f311e625..9c93df264 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -126,14 +126,7 @@ void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, in
const auto linkString = QString("%2 ").arg(url, url);
ui->code->setText(code);
ui->codeInfo->setText(tr("Enter this code into %1 and choose your account.
").arg(linkString));
-
- const auto isDefaultUrl = url == "https://www.microsoft.com/link";
-
- ui->qr->setVisible(isDefaultUrl);
- if (isDefaultUrl && !code.isEmpty()) {
- url += QString("?otc=%1").arg(code);
- }
- DesktopServices::openUrl(url);
+ ui->qr->setVisible(url == "https://www.microsoft.com/link");
}
void MSALoginDialog::onTaskStatus(QString status)
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index 3c77cb97a..d2350fb70 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -132,10 +132,10 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
{
QMessageBox box(this);
box.setWindowTitle(tr("Add account"));
- box.setText(tr("How do you want to login?"));
+ box.setText(tr("Where would you like to login?"));
box.setIcon(QMessageBox::Question);
- auto deviceCode = box.addButton(tr("Remote"), QMessageBox::ButtonRole::YesRole);
- auto authCode = box.addButton(tr("Recommended"), QMessageBox::ButtonRole::NoRole);
+ auto authCode = box.addButton(tr("On this device"), QMessageBox::ButtonRole::NoRole);
+ auto deviceCode = box.addButton(tr("On another device"), QMessageBox::ButtonRole::YesRole);
auto cancel = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole);
box.setDefaultButton(authCode);
box.exec();
From bbbe7c879e4497a48eee916730f00dab3aad578c Mon Sep 17 00:00:00 2001
From: Trial97
Date: Wed, 12 Jun 2024 12:35:02 +0300
Subject: [PATCH 07/38] update callback
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index c1eb3a33c..78cb0b8d2 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -54,7 +54,7 @@ class CustomOAuthOobReplyHandler : public QOAuthOobReplyHandler {
{
disconnect(APPLICATION, &Application::oauthReplyRecieved, this, &QOAuthOobReplyHandler::callbackReceived);
}
- QString callback() const override { return BuildConfig.LAUNCHER_APP_BINARY_NAME + "://oauth"; }
+ QString callback() const override { return BuildConfig.LAUNCHER_APP_BINARY_NAME + "://oauth/microsoft"; }
};
MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(silent)
From 5f5296ef5e2ff34d3726c73927c842e2c2a8073e Mon Sep 17 00:00:00 2001
From: Trial97
Date: Wed, 12 Jun 2024 19:34:19 +0300
Subject: [PATCH 08/38] update ui once again
Signed-off-by: Trial97
---
.../auth/steps/MSADeviceCodeStep.cpp | 8 +-
launcher/resources/documents/documents.qrc | 2 +-
launcher/resources/documents/login-qr.svg | 8 +
launcher/ui/dialogs/MSALoginDialog.cpp | 74 ++-
launcher/ui/dialogs/MSALoginDialog.h | 7 +-
launcher/ui/dialogs/MSALoginDialog.ui | 591 ++++++++++--------
launcher/ui/pages/global/AccountListPage.cpp | 14 +-
7 files changed, 415 insertions(+), 289 deletions(-)
create mode 100644 launcher/resources/documents/login-qr.svg
diff --git a/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp b/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp
index 22f5d4069..c34351bf2 100644
--- a/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp
+++ b/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp
@@ -135,9 +135,9 @@ void MSADeviceCodeStep::deviceAutorizationFinished()
m_expiration_timer.setSingleShot(true);
connect(&m_expiration_timer, &QTimer::timeout, this, &MSADeviceCodeStep::abort);
m_expiration_timer.start();
-
m_pool_timer.setTimerType(Qt::VeryCoarseTimer);
m_pool_timer.setSingleShot(true);
+ connect(&m_pool_timer, &QTimer::timeout, this, &MSADeviceCodeStep::authenticateUser);
startPoolTimer();
}
@@ -157,8 +157,12 @@ void MSADeviceCodeStep::startPoolTimer()
if (m_is_aborted) {
return;
}
+ if (m_expiration_timer.remainingTime() < interval * 1000) {
+ perform();
+ return;
+ }
+
m_pool_timer.setInterval(interval * 1000);
- connect(&m_pool_timer, &QTimer::timeout, this, &MSADeviceCodeStep::authenticateUser);
m_pool_timer.start();
}
diff --git a/launcher/resources/documents/documents.qrc b/launcher/resources/documents/documents.qrc
index a5ff84390..489d1d5a2 100644
--- a/launcher/resources/documents/documents.qrc
+++ b/launcher/resources/documents/documents.qrc
@@ -2,7 +2,7 @@
../../../COPYING.md
- login-qr.png
+ login-qr.svg
diff --git a/launcher/resources/documents/login-qr.svg b/launcher/resources/documents/login-qr.svg
new file mode 100644
index 000000000..1b88e3c83
--- /dev/null
+++ b/launcher/resources/documents/login-qr.svg
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 9c93df264..0a3bca86b 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -36,6 +36,7 @@
#include "MSALoginDialog.h"
#include "Application.h"
+#include "BuildConfig.h"
#include "ui_MSALoginDialog.h"
#include "DesktopServices.h"
@@ -59,25 +60,40 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
font.setFixedPitch(true);
ui->code->setFont(font);
- ui->buttonBox->button(QDialogButtonBox::Help)->setDefault(false);
+ // ui->buttonBox->button(QDialogButtonBox::Help)->setDefault(false);
connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); });
- ui->qr->setPixmap(QPixmap(":/documents/login-qr.png"));
+ ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(75, 75)));
+ ui->title->setText(tr("Login to %1").arg(BuildConfig.LAUNCHER_DISPLAYNAME));
+ connect(ui->loginButton, &QPushButton::clicked, this, [this] {
+ if (m_url.isValid())
+ DesktopServices::openUrl(m_url);
+ });
}
int MSALoginDialog::exec()
{
// Setup the login task and start it
m_account = MinecraftAccount::createBlankMSA();
- m_task = m_account->login(m_using_device_code);
- connect(m_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
- connect(m_task.get(), &Task::succeeded, this, &QDialog::accept);
- connect(m_task.get(), &Task::aborted, this, &MSALoginDialog::reject);
- connect(m_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus);
- connect(m_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser);
- connect(m_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
- connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_task.get(), &Task::abort);
- m_task->start();
+ m_authflow_task = m_account->login(false);
+ connect(m_authflow_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
+ connect(m_authflow_task.get(), &Task::succeeded, this, &QDialog::accept);
+ connect(m_authflow_task.get(), &Task::aborted, this, &MSALoginDialog::reject);
+ connect(m_authflow_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus);
+ connect(m_authflow_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser);
+ connect(m_authflow_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
+ connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_authflow_task.get(), &Task::abort);
+
+ m_devicecode_task.reset(new AuthFlow(m_account->accountData(), AuthFlow::Action::DeviceCode, this));
+ connect(m_devicecode_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
+ connect(m_devicecode_task.get(), &Task::succeeded, this, &QDialog::accept);
+ connect(m_devicecode_task.get(), &Task::aborted, this, &MSALoginDialog::reject);
+ connect(m_devicecode_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus);
+ connect(m_devicecode_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser);
+ connect(m_devicecode_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
+ connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_devicecode_task.get(), &Task::abort);
+ QMetaObject::invokeMethod(m_authflow_task.get(), &Task::start, Qt::QueuedConnection);
+ QMetaObject::invokeMethod(m_devicecode_task.get(), &Task::start, Qt::QueuedConnection);
return QDialog::exec();
}
@@ -100,23 +116,29 @@ void MSALoginDialog::onTaskFailed(QString reason)
processed += " ";
}
}
+ auto task = qobject_cast(sender());
ui->status->setText(processed);
- ui->loadingLabel->setText(m_task->getStatus());
- disconnect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_task.get(), &Task::abort);
+ if (task) {
+ ui->loadingLabel->setText(task->getStatus());
+ }
+ disconnect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_authflow_task.get(), &Task::abort);
+ disconnect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_devicecode_task.get(), &Task::abort);
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &MSALoginDialog::reject);
}
void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
{
- ui->stackedWidget->setCurrentIndex(2);
- DesktopServices::openUrl(url);
+ ui->stackedWidget->setCurrentIndex(1);
+ // DesktopServices::openUrl(url);
const auto uri = url.toString();
const auto linkString = QString("%2 ").arg(uri, uri);
- ui->urlInfo->setText(
- tr("Browser opened to complete the login process."
- " "
- "If your browser hasn't opened, please manually open the following link and choose your account:"));
- ui->url->setText(linkString);
+ m_url = url;
+ ui->link->setText(linkString);
+ // ui->urlInfo->setText(
+ // tr("Browser opened to complete the login process."
+ // " "
+ // "If your browser hasn't opened, please manually open the following link and choose your account:"));
+ // ui->url->setText(linkString);
}
void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn)
@@ -125,8 +147,13 @@ void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, in
const auto linkString = QString("%2 ").arg(url, url);
ui->code->setText(code);
- ui->codeInfo->setText(tr("Enter this code into %1 and choose your account.
").arg(linkString));
- ui->qr->setVisible(url == "https://www.microsoft.com/link");
+ auto isDefaultUrl = url == "https://www.microsoft.com/link";
+ ui->qr->setVisible(isDefaultUrl);
+ if (isDefaultUrl) {
+ ui->qrMessage->setText(tr("Open %1 or scan the QR and enter the above code.").arg(linkString));
+ } else {
+ ui->qrMessage->setText(tr("Open %1 and enter the above code.").arg(linkString));
+ }
}
void MSALoginDialog::onTaskStatus(QString status)
@@ -136,10 +163,9 @@ void MSALoginDialog::onTaskStatus(QString status)
}
// Public interface
-MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent, bool usingDeviceCode)
+MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent)
{
MSALoginDialog dlg(parent);
- dlg.m_using_device_code = usingDeviceCode;
if (dlg.exec() == QDialog::Accepted) {
return dlg.m_account;
}
diff --git a/launcher/ui/dialogs/MSALoginDialog.h b/launcher/ui/dialogs/MSALoginDialog.h
index cf806d88b..70f480ca9 100644
--- a/launcher/ui/dialogs/MSALoginDialog.h
+++ b/launcher/ui/dialogs/MSALoginDialog.h
@@ -32,7 +32,7 @@ class MSALoginDialog : public QDialog {
public:
~MSALoginDialog();
- static MinecraftAccountPtr newAccount(QWidget* parent, bool usingDeviceCode = false);
+ static MinecraftAccountPtr newAccount(QWidget* parent);
int exec() override;
private:
@@ -47,7 +47,8 @@ class MSALoginDialog : public QDialog {
private:
Ui::MSALoginDialog* ui;
MinecraftAccountPtr m_account;
- shared_qobject_ptr m_task;
+ shared_qobject_ptr m_devicecode_task;
+ shared_qobject_ptr m_authflow_task;
- bool m_using_device_code = false;
+ QUrl m_url;
};
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index afd97e348..b2ad80270 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -6,18 +6,18 @@
0
0
- 500
- 300
+ 772
+ 326
Add Microsoft Account
-
+
-
- 2
+ 1
@@ -49,6 +49,9 @@
Qt::AlignCenter
+
+ true
+
-
@@ -59,6 +62,9 @@
Qt::AlignCenter
+
+ true
+
-
@@ -76,253 +82,349 @@
-
-
+
+
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
+
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+
+ 16
+ 75
+ true
+
+
+
+ Login to Prismlauncher
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+
+ -
+
+
+ TextLabel
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+
+ -
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 250
+ 40
+
+
+
+ Login with Microsoft
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
-
-
-
-
- 40
- 75
- true
-
-
-
- IBeamCursor
-
-
- CODE
-
-
- Qt::AlignCenter
-
-
- Qt::TextBrowserInteraction
-
-
+
+ -
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 1
+
+
+ Qt::Vertical
+
+
+
+
+
+ -
+
+
+ Or
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 1
+
+
+ Qt::Vertical
+
+
+
+
+
+
-
-
-
- Copy code to clipboard
-
-
-
-
-
-
- . .
-
-
-
- 22
- 22
-
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 75
+ 75
+
+
+
+
+ 100
+ 100
+
+
+
+
+
+
+ true
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 30
+ 75
+ true
+
+
+
+ IBeamCursor
+
+
+ CODE
+
+
+ Qt::AlignCenter
+
+
+ Qt::TextBrowserInteraction
+
+
+
+ -
+
+
+ Copy code to clipboard
+
+
+
+
+
+
+ . .
+
+
+
+ 22
+ 22
+
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
- -
-
-
-
- false
-
-
-
- Information
-
-
- Qt::AlignCenter
-
-
- true
-
-
- Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse
-
-
-
- -
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 100
- 100
-
-
-
-
-
-
- :/assets/login-qr.png
-
-
- true
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
-
- false
-
-
-
- Information
-
-
- Qt::AlignCenter
-
-
- true
-
-
- true
-
-
- Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse
-
-
-
- -
-
-
- url
-
-
- Qt::AlignCenter
-
-
- true
-
-
- Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
@@ -330,10 +432,7 @@
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Help
-
-
- false
+ QDialogButtonBox::Cancel
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index d2350fb70..041b8faff 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -130,19 +130,7 @@ void AccountListPage::listChanged()
void AccountListPage::on_actionAddMicrosoft_triggered()
{
- QMessageBox box(this);
- box.setWindowTitle(tr("Add account"));
- box.setText(tr("Where would you like to login?"));
- box.setIcon(QMessageBox::Question);
- auto authCode = box.addButton(tr("On this device"), QMessageBox::ButtonRole::NoRole);
- auto deviceCode = box.addButton(tr("On another device"), QMessageBox::ButtonRole::YesRole);
- auto cancel = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole);
- box.setDefaultButton(authCode);
- box.exec();
- if ((box.clickedButton() != deviceCode && box.clickedButton() != authCode) || box.clickedButton() == cancel)
- return;
- MinecraftAccountPtr account = MSALoginDialog::newAccount(this, box.clickedButton() == deviceCode);
-
+ auto account = MSALoginDialog::newAccount(this);
if (account) {
m_accounts->addAccount(account);
if (m_accounts->count() == 1) {
From 125fb2eaf288cd650ed82ca1f28262594e78932d Mon Sep 17 00:00:00 2001
From: Trial97
Date: Wed, 12 Jun 2024 19:34:58 +0300
Subject: [PATCH 09/38] remove png qr code
Signed-off-by: Trial97
---
launcher/resources/documents/login-qr.png | Bin 7616 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 launcher/resources/documents/login-qr.png
diff --git a/launcher/resources/documents/login-qr.png b/launcher/resources/documents/login-qr.png
deleted file mode 100644
index 9bed0a73e2e456fd810cdc997dbf0db24dcafc1c..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 7616
zcmeHMdrVVT7(ZAChJgf^DBYxU5?^tY4a7R2fR52QCg?ync`3|_3Rno(+FrCGNaiGv
zg<4WxB|&5+6tG%QXr&AkwJlX}od{g&bcL>zf)#tUJa%r)k|kz;En9MvrD^X;d(-CY
z_nqJCoZT7CaCd#z6#(GA{qu;g09agrKbI_m?=TM^s)ZNl)F?&-Sim2(iiR=(ypL^<
z*cx}dYGSA>b2xli_u_JRkNOI@-BIg$LB9#*zKib`OKCKMW(k{9@p9Z
z8b#JPhn;m1b_u-be!H=)26~HQhy`=LV%w7;a+0B#niE;B3HH&uO!El?HE-Zy0%92m
z0Bu(w&-`?bX@T&|MfPoGDaJ0N%1$MXxSUUq_L$<~I}+!YK{7M3-JVlQ%`s9{)TCSf
ziJL9O2H$SE3mdJst{f4w2;RZjxOB;YkNlffx54@==+p@-dQ8Oi+wG-h6{%*MI@H8(
zJV4*qdd#0ENJkcX5|i7a-~VI!Tf1YNu)KZIeUvB*{TnSJB)iR~(BRC#tOwuwb1@~l2W
z#5MVTjj{^T-XfJ0>0u7?w8;Ky&%9B2XN$GQr@7W%XtBLroti%SEzKs9l6%N^#Kra
z5JWrFu9nXj{8>e?jmo~E_F|%QSDlsUO@LLk%>f-rNtgT01kL~0x
zw$V_%>lO(SNjf^YDo{Y=3T3uXdUuQrdgP~+k$tUhq6||Aqg>$q_Yx|exj3fD61fOtAY~9+)F@37SQX%_@a!fp1>LxQD5!i=3d6eK
zIxaLBA+SPKmWaSGid0d+egV#eGF=NP8|Oeyq-df)n=gDk55qXQLO~a62V%4O?RI-_
zZ?AC!09eZ3q;z1a8w(?tuY_h&`HL>Tfq`AZqaN&%G%8JD(dOjx2XhXPsn#ZlKYXm}
z{v44J2+E#Q!SN3N@dDN4L$O-ziOW~0$)P$ZOKRuZ4xwa1qtKs;^MDT&1$%N&2cmkv!{guEH
z;a@qvnr)s7S`Lp)fY(zN{ag~$6DT!!EPoW=16ct$4^`r)55r%=BNhEYJO-rUgK$j*
d57Yk1tqImvWx8DuF2sL)`)AP+P22XL{sR(L{Sp8G
From 80ea67f7cf3fa8d74e595546e4c0828868d3b18a Mon Sep 17 00:00:00 2001
From: Trial97
Date: Thu, 13 Jun 2024 00:00:08 +0300
Subject: [PATCH 10/38] finish login dialog
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.cpp | 11 -----------
launcher/ui/dialogs/MSALoginDialog.ui | 17 ++---------------
2 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 0a3bca86b..aebd04f08 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -60,8 +60,6 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
font.setFixedPitch(true);
ui->code->setFont(font);
- // ui->buttonBox->button(QDialogButtonBox::Help)->setDefault(false);
-
connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); });
ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(75, 75)));
ui->title->setText(tr("Login to %1").arg(BuildConfig.LAUNCHER_DISPLAYNAME));
@@ -129,16 +127,7 @@ void MSALoginDialog::onTaskFailed(QString reason)
void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
{
ui->stackedWidget->setCurrentIndex(1);
- // DesktopServices::openUrl(url);
- const auto uri = url.toString();
- const auto linkString = QString("%2 ").arg(uri, uri);
m_url = url;
- ui->link->setText(linkString);
- // ui->urlInfo->setText(
- // tr("Browser opened to complete the login process."
- // " "
- // "If your browser hasn't opened, please manually open the following link and choose your account:"));
- // ui->url->setText(linkString);
}
void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn)
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index b2ad80270..cac91512e 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -6,8 +6,8 @@
0
0
- 772
- 326
+ 770
+ 256
@@ -121,19 +121,6 @@
- -
-
-
- TextLabel
-
-
- Qt::AlignCenter
-
-
- true
-
-
-
-
-
From 2b229d7326f7460c766a9a4dc7d8685d21a3601e Mon Sep 17 00:00:00 2001
From: Trial97
Date: Thu, 13 Jun 2024 00:20:16 +0300
Subject: [PATCH 11/38] increase qr code size
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.cpp | 2 +-
launcher/ui/dialogs/MSALoginDialog.ui | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index aebd04f08..6f2937335 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -61,7 +61,7 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
ui->code->setFont(font);
connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); });
- ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(75, 75)));
+ ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150)));
ui->title->setText(tr("Login to %1").arg(BuildConfig.LAUNCHER_DISPLAYNAME));
connect(ui->loginButton, &QPushButton::clicked, this, [this] {
if (m_url.isValid())
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index cac91512e..02710e940 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -7,7 +7,7 @@
0
0
770
- 256
+ 331
@@ -270,14 +270,14 @@
- 75
- 75
+ 150
+ 150
- 100
- 100
+ 200
+ 200
From 7fdc65eda8032c677e6b1cc3b50dc7ea3c422ada Mon Sep 17 00:00:00 2001
From: Trial97
Date: Thu, 13 Jun 2024 08:51:11 +0300
Subject: [PATCH 12/38] add tooltip to url button
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp | 4 ++--
launcher/ui/dialogs/MSALoginDialog.cpp | 10 ++++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp b/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp
index c34351bf2..7df93d04d 100644
--- a/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp
+++ b/launcher/minecraft/auth/steps/MSADeviceCodeStep.cpp
@@ -46,6 +46,8 @@
MSADeviceCodeStep::MSADeviceCodeStep(AccountData* data) : AuthStep(data)
{
m_clientId = APPLICATION->getMSAClientID();
+ connect(&m_expiration_timer, &QTimer::timeout, this, &MSADeviceCodeStep::abort);
+ connect(&m_pool_timer, &QTimer::timeout, this, &MSADeviceCodeStep::authenticateUser);
}
QString MSADeviceCodeStep::describe()
@@ -133,11 +135,9 @@ void MSADeviceCodeStep::deviceAutorizationFinished()
m_expiration_timer.setTimerType(Qt::VeryCoarseTimer);
m_expiration_timer.setInterval(rsp.expires_in * 1000);
m_expiration_timer.setSingleShot(true);
- connect(&m_expiration_timer, &QTimer::timeout, this, &MSADeviceCodeStep::abort);
m_expiration_timer.start();
m_pool_timer.setTimerType(Qt::VeryCoarseTimer);
m_pool_timer.setSingleShot(true);
- connect(&m_pool_timer, &QTimer::timeout, this, &MSADeviceCodeStep::authenticateUser);
startPoolTimer();
}
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 6f2937335..59b45a0e4 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -64,8 +64,11 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150)));
ui->title->setText(tr("Login to %1").arg(BuildConfig.LAUNCHER_DISPLAYNAME));
connect(ui->loginButton, &QPushButton::clicked, this, [this] {
- if (m_url.isValid())
- DesktopServices::openUrl(m_url);
+ if (m_url.isValid()) {
+ if (!DesktopServices::openUrl(m_url)) {
+ QApplication::clipboard()->setText(m_url.toString());
+ }
+ }
});
}
@@ -104,6 +107,8 @@ MSALoginDialog::~MSALoginDialog()
void MSALoginDialog::onTaskFailed(QString reason)
{
// Set message
+ m_authflow_task->disconnect();
+ m_devicecode_task->disconnect();
ui->stackedWidget->setCurrentIndex(0);
auto lines = reason.split('\n');
QString processed;
@@ -127,6 +132,7 @@ void MSALoginDialog::onTaskFailed(QString reason)
void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
{
ui->stackedWidget->setCurrentIndex(1);
+ ui->loginButton->setToolTip(QString("%1
").arg(url.toString()));
m_url = url;
}
From f7c3e08ac8a8edf03d0be05257a4ac66cf4b6765 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Thu, 13 Jun 2024 18:27:37 +0300
Subject: [PATCH 13/38] add prismlauncher to plist
Signed-off-by: Trial97
---
cmake/MacOSXBundleInfo.plist.in | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/cmake/MacOSXBundleInfo.plist.in b/cmake/MacOSXBundleInfo.plist.in
index c439efe25..6d3845dfc 100644
--- a/cmake/MacOSXBundleInfo.plist.in
+++ b/cmake/MacOSXBundleInfo.plist.in
@@ -79,6 +79,14 @@
curseforge
+
+ CFBundleURLName
+ Prismlauncher
+ CFBundleURLSchemes
+
+ prismlauncher
+
+
From 6e8dc6ccc06ee706d71fd730f055396cd405be11 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Thu, 13 Jun 2024 19:20:32 +0300
Subject: [PATCH 14/38] add mouse interaction on microsoft link
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.ui | 3 +++
1 file changed, 3 insertions(+)
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index 02710e940..0d4b9f04a 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -393,6 +393,9 @@
true
+
+ Qt::TextBrowserInteraction
+
-
From 712fbc3a4bde6d8a112074247d330a7b55cd1a07 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 11:15:40 +0300
Subject: [PATCH 15/38] reverse login layout
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 21 +-
launcher/ui/dialogs/MSALoginDialog.cpp | 8 +-
launcher/ui/dialogs/MSALoginDialog.ui | 564 +++++++++-------------
3 files changed, 263 insertions(+), 330 deletions(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 78cb0b8d2..97590e273 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -37,10 +37,12 @@
#include
#include
+#include
#include
#include "Application.h"
#include "BuildConfig.h"
+#include "FileSystem.h"
class CustomOAuthOobReplyHandler : public QOAuthOobReplyHandler {
Q_OBJECT
@@ -61,9 +63,24 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
{
m_clientId = APPLICATION->getMSAClientID();
- auto bv = new CustomOAuthOobReplyHandler();
+ if (QCoreApplication::applicationFilePath().startsWith("/tmp/.mount_") ||
+ QFile::exists(FS::PathCombine(APPLICATION->root(), "portable.txt")))
- oauth2.setReplyHandler(bv);
+ {
+ auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this);
+ replyHandler->setCallbackText(R"XXX(
+
+
+
+ Login Successful, redirecting...
+
+ )XXX");
+ oauth2.setReplyHandler(replyHandler);
+ } else {
+ oauth2.setReplyHandler(new CustomOAuthOobReplyHandler(this));
+ }
oauth2.setAuthorizationUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize"));
oauth2.setAccessTokenUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/token"));
oauth2.setScope("XboxLive.SignIn XboxLive.offline_access");
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 59b45a0e4..04453499d 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -61,8 +61,7 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
ui->code->setFont(font);
connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); });
- ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150)));
- ui->title->setText(tr("Login to %1").arg(BuildConfig.LAUNCHER_DISPLAYNAME));
+ ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150), Qt::KeepAspectRatio));
connect(ui->loginButton, &QPushButton::clicked, this, [this] {
if (m_url.isValid()) {
if (!DesktopServices::openUrl(m_url)) {
@@ -119,8 +118,11 @@ void MSALoginDialog::onTaskFailed(QString reason)
processed += " ";
}
}
- auto task = qobject_cast(sender());
ui->status->setText(processed);
+ auto task = m_authflow_task;
+ if (task->failReason().isEmpty()) {
+ task = m_devicecode_task;
+ }
if (task) {
ui->loadingLabel->setText(task->getStatus());
}
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index 0d4b9f04a..bb9157aea 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -6,10 +6,16 @@
0
0
- 770
- 331
+ 440
+ 430
+
+
+ 0
+ 430
+
+
Add Microsoft Account
@@ -83,338 +89,246 @@
-
+
-
-
+
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
-
- 16
- 75
- true
-
-
-
- Login to Prismlauncher
-
-
- Qt::AlignCenter
-
-
- true
-
-
-
- -
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 250
- 40
-
-
-
- Login with Microsoft
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
-
-
- -
-
- -
-
-
-
- 0
- 0
-
-
-
- 1
-
-
- Qt::Vertical
-
-
-
-
-
- -
-
-
- Or
-
-
- Qt::AlignCenter
-
-
-
- -
-
- -
-
-
-
- 0
- 0
-
-
-
- 1
-
-
- Qt::Vertical
-
-
-
-
-
-
+
+
+
+ 250
+ 40
+
+
+
+ Login with Microsoft
+
+
+ true
+
+
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 150
- 150
-
-
-
-
- 200
- 200
-
-
-
-
-
-
- true
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 30
- 75
- true
-
-
-
- IBeamCursor
-
-
- CODE
-
-
- Qt::AlignCenter
-
-
- Qt::TextBrowserInteraction
-
-
-
- -
-
-
- Copy code to clipboard
-
-
-
-
-
-
- . .
-
-
-
- 22
- 22
-
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
- TextLabel
-
-
- Qt::AlignCenter
-
-
- true
-
-
- Qt::TextBrowserInteraction
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+ -
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ Or
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 150
+ 150
+
+
+
+
+ 150
+ 150
+
+
+
+
+
+
+ true
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 30
+ 75
+ true
+
+
+
+ IBeamCursor
+
+
+ CODE
+
+
+ Qt::AlignCenter
+
+
+ Qt::TextBrowserInteraction
+
+
+
+ -
+
+
+ Copy code to clipboard
+
+
+
+
+
+
+ . .
+
+
+
+ 22
+ 22
+
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+ Qt::TextBrowserInteraction
+
+
+
From 014721ca10d651f299041eb453a9ef221d260cd9 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 11:19:54 +0300
Subject: [PATCH 16/38] remove unused import
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 04453499d..047364714 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -36,7 +36,6 @@
#include "MSALoginDialog.h"
#include "Application.h"
-#include "BuildConfig.h"
#include "ui_MSALoginDialog.h"
#include "DesktopServices.h"
From c35461b314c6283ea32fd29b65a29cfc1cd0fecd Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 11:23:14 +0300
Subject: [PATCH 17/38] remove aspect ratio
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 047364714..799b5b332 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -60,7 +60,7 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
ui->code->setFont(font);
connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); });
- ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150), Qt::KeepAspectRatio));
+ ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150)));
connect(ui->loginButton, &QPushButton::clicked, this, [this] {
if (m_url.isValid()) {
if (!DesktopServices::openUrl(m_url)) {
From 74a86df53c3f11c4edc31ccecf428232338a141c Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 12:41:37 +0300
Subject: [PATCH 18/38] update the desktop file
Signed-off-by: Trial97
---
program_info/org.prismlauncher.PrismLauncher.desktop.in | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/program_info/org.prismlauncher.PrismLauncher.desktop.in b/program_info/org.prismlauncher.PrismLauncher.desktop.in
index 7d186a2e7..e33ce1601 100644
--- a/program_info/org.prismlauncher.PrismLauncher.desktop.in
+++ b/program_info/org.prismlauncher.PrismLauncher.desktop.in
@@ -1,13 +1,13 @@
[Desktop Entry]
Version=1.0
-Name=Prism Launcher
+Name=@Launcher_DisplayName@
Comment=Discover, manage, and play Minecraft instances
Type=Application
Terminal=false
Exec=@Launcher_APP_BINARY_NAME@ %U
StartupNotify=true
-Icon=org.prismlauncher.PrismLauncher
+Icon=org.@Launcher_APP_BINARY_NAME@.@Launcher_Name@
Categories=Game;ActionGame;AdventureGame;Simulation;
Keywords=game;minecraft;mc;
-StartupWMClass=PrismLauncher
-MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;x-scheme-handler/prismlauncher;
+StartupWMClass=@Launcher_Name@
+MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;x-scheme-handler/@Launcher_APP_BINARY_NAME@;
From f60d0135f7f357695f5a34a7cb667a770dbe1a15 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 12:47:44 +0300
Subject: [PATCH 19/38] made login link to open browser
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.ui | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index bb9157aea..fe883e915 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -316,7 +316,7 @@
-
- TextLabel
+ Info
Qt::AlignCenter
@@ -324,6 +324,9 @@
true
+
+ true
+
Qt::TextBrowserInteraction
From 8db0b5f421a7f0e917fe2a33076fd07324cefc8e Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 12:48:37 +0300
Subject: [PATCH 20/38] Register mime-type on the fly
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 97 ++++++++++++++++++++++-
1 file changed, 95 insertions(+), 2 deletions(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 97590e273..edb3f6559 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -44,6 +44,100 @@
#include "BuildConfig.h"
#include "FileSystem.h"
+#include
+#include
+#include
+
+bool isSchemeHandlerRegistered()
+{
+ QProcess process;
+ process.start("xdg-mime", { "query", "default", "x-scheme-handler/" + BuildConfig.LAUNCHER_APP_BINARY_NAME });
+ process.waitForFinished();
+ QString output = process.readAllStandardOutput().trimmed();
+
+ return output.contains(BuildConfig.LAUNCHER_APP_BINARY_NAME);
+}
+
+bool registerSchemeHandler()
+{
+#ifdef Q_OS_LINUX
+
+ // Paths for user-specific installations
+ QString desktopFilePath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) +
+ QString("/%1.desktop").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
+ QString mimeFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
+ QString("/mime/packages/x-scheme-handler-%1.xml").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
+ QFile desktopFile(desktopFilePath);
+ QFile mimeFile(mimeFilePath);
+ if ((desktopFile.exists() && mimeFile.exists()) || isSchemeHandlerRegistered()) {
+ return true;
+ }
+ // Create and write the .desktop file
+ if (desktopFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QTextStream out(&desktopFile);
+ out << QString(R"XXX([Desktop Entry]
+Version=1.0
+Name=%1
+Comment=Discover, manage, and play Minecraft instances
+Type=Application
+Terminal=false
+Exec=%2 %U
+StartupNotify=true
+Icon=org.%2.%3
+Categories=Game;ActionGame;AdventureGame;Simulation;
+Keywords=game;minecraft;mc;
+StartupWMClass=%3
+MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;x-scheme-handler/%2;
+)XXX")
+ .arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.LAUNCHER_APP_BINARY_NAME, BuildConfig.LAUNCHER_NAME);
+ desktopFile.close();
+ } else {
+ qDebug() << "Failed to write .desktop file:" << desktopFilePath;
+ return false;
+ }
+
+ // Create and write the MIME type XML file
+ if (mimeFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QTextStream out(&mimeFile);
+ out << "\n";
+ out << "\n";
+ out << QString(" \n").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
+ out << QString(" \n").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
+ out << " \n";
+ out << " \n";
+ mimeFile.close();
+ } else {
+ qDebug() << "Failed to write MIME type XML file:" << mimeFilePath;
+ return false;
+ }
+
+ // Update the MIME database
+ QProcess::execute("update-mime-database", { QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) });
+
+ // Update the desktop database
+ QProcess::execute("update-desktop-database", { QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) });
+
+ qDebug() << "Custom URL scheme handler registered successfully.";
+
+#elif defined(Q_OS_WIN)
+ QString regPath = QString("HKEY_CURRENT_USER\\Software\\Classes\\%1").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
+ QSettings settings(regPath, QSettings::NativeFormat);
+
+ if (settings.contains("shell/open/command/.")) {
+ return true;
+ }
+ QString appPath = QCoreApplication::applicationFilePath().replace("/", "\\");
+
+ settings.setValue(".", QString("URL:%1 Protocol")).arg(BuildConfig.LAUNCHER_NAME);
+ settings.setValue("URL Protocol", "");
+ settings.setValue("DefaultIcon/.", QString("\"%1\",1").arg(appPath));
+ settings.setValue("shell/open/command/.", QString("\"%1\" \"%2\"").arg(appPath).arg("%1"));
+
+ qDebug() << "Custom URL scheme handler registered successfully in Windows Registry.";
+#endif
+ return true;
+}
+
class CustomOAuthOobReplyHandler : public QOAuthOobReplyHandler {
Q_OBJECT
@@ -63,8 +157,7 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
{
m_clientId = APPLICATION->getMSAClientID();
- if (QCoreApplication::applicationFilePath().startsWith("/tmp/.mount_") ||
- QFile::exists(FS::PathCombine(APPLICATION->root(), "portable.txt")))
+ if (!registerSchemeHandler())
{
auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this);
From 3db4f4dc2be7c51e3838cd4dbca5f813165c3470 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 13:00:59 +0300
Subject: [PATCH 21/38] fix build
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 2 +-
launcher/ui/dialogs/MSALoginDialog.ui | 2 +-
program_info/org.prismlauncher.PrismLauncher.desktop.in | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index edb3f6559..05c25586b 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -42,10 +42,10 @@
#include "Application.h"
#include "BuildConfig.h"
-#include "FileSystem.h"
#include
#include
+#include
#include
bool isSchemeHandlerRegistered()
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index fe883e915..abf4b8876 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -114,7 +114,7 @@
- Login with Microsoft
+ Sign in with Microsoft
true
diff --git a/program_info/org.prismlauncher.PrismLauncher.desktop.in b/program_info/org.prismlauncher.PrismLauncher.desktop.in
index e33ce1601..c0e4e9458 100644
--- a/program_info/org.prismlauncher.PrismLauncher.desktop.in
+++ b/program_info/org.prismlauncher.PrismLauncher.desktop.in
@@ -6,8 +6,8 @@ Type=Application
Terminal=false
Exec=@Launcher_APP_BINARY_NAME@ %U
StartupNotify=true
-Icon=org.@Launcher_APP_BINARY_NAME@.@Launcher_Name@
+Icon=org.@Launcher_APP_BINARY_NAME@.@Launcher_CommonName@
Categories=Game;ActionGame;AdventureGame;Simulation;
Keywords=game;minecraft;mc;
-StartupWMClass=@Launcher_Name@
+StartupWMClass=@Launcher_CommonName@
MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;x-scheme-handler/@Launcher_APP_BINARY_NAME@;
From 164d31dcb1a2c4a9815e321bea8908750927e9db Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 13:09:22 +0300
Subject: [PATCH 22/38] fix win build take#2
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 05c25586b..8f3c2bc5e 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -128,7 +128,7 @@ MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/cur
}
QString appPath = QCoreApplication::applicationFilePath().replace("/", "\\");
- settings.setValue(".", QString("URL:%1 Protocol")).arg(BuildConfig.LAUNCHER_NAME);
+ settings.setValue(".", QString("URL:%1 Protocol").arg(BuildConfig.LAUNCHER_NAME));
settings.setValue("URL Protocol", "");
settings.setValue("DefaultIcon/.", QString("\"%1\",1").arg(appPath));
settings.setValue("shell/open/command/.", QString("\"%1\" \"%2\"").arg(appPath).arg("%1"));
From 52490743b4e515f949063d97a3dc061f80b13bad Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 14:16:23 +0300
Subject: [PATCH 23/38] revert desktop file creation
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 81 ++---------------------
1 file changed, 5 insertions(+), 76 deletions(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 8f3c2bc5e..b47a10583 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -42,98 +42,27 @@
#include "Application.h"
#include "BuildConfig.h"
+#include "FileSystem.h"
-#include
#include
#include
#include
bool isSchemeHandlerRegistered()
{
+#ifdef Q_OS_LINUX
QProcess process;
process.start("xdg-mime", { "query", "default", "x-scheme-handler/" + BuildConfig.LAUNCHER_APP_BINARY_NAME });
process.waitForFinished();
QString output = process.readAllStandardOutput().trimmed();
return output.contains(BuildConfig.LAUNCHER_APP_BINARY_NAME);
-}
-
-bool registerSchemeHandler()
-{
-#ifdef Q_OS_LINUX
-
- // Paths for user-specific installations
- QString desktopFilePath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) +
- QString("/%1.desktop").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
- QString mimeFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
- QString("/mime/packages/x-scheme-handler-%1.xml").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
- QFile desktopFile(desktopFilePath);
- QFile mimeFile(mimeFilePath);
- if ((desktopFile.exists() && mimeFile.exists()) || isSchemeHandlerRegistered()) {
- return true;
- }
- // Create and write the .desktop file
- if (desktopFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
- QTextStream out(&desktopFile);
- out << QString(R"XXX([Desktop Entry]
-Version=1.0
-Name=%1
-Comment=Discover, manage, and play Minecraft instances
-Type=Application
-Terminal=false
-Exec=%2 %U
-StartupNotify=true
-Icon=org.%2.%3
-Categories=Game;ActionGame;AdventureGame;Simulation;
-Keywords=game;minecraft;mc;
-StartupWMClass=%3
-MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;x-scheme-handler/%2;
-)XXX")
- .arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.LAUNCHER_APP_BINARY_NAME, BuildConfig.LAUNCHER_NAME);
- desktopFile.close();
- } else {
- qDebug() << "Failed to write .desktop file:" << desktopFilePath;
- return false;
- }
-
- // Create and write the MIME type XML file
- if (mimeFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
- QTextStream out(&mimeFile);
- out << "\n";
- out << "\n";
- out << QString(" \n").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
- out << QString(" \n").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
- out << " \n";
- out << " \n";
- mimeFile.close();
- } else {
- qDebug() << "Failed to write MIME type XML file:" << mimeFilePath;
- return false;
- }
-
- // Update the MIME database
- QProcess::execute("update-mime-database", { QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) });
-
- // Update the desktop database
- QProcess::execute("update-desktop-database", { QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) });
-
- qDebug() << "Custom URL scheme handler registered successfully.";
#elif defined(Q_OS_WIN)
QString regPath = QString("HKEY_CURRENT_USER\\Software\\Classes\\%1").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
QSettings settings(regPath, QSettings::NativeFormat);
- if (settings.contains("shell/open/command/.")) {
- return true;
- }
- QString appPath = QCoreApplication::applicationFilePath().replace("/", "\\");
-
- settings.setValue(".", QString("URL:%1 Protocol").arg(BuildConfig.LAUNCHER_NAME));
- settings.setValue("URL Protocol", "");
- settings.setValue("DefaultIcon/.", QString("\"%1\",1").arg(appPath));
- settings.setValue("shell/open/command/.", QString("\"%1\" \"%2\"").arg(appPath).arg("%1"));
-
- qDebug() << "Custom URL scheme handler registered successfully in Windows Registry.";
+ return settings.contains("shell/open/command/.");
#endif
return true;
}
@@ -156,8 +85,8 @@ class CustomOAuthOobReplyHandler : public QOAuthOobReplyHandler {
MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(silent)
{
m_clientId = APPLICATION->getMSAClientID();
-
- if (!registerSchemeHandler())
+ if (QCoreApplication::applicationFilePath().startsWith("/tmp/.mount_") ||
+ QFile::exists(FS::PathCombine(APPLICATION->root(), "portable.txt")) || !isSchemeHandlerRegistered())
{
auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this);
From 863ebe421cf905bd26427f76124da675a9b89737 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 16:38:41 +0300
Subject: [PATCH 24/38] randomize server port
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index b47a10583..2b8a02186 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -89,7 +89,7 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
QFile::exists(FS::PathCombine(APPLICATION->root(), "portable.txt")) || !isSchemeHandlerRegistered())
{
- auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this);
+ auto replyHandler = new QOAuthHttpServerReplyHandler(0, this);
replyHandler->setCallbackText(R"XXX(
From 9d16557328b936d23a9e999ab9127d346ecba261 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 14 Jun 2024 16:40:27 +0300
Subject: [PATCH 25/38] simplify constructor
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 2b8a02186..8899b224b 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -89,7 +89,7 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
QFile::exists(FS::PathCombine(APPLICATION->root(), "portable.txt")) || !isSchemeHandlerRegistered())
{
- auto replyHandler = new QOAuthHttpServerReplyHandler(0, this);
+ auto replyHandler = new QOAuthHttpServerReplyHandler(this);
replyHandler->setCallbackText(R"XXX(
From 24aa337a64cca509d249f57434d489d459ae9c9d Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sun, 23 Jun 2024 00:27:49 +0300
Subject: [PATCH 26/38] fixed offline accounts
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 8899b224b..62066b572 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -119,9 +119,18 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
emit finished(AccountTaskState::STATE_WORKING, tr("Got "));
});
connect(&oauth2, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, this, &MSAStep::authorizeWithBrowser);
- connect(&oauth2, &QOAuth2AuthorizationCodeFlow::requestFailed, this, [this](const QAbstractOAuth2::Error err) {
- emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Microsoft user authentication failed."));
+ connect(&oauth2, &QOAuth2AuthorizationCodeFlow::requestFailed, this, [this, silent](const QAbstractOAuth2::Error err) {
+ auto state = AccountTaskState::STATE_FAILED_HARD;
+ if (oauth2.status() == QAbstractOAuth::Status::Granted || silent) {
+ state = AccountTaskState::STATE_FAILED_SOFT;
+ }
+ emit finished(state, tr("Microsoft user authentication failed."));
});
+ connect(&oauth2, &QOAuth2AuthorizationCodeFlow::error, this,
+ [this](const QString& error, const QString& errorDescription, const QUrl& uri) {
+ qDebug() << "Failed to login because" << error << errorDescription;
+ emit finished(AccountTaskState::STATE_FAILED_HARD, errorDescription);
+ });
connect(&oauth2, &QOAuth2AuthorizationCodeFlow::extraTokensChanged, this,
[this](const QVariantMap& tokens) { m_data->msaToken.extra = tokens; });
@@ -141,17 +150,18 @@ void MSAStep::perform()
if (m_data->msaClientID != m_clientId) {
emit finished(AccountTaskState::STATE_DISABLED,
tr("Microsoft user authentication failed - client identification has changed."));
+ return;
}
oauth2.setRefreshToken(m_data->msaToken.refresh_token);
oauth2.refreshAccessToken();
} else {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) // QMultiMap param changed in 6.0
- oauth2.setModifyParametersFunction([](QAbstractOAuth::Stage stage, QMultiMap* map) {
+ oauth2.setModifyParametersFunction(
+ [](QAbstractOAuth::Stage stage, QMultiMap* map) { map->insert("prompt", "select_account"); });
#else
- oauth2.setModifyParametersFunction([](QAbstractOAuth::Stage stage, QMap* map) {
+ oauth2.setModifyParametersFunction(
+ [](QAbstractOAuth::Stage stage, QMap* map) { map->insert("prompt", "select_account"); });
#endif
- map->insert("prompt", "select_account");
- });
*m_data = AccountData();
m_data->msaClientID = m_clientId;
From b0386a4c2f323631b3b33d877a5a6e31312aa069 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sun, 23 Jun 2024 00:47:48 +0300
Subject: [PATCH 27/38] added better error handling
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 62066b572..665070bd3 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -124,11 +124,16 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
if (oauth2.status() == QAbstractOAuth::Status::Granted || silent) {
state = AccountTaskState::STATE_FAILED_SOFT;
}
- emit finished(state, tr("Microsoft user authentication failed."));
+ auto message = tr("Microsoft user authentication failed.");
+ if (silent) {
+ message = tr("Failed to refresh token.");
+ }
+ qWarning() << message;
+ emit finished(state, message);
});
connect(&oauth2, &QOAuth2AuthorizationCodeFlow::error, this,
[this](const QString& error, const QString& errorDescription, const QUrl& uri) {
- qDebug() << "Failed to login because" << error << errorDescription;
+ qWarning() << "Failed to login because" << error << errorDescription;
emit finished(AccountTaskState::STATE_FAILED_HARD, errorDescription);
});
@@ -152,6 +157,10 @@ void MSAStep::perform()
tr("Microsoft user authentication failed - client identification has changed."));
return;
}
+ if (m_data->msaToken.refresh_token.isEmpty()) {
+ emit finished(AccountTaskState::STATE_DISABLED, tr("Microsoft user authentication failed - refresh token is empty."));
+ return;
+ }
oauth2.setRefreshToken(m_data->msaToken.refresh_token);
oauth2.refreshAccessToken();
} else {
From 2ac89c237857ac38f72406f6e665f97e502b22f4 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sun, 23 Jun 2024 01:49:37 +0300
Subject: [PATCH 28/38] add more states for account refresh fail
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/MSAStep.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp
index 665070bd3..3db04bf2f 100644
--- a/launcher/minecraft/auth/steps/MSAStep.cpp
+++ b/launcher/minecraft/auth/steps/MSAStep.cpp
@@ -122,7 +122,11 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile
connect(&oauth2, &QOAuth2AuthorizationCodeFlow::requestFailed, this, [this, silent](const QAbstractOAuth2::Error err) {
auto state = AccountTaskState::STATE_FAILED_HARD;
if (oauth2.status() == QAbstractOAuth::Status::Granted || silent) {
- state = AccountTaskState::STATE_FAILED_SOFT;
+ if (err == QAbstractOAuth2::Error::NetworkError) {
+ state = AccountTaskState::STATE_OFFLINE;
+ } else {
+ state = AccountTaskState::STATE_FAILED_SOFT;
+ }
}
auto message = tr("Microsoft user authentication failed.");
if (silent) {
From 9d7c36c2fcdbf6e5c99270e875ef27acaf589f71 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Thu, 27 Jun 2024 15:35:44 +0300
Subject: [PATCH 29/38] made identty certain if the login ended
Signed-off-by: Trial97
---
launcher/minecraft/auth/steps/GetSkinStep.cpp | 2 +-
launcher/minecraft/auth/steps/MinecraftProfileStep.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/launcher/minecraft/auth/steps/GetSkinStep.cpp b/launcher/minecraft/auth/steps/GetSkinStep.cpp
index d9785b16a..a54366b50 100644
--- a/launcher/minecraft/auth/steps/GetSkinStep.cpp
+++ b/launcher/minecraft/auth/steps/GetSkinStep.cpp
@@ -29,5 +29,5 @@ void GetSkinStep::onRequestDone()
{
if (m_task->error() == QNetworkReply::NoError)
m_data->minecraftProfile.skin.data = *m_response;
- emit finished(AccountTaskState::STATE_SUCCEEDED, tr("Got skin"));
+ emit finished(AccountTaskState::STATE_WORKING, tr("Got skin"));
}
diff --git a/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp b/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp
index 305f44320..aef6f43af 100644
--- a/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp
+++ b/launcher/minecraft/auth/steps/MinecraftProfileStep.cpp
@@ -36,7 +36,7 @@ void MinecraftProfileStep::onRequestDone()
if (m_task->error() == QNetworkReply::ContentNotFoundError) {
// NOTE: Succeed even if we do not have a profile. This is a valid account state.
m_data->minecraftProfile = MinecraftProfile();
- emit finished(AccountTaskState::STATE_SUCCEEDED, tr("Account has no Minecraft profile."));
+ emit finished(AccountTaskState::STATE_WORKING, tr("Account has no Minecraft profile."));
return;
}
if (m_task->error() != QNetworkReply::NoError) {
From 2c02d022142950961df31d8d19e9bcf39999c1ce Mon Sep 17 00:00:00 2001
From: Trial97
Date: Fri, 28 Jun 2024 14:11:27 +0300
Subject: [PATCH 30/38] do not display message that no update is avvailable if
the check was done in the background
Signed-off-by: Trial97
---
launcher/updater/PrismExternalUpdater.cpp | 9 +++++++--
launcher/updater/PrismExternalUpdater.h | 1 +
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/launcher/updater/PrismExternalUpdater.cpp b/launcher/updater/PrismExternalUpdater.cpp
index dc1aae872..69774dc04 100644
--- a/launcher/updater/PrismExternalUpdater.cpp
+++ b/launcher/updater/PrismExternalUpdater.cpp
@@ -85,6 +85,11 @@ PrismExternalUpdater::~PrismExternalUpdater()
}
void PrismExternalUpdater::checkForUpdates()
+{
+ checkForUpdates(true);
+}
+
+void PrismExternalUpdater::checkForUpdates(bool triggeredByUser)
{
QProgressDialog progress(tr("Checking for updates..."), "", 0, 0, priv->parent);
progress.setCancelButton(nullptr);
@@ -160,7 +165,7 @@ void PrismExternalUpdater::checkForUpdates()
switch (exit_code) {
case 0:
// no update available
- {
+ if (triggeredByUser) {
qDebug() << "No update available";
auto msgBox = QMessageBox(QMessageBox::Information, tr("No Update Available"), tr("You are running the latest version."),
QMessageBox::Ok, priv->parent);
@@ -288,7 +293,7 @@ void PrismExternalUpdater::disconnectTimer()
void PrismExternalUpdater::autoCheckTimerFired()
{
qDebug() << "Auto update Timer fired";
- checkForUpdates();
+ checkForUpdates(false);
}
void PrismExternalUpdater::offerUpdate(const QString& version_name, const QString& version_tag, const QString& release_notes)
diff --git a/launcher/updater/PrismExternalUpdater.h b/launcher/updater/PrismExternalUpdater.h
index bfe94c149..b88676028 100644
--- a/launcher/updater/PrismExternalUpdater.h
+++ b/launcher/updater/PrismExternalUpdater.h
@@ -41,6 +41,7 @@ class PrismExternalUpdater : public ExternalUpdater {
* Check for updates manually, showing the user a progress bar and an alert if no updates are found.
*/
void checkForUpdates() override;
+ void checkForUpdates(bool triggeredByUser);
/*!
* Indicates whether or not to check for updates automatically.
From f1a4a1e8ee70ce298d745ea225a69d04a58e04da Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sat, 29 Jun 2024 08:41:35 +0300
Subject: [PATCH 31/38] increase 'or' font size for login dialog
Signed-off-by: Trial97
---
launcher/ui/dialogs/MSALoginDialog.ui | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui
index abf4b8876..c6821782f 100644
--- a/launcher/ui/dialogs/MSALoginDialog.ui
+++ b/launcher/ui/dialogs/MSALoginDialog.ui
@@ -153,6 +153,11 @@
-
+
+
+ 16
+
+
Or
From eab53c6e42c86ee1dc80b1b8a082212552b6db7b Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sat, 29 Jun 2024 14:02:09 +0300
Subject: [PATCH 32/38] make sure updater take into consideration UserData
Signed-off-by: Trial97
---
launcher/updater/prismupdater/PrismUpdater.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp
index 83d8efa22..03c3d2d8f 100644
--- a/launcher/updater/prismupdater/PrismUpdater.cpp
+++ b/launcher/updater/prismupdater/PrismUpdater.cpp
@@ -328,6 +328,9 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
adjustedBy = "Command line";
m_dataPath = dirParam;
#ifndef Q_OS_MACOS
+ if (QDir(FS::PathCombine(m_rootPath, "UserData")).exists()) {
+ m_isPortable = true;
+ }
if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
m_isPortable = true;
}
@@ -338,7 +341,11 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
adjustedBy = "Persistent data path";
#ifndef Q_OS_MACOS
- if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
+ if (auto portableUserData = FS::PathCombine(m_rootPath, "UserData"); QDir(portableUserData).exists()) {
+ m_dataPath = portableUserData;
+ adjustedBy = "Portable user data path";
+ m_isPortable = true;
+ } else if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
m_dataPath = m_rootPath;
adjustedBy = "Portable data path";
m_isPortable = true;
From 41bcfb3c07861bf960816927d7f90bea9708d3b9 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 29 Jun 2024 03:44:49 -0700
Subject: [PATCH 33/38] Fix #2586 non portable linux update technically works
even if not genraly a good idea.
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/updater/prismupdater/PrismUpdater.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp
index 83d8efa22..96ef48b12 100644
--- a/launcher/updater/prismupdater/PrismUpdater.cpp
+++ b/launcher/updater/prismupdater/PrismUpdater.cpp
@@ -1020,7 +1020,7 @@ void PrismUpdaterApp::performInstall(QFileInfo file)
FS::write(changelog_path, m_install_release.body.toUtf8());
logUpdate(tr("Updating from %1 to %2").arg(m_prismVersion).arg(m_install_release.tag_name));
- if (m_isPortable || file.suffix().toLower() == "zip") {
+ if (m_isPortable || file.fileName().endsWith(".zip") || file.fileName().endsWith(".tar.gz")) {
write_lock_file(update_lock_path, QDateTime::currentDateTime(), m_prismVersion, m_install_release.tag_name, m_rootPath, m_dataPath);
logUpdate(tr("Updating portable install at %1").arg(m_rootPath));
unpackAndInstall(file);
From 9d1fffff27854c3895ab316981d76d61c7e4f3ae Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 29 Jun 2024 03:57:30 -0700
Subject: [PATCH 34/38] reject zsync file as valid build artifact
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/updater/prismupdater/PrismUpdater.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp
index 96ef48b12..b335a19f9 100644
--- a/launcher/updater/prismupdater/PrismUpdater.cpp
+++ b/launcher/updater/prismupdater/PrismUpdater.cpp
@@ -787,6 +787,10 @@ QList PrismUpdaterApp::validReleaseArtifacts(const GitHubRel
if (BuildConfig.BUILD_ARTIFACT.isEmpty())
qWarning() << "Build platform is not set!";
for (auto asset : release.assets) {
+ if (asset.name.endsWith("zsync")) {
+ qDebug() << "Rejecting zsync file" << asset.name;
+ continue;
+ }
if (!m_isAppimage && asset.name.toLower().endsWith("appimage")) {
qDebug() << "Rejecting" << asset.name << "because it is an AppImage";
continue;
From b4f5c3d241c6e9c8525d786c0bbaf860a18032b0 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 29 Jun 2024 04:08:04 -0700
Subject: [PATCH 35/38] Update launcher/updater/prismupdater/PrismUpdater.cpp
Co-authored-by: TheKodeToad
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/updater/prismupdater/PrismUpdater.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp
index b335a19f9..76ba483f0 100644
--- a/launcher/updater/prismupdater/PrismUpdater.cpp
+++ b/launcher/updater/prismupdater/PrismUpdater.cpp
@@ -787,7 +787,7 @@ QList PrismUpdaterApp::validReleaseArtifacts(const GitHubRel
if (BuildConfig.BUILD_ARTIFACT.isEmpty())
qWarning() << "Build platform is not set!";
for (auto asset : release.assets) {
- if (asset.name.endsWith("zsync")) {
+ if (asset.name.endsWith(".zsync")) {
qDebug() << "Rejecting zsync file" << asset.name;
continue;
}
From ae3e4ed528aace5385c99047e9c7c431a26b8506 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sat, 29 Jun 2024 04:29:19 -0700
Subject: [PATCH 36/38] fix Build Artifact Checks
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/updater/prismupdater/PrismUpdater.cpp | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp
index 76ba483f0..de862b96e 100644
--- a/launcher/updater/prismupdater/PrismUpdater.cpp
+++ b/launcher/updater/prismupdater/PrismUpdater.cpp
@@ -244,8 +244,9 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
auto updater_executable = QCoreApplication::applicationFilePath();
- if (BuildConfig.BUILD_ARTIFACT.toLower() == "macos")
- showFatalErrorMessage(tr("MacOS Not Supported"), tr("The updater does not support installations on MacOS"));
+#ifdef Q_OS_MACOS
+ showFatalErrorMessage(tr("MacOS Not Supported"), tr("The updater does not support installations on MacOS"));
+#endif
if (updater_executable.startsWith("/tmp/.mount_")) {
m_isAppimage = true;
@@ -580,12 +581,6 @@ void PrismUpdaterApp::run()
return exit(result ? 0 : 1);
}
- if (BuildConfig.BUILD_ARTIFACT.toLower() == "linux" && !m_isPortable) {
- showFatalErrorMessage(tr("Updating Not Supported"),
- tr("Updating non-portable linux installations is not supported. Please use your system package manager"));
- return;
- }
-
if (need_update || m_forceUpdate || !m_userSelectedVersion.isEmpty()) {
GitHubRelease update_release = latest;
if (!m_userSelectedVersion.isEmpty()) {
@@ -1098,7 +1093,7 @@ void PrismUpdaterApp::backupAppDir()
if (file_list.isEmpty()) {
// best guess
- if (BuildConfig.BUILD_ARTIFACT.toLower() == "linux") {
+ if (BuildConfig.BUILD_ARTIFACT.toLower().contains("linux")) {
file_list.append({ "PrismLauncher", "bin", "share", "lib" });
} else { // windows by process of elimination
file_list.append({
From 7a0b299be98b93815e265ba2896e971d0bb8c4f8 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sat, 29 Jun 2024 18:08:28 +0300
Subject: [PATCH 37/38] control Prism data directory via env variable
Signed-off-by: Trial97
---
launcher/Application.cpp | 7 ++++++-
launcher/updater/prismupdater/PrismUpdater.cpp | 10 ++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 6d30d1101..2c0c3fca5 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -292,12 +292,17 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
QString adjustedBy;
QString dataPath;
// change folder
+ QString dataDirEnv;
QString dirParam = parser.value("dir");
if (!dirParam.isEmpty()) {
// the dir param. it makes multimc data path point to whatever the user specified
// on command line
adjustedBy = "Command line";
dataPath = dirParam;
+ } else if (dataDirEnv = QProcessEnvironment::systemEnvironment().value(QString("%1_DATA_DIR").arg(BuildConfig.LAUNCHER_NAME.toUpper()));
+ !dataDirEnv.isEmpty()) {
+ adjustedBy = "System environment";
+ dataPath = dataDirEnv;
} else {
QDir foo;
if (DesktopServices::isSnap()) {
@@ -443,7 +448,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// search the dataPath()
// seach app data standard path
- if (!foundLoggingRules && !isPortable() && dirParam.isEmpty()) {
+ if (!foundLoggingRules && !isPortable() && dirParam.isEmpty() && dataDirEnv.isEmpty()) {
logRulesPath = QStandardPaths::locate(QStandardPaths::AppDataLocation, FS::PathCombine("..", logRulesFile));
if (!logRulesPath.isEmpty()) {
qDebug() << "Found" << logRulesPath << "...";
diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp
index 83d8efa22..f49c8a0fb 100644
--- a/launcher/updater/prismupdater/PrismUpdater.cpp
+++ b/launcher/updater/prismupdater/PrismUpdater.cpp
@@ -331,6 +331,16 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
m_isPortable = true;
}
+#endif
+ } else if (auto dataDirEnv =
+ QProcessEnvironment::systemEnvironment().value(QString("%1_DATA_DIR").arg(BuildConfig.LAUNCHER_NAME.toUpper()));
+ !dataDirEnv.isEmpty()) {
+ adjustedBy = "System environment";
+ m_dataPath = dataDirEnv;
+#ifndef Q_OS_MACOS
+ if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
+ m_isPortable = true;
+ }
#endif
} else {
QDir foo(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
From 25bae20db4525b8f7e0671605d5927971e6ffab8 Mon Sep 17 00:00:00 2001
From: Trial97
Date: Sun, 30 Jun 2024 00:17:25 +0300
Subject: [PATCH 38/38] trim input from import page
Signed-off-by: Trial97
---
launcher/ui/pages/modplatform/ImportPage.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/launcher/ui/pages/modplatform/ImportPage.cpp b/launcher/ui/pages/modplatform/ImportPage.cpp
index 38208f5b0..1efc6199e 100644
--- a/launcher/ui/pages/modplatform/ImportPage.cpp
+++ b/launcher/ui/pages/modplatform/ImportPage.cpp
@@ -104,7 +104,7 @@ void ImportPage::updateState()
return;
}
if (ui->modpackEdit->hasAcceptableInput()) {
- QString input = ui->modpackEdit->text();
+ QString input = ui->modpackEdit->text().trimmed();
auto url = QUrl::fromUserInput(input);
if (url.isLocalFile()) {
// FIXME: actually do some validation of what's inside here... this is fake AF