From 55aaf7c1f669561310d0c42bd50ad51a882a3872 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 8 Jun 2022 13:55:15 -0400 Subject: [PATCH] Make tablet interface functional Right now OTP and other stuff is missing for an actual login, but it calls! --- launcher/cli/src/cmdinterface.cpp | 11 +- launcher/core/CMakeLists.txt | 1 + launcher/core/include/launchercore.h | 36 ++++- launcher/core/include/squareboot.h | 6 +- launcher/core/src/launchercore.cpp | 167 +++++++++++----------- launcher/core/src/sapphirelauncher.cpp | 4 +- launcher/core/src/squareboot.cpp | 10 +- launcher/core/src/squarelauncher.cpp | 6 +- launcher/desktop/include/launcherwindow.h | 1 - launcher/desktop/src/assetupdater.cpp | 6 +- launcher/desktop/src/desktopinterface.cpp | 2 +- launcher/desktop/src/launcherwindow.cpp | 23 ++- launcher/tablet/qml/main.qml | 11 +- launcher/tablet/src/tabletinterface.cpp | 9 +- 14 files changed, 170 insertions(+), 123 deletions(-) diff --git a/launcher/cli/src/cmdinterface.cpp b/launcher/cli/src/cmdinterface.cpp index 37c71e8..5f1ea74 100644 --- a/launcher/cli/src/cmdinterface.cpp +++ b/launcher/cli/src/cmdinterface.cpp @@ -19,7 +19,7 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) { } if(parser.isSet(autologinOption)) { - auto profile = core.getProfile(core.defaultProfileIndex); + auto& profile = core.getProfile(core.defaultProfileIndex); if(!profile.rememberUsername || !profile.rememberPassword) { qInfo() << "Profile does not have a username and/or password saved, autologin disabled."; @@ -52,12 +52,15 @@ bool CMDInterface::parse(QCommandLineParser &parser, LauncherCore &core) { loop->exec(); - auto info = LoginInformation{&profile, username, password, ""}; + auto info = new LoginInformation(); + info->settings = &profile; + info->username = username; + info->password = password; if(profile.isSapphire) { - core.sapphireLauncher->login(profile.lobbyURL, info); + core.sapphireLauncher->login(profile.lobbyURL, *info); } else { - core.squareBoot->bootCheck(info); + core.squareBoot->bootCheck(*info); } } diff --git a/launcher/core/CMakeLists.txt b/launcher/core/CMakeLists.txt index 8db3462..91ad0f2 100644 --- a/launcher/core/CMakeLists.txt +++ b/launcher/core/CMakeLists.txt @@ -43,6 +43,7 @@ target_link_libraries(astra_core PUBLIC Qt5::Core Qt5::Network Qt5::Widgets # widgets is required by watchdog, to be fixed/removed later + Qt5::Quick # required for some type registrations PRIVATE astra_desktop) # desktop is currently required by the core, to be fixed/removed later diff --git a/launcher/core/include/launchercore.h b/launcher/core/include/launchercore.h index 4930470..79599df 100755 --- a/launcher/core/include/launchercore.h +++ b/launcher/core/include/launchercore.h @@ -7,10 +7,12 @@ #include #include #include +#include + +#include "squareboot.h" class SapphireLauncher; class SquareLauncher; -class SquareBoot; class AssetUpdater; class Watchdog; @@ -33,7 +35,10 @@ enum class DalamudChannel { Net5 }; -struct ProfileSettings { +class ProfileSettings : public QObject { + Q_OBJECT + QML_ELEMENT +public: QUuid uuid; QString name; @@ -94,7 +99,14 @@ struct AppSettings { bool showNewsList = true; }; -struct LoginInformation { +class LoginInformation : public QObject { + Q_OBJECT + Q_PROPERTY(QString username MEMBER username) + Q_PROPERTY(QString password MEMBER password) + Q_PROPERTY(QString oneTimePassword MEMBER oneTimePassword) + Q_PROPERTY(ProfileSettings* settings MEMBER settings) + QML_ELEMENT +public: ProfileSettings* settings = nullptr; QString username, password, oneTimePassword; @@ -110,18 +122,28 @@ struct LoginAuth { }; class LauncherCore : public QObject { -Q_OBJECT + Q_OBJECT + Q_PROPERTY(SquareBoot* squareBoot MEMBER squareBoot) public: LauncherCore(); ~LauncherCore(); + // used for qml only, TODO: move this to a dedicated factory + Q_INVOKABLE LoginInformation* createNewLoginInfo() { + return new LoginInformation(); + } + QNetworkAccessManager* mgr; - ProfileSettings getProfile(int index) const; ProfileSettings& getProfile(int index); + // used for qml only + Q_INVOKABLE ProfileSettings* getProfileQML(int index) { + return profileSettings[index]; + } + int getProfileIndex(QString name); - QList profileList() const; + Q_INVOKABLE QList profileList() const; int addProfile(); int deleteProfile(QString name); @@ -190,5 +212,5 @@ private: QString getDefaultGamePath(); QString getDefaultWinePrefixPath(); - QVector profileSettings; + QVector profileSettings; }; diff --git a/launcher/core/include/squareboot.h b/launcher/core/include/squareboot.h index ce158a8..21db8ed 100644 --- a/launcher/core/include/squareboot.h +++ b/launcher/core/include/squareboot.h @@ -1,15 +1,17 @@ #pragma once #include -#include "launchercore.h" class SquareLauncher; +class LauncherCore; +struct LoginInformation; class SquareBoot : public QObject { + Q_OBJECT public: SquareBoot(LauncherCore& window, SquareLauncher& launcher); - void checkGateStatus(const LoginInformation& info); + Q_INVOKABLE void checkGateStatus(LoginInformation* info); void bootCheck(const LoginInformation& info); diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index dad3401..edfb7f3 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -134,10 +134,10 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au if(profile.dalamud.enabled) { auto socket = new QTcpServer(); - connect(socket, &QTcpServer::newConnection, [this, profile, socket] { + connect(socket, &QTcpServer::newConnection, [this, &profile, socket] { auto connection = socket->nextPendingConnection(); - connect(connection, &QTcpSocket::readyRead, [this, connection, profile, socket] { + connect(connection, &QTcpSocket::readyRead, [this, connection, &profile, socket] { QString output = connection->readAll(); bool success; int exitCode = output.toInt(&success, 10); @@ -381,69 +381,68 @@ void LauncherCore::readInitialInformation() { profileSettings.resize(profiles.size()); for(const auto& uuid : profiles) { - ProfileSettings profile; - profile.uuid = QUuid(uuid); + ProfileSettings* profile = new ProfileSettings(); + profile->uuid = QUuid(uuid); settings.beginGroup(uuid); - profile.name = settings.value("name", "Default").toString(); + profile->name = settings.value("name", "Default").toString(); if(settings.contains("gamePath") && settings.value("gamePath").canConvert() && !settings.value("gamePath").toString().isEmpty()) { - profile.gamePath = settings.value("gamePath").toString(); + profile->gamePath = settings.value("gamePath").toString(); } else { - profile.gamePath = getDefaultGamePath(); + profile->gamePath = getDefaultGamePath(); } if(settings.contains("winePrefixPath") && settings.value("winePrefixPath").canConvert() && !settings.value("winePrefixPath").toString().isEmpty()) { - profile.winePrefixPath = settings.value("winePrefixPath").toString(); + profile->winePrefixPath = settings.value("winePrefixPath").toString(); } else { - profile.winePrefixPath = getDefaultWinePrefixPath(); + profile->winePrefixPath = getDefaultWinePrefixPath(); } if(settings.contains("winePath") && settings.value("winePath").canConvert() && !settings.value("winePath").toString().isEmpty()) { - profile.winePath = settings.value("winePath").toString(); + profile->winePath = settings.value("winePath").toString(); } ProfileSettings defaultSettings; // login - profile.encryptArguments = settings.value("encryptArguments", defaultSettings.encryptArguments).toBool(); - profile.isSapphire = settings.value("isSapphire", defaultSettings.isSapphire).toBool(); - profile.lobbyURL = settings.value("lobbyURL", defaultSettings.lobbyURL).toString(); - profile.rememberUsername = settings.value("rememberUsername", defaultSettings.rememberUsername).toBool(); - profile.rememberPassword = settings.value("rememberPassword", defaultSettings.rememberPassword).toBool(); - profile.useOneTimePassword = settings.value("useOneTimePassword", defaultSettings.useOneTimePassword).toBool(); - profile.license = (GameLicense)settings.value("license", (int)defaultSettings.license).toInt(); - profile.isFreeTrial = settings.value("isFreeTrial", defaultSettings.isFreeTrial).toBool(); + profile->encryptArguments = settings.value("encryptArguments", defaultSettings.encryptArguments).toBool(); + profile->isSapphire = settings.value("isSapphire", defaultSettings.isSapphire).toBool(); + profile->lobbyURL = settings.value("lobbyURL", defaultSettings.lobbyURL).toString(); + profile->rememberUsername = settings.value("rememberUsername", defaultSettings.rememberUsername).toBool(); + profile->rememberPassword = settings.value("rememberPassword", defaultSettings.rememberPassword).toBool(); + profile->useOneTimePassword = settings.value("useOneTimePassword", defaultSettings.useOneTimePassword).toBool(); + profile->license = (GameLicense)settings.value("license", (int)defaultSettings.license).toInt(); + profile->isFreeTrial = settings.value("isFreeTrial", defaultSettings.isFreeTrial).toBool(); - profile.useDX9 = settings.value("useDX9", defaultSettings.useDX9).toBool(); + profile->useDX9 = settings.value("useDX9", defaultSettings.useDX9).toBool(); // wine - profile.wineType = (WineType)settings.value("wineType", (int)defaultSettings.wineType).toInt(); - profile.useEsync = settings.value("useEsync", defaultSettings.useEsync).toBool(); + profile->wineType = (WineType)settings.value("wineType", (int)defaultSettings.wineType).toInt(); + profile->useEsync = settings.value("useEsync", defaultSettings.useEsync).toBool(); - readWineInfo(profile); + readWineInfo(*profile); if(gamescopeAvailable) - profile.useGamescope = settings.value("useGamescope", defaultSettings.useGamescope).toBool(); + profile->useGamescope = settings.value("useGamescope", defaultSettings.useGamescope).toBool(); if(gamemodeAvailable) - profile.useGamemode = settings.value("useGamemode", defaultSettings.useGamemode).toBool(); + profile->useGamemode = settings.value("useGamemode", defaultSettings.useGamemode).toBool(); - profile.enableDXVKhud = settings.value("enableDXVKhud", defaultSettings.enableDXVKhud).toBool(); + profile->enableDXVKhud = settings.value("enableDXVKhud", defaultSettings.enableDXVKhud).toBool(); - profile.enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool(); + profile->enableWatchdog = settings.value("enableWatchdog", defaultSettings.enableWatchdog).toBool(); // gamescope - profile.gamescope.fullscreen = settings.value("gamescopeFullscreen", defaultSettings.gamescope.fullscreen).toBool(); - profile.gamescope.borderless = settings.value("gamescopeBorderless", defaultSettings.gamescope.borderless).toBool(); - profile.gamescope.width = settings.value("gamescopeWidth", defaultSettings.gamescope.width).toInt(); - profile.gamescope.height = settings.value("gamescopeHeight", defaultSettings.gamescope.height).toInt(); - profile.gamescope.refreshRate = settings.value("gamescopeRefreshRate", defaultSettings.gamescope.refreshRate).toInt(); + profile->gamescope.borderless = settings.value("gamescopeBorderless", defaultSettings.gamescope.borderless).toBool(); + profile->gamescope.width = settings.value("gamescopeWidth", defaultSettings.gamescope.width).toInt(); + profile->gamescope.height = settings.value("gamescopeHeight", defaultSettings.gamescope.height).toInt(); + profile->gamescope.refreshRate = settings.value("gamescopeRefreshRate", defaultSettings.gamescope.refreshRate).toInt(); - profile.dalamud.enabled = settings.value("enableDalamud", defaultSettings.dalamud.enabled).toBool(); - profile.dalamud.optOutOfMbCollection = settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool(); - profile.dalamud.channel = (DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt(); + profile->dalamud.enabled = settings.value("enableDalamud", defaultSettings.dalamud.enabled).toBool(); + profile->dalamud.optOutOfMbCollection = settings.value("dalamudOptOut", defaultSettings.dalamud.optOutOfMbCollection).toBool(); + profile->dalamud.channel = (DalamudChannel)settings.value("dalamudChannel", (int)defaultSettings.dalamud.channel).toInt(); profileSettings[settings.value("index").toInt()] = profile; @@ -498,11 +497,11 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) { void LauncherCore::readGameVersion() { for(auto& profile : profileSettings) { - profile.bootVersion = readVersion(profile.gamePath + "/boot/ffxivboot.ver"); - profile.installedMaxExpansion = 0; + profile->bootVersion = readVersion(profile->gamePath + "/boot/ffxivboot.ver"); + profile->installedMaxExpansion = 0; - auto sqpackDirectories = QDir(profile.gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot); - profile.gameVersions.resize(sqpackDirectories.size()); + auto sqpackDirectories = QDir(profile->gamePath + "/game/sqpack/").entryList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot); + profile->gameVersions.resize(sqpackDirectories.size()); for(auto dir : sqpackDirectories) { if(dir.contains("ex") || dir == "ffxiv") { @@ -512,7 +511,7 @@ void LauncherCore::readGameVersion() { if(dir == "ffxiv") { expansion = 0; - profile.gameVersions[0] = readVersion(profile.gamePath + QString("/game/ffxivgame.ver")); + profile->gameVersions[0] = readVersion(profile->gamePath + QString("/game/ffxivgame.ver")); } else { QString originalName = dir.remove("ex"); bool ok = false; @@ -520,17 +519,17 @@ void LauncherCore::readGameVersion() { if(ok) expansion = convertedInt; - profile.gameVersions[convertedInt] = readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(profile.gamePath, QString::number(expansion))); + profile->gameVersions[convertedInt] = readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(profile->gamePath, QString::number(expansion))); } if(expansion != -1) { - profile.installedMaxExpansion = std::max(profile.installedMaxExpansion, expansion); + profile->installedMaxExpansion = std::max(profile->installedMaxExpansion, expansion); } } } - if(profile.installedMaxExpansion >= 0) - readGameData(profile); + if(profile->installedMaxExpansion >= 0) + readGameData(*profile); } } @@ -554,17 +553,13 @@ LauncherCore::~LauncherCore() noexcept { #endif } -ProfileSettings LauncherCore::getProfile(int index) const { - return profileSettings[index]; -} - ProfileSettings& LauncherCore::getProfile(int index) { - return profileSettings[index]; + return *profileSettings[index]; } int LauncherCore::getProfileIndex(QString name) { for(int i = 0; i < profileSettings.size(); i++) { - if(profileSettings[i].name == name) + if(profileSettings[i]->name == name) return i; } @@ -574,21 +569,21 @@ int LauncherCore::getProfileIndex(QString name) { QList LauncherCore::profileList() const { QList list; for(auto profile : profileSettings) { - list.append(profile.name); + list.append(profile->name); } return list; } int LauncherCore::addProfile() { - ProfileSettings newProfile; - newProfile.uuid = QUuid::createUuid(); - newProfile.name = "New Profile"; + ProfileSettings* newProfile = new ProfileSettings(); + newProfile->uuid = QUuid::createUuid(); + newProfile->name = "New Profile"; - readWineInfo(newProfile); + readWineInfo(*newProfile); - newProfile.gamePath = getDefaultGamePath(); - newProfile.winePrefixPath = getDefaultWinePrefixPath(); + newProfile->gamePath = getDefaultGamePath(); + newProfile->winePrefixPath = getDefaultWinePrefixPath(); profileSettings.append(newProfile); @@ -600,12 +595,12 @@ int LauncherCore::addProfile() { int LauncherCore::deleteProfile(QString name) { int index = 0; for(int i = 0; i < profileSettings.size(); i++) { - if(profileSettings[i].name == name) + if(profileSettings[i]->name == name) index = i; } // remove group so it doesnt stay - settings.beginGroup(profileSettings[index].uuid.toString(QUuid::StringFormat::WithoutBraces)); + settings.beginGroup(profileSettings[index]->uuid.toString(QUuid::StringFormat::WithoutBraces)); settings.remove(""); settings.endGroup(); @@ -623,45 +618,45 @@ void LauncherCore::saveSettings() { for(int i = 0; i < profileSettings.size(); i++) { const auto& profile = profileSettings[i]; - settings.beginGroup(profile.uuid.toString(QUuid::StringFormat::WithoutBraces)); + settings.beginGroup(profile->uuid.toString(QUuid::StringFormat::WithoutBraces)); - settings.setValue("name", profile.name); + settings.setValue("name", profile->name); settings.setValue("index", i); // game - settings.setValue("useDX9", profile.useDX9); - settings.setValue("gamePath", profile.gamePath); + settings.setValue("useDX9", profile->useDX9); + settings.setValue("gamePath", profile->gamePath); // wine - settings.setValue("wineType", (int)profile.wineType); - settings.setValue("winePath", profile.winePath); - settings.setValue("winePrefixPath", profile.winePrefixPath); + settings.setValue("wineType", (int)profile->wineType); + settings.setValue("winePath", profile->winePath); + settings.setValue("winePrefixPath", profile->winePrefixPath); - settings.setValue("useEsync", profile.useEsync); - settings.setValue("useGamescope", profile.useGamescope); - settings.setValue("useGamemode", profile.useGamemode); + settings.setValue("useEsync", profile->useEsync); + settings.setValue("useGamescope", profile->useGamescope); + settings.setValue("useGamemode", profile->useGamemode); // gamescope - settings.setValue("gamescopeFullscreen", profile.gamescope.fullscreen); - settings.setValue("gamescopeBorderless", profile.gamescope.borderless); - settings.setValue("gamescopeWidth", profile.gamescope.width); - settings.setValue("gamescopeHeight", profile.gamescope.height); - settings.setValue("gamescopeRefreshRate", profile.gamescope.refreshRate); + settings.setValue("gamescopeFullscreen", profile->gamescope.fullscreen); + settings.setValue("gamescopeBorderless", profile->gamescope.borderless); + settings.setValue("gamescopeWidth", profile->gamescope.width); + settings.setValue("gamescopeHeight", profile->gamescope.height); + settings.setValue("gamescopeRefreshRate", profile->gamescope.refreshRate); // login - settings.setValue("encryptArguments", profile.encryptArguments); - settings.setValue("isSapphire", profile.isSapphire); - settings.setValue("lobbyURL", profile.lobbyURL); - settings.setValue("rememberUsername", profile.rememberUsername); - settings.setValue("rememberPassword", profile.rememberPassword); - settings.setValue("useOneTimePassword", profile.useOneTimePassword); - settings.setValue("license", (int)profile.license); - settings.setValue("isFreeTrial", profile.isFreeTrial); + settings.setValue("encryptArguments", profile->encryptArguments); + settings.setValue("isSapphire", profile->isSapphire); + settings.setValue("lobbyURL", profile->lobbyURL); + settings.setValue("rememberUsername", profile->rememberUsername); + settings.setValue("rememberPassword", profile->rememberPassword); + settings.setValue("useOneTimePassword", profile->useOneTimePassword); + settings.setValue("license", (int)profile->license); + settings.setValue("isFreeTrial", profile->isFreeTrial); - settings.setValue("enableDalamud", profile.dalamud.enabled); - settings.setValue("dalamudOptOut", profile.dalamud.optOutOfMbCollection); - settings.setValue("dalamudChannel", (int)profile.dalamud.channel); - settings.setValue("enableWatchdog", profile.enableWatchdog); + settings.setValue("enableDalamud", profile->dalamud.enabled); + settings.setValue("dalamudOptOut", profile->dalamud.optOutOfMbCollection); + settings.setValue("dalamudChannel", (int)profile->dalamud.channel); + settings.setValue("enableWatchdog", profile->enableWatchdog); settings.endGroup(); } @@ -669,7 +664,7 @@ void LauncherCore::saveSettings() { void LauncherCore::addUpdateButtons(const ProfileSettings& settings, QMessageBox& messageBox) { auto launcherButton = messageBox.addButton("Launch Official Launcher", QMessageBox::NoRole); - connect(launcherButton, &QPushButton::clicked, [=] { + connect(launcherButton, &QPushButton::clicked, [&] { launchExecutable(settings, {settings.gamePath + "/boot/ffxivboot.exe"}); }); diff --git a/launcher/core/src/sapphirelauncher.cpp b/launcher/core/src/sapphirelauncher.cpp index 41c9a6f..cd8036a 100644 --- a/launcher/core/src/sapphirelauncher.cpp +++ b/launcher/core/src/sapphirelauncher.cpp @@ -24,7 +24,7 @@ void SapphireLauncher::login(QString lobbyUrl, const LoginInformation& info) { request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact)); - connect(reply, &QNetworkReply::finished, [=] { + connect(reply, &QNetworkReply::finished, [&] { QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); if(!document.isEmpty()) { LoginAuth auth; @@ -55,7 +55,7 @@ void SapphireLauncher::registerAccount(QString lobbyUrl, const LoginInformation& request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded"); auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact)); - connect(reply, &QNetworkReply::finished, [=] { + connect(reply, &QNetworkReply::finished, [&] { QJsonDocument document = QJsonDocument::fromJson(reply->readAll()); LoginAuth auth; diff --git a/launcher/core/src/squareboot.cpp b/launcher/core/src/squareboot.cpp index e0eafab..5e373d7 100644 --- a/launcher/core/src/squareboot.cpp +++ b/launcher/core/src/squareboot.cpp @@ -40,7 +40,7 @@ void SquareBoot::bootCheck(const LoginInformation& info) { request.setRawHeader("Host", "patch-bootver.ffxiv.com"); auto reply = window.mgr->get(request); - connect(reply, &QNetworkReply::finished, [=] { + connect(reply, &QNetworkReply::finished, [=, &info] { const QString response = reply->readAll(); if(response.isEmpty()) { @@ -77,7 +77,7 @@ void SquareBoot::bootCheck(const LoginInformation& info) { dialog->setValue(recieved); }); - connect(patchReply, &QNetworkReply::finished, [=] { + connect(patchReply, &QNetworkReply::finished, [&] { const QString dataDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation); @@ -103,7 +103,7 @@ void SquareBoot::bootCheck(const LoginInformation& info) { }); } -void SquareBoot::checkGateStatus(const LoginInformation& info) { +void SquareBoot::checkGateStatus(LoginInformation* info) { QUrlQuery query; query.addQueryItem("", QString::number(QDateTime::currentMSecsSinceEpoch())); @@ -115,7 +115,7 @@ void SquareBoot::checkGateStatus(const LoginInformation& info) { request.setUrl(url); // TODO: really? - window.buildRequest(*info.settings, request); + window.buildRequest(*info->settings, request); auto reply = window.mgr->get(request); connect(reply, &QNetworkReply::finished, [=] { @@ -132,7 +132,7 @@ void SquareBoot::checkGateStatus(const LoginInformation& info) { const bool isGateOpen = !document.isEmpty() && document.object()["status"].toInt() != 0; if(isGateOpen) { - bootCheck(info); + bootCheck(*info); } else { auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", diff --git a/launcher/core/src/squarelauncher.cpp b/launcher/core/src/squarelauncher.cpp index 94f70f2..ce0e64b 100644 --- a/launcher/core/src/squarelauncher.cpp +++ b/launcher/core/src/squarelauncher.cpp @@ -58,7 +58,7 @@ void SquareLauncher::getStored(const LoginInformation& info) { QNetworkReply* reply = window.mgr->get(request); - connect(reply, &QNetworkReply::finished, [=] { + connect(reply, &QNetworkReply::finished, [=, &info] { auto str = QString(reply->readAll()); // fetches Steam username @@ -102,7 +102,7 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) { request.setRawHeader("Cache-Control", "no-cache"); auto reply = window.mgr->post(request, postData.toString(QUrl::FullyEncoded).toUtf8()); - connect(reply, &QNetworkReply::finished, [=] { + connect(reply, &QNetworkReply::finished, [=, &info] { auto str = QString(reply->readAll()); QRegularExpression re(R"lit(window.external.user\("login=auth,ok,(?.*)\);)lit"); @@ -175,7 +175,7 @@ void SquareLauncher::registerSession(const LoginInformation& info) { report += QString("\nex%1\t%2").arg(QString::number(i), info.settings->gameVersions[i]); auto reply = window.mgr->post(request, report.toUtf8()); - connect(reply, &QNetworkReply::finished, [=] { + connect(reply, &QNetworkReply::finished, [&] { if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) { auth.SID = reply->rawHeader("X-Patch-Unique-Id"); diff --git a/launcher/desktop/include/launcherwindow.h b/launcher/desktop/include/launcherwindow.h index 6853db2..63be5e8 100644 --- a/launcher/desktop/include/launcherwindow.h +++ b/launcher/desktop/include/launcherwindow.h @@ -17,7 +17,6 @@ class LauncherWindow : public QMainWindow { public: explicit LauncherWindow(LauncherCore& core, QWidget* parent = nullptr); - ProfileSettings currentProfile() const; ProfileSettings& currentProfile(); void openPath(const QString path); diff --git a/launcher/desktop/src/assetupdater.cpp b/launcher/desktop/src/assetupdater.cpp index 75ed251..c807a97 100644 --- a/launcher/desktop/src/assetupdater.cpp +++ b/launcher/desktop/src/assetupdater.cpp @@ -73,7 +73,7 @@ void AssetUpdater::update(const ProfileSettings& profile) { QNetworkRequest request(dalamudAssetManifestURL); auto reply = launcher.mgr->get(request); - connect(reply, &QNetworkReply::finished, [reply, this, profile] { + connect(reply, &QNetworkReply::finished, [reply, this, &profile] { dialog->setLabelText("Checking for Dalamud asset updates..."); // TODO: handle asset failure @@ -97,7 +97,7 @@ void AssetUpdater::update(const ProfileSettings& profile) { remoteNativeLauncherVersion.clear(); auto reply = launcher.mgr->get(request); - connect(reply, &QNetworkReply::finished, [this, profile, reply] { + connect(reply, &QNetworkReply::finished, [this, &profile, reply] { dialog->setLabelText("Checking for native launcher updates..."); remoteNativeLauncherVersion = reply->readAll().trimmed(); @@ -119,7 +119,7 @@ void AssetUpdater::update(const ProfileSettings& profile) { remoteRuntimeVersion.clear(); auto reply = launcher.mgr->get(request); - connect(reply, &QNetworkReply::finished, [this, profile, reply] { + connect(reply, &QNetworkReply::finished, [this, &profile, reply] { dialog->setLabelText("Checking for Dalamud updates..."); QByteArray str = reply->readAll(); diff --git a/launcher/desktop/src/desktopinterface.cpp b/launcher/desktop/src/desktopinterface.cpp index 5198596..8835fc4 100644 --- a/launcher/desktop/src/desktopinterface.cpp +++ b/launcher/desktop/src/desktopinterface.cpp @@ -5,7 +5,7 @@ DesktopInterface::DesktopInterface(LauncherCore& core) { window = new LauncherWindow(core); window->show(); - auto defaultProfile = core.getProfile(core.defaultProfileIndex); + auto& defaultProfile = core.getProfile(core.defaultProfileIndex); if(!defaultProfile.isGameInstalled()) { auto messageBox = new QMessageBox(window); diff --git a/launcher/desktop/src/launcherwindow.cpp b/launcher/desktop/src/launcherwindow.cpp index dc1c253..2e8fe23 100644 --- a/launcher/desktop/src/launcherwindow.cpp +++ b/launcher/desktop/src/launcherwindow.cpp @@ -258,7 +258,13 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo setCentralWidget(emptyWidget); connect(core.assetUpdater, &AssetUpdater::finishedUpdating, [=] { - auto info = LoginInformation{¤tProfile(), usernameEdit->text(), passwordEdit->text(), otpEdit->text()}; + auto& profile = currentProfile(); + + LoginInformation info; + info.settings = &profile; + info.username = usernameEdit->text(); + info.password = passwordEdit->text(); + info.oneTimePassword = otpEdit->text(); #ifndef QT_DEBUG if(currentProfile().rememberUsername) { @@ -281,7 +287,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo if(currentProfile().isSapphire) { this->core.sapphireLauncher->login(currentProfile().lobbyURL, info); } else { - this->core.squareBoot->checkGateStatus(info); + this->core.squareBoot->checkGateStatus(&info); } }); @@ -292,7 +298,14 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo connect(registerButton, &QPushButton::released, [=] { if(currentProfile().isSapphire) { - auto info = LoginInformation{¤tProfile(), usernameEdit->text(), passwordEdit->text(), otpEdit->text()}; + auto& profile = currentProfile(); + + LoginInformation info; + info.settings = &profile; + info.username = usernameEdit->text(); + info.password = passwordEdit->text(); + info.oneTimePassword = otpEdit->text(); + this->core.sapphireLauncher->registerAccount(currentProfile().lobbyURL, info); } }); @@ -315,10 +328,6 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo reloadControls(); } -ProfileSettings LauncherWindow::currentProfile() const { - return core.getProfile(profileSelect->currentIndex()); -} - ProfileSettings& LauncherWindow::currentProfile() { return core.getProfile(profileSelect->currentIndex()); } diff --git a/launcher/tablet/qml/main.qml b/launcher/tablet/qml/main.qml index a19f54e..1ac5afe 100644 --- a/launcher/tablet/qml/main.qml +++ b/launcher/tablet/qml/main.qml @@ -1,6 +1,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.15 import QtQuick.Window 2.0 +import Astra 1.0 ApplicationWindow { id: window @@ -45,6 +46,14 @@ ApplicationWindow { anchors.top: passwordField.bottom - onClicked: print("Hooray!"); + onClicked: { + var info = core.createNewLoginInfo(); + info.settings = core.getProfileQML(0); + info.username = usernameField.text + info.password = passwordField.text + + print(info); + core.squareBoot.checkGateStatus(info); + } } } \ No newline at end of file diff --git a/launcher/tablet/src/tabletinterface.cpp b/launcher/tablet/src/tabletinterface.cpp index 838b8a1..1e503ff 100644 --- a/launcher/tablet/src/tabletinterface.cpp +++ b/launcher/tablet/src/tabletinterface.cpp @@ -1,7 +1,14 @@ -#include "../launcher/tablet/include/tabletinterface.h" +#include "tabletinterface.h" + +#include +#include TabletInterface::TabletInterface(LauncherCore &core) { + qmlRegisterType("Astra", 1, 0, "ProfileSettings"); + qmlRegisterType("Astra", 1, 0, "LoginInformation"); + applicationEngine = new QQmlApplicationEngine(); + applicationEngine->rootContext()->setContextProperty("core", &core); applicationEngine->load("qrc:/main.qml"); }