From 3d989d5790aa909d76e747180df93a286eb28080 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 30 Jul 2024 18:43:06 -0400 Subject: [PATCH] Add CMake option for sync support This is to ease the amount of work for me packaging at first, so I can focus on the actual feature. Once all packages support it, this option can go away. --- CMakeLists.txt | 7 ++++++- launcher/CMakeLists.txt | 14 ++++++++++---- launcher/include/launchercore.h | 10 ++++++++++ launcher/src/launchercore.cpp | 23 +++++++++++++++++++++-- launcher/ui/Settings/SettingsPage.qml | 1 + 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e31237..007b068 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,9 @@ project(Astra VERSION 0.6.0 LANGUAGES CXX) option(BUILD_FLATPAK "Build for Flatpak." OFF) option(BUILD_WEBVIEW "Build support for the integrated web browser. Only used on the Steam Deck." OFF) +# TODO: phase out once all supported builds can turn on this option +option(BUILD_SYNC "Build Matrix sync support." OFF) + # options for features you may want or need if (NOT WIN32 AND NOT APPLE) option(ENABLE_GAMEMODE "Build with Feral GameMode support, requires the daemon to be installed." ON) @@ -51,7 +54,9 @@ find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami I18n Config Core find_package(KF6KirigamiAddons 1.2.1 REQUIRED) find_package(QCoro6 REQUIRED COMPONENTS Core Network Qml) qcoro_enable_coroutines() -find_package(QuotientQt6 REQUIRED) +if (BUILD_SYNC) + find_package(QuotientQt6 REQUIRED) +endif() qt_policy(SET QTP0001 NEW) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 8c7a91b..e45b59d 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -45,7 +45,6 @@ target_sources(astra PRIVATE include/accountmanager.h include/assetupdater.h include/benchmarkinstaller.h - include/charactersync.h include/compatibilitytoolinstaller.h include/encryptedarg.h include/existinginstallmodel.h @@ -63,14 +62,12 @@ target_sources(astra PRIVATE include/sapphirelogin.h include/squareenixlogin.h include/steamapi.h - include/syncmanager.h include/utility.h src/account.cpp src/accountmanager.cpp src/assetupdater.cpp src/benchmarkinstaller.cpp - src/charactersync.cpp src/compatibilitytoolinstaller.cpp src/encryptedarg.cpp src/existinginstallmodel.cpp @@ -89,7 +86,6 @@ target_sources(astra PRIVATE src/sapphirelogin.cpp src/squareenixlogin.cpp src/steamapi.cpp - src/syncmanager.cpp src/utility.cpp ) @@ -122,6 +118,16 @@ qt_target_qml_sources(astra ui/Setup/SetupPage.qml ui/Main.qml ) +if (BUILD_SYNC) + target_sources(astra PRIVATE + include/charactersync.h + include/syncmanager.h + + src/charactersync.cpp + src/syncmanager.cpp + ) + target_compile_definitions(astra PRIVATE BUILD_SYNC) +endif() set_source_files_properties(../zone.xiv.astra.svg PROPERTIES QT_RESOURCE_ALIAS /zone.xiv.astra.svg diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 599858c..587e1b0 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -68,7 +68,10 @@ class LauncherCore : public QObject Q_PROPERTY(Headline *headline READ headline NOTIFY newsChanged) Q_PROPERTY(Profile *currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged) Q_PROPERTY(Profile *autoLoginProfile READ autoLoginProfile WRITE setAutoLoginProfile NOTIFY autoLoginProfileChanged) + +#ifdef BUILD_SYNC Q_PROPERTY(SyncManager *syncManager READ syncManager CONSTANT) +#endif public: LauncherCore(); @@ -117,6 +120,7 @@ public: [[nodiscard]] static bool isWindows(); [[nodiscard]] static bool needsCompatibilityTool(); [[nodiscard]] Q_INVOKABLE bool isPatching() const; + [[nodiscard]] Q_INVOKABLE bool supportsSync() const; [[nodiscard]] QNetworkAccessManager *mgr(); [[nodiscard]] LauncherSettings *settings(); @@ -124,7 +128,10 @@ public: [[nodiscard]] AccountManager *accountManager(); [[nodiscard]] Headline *headline() const; [[nodiscard]] QString cachedLogoImage() const; + +#ifdef BUILD_SYNC [[nodiscard]] SyncManager *syncManager() const; +#endif Q_SIGNALS: void loadingFinished(); @@ -166,7 +173,10 @@ private: LauncherSettings *m_settings = nullptr; GameRunner *m_runner = nullptr; QString m_cachedLogoImage; + +#ifdef BUILD_SYNC SyncManager *m_syncManager = nullptr; +#endif int m_currentProfileIndex = 0; }; diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index e6d5c22..b8cf6cd 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -15,15 +15,18 @@ #include "assetupdater.h" #include "astra_log.h" #include "benchmarkinstaller.h" -#include "charactersync.h" #include "compatibilitytoolinstaller.h" #include "gamerunner.h" #include "launchercore.h" #include "sapphirelogin.h" #include "squareenixlogin.h" -#include "syncmanager.h" #include "utility.h" +#ifdef BUILD_SYNC +#include "charactersync.h" +#include "syncmanager.h" +#endif + using namespace Qt::StringLiterals; LauncherCore::LauncherCore() @@ -36,7 +39,10 @@ LauncherCore::LauncherCore() m_profileManager = new ProfileManager(*this, this); m_accountManager = new AccountManager(*this, this); m_runner = new GameRunner(*this, this); + +#ifdef BUILD_SYNC m_syncManager = new SyncManager(this); +#endif m_profileManager->load(); m_accountManager->load(); @@ -327,6 +333,15 @@ bool LauncherCore::isPatching() const return m_isPatching; } +bool LauncherCore::supportsSync() const +{ +#ifdef BUILD_SYNC + return true; +#else + return false; +#endif +} + QNetworkAccessManager *LauncherCore::mgr() { return m_mgr; @@ -357,10 +372,12 @@ QString LauncherCore::cachedLogoImage() const return m_cachedLogoImage; } +#ifdef BUILD_SYNC SyncManager *LauncherCore::syncManager() const { return m_syncManager; } +#endif QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) { @@ -369,10 +386,12 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) info.profile->account()->updateConfig(); } +#ifdef BUILD_SYNC const auto characterSync = new CharacterSync(*info.profile->account(), *this, this); if (!co_await characterSync->sync()) { co_return; } +#endif std::optional auth; if (!info.profile->isBenchmark()) { diff --git a/launcher/ui/Settings/SettingsPage.qml b/launcher/ui/Settings/SettingsPage.qml index 2bccc86..4a967bb 100644 --- a/launcher/ui/Settings/SettingsPage.qml +++ b/launcher/ui/Settings/SettingsPage.qml @@ -51,6 +51,7 @@ KirigamiSettings.CategorizedSettings { text: i18n("Sync") icon.name: "state-sync-symbolic" page: Qt.resolvedUrl("/qt/qml/zone/xiv/astra/ui/Settings/SyncSettings.qml") + visible: LauncherCore.supportsSync() }, KirigamiSettings.SettingAction { actionName: "compattool"