mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-21 20:27:45 +00:00
Prevent logging in when maintenance is in progress
This commit is contained in:
parent
80306d65fb
commit
f4f3bfb07c
5 changed files with 53 additions and 2 deletions
|
@ -353,6 +353,12 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco
|
|||
assetUpdater = new AssetUpdater(*this);
|
||||
|
||||
readInitialInformation();
|
||||
|
||||
// check gate status before login
|
||||
squareLauncher->gateOpen();
|
||||
|
||||
// TODO: we really should call this "heavy" signal
|
||||
connect(squareLauncher, &SquareLauncher::gateStatusRecieved, this, &LauncherCore::settingsChanged);
|
||||
}
|
||||
|
||||
ProfileSettings LauncherCore::getProfile(int index) const {
|
||||
|
|
|
@ -86,7 +86,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
|
|||
otpEdit = new QLineEdit();
|
||||
layout->addRow("One-Time Password", otpEdit);
|
||||
|
||||
auto loginButton = new QPushButton("Login");
|
||||
loginButton = new QPushButton("Login");
|
||||
layout->addRow(loginButton);
|
||||
|
||||
registerButton = new QPushButton("Register");
|
||||
|
@ -185,6 +185,15 @@ void LauncherWindow::reloadControls() {
|
|||
});
|
||||
}
|
||||
|
||||
const bool isLockedOut = !currentProfile().isSapphire && !core.squareLauncher->isGateOpen;
|
||||
|
||||
if(!isLockedOut) {
|
||||
loginButton->setText("Login");
|
||||
} else {
|
||||
loginButton->setText("Login (Maintenance is in progress)");
|
||||
}
|
||||
|
||||
loginButton->setEnabled(!isLockedOut);
|
||||
registerButton->setEnabled(currentProfile().isSapphire);
|
||||
otpEdit->setEnabled(!currentProfile().isSapphire);
|
||||
|
||||
|
|
|
@ -27,5 +27,5 @@ private:
|
|||
QLineEdit* usernameEdit, *passwordEdit;
|
||||
QLineEdit* otpEdit;
|
||||
QCheckBox* rememberUsernameBox, *rememberPasswordBox;
|
||||
QPushButton* registerButton;
|
||||
QPushButton* loginButton, *registerButton;
|
||||
};
|
|
@ -5,6 +5,8 @@
|
|||
#include <QNetworkReply>
|
||||
#include <QRegularExpressionMatch>
|
||||
#include <QMessageBox>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "launchercore.h"
|
||||
|
||||
|
@ -157,3 +159,29 @@ void SquareLauncher::readExpansionVersions(const LoginInformation& info, int max
|
|||
for(int i = 0; i < max; i++)
|
||||
expansionVersions.push_back(window.readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(info.settings->gamePath, QString::number(i + 1))));
|
||||
}
|
||||
|
||||
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);
|
||||
window.buildRequest(request);
|
||||
|
||||
auto reply = window.mgr->get(request);
|
||||
connect(reply, &QNetworkReply::finished, [this, reply] {
|
||||
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
||||
|
||||
if(document.isEmpty() || document.object()["status"].toInt() == 0) {
|
||||
gateStatusRecieved(false);
|
||||
isGateOpen = false;
|
||||
} else {
|
||||
gateStatusRecieved(true);
|
||||
isGateOpen = true;
|
||||
}
|
||||
});
|
||||
}
|
|
@ -3,15 +3,23 @@
|
|||
#include "launchercore.h"
|
||||
|
||||
class SquareLauncher : public QObject {
|
||||
Q_OBJECT
|
||||
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);
|
||||
void readExpansionVersions(const LoginInformation& info, int max);
|
||||
|
|
Loading…
Add table
Reference in a new issue