1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-23 21:07:45 +00:00

Report login gate errors as well

This commit is contained in:
Joshua Goins 2023-08-18 22:03:07 -04:00
parent 6ac00e6a2c
commit 9243a699a8
3 changed files with 7 additions and 15 deletions

View file

@ -95,12 +95,13 @@ void AssetUpdater::update()
connect(reply, &QNetworkReply::finished, [this, reply] { connect(reply, &QNetworkReply::finished, [this, reply] {
Q_EMIT launcher.stageChanged("Checking for Dalamud updates..."); Q_EMIT launcher.stageChanged("Checking for Dalamud updates...");
QByteArray str = reply->readAll(); if (reply->error() != QNetworkReply::NetworkError::NoError) {
if (str.isEmpty()) { Q_EMIT launcher.loginError(QStringLiteral("Could not check for Dalamud updates.\n\n%1").arg(reply->errorString()));
Q_EMIT launcher.loginError("Could not check for Dalamud updates.");
return; return;
} }
QByteArray str = reply->readAll();
// for some god forsaken reason, the version string comes back as raw // for some god forsaken reason, the version string comes back as raw
// bytes, ex: \xFF\xFE{\x00\"\x00""A\x00s\x00s\x00""e\x00m\x00 so we // bytes, ex: \xFF\xFE{\x00\"\x00""A\x00s\x00s\x00""e\x00m\x00 so we
// start at the first character of the json '{' and work our way up. // start at the first character of the json '{' and work our way up.

View file

@ -30,7 +30,7 @@ void GameInstaller::installGame()
auto reply = m_launcher.mgr->get(request); auto reply = m_launcher.mgr->get(request);
QObject::connect(reply, &QNetworkReply::finished, [this, reply, installDirectory] { QObject::connect(reply, &QNetworkReply::finished, [this, reply, installDirectory] {
if (reply->error() != QNetworkReply::NetworkError::NoError) { if (reply->error() != QNetworkReply::NetworkError::NoError) {
Q_EMIT error(QStringLiteral("An error has occurred when downloading the installer:\n%1").arg(reply->errorString())); Q_EMIT error(QStringLiteral("An error has occurred when downloading the installer.\n\n%1").arg(reply->errorString()));
return; return;
} }

View file

@ -77,23 +77,14 @@ void SquareBoot::checkGateStatus(LoginInformation *info)
auto reply = window.mgr->get(request); auto reply = window.mgr->get(request);
connect(reply, &QNetworkReply::finished, [this, reply, info] { connect(reply, &QNetworkReply::finished, [this, reply, info] {
// I happen to run into this issue often, if I start the launcher really quickly after bootup const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
// 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; const bool isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0;
if (isGateOpen) { if (isGateOpen) {
bootCheck(*info); bootCheck(*info);
} else { } else {
Q_EMIT window.loginError(i18n("The login gate is closed, the game may be under maintenance.")); Q_EMIT window.loginError(i18n("The login gate is closed, the game may be under maintenance.\n\n%1", reply->errorString()));
} }
}); });
} }