diff --git a/include/squareboot.h b/include/squareboot.h index d83f652..ce158a8 100644 --- a/include/squareboot.h +++ b/include/squareboot.h @@ -9,7 +9,9 @@ class SquareBoot : public QObject { public: SquareBoot(LauncherCore& window, SquareLauncher& launcher); - void bootCheck(LoginInformation& info); + void checkGateStatus(const LoginInformation& info); + + void bootCheck(const LoginInformation& info); private: QProgressDialog* dialog; diff --git a/include/squarelauncher.h b/include/squarelauncher.h index c394619..db43adb 100644 --- a/include/squarelauncher.h +++ b/include/squarelauncher.h @@ -7,19 +7,12 @@ class SquareLauncher : public QObject { public: SquareLauncher(LauncherCore& window); - void gateOpen(); - void getStored(const LoginInformation& info); void login(const LoginInformation& info, QUrl referer); void registerSession(const LoginInformation& info); - bool isGateOpen = false; - -signals: - void gateStatusRecieved(bool gateOpen); - private: QString getBootHash(const LoginInformation& info); diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 29177d1..9d23195 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -545,12 +545,6 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco #endif readInitialInformation(); - - // check gate status before login - squareLauncher->gateOpen(); - - // TODO: we really should call this "heavy" signal - connect(squareLauncher, &SquareLauncher::gateStatusRecieved, this, &LauncherCore::settingsChanged); } LauncherCore::~LauncherCore() noexcept { diff --git a/src/launcherwindow.cpp b/src/launcherwindow.cpp index ae2e99d..dc1c253 100644 --- a/src/launcherwindow.cpp +++ b/src/launcherwindow.cpp @@ -279,9 +279,9 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo #endif if(currentProfile().isSapphire) { - //this->core.sapphireLauncher->login(currentProfile().lobbyURL, info); + this->core.sapphireLauncher->login(currentProfile().lobbyURL, info); } else { - this->core.squareBoot->bootCheck(info); + this->core.squareBoot->checkGateStatus(info); } }); @@ -375,11 +375,6 @@ void LauncherWindow::reloadControls() { loginButton->setText("Login (Lobby URL is invalid)"); canLogin = false; } - } else { - if(!core.squareLauncher->isGateOpen) { - loginButton->setText("Login (Maintenance is in progress)"); - canLogin = false; - } } #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) diff --git a/src/squareboot.cpp b/src/squareboot.cpp index 3e220b0..e0eafab 100644 --- a/src/squareboot.cpp +++ b/src/squareboot.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "squarelauncher.h" @@ -14,7 +16,7 @@ SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher) : window( } -void SquareBoot::bootCheck(LoginInformation& info) { +void SquareBoot::bootCheck(const LoginInformation& info) { dialog = new QProgressDialog(); dialog->setLabelText("Checking the FINAL FANTASY XIV Updater/Launcher version."); dialog->show(); @@ -99,4 +101,44 @@ void SquareBoot::bootCheck(LoginInformation& info) { } } }); -} \ No newline at end of file +} + +void SquareBoot::checkGateStatus(const LoginInformation& info) { + QUrlQuery query; + query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch())); + + QUrl url; + url.setUrl("https://frontier.ffxiv.com/worldStatus/gate_status.json"); + url.setQuery(query); + + QNetworkRequest request; + request.setUrl(url); + + // TODO: really? + window.buildRequest(*info.settings, request); + + auto reply = window.mgr->get(request); + connect(reply, &QNetworkReply::finished, [=] { + // I happen to run into this issue often, if I start the launcher really quickly after bootup + // it's possible to actually check this quicker than the network is actually available, + // causing the launcher to be stuck in "maintenace mode". so if that happens, we try to rerun this logic. + // TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of "internet is unavailable" in + // some way. + if(reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || reply->error() == QNetworkReply::UnknownServerError) + checkGateStatus(info); + + QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); + + const bool isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0; + + if(isGateOpen) { + bootCheck(info); + } else { + auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, + "Failed to Login", + "The login gate is closed, the game may be under maintenance."); + + messageBox->show(); + } + }); +} diff --git a/src/squarelauncher.cpp b/src/squarelauncher.cpp index f05cdf7..2ffe0eb 100644 --- a/src/squarelauncher.cpp +++ b/src/squarelauncher.cpp @@ -217,36 +217,4 @@ QString SquareLauncher::getBootHash(const LoginInformation& info) { } return result; -} - -void SquareLauncher::gateOpen() { - QUrlQuery query; - query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch())); - - QUrl url; - url.setUrl("https://frontier.ffxiv.com/worldStatus/gate_status.json"); - url.setQuery(query); - - QNetworkRequest request; - request.setUrl(url); - - // TODO: really? - window.buildRequest(window.getProfile(window.defaultProfileIndex), request); - - auto reply = window.mgr->get(request); - connect(reply, &QNetworkReply::finished, [this, reply] { - // I happen to run into this issue often, if I start the launcher really quickly after bootup - // it's possible to actually check this quicker than the network is actually available, - // causing the launcher to be stuck in "maintenace mode". so if that happens, we try to rerun this logic. - // TODO: this selection of errors is currently guesswork, i'm assuming one of these will fit the bill of "internet is unavailable" in - // some way. - if(reply->error() == QNetworkReply::HostNotFoundError || reply->error() == QNetworkReply::TimeoutError || reply->error() == QNetworkReply::UnknownServerError) - gateOpen(); - - QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); - - isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0; - - gateStatusRecieved(isGateOpen); - }); -} +} \ No newline at end of file