1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-24 05:17:46 +00:00

Ensure private members are prefixed with m_

This commit is contained in:
Joshua Goins 2023-10-11 13:39:10 -04:00
parent f0d1e1bcbe
commit 999a2dc311
12 changed files with 126 additions and 131 deletions

View file

@ -37,21 +37,19 @@ private:
LauncherCore &launcher; LauncherCore &launcher;
Profile::DalamudChannel chosenChannel; QString m_remoteDalamudVersion;
QString m_remoteRuntimeVersion;
QString remoteDalamudVersion; QTemporaryDir m_tempDir;
QString remoteRuntimeVersion; QDir m_dataDir;
QDir m_appDataDir;
QDir m_dalamudDir;
QDir m_dalamudAssetDir;
QDir m_dalamudRuntimeDir;
QTemporaryDir tempDir; int m_remoteDalamudAssetVersion = -1;
QDir dataDir; QJsonArray m_remoteDalamudAssetArray;
QDir appDataDir; QString m_remoteDalamudDownloadUrl;
QDir dalamudDir;
QDir dalamudAssetDir;
QDir dalamudRuntimeDir;
int remoteDalamudAssetVersion = -1;
QJsonArray remoteDalamudAssetArray;
QString remoteDalamudDownloadUrl;
Profile &m_profile; Profile &m_profile;
}; };

View file

@ -177,7 +177,6 @@ private:
QCoro::Task<> fetchNews(); QCoro::Task<> fetchNews();
bool m_isSteam = false;
SteamAPI *m_steamApi = nullptr; SteamAPI *m_steamApi = nullptr;
bool m_loadingFinished = false; bool m_loadingFinished = false;

View file

@ -13,5 +13,5 @@ public:
explicit ProcessLogger(QProcess *process); explicit ProcessLogger(QProcess *process);
private: private:
QFile file; QFile m_file;
}; };

View file

@ -16,5 +16,5 @@ public:
void registerAccount(const QString &lobbyUrl, const LoginInformation &info); void registerAccount(const QString &lobbyUrl, const LoginInformation &info);
private: private:
LauncherCore &window; LauncherCore &m_launcher;
}; };

View file

@ -23,8 +23,8 @@ public:
private: private:
QCoro::Task<> bootCheck(const LoginInformation &info); QCoro::Task<> bootCheck(const LoginInformation &info);
Patcher *patcher = nullptr; Patcher *m_patcher = nullptr;
LauncherCore &window; LauncherCore &m_launcher;
SquareLauncher &launcher; SquareLauncher &m_squareLauncher;
}; };

View file

@ -25,10 +25,10 @@ public:
private: private:
static QCoro::Task<QString> getBootHash(const LoginInformation &info); static QCoro::Task<QString> getBootHash(const LoginInformation &info);
Patcher *patcher = nullptr; Patcher *m_patcher = nullptr;
QString SID, username; QString m_SID, m_username;
LoginAuth auth; LoginAuth m_auth;
LauncherCore &window; LauncherCore &m_launcher;
}; };

View file

@ -19,7 +19,6 @@
AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent) AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent)
: QObject(parent) : QObject(parent)
, launcher(launcher) , launcher(launcher)
, chosenChannel(profile.dalamudChannel())
, m_profile(profile) , m_profile(profile)
{ {
} }
@ -32,19 +31,19 @@ QCoro::Task<bool> AssetUpdater::update()
qInfo(ASTRA_LOG) << "Checking for asset updates..."; qInfo(ASTRA_LOG) << "Checking for asset updates...";
dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); m_dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
dalamudDir = dataDir.absoluteFilePath(QStringLiteral("dalamud")); m_dalamudDir = m_dataDir.absoluteFilePath(QStringLiteral("dalamud"));
dalamudAssetDir = dalamudDir.absoluteFilePath(QStringLiteral("assets")); m_dalamudAssetDir = m_dalamudDir.absoluteFilePath(QStringLiteral("assets"));
dalamudRuntimeDir = dalamudDir.absoluteFilePath(QStringLiteral("runtime")); m_dalamudRuntimeDir = m_dalamudDir.absoluteFilePath(QStringLiteral("runtime"));
const auto createIfNeeded = [](const QDir &dir) { const auto createIfNeeded = [](const QDir &dir) {
if (!QDir().exists(dir.absolutePath())) if (!QDir().exists(dir.absolutePath()))
QDir().mkpath(dir.absolutePath()); QDir().mkpath(dir.absolutePath());
}; };
createIfNeeded(dalamudDir); createIfNeeded(m_dalamudDir);
createIfNeeded(dalamudAssetDir); createIfNeeded(m_dalamudAssetDir);
createIfNeeded(dalamudRuntimeDir); createIfNeeded(m_dalamudRuntimeDir);
if (!co_await checkRemoteDalamudAssetVersion()) { if (!co_await checkRemoteDalamudAssetVersion()) {
co_return false; co_return false;
@ -73,14 +72,14 @@ QCoro::Task<bool> AssetUpdater::checkRemoteDalamudAssetVersion()
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll()); const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
remoteDalamudAssetVersion = doc.object()[QLatin1String("version")].toInt(); m_remoteDalamudAssetVersion = doc.object()[QLatin1String("version")].toInt();
remoteDalamudAssetArray = doc.object()[QLatin1String("assets")].toArray(); m_remoteDalamudAssetArray = doc.object()[QLatin1String("assets")].toArray();
qInfo(ASTRA_LOG) << "Dalamud asset remote version" << remoteDalamudAssetVersion; qInfo(ASTRA_LOG) << "Dalamud asset remote version" << m_remoteDalamudAssetVersion;
qInfo(ASTRA_LOG) << "Dalamud asset local version" << m_profile.dalamudAssetVersion(); qInfo(ASTRA_LOG) << "Dalamud asset local version" << m_profile.dalamudAssetVersion();
// dalamud assets // dalamud assets
if (remoteDalamudAssetVersion != m_profile.dalamudAssetVersion()) { if (m_remoteDalamudAssetVersion != m_profile.dalamudAssetVersion()) {
qInfo(ASTRA_LOG) << "Dalamud assets out of date"; qInfo(ASTRA_LOG) << "Dalamud assets out of date";
co_return co_await installDalamudAssets(); co_return co_await installDalamudAssets();
@ -99,8 +98,8 @@ QCoro::Task<bool> AssetUpdater::checkRemoteDalamudVersion()
const QNetworkRequest request(url); const QNetworkRequest request(url);
Utility::printRequest(QStringLiteral("GET"), request); Utility::printRequest(QStringLiteral("GET"), request);
remoteDalamudVersion.clear(); m_remoteDalamudVersion.clear();
remoteRuntimeVersion.clear(); m_remoteRuntimeVersion.clear();
const auto reply = launcher.mgr()->get(request); const auto reply = launcher.mgr()->get(request);
co_await reply; co_await reply;
@ -111,20 +110,20 @@ QCoro::Task<bool> AssetUpdater::checkRemoteDalamudVersion()
} }
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll()); const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
remoteDalamudVersion = doc[QLatin1String("assemblyVersion")].toString(); m_remoteDalamudVersion = doc[QLatin1String("assemblyVersion")].toString();
remoteRuntimeVersion = doc[QLatin1String("runtimeVersion")].toString(); m_remoteRuntimeVersion = doc[QLatin1String("runtimeVersion")].toString();
remoteDalamudDownloadUrl = doc[QLatin1String("downloadUrl")].toString(); m_remoteDalamudDownloadUrl = doc[QLatin1String("downloadUrl")].toString();
qInfo(ASTRA_LOG) << "Latest available Dalamud version:" << remoteDalamudVersion << "local:" << m_profile.dalamudVersion(); qInfo(ASTRA_LOG) << "Latest available Dalamud version:" << m_remoteDalamudVersion << "local:" << m_profile.dalamudVersion();
qInfo(ASTRA_LOG) << "Latest available NET runtime:" << remoteRuntimeVersion; qInfo(ASTRA_LOG) << "Latest available NET runtime:" << m_remoteRuntimeVersion;
if (remoteDalamudVersion != m_profile.dalamudVersion()) { if (m_remoteDalamudVersion != m_profile.dalamudVersion()) {
if (!co_await installDalamud()) { if (!co_await installDalamud()) {
co_return false; co_return false;
} }
} }
if (m_profile.runtimeVersion() != remoteRuntimeVersion) { if (m_profile.runtimeVersion() != m_remoteRuntimeVersion) {
if (!co_await installRuntime()) { if (!co_await installRuntime()) {
co_return false; co_return false;
} }
@ -139,7 +138,7 @@ QCoro::Task<bool> AssetUpdater::installDalamudAssets()
QFutureSynchronizer<void> synchronizer; QFutureSynchronizer<void> synchronizer;
for (const auto &assetObject : remoteDalamudAssetArray) { for (const auto &assetObject : m_remoteDalamudAssetArray) {
const QNetworkRequest assetRequest(assetObject.toObject()[QLatin1String("url")].toString()); const QNetworkRequest assetRequest(assetObject.toObject()[QLatin1String("url")].toString());
Utility::printRequest(QStringLiteral("GET"), assetRequest); Utility::printRequest(QStringLiteral("GET"), assetRequest);
@ -149,12 +148,12 @@ QCoro::Task<bool> AssetUpdater::installDalamudAssets()
const QString fileName = assetObject.toObject()[QLatin1String("fileName")].toString(); const QString fileName = assetObject.toObject()[QLatin1String("fileName")].toString();
const QString dirPath = fileName.left(fileName.lastIndexOf(QLatin1Char('/'))); const QString dirPath = fileName.left(fileName.lastIndexOf(QLatin1Char('/')));
const QString path = dalamudAssetDir.absoluteFilePath(dirPath); const QString path = m_dalamudAssetDir.absoluteFilePath(dirPath);
if (!QDir().exists(path)) if (!QDir().exists(path))
QDir().mkpath(path); QDir().mkpath(path);
QFile file(dalamudAssetDir.absoluteFilePath(assetObject.toObject()[QLatin1String("fileName")].toString())); QFile file(m_dalamudAssetDir.absoluteFilePath(assetObject.toObject()[QLatin1String("fileName")].toString()));
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(assetReply->readAll()); file.write(assetReply->readAll());
file.close(); file.close();
@ -169,11 +168,11 @@ QCoro::Task<bool> AssetUpdater::installDalamudAssets()
qInfo(ASTRA_LOG) << "Finished downloading Dalamud assets"; qInfo(ASTRA_LOG) << "Finished downloading Dalamud assets";
m_profile.setDalamudAssetVersion(remoteDalamudAssetVersion); m_profile.setDalamudAssetVersion(m_remoteDalamudAssetVersion);
QFile file(dalamudAssetDir.absoluteFilePath(QStringLiteral("asset.ver"))); QFile file(m_dalamudAssetDir.absoluteFilePath(QStringLiteral("asset.ver")));
file.open(QIODevice::WriteOnly | QIODevice::Text); file.open(QIODevice::WriteOnly | QIODevice::Text);
file.write(QString::number(remoteDalamudAssetVersion).toUtf8()); file.write(QString::number(m_remoteDalamudAssetVersion).toUtf8());
file.close(); file.close();
co_return true; co_return true;
@ -183,7 +182,7 @@ QCoro::Task<bool> AssetUpdater::installDalamud()
{ {
Q_EMIT launcher.stageChanged(i18n("Updating Dalamud...")); Q_EMIT launcher.stageChanged(i18n("Updating Dalamud..."));
const QNetworkRequest request(remoteDalamudDownloadUrl); const QNetworkRequest request(m_remoteDalamudDownloadUrl);
Utility::printRequest(QStringLiteral("GET"), request); Utility::printRequest(QStringLiteral("GET"), request);
const auto reply = launcher.mgr()->get(request); const auto reply = launcher.mgr()->get(request);
@ -191,13 +190,13 @@ QCoro::Task<bool> AssetUpdater::installDalamud()
qInfo(ASTRA_LOG) << "Finished downloading Dalamud"; qInfo(ASTRA_LOG) << "Finished downloading Dalamud";
QFile file(tempDir.filePath(QStringLiteral("/latest.zip"))); QFile file(m_tempDir.filePath(QStringLiteral("/latest.zip")));
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(reply->readAll()); file.write(reply->readAll());
file.close(); file.close();
const bool success = const bool success =
!JlCompress::extractDir(tempDir.filePath(QStringLiteral("latest.zip")), dalamudDir.absoluteFilePath(m_profile.dalamudChannelName())).empty(); !JlCompress::extractDir(m_tempDir.filePath(QStringLiteral("latest.zip")), m_dalamudDir.absoluteFilePath(m_profile.dalamudChannelName())).empty();
if (!success) { if (!success) {
qCritical(ASTRA_LOG) << "Failed to install Dalamud"; qCritical(ASTRA_LOG) << "Failed to install Dalamud";
@ -205,7 +204,7 @@ QCoro::Task<bool> AssetUpdater::installDalamud()
co_return false; co_return false;
} }
m_profile.setDalamudVersion(remoteDalamudVersion); m_profile.setDalamudVersion(m_remoteDalamudVersion);
co_return true; co_return true;
} }
@ -216,7 +215,7 @@ QCoro::Task<bool> AssetUpdater::installRuntime()
// core // core
{ {
const QNetworkRequest request(dotnetRuntimePackageUrl(remoteRuntimeVersion)); const QNetworkRequest request(dotnetRuntimePackageUrl(m_remoteRuntimeVersion));
Utility::printRequest(QStringLiteral("GET"), request); Utility::printRequest(QStringLiteral("GET"), request);
const auto reply = launcher.mgr()->get(request); const auto reply = launcher.mgr()->get(request);
@ -224,7 +223,7 @@ QCoro::Task<bool> AssetUpdater::installRuntime()
qInfo(ASTRA_LOG) << "Finished downloading Dotnet-core"; qInfo(ASTRA_LOG) << "Finished downloading Dotnet-core";
QFile file(tempDir.filePath(QStringLiteral("dotnet-core.zip"))); QFile file(m_tempDir.filePath(QStringLiteral("dotnet-core.zip")));
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(reply->readAll()); file.write(reply->readAll());
file.close(); file.close();
@ -232,7 +231,7 @@ QCoro::Task<bool> AssetUpdater::installRuntime()
// desktop // desktop
{ {
const QNetworkRequest request(dotnetDesktopPackageUrl(remoteRuntimeVersion)); const QNetworkRequest request(dotnetDesktopPackageUrl(m_remoteRuntimeVersion));
Utility::printRequest(QStringLiteral("GET"), request); Utility::printRequest(QStringLiteral("GET"), request);
const auto reply = launcher.mgr()->get(request); const auto reply = launcher.mgr()->get(request);
@ -240,14 +239,14 @@ QCoro::Task<bool> AssetUpdater::installRuntime()
qInfo(ASTRA_LOG) << "Finished downloading Dotnet-desktop"; qInfo(ASTRA_LOG) << "Finished downloading Dotnet-desktop";
QFile file(tempDir.filePath(QStringLiteral("dotnet-desktop.zip"))); QFile file(m_tempDir.filePath(QStringLiteral("dotnet-desktop.zip")));
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(reply->readAll()); file.write(reply->readAll());
file.close(); file.close();
} }
bool success = !JlCompress::extractDir(tempDir.filePath(QStringLiteral("dotnet-core.zip")), dalamudRuntimeDir.absolutePath()).empty(); bool success = !JlCompress::extractDir(m_tempDir.filePath(QStringLiteral("dotnet-core.zip")), m_dalamudRuntimeDir.absolutePath()).empty();
success |= !JlCompress::extractDir(tempDir.filePath(QStringLiteral("dotnet-desktop.zip")), dalamudRuntimeDir.absolutePath()).empty(); success |= !JlCompress::extractDir(m_tempDir.filePath(QStringLiteral("dotnet-desktop.zip")), m_dalamudRuntimeDir.absolutePath()).empty();
if (!success) { if (!success) {
qCritical(ASTRA_LOG) << "Failed to install dotnet"; qCritical(ASTRA_LOG) << "Failed to install dotnet";
@ -255,9 +254,9 @@ QCoro::Task<bool> AssetUpdater::installRuntime()
co_return false; co_return false;
} else { } else {
QFile file(dalamudRuntimeDir.absoluteFilePath(QStringLiteral("runtime.ver"))); QFile file(m_dalamudRuntimeDir.absoluteFilePath(QStringLiteral("runtime.ver")));
file.open(QIODevice::WriteOnly | QIODevice::Text); file.open(QIODevice::WriteOnly | QIODevice::Text);
file.write(remoteRuntimeVersion.toUtf8()); file.write(m_remoteRuntimeVersion.toUtf8());
file.close(); file.close();
co_return true; co_return true;

View file

@ -303,7 +303,7 @@ void LauncherCore::launchExecutable(const Profile &profile, QProcess *process, c
#endif #endif
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX) #if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
if (m_isSteam) { if (isSteam()) {
const QDir steamDirectory = QProcessEnvironment::systemEnvironment().value(QStringLiteral("STEAM_COMPAT_CLIENT_INSTALL_PATH")); const QDir steamDirectory = QProcessEnvironment::systemEnvironment().value(QStringLiteral("STEAM_COMPAT_CLIENT_INSTALL_PATH"));
const QDir compatData = const QDir compatData =
QProcessEnvironment::systemEnvironment().value(QStringLiteral("STEAM_COMPAT_DATA_PATH")); // TODO: do these have to exist on the root steam folder? QProcessEnvironment::systemEnvironment().value(QStringLiteral("STEAM_COMPAT_DATA_PATH")); // TODO: do these have to exist on the root steam folder?
@ -640,7 +640,7 @@ Headline *LauncherCore::headline() const
bool LauncherCore::isSteam() const bool LauncherCore::isSteam() const
{ {
return m_isSteam; return m_steamApi != nullptr;
} }
bool LauncherCore::isSteamDeck() const bool LauncherCore::isSteamDeck() const
@ -680,7 +680,6 @@ void LauncherCore::clearAvatarCache()
void LauncherCore::initializeSteam() void LauncherCore::initializeSteam()
{ {
m_isSteam = true;
m_steamApi = new SteamAPI(this); m_steamApi = new SteamAPI(this);
m_steamApi->setLauncherMode(true); m_steamApi->setLauncherMode(true);
} }

View file

@ -9,22 +9,22 @@ ProcessLogger::ProcessLogger(QProcess *process)
{ {
const QDir logDirectory = Utility::stateDirectory().absoluteFilePath("log"); const QDir logDirectory = Utility::stateDirectory().absoluteFilePath("log");
file.setFileName(logDirectory.absoluteFilePath(QStringLiteral("ffxiv.log"))); m_file.setFileName(logDirectory.absoluteFilePath(QStringLiteral("ffxiv.log")));
file.open(QIODevice::WriteOnly | QIODevice::Unbuffered); m_file.open(QIODevice::WriteOnly | QIODevice::Unbuffered);
connect(process, &QProcess::readyReadStandardOutput, this, [this, process] { connect(process, &QProcess::readyReadStandardOutput, this, [this, process] {
file.write(process->readAllStandardOutput()); m_file.write(process->readAllStandardOutput());
file.flush(); m_file.flush();
}); });
connect(process, &QProcess::readyReadStandardError, this, [this, process] { connect(process, &QProcess::readyReadStandardError, this, [this, process] {
file.write(process->readAllStandardError()); m_file.write(process->readAllStandardError());
file.flush(); m_file.flush();
}); });
connect(process, &QProcess::finished, this, [this] { connect(process, &QProcess::finished, this, [this] {
deleteLater(); deleteLater();
}); });
qInfo(ASTRA_LOG) << "Client logs are being written to" << file.fileName().toUtf8().constData(); qInfo(ASTRA_LOG) << "Client logs are being written to" << m_file.fileName().toUtf8().constData();
} }

View file

@ -11,7 +11,7 @@
SapphireLauncher::SapphireLauncher(LauncherCore &window, QObject *parent) SapphireLauncher::SapphireLauncher(LauncherCore &window, QObject *parent)
: QObject(parent) : QObject(parent)
, window(window) , m_launcher(window)
{ {
} }
@ -25,11 +25,11 @@ void SapphireLauncher::login(const QString &lobbyUrl, const LoginInformation &in
request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded")); request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded"));
Utility::printRequest(QStringLiteral("POST"), request); Utility::printRequest(QStringLiteral("POST"), request);
const auto reply = window.mgr()->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact)); const auto reply = m_launcher.mgr()->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
connect(reply, &QNetworkReply::finished, [this, reply, &info] { connect(reply, &QNetworkReply::finished, [this, reply, &info] {
if (reply->error() != QNetworkReply::NetworkError::NoError) { if (reply->error() != QNetworkReply::NetworkError::NoError) {
Q_EMIT window.loginError(i18n("Could not contact lobby server.\n\n%1", reply->errorString())); Q_EMIT m_launcher.loginError(i18n("Could not contact lobby server.\n\n%1", reply->errorString()));
return; return;
} }
@ -41,9 +41,9 @@ void SapphireLauncher::login(const QString &lobbyUrl, const LoginInformation &in
auth.frontierHost = document[QLatin1String("frontierHost")].toString(); auth.frontierHost = document[QLatin1String("frontierHost")].toString();
auth.region = 3; auth.region = 3;
window.launchGame(*info.profile, auth); m_launcher.launchGame(*info.profile, auth);
} else { } else {
Q_EMIT window.loginError(i18n("Invalid username or password.")); Q_EMIT m_launcher.loginError(i18n("Invalid username or password."));
} }
}); });
} }
@ -58,7 +58,7 @@ void SapphireLauncher::registerAccount(const QString &lobbyUrl, const LoginInfor
Utility::printRequest(QStringLiteral("POST"), request); Utility::printRequest(QStringLiteral("POST"), request);
const auto reply = window.mgr()->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact)); const auto reply = m_launcher.mgr()->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
connect(reply, &QNetworkReply::finished, [&] { connect(reply, &QNetworkReply::finished, [&] {
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
@ -68,6 +68,6 @@ void SapphireLauncher::registerAccount(const QString &lobbyUrl, const LoginInfor
auth.frontierHost = document[QLatin1String("frontierHost")].toString(); auth.frontierHost = document[QLatin1String("frontierHost")].toString();
auth.region = 3; auth.region = 3;
window.launchGame(*info.profile, auth); m_launcher.launchGame(*info.profile, auth);
}); });
} }

View file

@ -18,21 +18,21 @@
SquareBoot::SquareBoot(LauncherCore &window, SquareLauncher &launcher, QObject *parent) SquareBoot::SquareBoot(LauncherCore &window, SquareLauncher &launcher, QObject *parent)
: QObject(parent) : QObject(parent)
, window(window) , m_launcher(window)
, launcher(launcher) , m_squareLauncher(launcher)
{ {
} }
QCoro::Task<> SquareBoot::bootCheck(const LoginInformation &info) QCoro::Task<> SquareBoot::bootCheck(const LoginInformation &info)
{ {
Q_EMIT window.stageChanged(i18n("Checking for launcher updates...")); Q_EMIT m_launcher.stageChanged(i18n("Checking for launcher updates..."));
qDebug() << "Performing boot check..."; qDebug() << "Performing boot check...";
const QUrlQuery query{{QStringLiteral("time"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH-mm"))}}; const QUrlQuery query{{QStringLiteral("time"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH-mm"))}};
QUrl url; QUrl url;
url.setScheme(QStringLiteral("http")); url.setScheme(QStringLiteral("http"));
url.setHost(QStringLiteral("patch-bootver.%1").arg(window.settings()->squareEnixServer())); url.setHost(QStringLiteral("patch-bootver.%1").arg(m_launcher.settings()->squareEnixServer()));
url.setPath(QStringLiteral("/http/win32/ffxivneo_release_boot/%1").arg(info.profile->bootVersion())); url.setPath(QStringLiteral("/http/win32/ffxivneo_release_boot/%1").arg(info.profile->bootVersion()));
url.setQuery(query); url.setQuery(query);
@ -43,46 +43,46 @@ QCoro::Task<> SquareBoot::bootCheck(const LoginInformation &info)
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("FFXIV PATCH CLIENT")); request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("FFXIV PATCH CLIENT"));
} }
request.setRawHeader(QByteArrayLiteral("Host"), QStringLiteral("patch-bootver.%1").arg(window.settings()->squareEnixServer()).toUtf8()); request.setRawHeader(QByteArrayLiteral("Host"), QStringLiteral("patch-bootver.%1").arg(m_launcher.settings()->squareEnixServer()).toUtf8());
Utility::printRequest(QStringLiteral("GET"), request); Utility::printRequest(QStringLiteral("GET"), request);
const auto reply = window.mgr()->get(request); const auto reply = m_launcher.mgr()->get(request);
co_await reply; co_await reply;
const QString patchList = reply->readAll(); const QString patchList = reply->readAll();
if (!patchList.isEmpty()) { if (!patchList.isEmpty()) {
patcher = new Patcher(window, info.profile->gamePath() + QStringLiteral("/boot"), *info.profile->bootData(), this); m_patcher = new Patcher(m_launcher, info.profile->gamePath() + QStringLiteral("/boot"), *info.profile->bootData(), this);
const bool hasPatched = co_await patcher->patch(PatchList(patchList)); const bool hasPatched = co_await m_patcher->patch(PatchList(patchList));
if (hasPatched) { if (hasPatched) {
// update game version information // update game version information
info.profile->readGameVersion(); info.profile->readGameVersion();
} }
patcher->deleteLater(); m_patcher->deleteLater();
} }
launcher.login(info); m_squareLauncher.login(info);
} }
QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info) QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info)
{ {
Q_EMIT window.stageChanged(i18n("Checking gate...")); Q_EMIT m_launcher.stageChanged(i18n("Checking gate..."));
qDebug() << "Checking gate..."; qDebug() << "Checking gate...";
QUrl url; QUrl url;
url.setScheme(window.settings()->preferredProtocol()); url.setScheme(m_launcher.settings()->preferredProtocol());
url.setHost(QStringLiteral("frontier.%1").arg(window.settings()->squareEnixServer())); url.setHost(QStringLiteral("frontier.%1").arg(m_launcher.settings()->squareEnixServer()));
url.setPath(QStringLiteral("/worldStatus/gate_status.json")); url.setPath(QStringLiteral("/worldStatus/gate_status.json"));
url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch())); url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch()));
QNetworkRequest request(url); QNetworkRequest request(url);
// TODO: really? // TODO: really?
window.buildRequest(*info.profile, request); m_launcher.buildRequest(*info.profile, request);
Utility::printRequest(QStringLiteral("GET"), request); Utility::printRequest(QStringLiteral("GET"), request);
const auto reply = window.mgr()->get(request); const auto reply = m_launcher.mgr()->get(request);
window.setupIgnoreSSL(reply); m_launcher.setupIgnoreSSL(reply);
co_await reply; co_await reply;
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
@ -91,6 +91,6 @@ QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info)
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.\n\n%1", reply->errorString())); Q_EMIT m_launcher.loginError(i18n("The login gate is closed, the game may be under maintenance.\n\n%1", reply->errorString()));
} }
} }

View file

@ -19,7 +19,7 @@
SquareLauncher::SquareLauncher(LauncherCore &window, QObject *parent) SquareLauncher::SquareLauncher(LauncherCore &window, QObject *parent)
: QObject(parent) : QObject(parent)
, window(window) , m_launcher(window)
{ {
} }
@ -37,7 +37,7 @@ QString getFileHash(const QString &file)
QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored(const LoginInformation &info) QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored(const LoginInformation &info)
{ {
Q_EMIT window.stageChanged(i18n("Logging in...")); Q_EMIT m_launcher.stageChanged(i18n("Logging in..."));
QUrlQuery query; QUrlQuery query;
// en is always used to the top url // en is always used to the top url
@ -58,17 +58,17 @@ QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored
} }
QUrl url; QUrl url;
url.setScheme(window.settings()->preferredProtocol()); url.setScheme(m_launcher.settings()->preferredProtocol());
url.setHost(QStringLiteral("ffxiv-login.%1").arg(window.settings()->squareEnixLoginServer())); url.setHost(QStringLiteral("ffxiv-login.%1").arg(m_launcher.settings()->squareEnixLoginServer()));
url.setPath(QStringLiteral("/oauth/ffxivarr/login/top")); url.setPath(QStringLiteral("/oauth/ffxivarr/login/top"));
url.setQuery(query); url.setQuery(query);
auto request = QNetworkRequest(url); auto request = QNetworkRequest(url);
window.buildRequest(*info.profile, request); m_launcher.buildRequest(*info.profile, request);
Utility::printRequest(QStringLiteral("GET"), request); Utility::printRequest(QStringLiteral("GET"), request);
const auto reply = window.mgr()->get(request); const auto reply = m_launcher.mgr()->get(request);
co_await reply; co_await reply;
const QString str = reply->readAll(); const QString str = reply->readAll();
@ -79,12 +79,12 @@ QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored
const QRegularExpressionMatch match = re.match(str); const QRegularExpressionMatch match = re.match(str);
if (match.hasMatch()) { if (match.hasMatch()) {
username = match.captured(1); m_username = match.captured(1);
} else { } else {
Q_EMIT window.loginError(i18n("Could not get Steam username, have you attached your account?")); Q_EMIT m_launcher.loginError(i18n("Could not get Steam username, have you attached your account?"));
} }
} else { } else {
username = info.username; m_username = info.username;
} }
const QRegularExpression re(QStringLiteral(R"lit(\t<\s*input .* name="_STORED_" value="(?<stored>.*)">)lit")); const QRegularExpression re(QStringLiteral(R"lit(\t<\s*input .* name="_STORED_" value="(?<stored>.*)">)lit"));
@ -92,7 +92,7 @@ QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored
if (match.hasMatch()) { if (match.hasMatch()) {
co_return StoredInfo{match.captured(1), url}; co_return StoredInfo{match.captured(1), url};
} else { } else {
Q_EMIT window.loginError( Q_EMIT m_launcher.loginError(
i18n("Square Enix servers refused to confirm session information. The game may be under maintenance, try the official launcher.")); i18n("Square Enix servers refused to confirm session information. The game may be under maintenance, try the official launcher."));
co_return {}; co_return {};
} }
@ -117,19 +117,19 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info)
QUrl url; QUrl url;
url.setScheme(QStringLiteral("https")); url.setScheme(QStringLiteral("https"));
url.setHost(QStringLiteral("ffxiv-login.%1").arg(window.settings()->squareEnixLoginServer())); url.setHost(QStringLiteral("ffxiv-login.%1").arg(m_launcher.settings()->squareEnixLoginServer()));
url.setPath(QStringLiteral("/oauth/ffxivarr/login/login.send")); url.setPath(QStringLiteral("/oauth/ffxivarr/login/login.send"));
QNetworkRequest request(url); QNetworkRequest request(url);
window.buildRequest(*info.profile, request); m_launcher.buildRequest(*info.profile, request);
request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded")); request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded"));
request.setRawHeader(QByteArrayLiteral("Referer"), referer.toEncoded()); request.setRawHeader(QByteArrayLiteral("Referer"), referer.toEncoded());
request.setRawHeader(QByteArrayLiteral("Cache-Control"), QByteArrayLiteral("no-cache")); request.setRawHeader(QByteArrayLiteral("Cache-Control"), QByteArrayLiteral("no-cache"));
Utility::printRequest(QStringLiteral("POST"), request); Utility::printRequest(QStringLiteral("POST"), request);
const auto reply = window.mgr()->post(request, postData.toString(QUrl::FullyEncoded).toUtf8()); const auto reply = m_launcher.mgr()->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
window.setupIgnoreSSL(reply); m_launcher.setupIgnoreSSL(reply);
co_await reply; co_await reply;
const QString str = reply->readAll(); const QString str = reply->readAll();
@ -143,18 +143,18 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info)
const bool playable = parts[9] == QLatin1String("1"); const bool playable = parts[9] == QLatin1String("1");
if (!playable) { if (!playable) {
Q_EMIT window.loginError(i18n("Your account is unplayable. Check that you have the correct license, and a valid subscription.")); Q_EMIT m_launcher.loginError(i18n("Your account is unplayable. Check that you have the correct license, and a valid subscription."));
co_return; co_return;
} }
if (!terms) { if (!terms) {
Q_EMIT window.loginError(i18n("Your account is unplayable. You need to accept the terms of service from the official launcher first.")); Q_EMIT m_launcher.loginError(i18n("Your account is unplayable. You need to accept the terms of service from the official launcher first."));
co_return; co_return;
} }
SID = parts[1]; m_SID = parts[1];
auth.region = parts[5].toInt(); m_auth.region = parts[5].toInt();
auth.maxExpansion = parts[13].toInt(); m_auth.maxExpansion = parts[13].toInt();
registerSession(info); registerSession(info);
} else { } else {
@ -162,7 +162,7 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info)
const QRegularExpressionMatch match = re.match(str); const QRegularExpressionMatch match = re.match(str);
// there's a stray quote at the end of the error string, so let's remove that // there's a stray quote at the end of the error string, so let's remove that
Q_EMIT window.loginError(match.captured(1).chopped(1)); Q_EMIT m_launcher.loginError(match.captured(1).chopped(1));
} }
} }
@ -170,17 +170,17 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
{ {
QUrl url; QUrl url;
url.setScheme(QStringLiteral("https")); url.setScheme(QStringLiteral("https"));
url.setHost(QStringLiteral("patch-gamever.%1").arg(window.settings()->squareEnixServer())); url.setHost(QStringLiteral("patch-gamever.%1").arg(m_launcher.settings()->squareEnixServer()));
url.setPath(QStringLiteral("/http/win32/ffxivneo_release_game/%1/%2").arg(info.profile->baseGameVersion(), SID)); url.setPath(QStringLiteral("/http/win32/ffxivneo_release_game/%1/%2").arg(info.profile->baseGameVersion(), m_SID));
auto request = QNetworkRequest(url); auto request = QNetworkRequest(url);
window.setSSL(request); m_launcher.setSSL(request);
request.setRawHeader(QByteArrayLiteral("X-Hash-Check"), QByteArrayLiteral("enabled")); request.setRawHeader(QByteArrayLiteral("X-Hash-Check"), QByteArrayLiteral("enabled"));
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("FFXIV PATCH CLIENT")); request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("FFXIV PATCH CLIENT"));
request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded")); request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded"));
QString report = QStringLiteral("%1=%2").arg(info.profile->bootVersion(), co_await getBootHash(info)); QString report = QStringLiteral("%1=%2").arg(info.profile->bootVersion(), co_await getBootHash(info));
for (int i = 0; i < auth.maxExpansion; i++) { for (int i = 0; i < m_auth.maxExpansion; i++) {
if (i < static_cast<int>(info.profile->numInstalledExpansions())) { if (i < static_cast<int>(info.profile->numInstalledExpansions())) {
report += QStringLiteral("\nex%1\t%2").arg(QString::number(i + 1), info.profile->expansionVersion(i)); report += QStringLiteral("\nex%1\t%2").arg(QString::number(i + 1), info.profile->expansionVersion(i));
} else { } else {
@ -190,7 +190,7 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
Utility::printRequest(QStringLiteral("POST"), request); Utility::printRequest(QStringLiteral("POST"), request);
const auto reply = window.mgr()->post(request, report.toUtf8()); const auto reply = m_launcher.mgr()->post(request, report.toUtf8());
co_await reply; co_await reply;
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
@ -205,31 +205,31 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
const QString body = reply->readAll(); const QString body = reply->readAll();
if (!body.isEmpty()) { if (!body.isEmpty()) {
patcher = new Patcher(window, info.profile->gamePath() + QStringLiteral("/game"), *info.profile->gameData(), this); m_patcher = new Patcher(m_launcher, info.profile->gamePath() + QStringLiteral("/game"), *info.profile->gameData(), this);
const bool hasPatched = co_await patcher->patch(PatchList(body)); const bool hasPatched = co_await m_patcher->patch(PatchList(body));
if (hasPatched) { if (hasPatched) {
// re-read game version if it has updated // re-read game version if it has updated
info.profile->readGameVersion(); info.profile->readGameVersion();
} }
patcher->deleteLater(); m_patcher->deleteLater();
} }
auth.SID = patchUniqueId; m_auth.SID = patchUniqueId;
window.launchGame(*info.profile, auth); m_launcher.launchGame(*info.profile, m_auth);
} else { } else {
Q_EMIT window.loginError(i18n("Fatal error, request was successful but X-Patch-Unique-Id was not recieved.")); Q_EMIT m_launcher.loginError(i18n("Fatal error, request was successful but X-Patch-Unique-Id was not recieved."));
} }
} else { } else {
if (reply->error() == QNetworkReply::SslHandshakeFailedError) { if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
Q_EMIT window.loginError( Q_EMIT m_launcher.loginError(
i18n("SSL handshake error detected. If you are using OpenSUSE or Fedora, try running `update-crypto-policies --set LEGACY`.")); i18n("SSL handshake error detected. If you are using OpenSUSE or Fedora, try running `update-crypto-policies --set LEGACY`."));
} else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 405) { } else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 405) {
Q_EMIT window.loginError(i18n("The game failed the anti-tamper check. Restore the game to the original state and try updating again.")); Q_EMIT m_launcher.loginError(i18n("The game failed the anti-tamper check. Restore the game to the original state and try updating again."));
} else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 410) { } else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 410) {
Q_EMIT window.loginError(i18n("This game version is no longer supported.")); Q_EMIT m_launcher.loginError(i18n("This game version is no longer supported."));
} else { } else {
Q_EMIT window.loginError(i18n("Unknown error when registering the session.")); Q_EMIT m_launcher.loginError(i18n("Unknown error when registering the session."));
} }
} }
} }