mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-23 04:57:44 +00:00
Misc code cleanup, remove duplicate code, improve if checks
This commit is contained in:
parent
95ad51c6f5
commit
6e33379f4f
16 changed files with 130 additions and 133 deletions
|
@ -11,4 +11,5 @@ namespace Utility
|
||||||
QDir stateDirectory();
|
QDir stateDirectory();
|
||||||
QString toWindowsPath(const QDir &dir);
|
QString toWindowsPath(const QDir &dir);
|
||||||
void printRequest(const QString &type, const QNetworkRequest &request);
|
void printRequest(const QString &type, const QNetworkRequest &request);
|
||||||
|
void createPathIfNeeded(const QDir &dir);
|
||||||
}
|
}
|
|
@ -14,6 +14,8 @@
|
||||||
#include "launchercore.h"
|
#include "launchercore.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
Account::Account(LauncherCore &launcher, const QString &key, QObject *parent)
|
Account::Account(LauncherCore &launcher, const QString &key, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_config(key)
|
, m_config(key)
|
||||||
|
@ -222,9 +224,7 @@ void Account::fetchAvatar()
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString cacheLocation = QStandardPaths::standardLocations(QStandardPaths::CacheLocation)[0] + QStringLiteral("/avatars");
|
const QString cacheLocation = QStandardPaths::standardLocations(QStandardPaths::CacheLocation)[0] + QStringLiteral("/avatars");
|
||||||
if (!QDir().exists(cacheLocation)) {
|
Utility::createPathIfNeeded(cacheLocation);
|
||||||
QDir().mkpath(cacheLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString filename = QStringLiteral("%1/%2.jpg").arg(cacheLocation, lodestoneId());
|
const QString filename = QStringLiteral("%1/%2.jpg").arg(cacheLocation, lodestoneId());
|
||||||
if (!QFile(filename).exists()) {
|
if (!QFile(filename).exists()) {
|
||||||
|
@ -242,7 +242,7 @@ void Account::fetchAvatar()
|
||||||
connect(reply, &QNetworkReply::finished, [this, filename, reply] {
|
connect(reply, &QNetworkReply::finished, [this, filename, reply] {
|
||||||
auto document = QJsonDocument::fromJson(reply->readAll());
|
auto document = QJsonDocument::fromJson(reply->readAll());
|
||||||
if (document.isObject()) {
|
if (document.isObject()) {
|
||||||
const QNetworkRequest avatarRequest(QUrl(document.object()[QLatin1String("Character")].toObject()[QLatin1String("Avatar")].toString()));
|
const QNetworkRequest avatarRequest(QUrl(document.object()["Character"_L1].toObject()["Avatar"_L1].toString()));
|
||||||
Utility::printRequest(QStringLiteral("GET"), avatarRequest);
|
Utility::printRequest(QStringLiteral("GET"), avatarRequest);
|
||||||
|
|
||||||
auto avatarReply = m_launcher.mgr()->get(avatarRequest);
|
auto avatarReply = m_launcher.mgr()->get(avatarRequest);
|
||||||
|
@ -311,9 +311,7 @@ void Account::updateConfig()
|
||||||
physis_cfg_set_value(cfgFile, "CutsceneMovieOpening", "1");
|
physis_cfg_set_value(cfgFile, "CutsceneMovieOpening", "1");
|
||||||
|
|
||||||
auto screenshotDir = m_launcher.settings()->screenshotDir();
|
auto screenshotDir = m_launcher.settings()->screenshotDir();
|
||||||
|
Utility::createPathIfNeeded(screenshotDir);
|
||||||
if (!QDir().exists(screenshotDir))
|
|
||||||
QDir().mkpath(screenshotDir);
|
|
||||||
|
|
||||||
auto screenshotDirWin = Utility::toWindowsPath(screenshotDir);
|
auto screenshotDirWin = Utility::toWindowsPath(screenshotDir);
|
||||||
auto screenshotDirWinStd = screenshotDirWin.toStdString();
|
auto screenshotDirWinStd = screenshotDirWin.toStdString();
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
AccountManager::AccountManager(LauncherCore &launcher, QObject *parent)
|
AccountManager::AccountManager(LauncherCore &launcher, QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
, m_launcher(launcher)
|
, m_launcher(launcher)
|
||||||
|
@ -16,8 +18,8 @@ void AccountManager::load()
|
||||||
{
|
{
|
||||||
auto config = KSharedConfig::openStateConfig();
|
auto config = KSharedConfig::openStateConfig();
|
||||||
for (const auto &id : config->groupList()) {
|
for (const auto &id : config->groupList()) {
|
||||||
if (id.contains(QLatin1String("account-"))) {
|
if (id.contains("account-"_L1)) {
|
||||||
const QString uuid = QString(id).remove(QLatin1String("account-"));
|
const QString uuid = QString(id).remove("account-"_L1);
|
||||||
qInfo(ASTRA_LOG) << "Loading account" << uuid;
|
qInfo(ASTRA_LOG) << "Loading account" << uuid;
|
||||||
|
|
||||||
auto account = new Account(m_launcher, uuid, this);
|
auto account = new Account(m_launcher, uuid, this);
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <JlCompress.h>
|
#include <JlCompress.h>
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent)
|
AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, launcher(launcher)
|
, launcher(launcher)
|
||||||
|
@ -36,14 +38,9 @@ QCoro::Task<bool> AssetUpdater::update()
|
||||||
m_dalamudAssetDir = m_dalamudDir.absoluteFilePath(QStringLiteral("assets"));
|
m_dalamudAssetDir = m_dalamudDir.absoluteFilePath(QStringLiteral("assets"));
|
||||||
m_dalamudRuntimeDir = m_dalamudDir.absoluteFilePath(QStringLiteral("runtime"));
|
m_dalamudRuntimeDir = m_dalamudDir.absoluteFilePath(QStringLiteral("runtime"));
|
||||||
|
|
||||||
const auto createIfNeeded = [](const QDir &dir) {
|
Utility::createPathIfNeeded(m_dalamudDir);
|
||||||
if (!QDir().exists(dir.absolutePath()))
|
Utility::createPathIfNeeded(m_dalamudAssetDir);
|
||||||
QDir().mkpath(dir.absolutePath());
|
Utility::createPathIfNeeded(m_dalamudRuntimeDir);
|
||||||
};
|
|
||||||
|
|
||||||
createIfNeeded(m_dalamudDir);
|
|
||||||
createIfNeeded(m_dalamudAssetDir);
|
|
||||||
createIfNeeded(m_dalamudRuntimeDir);
|
|
||||||
|
|
||||||
if (!co_await checkRemoteDalamudAssetVersion()) {
|
if (!co_await checkRemoteDalamudAssetVersion()) {
|
||||||
co_return false;
|
co_return false;
|
||||||
|
@ -72,8 +69,8 @@ QCoro::Task<bool> AssetUpdater::checkRemoteDalamudAssetVersion()
|
||||||
|
|
||||||
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
|
||||||
m_remoteDalamudAssetVersion = doc.object()[QLatin1String("version")].toInt();
|
m_remoteDalamudAssetVersion = doc.object()["version"_L1].toInt();
|
||||||
m_remoteDalamudAssetArray = doc.object()[QLatin1String("assets")].toArray();
|
m_remoteDalamudAssetArray = doc.object()["assets"_L1].toArray();
|
||||||
|
|
||||||
qInfo(ASTRA_LOG) << "Dalamud asset remote version" << m_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();
|
||||||
|
@ -110,9 +107,9 @@ QCoro::Task<bool> AssetUpdater::checkRemoteDalamudVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
||||||
m_remoteDalamudVersion = doc[QLatin1String("assemblyVersion")].toString();
|
m_remoteDalamudVersion = doc["assemblyVersion"_L1].toString();
|
||||||
m_remoteRuntimeVersion = doc[QLatin1String("runtimeVersion")].toString();
|
m_remoteRuntimeVersion = doc["runtimeVersion"_L1].toString();
|
||||||
m_remoteDalamudDownloadUrl = doc[QLatin1String("downloadUrl")].toString();
|
m_remoteDalamudDownloadUrl = doc["downloadUrl"_L1].toString();
|
||||||
|
|
||||||
qInfo(ASTRA_LOG) << "Latest available Dalamud version:" << m_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:" << m_remoteRuntimeVersion;
|
qInfo(ASTRA_LOG) << "Latest available NET runtime:" << m_remoteRuntimeVersion;
|
||||||
|
@ -139,21 +136,19 @@ QCoro::Task<bool> AssetUpdater::installDalamudAssets()
|
||||||
QFutureSynchronizer<void> synchronizer;
|
QFutureSynchronizer<void> synchronizer;
|
||||||
|
|
||||||
for (const auto &assetObject : m_remoteDalamudAssetArray) {
|
for (const auto &assetObject : m_remoteDalamudAssetArray) {
|
||||||
const QNetworkRequest assetRequest(QUrl(assetObject.toObject()[QLatin1String("url")].toString()));
|
const QNetworkRequest assetRequest(QUrl(assetObject.toObject()["url"_L1].toString()));
|
||||||
Utility::printRequest(QStringLiteral("GET"), assetRequest);
|
Utility::printRequest(QStringLiteral("GET"), assetRequest);
|
||||||
|
|
||||||
const auto assetReply = launcher.mgr()->get(assetRequest);
|
const auto assetReply = launcher.mgr()->get(assetRequest);
|
||||||
|
|
||||||
const auto future = QtFuture::connect(assetReply, &QNetworkReply::finished).then([this, assetReply, assetObject] {
|
const auto future = QtFuture::connect(assetReply, &QNetworkReply::finished).then([this, assetReply, assetObject] {
|
||||||
const QString fileName = assetObject.toObject()[QLatin1String("fileName")].toString();
|
const QString fileName = assetObject.toObject()["fileName"_L1].toString();
|
||||||
const QString dirPath = fileName.left(fileName.lastIndexOf(QLatin1Char('/')));
|
const QString dirPath = fileName.left(fileName.lastIndexOf('/'_L1));
|
||||||
|
|
||||||
const QString path = m_dalamudAssetDir.absoluteFilePath(dirPath);
|
const QString path = m_dalamudAssetDir.absoluteFilePath(dirPath);
|
||||||
|
Utility::createPathIfNeeded(path);
|
||||||
|
|
||||||
if (!QDir().exists(path))
|
QFile file(m_dalamudAssetDir.absoluteFilePath(assetObject.toObject()["fileName"_L1].toString()));
|
||||||
QDir().mkpath(path);
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
|
@ -28,7 +28,7 @@ void GameInstaller::installGame()
|
||||||
{
|
{
|
||||||
const QDir installDirectory = m_profile.gamePath();
|
const QDir installDirectory = m_profile.gamePath();
|
||||||
|
|
||||||
QNetworkRequest request((QUrl(installerUrl)));
|
const QNetworkRequest request = QNetworkRequest(QUrl(installerUrl));
|
||||||
|
|
||||||
auto reply = m_launcher.mgr()->get(request);
|
auto reply = m_launcher.mgr()->get(request);
|
||||||
Utility::printRequest(QStringLiteral("GET"), request);
|
Utility::printRequest(QStringLiteral("GET"), request);
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "processlogger.h"
|
#include "processlogger.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
GameRunner::GameRunner(LauncherCore &launcher, QObject *parent)
|
GameRunner::GameRunner(LauncherCore &launcher, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_launcher(launcher)
|
, m_launcher(launcher)
|
||||||
|
@ -75,9 +77,7 @@ void GameRunner::beginDalamudGame(const QString &gameExecutablePath, Profile &pr
|
||||||
const QDir dalamudPluginDir = dalamudUserPluginDir.absoluteFilePath(QStringLiteral("installedPlugins"));
|
const QDir dalamudPluginDir = dalamudUserPluginDir.absoluteFilePath(QStringLiteral("installedPlugins"));
|
||||||
|
|
||||||
const QString logDir = stateDir.absoluteFilePath(QStringLiteral("log"));
|
const QString logDir = stateDir.absoluteFilePath(QStringLiteral("log"));
|
||||||
|
Utility::createPathIfNeeded(logDir);
|
||||||
if (!QDir().exists(logDir))
|
|
||||||
QDir().mkpath(logDir);
|
|
||||||
|
|
||||||
const QDir dalamudRuntimeDir = dalamudDir.absoluteFilePath(QStringLiteral("runtime"));
|
const QDir dalamudRuntimeDir = dalamudDir.absoluteFilePath(QStringLiteral("runtime"));
|
||||||
const QDir dalamudAssetDir = dalamudDir.absoluteFilePath(QStringLiteral("assets"));
|
const QDir dalamudAssetDir = dalamudDir.absoluteFilePath(QStringLiteral("assets"));
|
||||||
|
@ -126,11 +126,7 @@ void GameRunner::beginDalamudGame(const QString &gameExecutablePath, Profile &pr
|
||||||
|
|
||||||
QString GameRunner::getGameArgs(const Profile &profile, const LoginAuth &auth)
|
QString GameRunner::getGameArgs(const Profile &profile, const LoginAuth &auth)
|
||||||
{
|
{
|
||||||
struct Argument {
|
QList<std::pair<QString, QString>> gameArgs;
|
||||||
QString key, value;
|
|
||||||
};
|
|
||||||
|
|
||||||
QList<Argument> gameArgs;
|
|
||||||
gameArgs.push_back({QStringLiteral("DEV.DataPathType"), QString::number(1)});
|
gameArgs.push_back({QStringLiteral("DEV.DataPathType"), QString::number(1)});
|
||||||
gameArgs.push_back({QStringLiteral("DEV.UseSqPack"), QString::number(1)});
|
gameArgs.push_back({QStringLiteral("DEV.UseSqPack"), QString::number(1)});
|
||||||
|
|
||||||
|
@ -142,13 +138,8 @@ QString GameRunner::getGameArgs(const Profile &profile, const LoginAuth &auth)
|
||||||
gameArgs.push_back({QStringLiteral("UserPath"), Utility::toWindowsPath(profile.account()->getConfigDir().absolutePath())});
|
gameArgs.push_back({QStringLiteral("UserPath"), Utility::toWindowsPath(profile.account()->getConfigDir().absolutePath())});
|
||||||
|
|
||||||
// FIXME: this should belong somewhere else...
|
// FIXME: this should belong somewhere else...
|
||||||
if (!QDir().exists(profile.account()->getConfigDir().absolutePath())) {
|
Utility::createPathIfNeeded(profile.account()->getConfigDir().absolutePath());
|
||||||
QDir().mkpath(profile.account()->getConfigDir().absolutePath());
|
Utility::createPathIfNeeded(profile.winePrefixPath());
|
||||||
}
|
|
||||||
|
|
||||||
if (!QDir().exists(profile.winePrefixPath())) {
|
|
||||||
QDir().mkpath(profile.winePrefixPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!auth.lobbyhost.isEmpty()) {
|
if (!auth.lobbyhost.isEmpty()) {
|
||||||
gameArgs.push_back({QStringLiteral("DEV.GMServerHost"), auth.frontierHost});
|
gameArgs.push_back({QStringLiteral("DEV.GMServerHost"), auth.frontierHost});
|
||||||
|
@ -159,14 +150,14 @@ QString GameRunner::getGameArgs(const Profile &profile, const LoginAuth &auth)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.account()->license() == Account::GameLicense::WindowsSteam) {
|
if (profile.account()->license() == Account::GameLicense::WindowsSteam) {
|
||||||
gameArgs.push_back({QStringLiteral("IsSteam"), QStringLiteral("1")});
|
gameArgs.push_back({QStringLiteral("IsSteam"), QString::number(1)});
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString argFormat = m_launcher.settings()->argumentsEncrypted() ? QStringLiteral(" /%1 =%2") : QStringLiteral(" %1=%2");
|
const QString argFormat = m_launcher.settings()->argumentsEncrypted() ? QStringLiteral(" /%1 =%2") : QStringLiteral(" %1=%2");
|
||||||
|
|
||||||
QString argJoined;
|
QString argJoined;
|
||||||
for (const auto &arg : gameArgs) {
|
for (const auto &[key, value] : gameArgs) {
|
||||||
argJoined += argFormat.arg(arg.key, arg.value);
|
argJoined += argFormat.arg(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_launcher.settings()->argumentsEncrypted() ? encryptGameArg(argJoined) : argJoined;
|
return m_launcher.settings()->argumentsEncrypted() ? encryptGameArg(argJoined) : argJoined;
|
||||||
|
@ -179,11 +170,9 @@ void GameRunner::launchExecutable(const Profile &profile, QProcess *process, con
|
||||||
|
|
||||||
if (needsRegistrySetup) {
|
if (needsRegistrySetup) {
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
|
||||||
if (profile.account()->license() == Account::GameLicense::macOS) {
|
// FFXIV detects this as a "macOS" build by checking if Wine shows up
|
||||||
addRegistryKey(profile, QStringLiteral("HKEY_CURRENT_USER\\Software\\Wine"), QStringLiteral("HideWineExports"), QStringLiteral("0"));
|
const int value = profile.account()->license() == Account::GameLicense::macOS ? 0 : 1;
|
||||||
} else {
|
addRegistryKey(profile, QStringLiteral("HKEY_CURRENT_USER\\Software\\Wine"), QStringLiteral("HideWineExports"), QString::number(value));
|
||||||
addRegistryKey(profile, QStringLiteral("HKEY_CURRENT_USER\\Software\\Wine"), QStringLiteral("HideWineExports"), QStringLiteral("1"));
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,16 +238,16 @@ void GameRunner::launchExecutable(const Profile &profile, QProcess *process, con
|
||||||
}
|
}
|
||||||
|
|
||||||
QString dirName = fileInfo.fileName();
|
QString dirName = fileInfo.fileName();
|
||||||
if (dirName.contains(QLatin1String("Proton"))) {
|
if (dirName.contains("Proton"_L1)) {
|
||||||
if (dirName == QLatin1String("Proton - Experimental")) {
|
if (dirName == "Proton - Experimental"_L1) {
|
||||||
highestVersion.setPath(dir);
|
highestVersion.setPath(dir);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
QString version = dirName.remove(QLatin1String("Proton "));
|
QString version = dirName.remove("Proton "_L1);
|
||||||
// Exclude "BattlEye Runtime" and other unrelated things
|
// Exclude "BattlEye Runtime" and other unrelated things
|
||||||
if (version.contains(QLatin1Char('.'))) {
|
if (version.contains('.'_L1)) {
|
||||||
// TODO: better error handling (they might never be invalid, but better safe than sorry)
|
// TODO: better error handling (they might never be invalid, but better safe than sorry)
|
||||||
QStringList parts = version.split(QLatin1Char('.'));
|
QStringList parts = version.split('.'_L1);
|
||||||
int versionNum = parts[0].toInt();
|
int versionNum = parts[0].toInt();
|
||||||
|
|
||||||
// TODO: doesn't handle minor versions, not like they really exist anymore anyway
|
// TODO: doesn't handle minor versions, not like they really exist anymore anyway
|
||||||
|
@ -288,10 +277,10 @@ void GameRunner::launchExecutable(const Profile &profile, QProcess *process, con
|
||||||
|
|
||||||
env.insert(QStringLiteral("DYLD_FALLBACK_LIBRARY_PATH"), xivLibPath);
|
env.insert(QStringLiteral("DYLD_FALLBACK_LIBRARY_PATH"), xivLibPath);
|
||||||
env.insert(QStringLiteral("DYLD_VERSIONED_LIBRARY_PATH"), xivLibPath);
|
env.insert(QStringLiteral("DYLD_VERSIONED_LIBRARY_PATH"), xivLibPath);
|
||||||
env.insert(QStringLiteral("MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE"), QStringLiteral("1"));
|
env.insert(QStringLiteral("MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE"), QString::number(1));
|
||||||
env.insert(QStringLiteral("MVK_CONFIG_RESUME_LOST_DEVICE"), QStringLiteral("1"));
|
env.insert(QStringLiteral("MVK_CONFIG_RESUME_LOST_DEVICE"), QString::number(1));
|
||||||
env.insert(QStringLiteral("MVK_ALLOW_METAL_FENCES"), QStringLiteral("1"));
|
env.insert(QStringLiteral("MVK_ALLOW_METAL_FENCES"), QString::number(1));
|
||||||
env.insert(QStringLiteral("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS"), QStringLiteral("1"));
|
env.insert(QStringLiteral("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS"), QString::number(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FLATPAK)
|
#if defined(FLATPAK)
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "squareenixlogin.h"
|
#include "squareenixlogin.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
LauncherCore::LauncherCore()
|
LauncherCore::LauncherCore()
|
||||||
: QObject()
|
: QObject()
|
||||||
{
|
{
|
||||||
|
@ -42,7 +44,7 @@ LauncherCore::LauncherCore()
|
||||||
}
|
}
|
||||||
|
|
||||||
// set default profile, if found
|
// set default profile, if found
|
||||||
if (auto profile = m_profileManager->getProfileByUUID(m_settings->currentProfile()); profile != nullptr) {
|
if (auto profile = m_profileManager->getProfileByUUID(m_settings->currentProfile())) {
|
||||||
setCurrentProfile(profile);
|
setCurrentProfile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +111,7 @@ CompatibilityToolInstaller *LauncherCore::createCompatInstaller()
|
||||||
|
|
||||||
void LauncherCore::clearAvatarCache()
|
void LauncherCore::clearAvatarCache()
|
||||||
{
|
{
|
||||||
const auto cacheLocation = QStandardPaths::standardLocations(QStandardPaths::CacheLocation)[0] + QStringLiteral("/avatars");
|
const QString cacheLocation = QStandardPaths::standardLocations(QStandardPaths::CacheLocation)[0] + QStringLiteral("/avatars");
|
||||||
if (QDir(cacheLocation).exists()) {
|
if (QDir(cacheLocation).exists()) {
|
||||||
QDir(cacheLocation).removeRecursively();
|
QDir(cacheLocation).removeRecursively();
|
||||||
}
|
}
|
||||||
|
@ -153,19 +155,17 @@ void LauncherCore::setCurrentProfile(Profile *profile)
|
||||||
|
|
||||||
void LauncherCore::setAutoLoginProfile(Profile *profile)
|
void LauncherCore::setAutoLoginProfile(Profile *profile)
|
||||||
{
|
{
|
||||||
if (profile == nullptr) {
|
if (profile != nullptr) {
|
||||||
|
auto uuid = profile->uuid();
|
||||||
|
if (uuid != m_settings->config()->autoLoginProfile()) {
|
||||||
|
m_settings->config()->setAutoLoginProfile(uuid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
m_settings->config()->setAutoLoginProfile({});
|
m_settings->config()->setAutoLoginProfile({});
|
||||||
m_settings->config()->save();
|
|
||||||
Q_EMIT autoLoginProfileChanged();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto uuid = profile->uuid();
|
m_settings->config()->save();
|
||||||
if (uuid != m_settings->config()->autoLoginProfile()) {
|
Q_EMIT autoLoginProfileChanged();
|
||||||
m_settings->config()->setAutoLoginProfile(uuid);
|
|
||||||
m_settings->config()->save();
|
|
||||||
Q_EMIT autoLoginProfileChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherCore::buildRequest(const Profile &settings, QNetworkRequest &request)
|
void LauncherCore::buildRequest(const Profile &settings, QNetworkRequest &request)
|
||||||
|
@ -317,41 +317,35 @@ QCoro::Task<> LauncherCore::fetchNews()
|
||||||
|
|
||||||
const auto parseNews = [](QJsonObject object) -> News {
|
const auto parseNews = [](QJsonObject object) -> News {
|
||||||
News news;
|
News news;
|
||||||
news.date = QDateTime::fromString(object[QLatin1String("date")].toString(), Qt::DateFormat::ISODate);
|
news.date = QDateTime::fromString(object["date"_L1].toString(), Qt::DateFormat::ISODate);
|
||||||
news.id = object[QLatin1String("id")].toString();
|
news.id = object["id"_L1].toString();
|
||||||
news.tag = object[QLatin1String("tag")].toString();
|
news.tag = object["tag"_L1].toString();
|
||||||
news.title = object[QLatin1String("title")].toString();
|
news.title = object["title"_L1].toString();
|
||||||
|
|
||||||
if (object[QLatin1String("url")].toString().isEmpty()) {
|
if (object["url"_L1].toString().isEmpty()) {
|
||||||
news.url = QUrl(QStringLiteral("https://na.finalfantasyxiv.com/lodestone/news/detail/%1").arg(news.id));
|
news.url = QUrl(QStringLiteral("https://na.finalfantasyxiv.com/lodestone/news/detail/%1").arg(news.id));
|
||||||
} else {
|
} else {
|
||||||
news.url = QUrl(object[QLatin1String("url")].toString());
|
news.url = QUrl(object["url"_L1].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return news;
|
return news;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto bannerObject : document.object()[QLatin1String("banner")].toArray()) {
|
for (const auto bannerObject : document.object()["banner"_L1].toArray()) {
|
||||||
auto banner = Banner();
|
headline->banners.push_back(
|
||||||
banner.link = QUrl(bannerObject.toObject()[QLatin1String("link")].toString());
|
{.link = QUrl(bannerObject.toObject()["link"_L1].toString()), .bannerImage = QUrl(bannerObject.toObject()["lsb_banner"_L1].toString())});
|
||||||
banner.bannerImage = QUrl(bannerObject.toObject()[QLatin1String("lsb_banner")].toString());
|
|
||||||
|
|
||||||
headline->banners.push_back(banner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto newsObject : document.object()[QLatin1String("news")].toArray()) {
|
for (const auto newsObject : document.object()["news"_L1].toArray()) {
|
||||||
auto news = parseNews(newsObject.toObject());
|
headline->news.push_back(parseNews(newsObject.toObject()));
|
||||||
headline->news.push_back(news);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto pinnedObject : document.object()[QLatin1String("pinned")].toArray()) {
|
for (const auto pinnedObject : document.object()["pinned"_L1].toArray()) {
|
||||||
auto pinned = parseNews(pinnedObject.toObject());
|
headline->pinned.push_back(parseNews(pinnedObject.toObject()));
|
||||||
headline->pinned.push_back(pinned);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto pinnedObject : document.object()[QLatin1String("topics")].toArray()) {
|
for (const auto pinnedObject : document.object()["topics"_L1].toArray()) {
|
||||||
auto pinned = parseNews(pinnedObject.toObject());
|
headline->topics.push_back(parseNews(pinnedObject.toObject()));
|
||||||
headline->topics.push_back(pinned);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_headline = headline;
|
m_headline = headline;
|
||||||
|
|
|
@ -39,10 +39,7 @@ public:
|
||||||
const QString filename{QStringLiteral("astra.log")};
|
const QString filename{QStringLiteral("astra.log")};
|
||||||
|
|
||||||
const QDir logDirectory = Utility::stateDirectory().absoluteFilePath(QStringLiteral("log"));
|
const QDir logDirectory = Utility::stateDirectory().absoluteFilePath(QStringLiteral("log"));
|
||||||
|
Utility::createPathIfNeeded(logDirectory);
|
||||||
if (!logDirectory.exists()) {
|
|
||||||
QDir().mkpath(logDirectory.absolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort them from highest to lowest (4, 3, 2, 1, 0)
|
// Sort them from highest to lowest (4, 3, 2, 1, 0)
|
||||||
auto existingLogEntries = logDirectory.entryList({filename + QStringLiteral(".*")});
|
auto existingLogEntries = logDirectory.entryList({filename + QStringLiteral(".*")});
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "physis_logger.h"
|
#include "physis_logger.h"
|
||||||
#include "sapphirelogin.h"
|
#include "sapphirelogin.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
initializeLogging();
|
initializeLogging();
|
||||||
|
@ -98,7 +100,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
const QStringList args = parser.positionalArguments();
|
const QStringList args = parser.positionalArguments();
|
||||||
// Steam tries to use as a compatibility tool, running installation scripts (like DirectX), so try to ignore it.
|
// Steam tries to use as a compatibility tool, running installation scripts (like DirectX), so try to ignore it.
|
||||||
if (!args.empty() && !args[0].contains(QLatin1String("ffxivboot.exe"))) {
|
if (!args.empty() && !args[0].contains("ffxivboot.exe"_L1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "patchlist.h"
|
#include "patchlist.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
Patcher::Patcher(LauncherCore &launcher, const QString &baseDirectory, BootData &bootData, QObject *parent)
|
Patcher::Patcher(LauncherCore &launcher, const QString &baseDirectory, BootData &bootData, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_baseDirectory(baseDirectory)
|
, m_baseDirectory(baseDirectory)
|
||||||
|
@ -70,9 +72,7 @@ QCoro::Task<bool> Patcher::patch(const PatchList &patchList)
|
||||||
|
|
||||||
const QString filename = QStringLiteral("%1.patch").arg(patch.name);
|
const QString filename = QStringLiteral("%1.patch").arg(patch.name);
|
||||||
const QDir repositoryDir = m_patchesDir.absoluteFilePath(patch.repository);
|
const QDir repositoryDir = m_patchesDir.absoluteFilePath(patch.repository);
|
||||||
|
Utility::createPathIfNeeded(repositoryDir);
|
||||||
if (!QDir().exists(repositoryDir.absolutePath()))
|
|
||||||
QDir().mkpath(repositoryDir.absolutePath());
|
|
||||||
|
|
||||||
const QString patchPath = repositoryDir.absoluteFilePath(filename);
|
const QString patchPath = repositoryDir.absoluteFilePath(filename);
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void Patcher::processPatch(const QueuedPatch &patch)
|
||||||
if (isBoot()) {
|
if (isBoot()) {
|
||||||
verFilePath = m_baseDirectory + QStringLiteral("/ffxivboot.ver");
|
verFilePath = m_baseDirectory + QStringLiteral("/ffxivboot.ver");
|
||||||
} else {
|
} else {
|
||||||
if (patch.repository == QLatin1String("game")) {
|
if (patch.repository == "game"_L1) {
|
||||||
verFilePath = m_baseDirectory + QStringLiteral("/ffxivgame.ver");
|
verFilePath = m_baseDirectory + QStringLiteral("/ffxivgame.ver");
|
||||||
} else {
|
} else {
|
||||||
verFilePath = m_baseDirectory + QStringLiteral("/sqpack/") + patch.repository + QStringLiteral("/") + patch.repository + QStringLiteral(".ver");
|
verFilePath = m_baseDirectory + QStringLiteral("/sqpack/") + patch.repository + QStringLiteral("/") + patch.repository + QStringLiteral(".ver");
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
#include "patchlist.h"
|
#include "patchlist.h"
|
||||||
#include "astra_patcher_log.h"
|
#include "astra_patcher_log.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
PatchList::PatchList(const QString &patchList)
|
PatchList::PatchList(const QString &patchList)
|
||||||
{
|
{
|
||||||
const QStringList parts = patchList.split(QStringLiteral("\r\n"));
|
const QStringList parts = patchList.split(QStringLiteral("\r\n"));
|
||||||
|
|
||||||
for (int i = 5; i < parts.size() - 2; i++) {
|
for (int i = 5; i < parts.size() - 2; i++) {
|
||||||
const QStringList patchParts = parts[i].split(QLatin1Char('\t'));
|
const QStringList patchParts = parts[i].split('\t'_L1);
|
||||||
|
|
||||||
const int length = patchParts[0].toInt();
|
const int length = patchParts[0].toInt();
|
||||||
|
|
||||||
|
@ -17,10 +19,10 @@ PatchList::PatchList(const QString &patchList)
|
||||||
const long hashBlockSize = patchParts.size() == 9 ? patchParts[6].toLong() : 0;
|
const long hashBlockSize = patchParts.size() == 9 ? patchParts[6].toLong() : 0;
|
||||||
|
|
||||||
const QString &name = version;
|
const QString &name = version;
|
||||||
const QStringList hashes = patchParts.size() == 9 ? (patchParts[7].split(QLatin1Char(','))) : QStringList();
|
const QStringList hashes = patchParts.size() == 9 ? (patchParts[7].split(','_L1)) : QStringList();
|
||||||
const QString &url = patchParts[patchParts.size() == 9 ? 8 : 5];
|
const QString &url = patchParts[patchParts.size() == 9 ? 8 : 5];
|
||||||
|
|
||||||
auto url_parts = url.split(QLatin1Char('/'));
|
auto url_parts = url.split('/'_L1);
|
||||||
const QString repository = url_parts[url_parts.size() - 3];
|
const QString repository = url_parts[url_parts.size() - 3];
|
||||||
|
|
||||||
m_patches.push_back(
|
m_patches.push_back(
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "launchercore.h"
|
#include "launchercore.h"
|
||||||
#include "profileconfig.h"
|
#include "profileconfig.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
Profile::Profile(LauncherCore &launcher, const QString &key, QObject *parent)
|
Profile::Profile(LauncherCore &launcher, const QString &key, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_uuid(key)
|
, m_uuid(key)
|
||||||
|
@ -42,13 +44,13 @@ void Profile::readDalamudInfo()
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll());
|
QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll());
|
||||||
|
|
||||||
QString versionString;
|
QString versionString;
|
||||||
for (const auto &target : doc[QLatin1String("targets")].toObject().keys()) {
|
for (const auto &target : doc["targets"_L1].toObject().keys()) {
|
||||||
if (target.contains(QLatin1String(".NETCoreApp"))) {
|
if (target.contains(".NETCoreApp"_L1)) {
|
||||||
versionString = doc[QLatin1String("targets")].toObject()[target].toObject().keys().filter(QStringLiteral("Dalamud/"))[0];
|
versionString = doc["targets"_L1].toObject()[target].toObject().keys().filter(QStringLiteral("Dalamud/"))[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dalamudVersion = versionString.remove(QLatin1String("Dalamud/"));
|
m_dalamudVersion = versionString.remove("Dalamud/"_L1);
|
||||||
qInfo(ASTRA_LOG) << "Dalamud version:" << m_dalamudVersion;
|
qInfo(ASTRA_LOG) << "Dalamud version:" << m_dalamudVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
ProfileManager::ProfileManager(LauncherCore &launcher, QObject *parent)
|
ProfileManager::ProfileManager(LauncherCore &launcher, QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
, m_launcher(launcher)
|
, m_launcher(launcher)
|
||||||
|
@ -91,8 +93,8 @@ void ProfileManager::load()
|
||||||
{
|
{
|
||||||
auto config = KSharedConfig::openStateConfig();
|
auto config = KSharedConfig::openStateConfig();
|
||||||
for (const auto &id : config->groupList()) {
|
for (const auto &id : config->groupList()) {
|
||||||
if (id.contains(QLatin1String("profile-"))) {
|
if (id.contains("profile-"_L1)) {
|
||||||
const QString uuid = QString(id).remove(QLatin1String("profile-"));
|
const QString uuid = QString(id).remove("profile-"_L1);
|
||||||
qInfo(ASTRA_LOG) << "Loading profile" << uuid;
|
qInfo(ASTRA_LOG) << "Loading profile" << uuid;
|
||||||
auto profile = new Profile(m_launcher, uuid, this);
|
auto profile = new Profile(m_launcher, uuid, this);
|
||||||
insertProfile(profile);
|
insertProfile(profile);
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <qcoronetwork.h>
|
#include <qcoronetwork.h>
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
SapphireLogin::SapphireLogin(LauncherCore &window, QObject *parent)
|
SapphireLogin::SapphireLogin(LauncherCore &window, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_launcher(window)
|
, m_launcher(window)
|
||||||
|
@ -37,9 +39,9 @@ QCoro::Task<std::optional<LoginAuth>> SapphireLogin::login(const QString &lobbyU
|
||||||
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
||||||
if (!document.isEmpty()) {
|
if (!document.isEmpty()) {
|
||||||
LoginAuth auth;
|
LoginAuth auth;
|
||||||
auth.SID = document[QLatin1String("sId")].toString();
|
auth.SID = document["sId"_L1].toString();
|
||||||
auth.lobbyhost = document[QLatin1String("lobbyHost")].toString();
|
auth.lobbyhost = document["lobbyHost"_L1].toString();
|
||||||
auth.frontierHost = document[QLatin1String("frontierHost")].toString();
|
auth.frontierHost = document["frontierHost"_L1].toString();
|
||||||
auth.region = 3;
|
auth.region = 3;
|
||||||
|
|
||||||
co_return auth;
|
co_return auth;
|
||||||
|
@ -64,9 +66,9 @@ void SapphireLogin::registerAccount(const QString &lobbyUrl, const LoginInformat
|
||||||
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
|
||||||
LoginAuth auth;
|
LoginAuth auth;
|
||||||
auth.SID = document[QLatin1String("sId")].toString();
|
auth.SID = document["sId"_L1].toString();
|
||||||
auth.lobbyhost = document[QLatin1String("lobbyHost")].toString();
|
auth.lobbyhost = document["lobbyHost"_L1].toString();
|
||||||
auth.frontierHost = document[QLatin1String("frontierHost")].toString();
|
auth.frontierHost = document["frontierHost"_L1].toString();
|
||||||
auth.region = 3;
|
auth.region = 3;
|
||||||
|
|
||||||
// m_launcher.launchGame(*info.profile, auth);
|
// m_launcher.launchGame(*info.profile, auth);
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "launchercore.h"
|
#include "launchercore.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
SquareEnixLogin::SquareEnixLogin(LauncherCore &window, QObject *parent)
|
SquareEnixLogin::SquareEnixLogin(LauncherCore &window, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_launcher(window)
|
, m_launcher(window)
|
||||||
|
@ -69,7 +71,7 @@ QCoro::Task<bool> SquareEnixLogin::checkGateStatus()
|
||||||
co_await reply;
|
co_await reply;
|
||||||
|
|
||||||
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
||||||
const bool isGateOpen = !document.isEmpty() && document.object()[QLatin1String("status")].toInt() != 0;
|
const bool isGateOpen = !document.isEmpty() && document.object()["status"_L1].toInt() != 0;
|
||||||
|
|
||||||
if (isGateOpen) {
|
if (isGateOpen) {
|
||||||
qInfo(ASTRA_LOG) << "Gate is open!";
|
qInfo(ASTRA_LOG) << "Gate is open!";
|
||||||
|
@ -87,7 +89,7 @@ QCoro::Task<> SquareEnixLogin::checkBootUpdates()
|
||||||
qInfo(ASTRA_LOG) << "Checking for updates to boot components...";
|
qInfo(ASTRA_LOG) << "Checking for updates to boot components...";
|
||||||
|
|
||||||
QString formattedDate = QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH-mm"));
|
QString formattedDate = QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH-mm"));
|
||||||
formattedDate[15] = QLatin1Char('0');
|
formattedDate[15] = '0'_L1;
|
||||||
|
|
||||||
const QUrlQuery query{{QStringLiteral("time"), formattedDate}};
|
const QUrlQuery query{{QStringLiteral("time"), formattedDate}};
|
||||||
|
|
||||||
|
@ -134,18 +136,18 @@ QCoro::Task<std::optional<SquareEnixLogin::StoredInfo>> SquareEnixLogin::getStor
|
||||||
// en is always used to the top url
|
// en is always used to the top url
|
||||||
query.addQueryItem(QStringLiteral("lng"), QStringLiteral("en"));
|
query.addQueryItem(QStringLiteral("lng"), QStringLiteral("en"));
|
||||||
// for some reason, we always use region 3. the actual region is acquired later
|
// for some reason, we always use region 3. the actual region is acquired later
|
||||||
query.addQueryItem(QStringLiteral("rgn"), QStringLiteral("3"));
|
query.addQueryItem(QStringLiteral("rgn"), QString::number(3));
|
||||||
query.addQueryItem(QStringLiteral("isft"), m_info->profile->account()->isFreeTrial() ? QStringLiteral("1") : QStringLiteral("0"));
|
query.addQueryItem(QStringLiteral("isft"), QString::number(m_info->profile->account()->isFreeTrial() ? 1 : 0));
|
||||||
query.addQueryItem(QStringLiteral("cssmode"), QStringLiteral("1"));
|
query.addQueryItem(QStringLiteral("cssmode"), QString::number(1));
|
||||||
query.addQueryItem(QStringLiteral("isnew"), QStringLiteral("1"));
|
query.addQueryItem(QStringLiteral("isnew"), QString::number(1));
|
||||||
query.addQueryItem(QStringLiteral("launchver"), QStringLiteral("3"));
|
query.addQueryItem(QStringLiteral("launchver"), QString::number(3));
|
||||||
|
|
||||||
if (m_info->profile->account()->license() == Account::GameLicense::WindowsSteam) {
|
if (m_info->profile->account()->license() == Account::GameLicense::WindowsSteam) {
|
||||||
query.addQueryItem(QStringLiteral("issteam"), QStringLiteral("1"));
|
query.addQueryItem(QStringLiteral("issteam"), QString::number(1));
|
||||||
|
|
||||||
// TODO: get steam ticket information from steam api
|
// TODO: get steam ticket information from steam api
|
||||||
query.addQueryItem(QStringLiteral("session_ticket"), QStringLiteral("1"));
|
query.addQueryItem(QStringLiteral("session_ticket"), QString::number(1));
|
||||||
query.addQueryItem(QStringLiteral("ticket_size"), QStringLiteral("1"));
|
query.addQueryItem(QStringLiteral("ticket_size"), QString::number(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
|
@ -228,10 +230,10 @@ QCoro::Task<bool> SquareEnixLogin::loginOAuth()
|
||||||
const QRegularExpression re(QStringLiteral(R"lit(window.external.user\("login=auth,ok,(?<launchParams>.*)\);)lit"));
|
const QRegularExpression re(QStringLiteral(R"lit(window.external.user\("login=auth,ok,(?<launchParams>.*)\);)lit"));
|
||||||
const QRegularExpressionMatch match = re.match(str);
|
const QRegularExpressionMatch match = re.match(str);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
const auto parts = match.captured(1).split(QLatin1Char(','));
|
const auto parts = match.captured(1).split(','_L1);
|
||||||
|
|
||||||
const bool terms = parts[3] == QLatin1String("1");
|
const bool terms = parts[3] == "1"_L1;
|
||||||
const bool playable = parts[9] == QLatin1String("1");
|
const bool playable = parts[9] == "1"_L1;
|
||||||
|
|
||||||
if (!playable) {
|
if (!playable) {
|
||||||
Q_EMIT m_launcher.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."));
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
QDir Utility::stateDirectory()
|
QDir Utility::stateDirectory()
|
||||||
{
|
{
|
||||||
if (qEnvironmentVariableIsSet("XDG_STATE_HOME")) {
|
if (qEnvironmentVariableIsSet("XDG_STATE_HOME")) {
|
||||||
|
@ -20,10 +22,17 @@ QDir Utility::stateDirectory()
|
||||||
|
|
||||||
QString Utility::toWindowsPath(const QDir &dir)
|
QString Utility::toWindowsPath(const QDir &dir)
|
||||||
{
|
{
|
||||||
return QStringLiteral("Z:") + dir.absolutePath().replace(QLatin1Char('/'), QLatin1Char('\\'));
|
return QStringLiteral("Z:") + dir.absolutePath().replace('/'_L1, '\\'_L1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utility::printRequest(const QString &type, const QNetworkRequest &request)
|
void Utility::printRequest(const QString &type, const QNetworkRequest &request)
|
||||||
{
|
{
|
||||||
qDebug(ASTRA_HTTP) << type.toUtf8().constData() << request.url().toDisplayString();
|
qDebug(ASTRA_HTTP) << type.toUtf8().constData() << request.url().toDisplayString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Utility::createPathIfNeeded(const QDir &dir)
|
||||||
|
{
|
||||||
|
if (!QDir().exists(dir.absolutePath())) {
|
||||||
|
QDir().mkpath(dir.absolutePath());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue