diff --git a/launcher/include/assetupdater.h b/launcher/include/assetupdater.h index 527a3cd..6c53c8f 100644 --- a/launcher/include/assetupdater.h +++ b/launcher/include/assetupdater.h @@ -37,21 +37,19 @@ private: LauncherCore &launcher; - Profile::DalamudChannel chosenChannel; + QString m_remoteDalamudVersion; + QString m_remoteRuntimeVersion; - QString remoteDalamudVersion; - QString remoteRuntimeVersion; + QTemporaryDir m_tempDir; + QDir m_dataDir; + QDir m_appDataDir; + QDir m_dalamudDir; + QDir m_dalamudAssetDir; + QDir m_dalamudRuntimeDir; - QTemporaryDir tempDir; - QDir dataDir; - QDir appDataDir; - QDir dalamudDir; - QDir dalamudAssetDir; - QDir dalamudRuntimeDir; - - int remoteDalamudAssetVersion = -1; - QJsonArray remoteDalamudAssetArray; - QString remoteDalamudDownloadUrl; + int m_remoteDalamudAssetVersion = -1; + QJsonArray m_remoteDalamudAssetArray; + QString m_remoteDalamudDownloadUrl; Profile &m_profile; }; diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 5c87061..4b2b616 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -177,7 +177,6 @@ private: QCoro::Task<> fetchNews(); - bool m_isSteam = false; SteamAPI *m_steamApi = nullptr; bool m_loadingFinished = false; diff --git a/launcher/include/processlogger.h b/launcher/include/processlogger.h index 113a4ba..8542936 100644 --- a/launcher/include/processlogger.h +++ b/launcher/include/processlogger.h @@ -13,5 +13,5 @@ public: explicit ProcessLogger(QProcess *process); private: - QFile file; + QFile m_file; }; \ No newline at end of file diff --git a/launcher/include/sapphirelauncher.h b/launcher/include/sapphirelauncher.h index ad3766f..55a2671 100644 --- a/launcher/include/sapphirelauncher.h +++ b/launcher/include/sapphirelauncher.h @@ -16,5 +16,5 @@ public: void registerAccount(const QString &lobbyUrl, const LoginInformation &info); private: - LauncherCore &window; + LauncherCore &m_launcher; }; \ No newline at end of file diff --git a/launcher/include/squareboot.h b/launcher/include/squareboot.h index 67f4cf4..6824bf7 100644 --- a/launcher/include/squareboot.h +++ b/launcher/include/squareboot.h @@ -23,8 +23,8 @@ public: private: QCoro::Task<> bootCheck(const LoginInformation &info); - Patcher *patcher = nullptr; + Patcher *m_patcher = nullptr; - LauncherCore &window; - SquareLauncher &launcher; + LauncherCore &m_launcher; + SquareLauncher &m_squareLauncher; }; \ No newline at end of file diff --git a/launcher/include/squarelauncher.h b/launcher/include/squarelauncher.h index 89d7fac..7fd4470 100644 --- a/launcher/include/squarelauncher.h +++ b/launcher/include/squarelauncher.h @@ -25,10 +25,10 @@ public: private: static QCoro::Task getBootHash(const LoginInformation &info); - Patcher *patcher = nullptr; + Patcher *m_patcher = nullptr; - QString SID, username; - LoginAuth auth; + QString m_SID, m_username; + LoginAuth m_auth; - LauncherCore &window; + LauncherCore &m_launcher; }; diff --git a/launcher/src/assetupdater.cpp b/launcher/src/assetupdater.cpp index 1f850c5..3409d4d 100644 --- a/launcher/src/assetupdater.cpp +++ b/launcher/src/assetupdater.cpp @@ -19,7 +19,6 @@ AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent) : QObject(parent) , launcher(launcher) - , chosenChannel(profile.dalamudChannel()) , m_profile(profile) { } @@ -32,19 +31,19 @@ QCoro::Task AssetUpdater::update() qInfo(ASTRA_LOG) << "Checking for asset updates..."; - dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - dalamudDir = dataDir.absoluteFilePath(QStringLiteral("dalamud")); - dalamudAssetDir = dalamudDir.absoluteFilePath(QStringLiteral("assets")); - dalamudRuntimeDir = dalamudDir.absoluteFilePath(QStringLiteral("runtime")); + m_dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + m_dalamudDir = m_dataDir.absoluteFilePath(QStringLiteral("dalamud")); + m_dalamudAssetDir = m_dalamudDir.absoluteFilePath(QStringLiteral("assets")); + m_dalamudRuntimeDir = m_dalamudDir.absoluteFilePath(QStringLiteral("runtime")); const auto createIfNeeded = [](const QDir &dir) { if (!QDir().exists(dir.absolutePath())) QDir().mkpath(dir.absolutePath()); }; - createIfNeeded(dalamudDir); - createIfNeeded(dalamudAssetDir); - createIfNeeded(dalamudRuntimeDir); + createIfNeeded(m_dalamudDir); + createIfNeeded(m_dalamudAssetDir); + createIfNeeded(m_dalamudRuntimeDir); if (!co_await checkRemoteDalamudAssetVersion()) { co_return false; @@ -73,14 +72,14 @@ QCoro::Task AssetUpdater::checkRemoteDalamudAssetVersion() const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll()); - remoteDalamudAssetVersion = doc.object()[QLatin1String("version")].toInt(); - remoteDalamudAssetArray = doc.object()[QLatin1String("assets")].toArray(); + m_remoteDalamudAssetVersion = doc.object()[QLatin1String("version")].toInt(); + 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(); // dalamud assets - if (remoteDalamudAssetVersion != m_profile.dalamudAssetVersion()) { + if (m_remoteDalamudAssetVersion != m_profile.dalamudAssetVersion()) { qInfo(ASTRA_LOG) << "Dalamud assets out of date"; co_return co_await installDalamudAssets(); @@ -99,8 +98,8 @@ QCoro::Task AssetUpdater::checkRemoteDalamudVersion() const QNetworkRequest request(url); Utility::printRequest(QStringLiteral("GET"), request); - remoteDalamudVersion.clear(); - remoteRuntimeVersion.clear(); + m_remoteDalamudVersion.clear(); + m_remoteRuntimeVersion.clear(); const auto reply = launcher.mgr()->get(request); co_await reply; @@ -111,20 +110,20 @@ QCoro::Task AssetUpdater::checkRemoteDalamudVersion() } const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll()); - remoteDalamudVersion = doc[QLatin1String("assemblyVersion")].toString(); - remoteRuntimeVersion = doc[QLatin1String("runtimeVersion")].toString(); - remoteDalamudDownloadUrl = doc[QLatin1String("downloadUrl")].toString(); + m_remoteDalamudVersion = doc[QLatin1String("assemblyVersion")].toString(); + m_remoteRuntimeVersion = doc[QLatin1String("runtimeVersion")].toString(); + m_remoteDalamudDownloadUrl = doc[QLatin1String("downloadUrl")].toString(); - qInfo(ASTRA_LOG) << "Latest available Dalamud version:" << remoteDalamudVersion << "local:" << m_profile.dalamudVersion(); - qInfo(ASTRA_LOG) << "Latest available NET runtime:" << remoteRuntimeVersion; + qInfo(ASTRA_LOG) << "Latest available Dalamud version:" << m_remoteDalamudVersion << "local:" << m_profile.dalamudVersion(); + qInfo(ASTRA_LOG) << "Latest available NET runtime:" << m_remoteRuntimeVersion; - if (remoteDalamudVersion != m_profile.dalamudVersion()) { + if (m_remoteDalamudVersion != m_profile.dalamudVersion()) { if (!co_await installDalamud()) { co_return false; } } - if (m_profile.runtimeVersion() != remoteRuntimeVersion) { + if (m_profile.runtimeVersion() != m_remoteRuntimeVersion) { if (!co_await installRuntime()) { co_return false; } @@ -139,7 +138,7 @@ QCoro::Task AssetUpdater::installDalamudAssets() QFutureSynchronizer synchronizer; - for (const auto &assetObject : remoteDalamudAssetArray) { + for (const auto &assetObject : m_remoteDalamudAssetArray) { const QNetworkRequest assetRequest(assetObject.toObject()[QLatin1String("url")].toString()); Utility::printRequest(QStringLiteral("GET"), assetRequest); @@ -149,12 +148,12 @@ QCoro::Task AssetUpdater::installDalamudAssets() const QString fileName = assetObject.toObject()[QLatin1String("fileName")].toString(); 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)) 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.write(assetReply->readAll()); file.close(); @@ -169,11 +168,11 @@ QCoro::Task AssetUpdater::installDalamudAssets() 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.write(QString::number(remoteDalamudAssetVersion).toUtf8()); + file.write(QString::number(m_remoteDalamudAssetVersion).toUtf8()); file.close(); co_return true; @@ -183,7 +182,7 @@ QCoro::Task AssetUpdater::installDalamud() { Q_EMIT launcher.stageChanged(i18n("Updating Dalamud...")); - const QNetworkRequest request(remoteDalamudDownloadUrl); + const QNetworkRequest request(m_remoteDalamudDownloadUrl); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = launcher.mgr()->get(request); @@ -191,13 +190,13 @@ QCoro::Task AssetUpdater::installDalamud() 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.write(reply->readAll()); file.close(); 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) { qCritical(ASTRA_LOG) << "Failed to install Dalamud"; @@ -205,7 +204,7 @@ QCoro::Task AssetUpdater::installDalamud() co_return false; } - m_profile.setDalamudVersion(remoteDalamudVersion); + m_profile.setDalamudVersion(m_remoteDalamudVersion); co_return true; } @@ -216,7 +215,7 @@ QCoro::Task AssetUpdater::installRuntime() // core { - const QNetworkRequest request(dotnetRuntimePackageUrl(remoteRuntimeVersion)); + const QNetworkRequest request(dotnetRuntimePackageUrl(m_remoteRuntimeVersion)); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = launcher.mgr()->get(request); @@ -224,7 +223,7 @@ QCoro::Task AssetUpdater::installRuntime() 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.write(reply->readAll()); file.close(); @@ -232,7 +231,7 @@ QCoro::Task AssetUpdater::installRuntime() // desktop { - const QNetworkRequest request(dotnetDesktopPackageUrl(remoteRuntimeVersion)); + const QNetworkRequest request(dotnetDesktopPackageUrl(m_remoteRuntimeVersion)); Utility::printRequest(QStringLiteral("GET"), request); const auto reply = launcher.mgr()->get(request); @@ -240,14 +239,14 @@ QCoro::Task AssetUpdater::installRuntime() 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.write(reply->readAll()); file.close(); } - bool success = !JlCompress::extractDir(tempDir.filePath(QStringLiteral("dotnet-core.zip")), dalamudRuntimeDir.absolutePath()).empty(); - success |= !JlCompress::extractDir(tempDir.filePath(QStringLiteral("dotnet-desktop.zip")), dalamudRuntimeDir.absolutePath()).empty(); + bool success = !JlCompress::extractDir(m_tempDir.filePath(QStringLiteral("dotnet-core.zip")), m_dalamudRuntimeDir.absolutePath()).empty(); + success |= !JlCompress::extractDir(m_tempDir.filePath(QStringLiteral("dotnet-desktop.zip")), m_dalamudRuntimeDir.absolutePath()).empty(); if (!success) { qCritical(ASTRA_LOG) << "Failed to install dotnet"; @@ -255,9 +254,9 @@ QCoro::Task AssetUpdater::installRuntime() co_return false; } else { - QFile file(dalamudRuntimeDir.absoluteFilePath(QStringLiteral("runtime.ver"))); + QFile file(m_dalamudRuntimeDir.absoluteFilePath(QStringLiteral("runtime.ver"))); file.open(QIODevice::WriteOnly | QIODevice::Text); - file.write(remoteRuntimeVersion.toUtf8()); + file.write(m_remoteRuntimeVersion.toUtf8()); file.close(); co_return true; diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 11e3da8..e61148a 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -303,7 +303,7 @@ void LauncherCore::launchExecutable(const Profile &profile, QProcess *process, c #endif #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 compatData = 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 { - return m_isSteam; + return m_steamApi != nullptr; } bool LauncherCore::isSteamDeck() const @@ -680,7 +680,6 @@ void LauncherCore::clearAvatarCache() void LauncherCore::initializeSteam() { - m_isSteam = true; m_steamApi = new SteamAPI(this); m_steamApi->setLauncherMode(true); } diff --git a/launcher/src/processlogger.cpp b/launcher/src/processlogger.cpp index 5a29bf9..c2208ea 100644 --- a/launcher/src/processlogger.cpp +++ b/launcher/src/processlogger.cpp @@ -9,22 +9,22 @@ ProcessLogger::ProcessLogger(QProcess *process) { const QDir logDirectory = Utility::stateDirectory().absoluteFilePath("log"); - file.setFileName(logDirectory.absoluteFilePath(QStringLiteral("ffxiv.log"))); - file.open(QIODevice::WriteOnly | QIODevice::Unbuffered); + m_file.setFileName(logDirectory.absoluteFilePath(QStringLiteral("ffxiv.log"))); + m_file.open(QIODevice::WriteOnly | QIODevice::Unbuffered); connect(process, &QProcess::readyReadStandardOutput, this, [this, process] { - file.write(process->readAllStandardOutput()); - file.flush(); + m_file.write(process->readAllStandardOutput()); + m_file.flush(); }); connect(process, &QProcess::readyReadStandardError, this, [this, process] { - file.write(process->readAllStandardError()); - file.flush(); + m_file.write(process->readAllStandardError()); + m_file.flush(); }); connect(process, &QProcess::finished, this, [this] { 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(); } diff --git a/launcher/src/sapphirelauncher.cpp b/launcher/src/sapphirelauncher.cpp index 737d827..adb2b83 100644 --- a/launcher/src/sapphirelauncher.cpp +++ b/launcher/src/sapphirelauncher.cpp @@ -11,7 +11,7 @@ SapphireLauncher::SapphireLauncher(LauncherCore &window, 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")); 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] { 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; } @@ -41,9 +41,9 @@ void SapphireLauncher::login(const QString &lobbyUrl, const LoginInformation &in auth.frontierHost = document[QLatin1String("frontierHost")].toString(); auth.region = 3; - window.launchGame(*info.profile, auth); + m_launcher.launchGame(*info.profile, auth); } 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); - 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, [&] { 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.region = 3; - window.launchGame(*info.profile, auth); + m_launcher.launchGame(*info.profile, auth); }); } \ No newline at end of file diff --git a/launcher/src/squareboot.cpp b/launcher/src/squareboot.cpp index 52b6bf2..5fd690a 100644 --- a/launcher/src/squareboot.cpp +++ b/launcher/src/squareboot.cpp @@ -18,21 +18,21 @@ SquareBoot::SquareBoot(LauncherCore &window, SquareLauncher &launcher, QObject *parent) : QObject(parent) - , window(window) - , launcher(launcher) + , m_launcher(window) + , m_squareLauncher(launcher) { } 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..."; const QUrlQuery query{{QStringLiteral("time"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH-mm"))}}; QUrl url; 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.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("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); - const auto reply = window.mgr()->get(request); + const auto reply = m_launcher.mgr()->get(request); co_await reply; const QString patchList = reply->readAll(); if (!patchList.isEmpty()) { - patcher = new Patcher(window, info.profile->gamePath() + QStringLiteral("/boot"), *info.profile->bootData(), this); - const bool hasPatched = co_await patcher->patch(PatchList(patchList)); + m_patcher = new Patcher(m_launcher, info.profile->gamePath() + QStringLiteral("/boot"), *info.profile->bootData(), this); + const bool hasPatched = co_await m_patcher->patch(PatchList(patchList)); if (hasPatched) { // update game version information info.profile->readGameVersion(); } - patcher->deleteLater(); + m_patcher->deleteLater(); } - launcher.login(info); + m_squareLauncher.login(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..."; QUrl url; - url.setScheme(window.settings()->preferredProtocol()); - url.setHost(QStringLiteral("frontier.%1").arg(window.settings()->squareEnixServer())); + url.setScheme(m_launcher.settings()->preferredProtocol()); + url.setHost(QStringLiteral("frontier.%1").arg(m_launcher.settings()->squareEnixServer())); url.setPath(QStringLiteral("/worldStatus/gate_status.json")); url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch())); QNetworkRequest request(url); // TODO: really? - window.buildRequest(*info.profile, request); + m_launcher.buildRequest(*info.profile, request); Utility::printRequest(QStringLiteral("GET"), request); - const auto reply = window.mgr()->get(request); - window.setupIgnoreSSL(reply); + const auto reply = m_launcher.mgr()->get(request); + m_launcher.setupIgnoreSSL(reply); co_await reply; const QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); @@ -91,6 +91,6 @@ QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info) if (isGateOpen) { bootCheck(info); } 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())); } } diff --git a/launcher/src/squarelauncher.cpp b/launcher/src/squarelauncher.cpp index 610e4c8..d8c0e24 100644 --- a/launcher/src/squarelauncher.cpp +++ b/launcher/src/squarelauncher.cpp @@ -19,7 +19,7 @@ SquareLauncher::SquareLauncher(LauncherCore &window, QObject *parent) : QObject(parent) - , window(window) + , m_launcher(window) { } @@ -37,7 +37,7 @@ QString getFileHash(const QString &file) QCoro::Task> SquareLauncher::getStored(const LoginInformation &info) { - Q_EMIT window.stageChanged(i18n("Logging in...")); + Q_EMIT m_launcher.stageChanged(i18n("Logging in...")); QUrlQuery query; // en is always used to the top url @@ -58,17 +58,17 @@ QCoro::Task> SquareLauncher::getStored } QUrl url; - url.setScheme(window.settings()->preferredProtocol()); - url.setHost(QStringLiteral("ffxiv-login.%1").arg(window.settings()->squareEnixLoginServer())); + url.setScheme(m_launcher.settings()->preferredProtocol()); + url.setHost(QStringLiteral("ffxiv-login.%1").arg(m_launcher.settings()->squareEnixLoginServer())); url.setPath(QStringLiteral("/oauth/ffxivarr/login/top")); url.setQuery(query); auto request = QNetworkRequest(url); - window.buildRequest(*info.profile, request); + m_launcher.buildRequest(*info.profile, request); Utility::printRequest(QStringLiteral("GET"), request); - const auto reply = window.mgr()->get(request); + const auto reply = m_launcher.mgr()->get(request); co_await reply; const QString str = reply->readAll(); @@ -79,12 +79,12 @@ QCoro::Task> SquareLauncher::getStored const QRegularExpressionMatch match = re.match(str); if (match.hasMatch()) { - username = match.captured(1); + m_username = match.captured(1); } 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 { - username = info.username; + m_username = info.username; } const QRegularExpression re(QStringLiteral(R"lit(\t<\s*input .* name="_STORED_" value="(?.*)">)lit")); @@ -92,7 +92,7 @@ QCoro::Task> SquareLauncher::getStored if (match.hasMatch()) { co_return StoredInfo{match.captured(1), url}; } 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.")); co_return {}; } @@ -117,19 +117,19 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info) QUrl url; 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")); 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.setRawHeader(QByteArrayLiteral("Referer"), referer.toEncoded()); request.setRawHeader(QByteArrayLiteral("Cache-Control"), QByteArrayLiteral("no-cache")); Utility::printRequest(QStringLiteral("POST"), request); - const auto reply = window.mgr()->post(request, postData.toString(QUrl::FullyEncoded).toUtf8()); - window.setupIgnoreSSL(reply); + const auto reply = m_launcher.mgr()->post(request, postData.toString(QUrl::FullyEncoded).toUtf8()); + m_launcher.setupIgnoreSSL(reply); co_await reply; const QString str = reply->readAll(); @@ -143,18 +143,18 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info) const bool playable = parts[9] == QLatin1String("1"); 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; } 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; } - SID = parts[1]; - auth.region = parts[5].toInt(); - auth.maxExpansion = parts[13].toInt(); + m_SID = parts[1]; + m_auth.region = parts[5].toInt(); + m_auth.maxExpansion = parts[13].toInt(); registerSession(info); } else { @@ -162,7 +162,7 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info) const QRegularExpressionMatch match = re.match(str); // 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; url.setScheme(QStringLiteral("https")); - url.setHost(QStringLiteral("patch-gamever.%1").arg(window.settings()->squareEnixServer())); - url.setPath(QStringLiteral("/http/win32/ffxivneo_release_game/%1/%2").arg(info.profile->baseGameVersion(), SID)); + 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(), m_SID)); auto request = QNetworkRequest(url); - window.setSSL(request); + m_launcher.setSSL(request); request.setRawHeader(QByteArrayLiteral("X-Hash-Check"), QByteArrayLiteral("enabled")); request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("FFXIV PATCH CLIENT")); request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded")); 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(info.profile->numInstalledExpansions())) { report += QStringLiteral("\nex%1\t%2").arg(QString::number(i + 1), info.profile->expansionVersion(i)); } else { @@ -190,7 +190,7 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info) 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; if (reply->error() == QNetworkReply::NoError) { @@ -205,31 +205,31 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info) const QString body = reply->readAll(); if (!body.isEmpty()) { - patcher = new Patcher(window, info.profile->gamePath() + QStringLiteral("/game"), *info.profile->gameData(), this); - const bool hasPatched = co_await patcher->patch(PatchList(body)); + m_patcher = new Patcher(m_launcher, info.profile->gamePath() + QStringLiteral("/game"), *info.profile->gameData(), this); + const bool hasPatched = co_await m_patcher->patch(PatchList(body)); if (hasPatched) { // re-read game version if it has updated 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 { - 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 { 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`.")); } 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) { - 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 { - Q_EMIT window.loginError(i18n("Unknown error when registering the session.")); + Q_EMIT m_launcher.loginError(i18n("Unknown error when registering the session.")); } } }