1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 19:57:45 +00:00

Make Watchdog an optional feature

This commit is contained in:
Joshua Goins 2022-01-27 09:25:23 -05:00
parent fbc2a29b67
commit 5afca07f1e
4 changed files with 46 additions and 12 deletions

View file

@ -8,6 +8,14 @@ set(CMAKE_CXX_STANDARD 17)
find_package(Qt5 COMPONENTS Core Widgets Network CONFIG REQUIRED) find_package(Qt5 COMPONENTS Core Widgets Network CONFIG REQUIRED)
option(ENABLE_WATCHDOG "Build with Tesseract support (needed for Watchdog)" OFF)
if(ENABLE_WATCHDOG)
find_package(PkgConfig REQUIRED)
pkg_search_module(TESSERACT REQUIRED tesseract)
pkg_search_module(LEPTONICA REQUIRED lept)
endif()
add_subdirectory(external) add_subdirectory(external)
set(SRC set(SRC
@ -21,21 +29,23 @@ set(SRC
src/assetupdater.cpp src/assetupdater.cpp
src/assetupdater.h src/assetupdater.h
src/launcherwindow.cpp src/launcherwindow.cpp
src/launcherwindow.h src/launcherwindow.h)
src/watchdog.h
src/watchdog.cpp)
set(LIBRARIES set(LIBRARIES
Qt5::Core Qt5::Widgets Qt5::Network qt5keychain QuaZip) Qt5::Core Qt5::Widgets Qt5::Network qt5keychain QuaZip)
if(UNIX) if(ENABLE_WATCHDOG)
set(SRC ${SRC} set(LIBRARIES ${LIBRARIES} ${TESSERACT_LIBRARIES} ${LEPTONICA_LIBRARIES})
src/gameparser.h
src/gameparser.cpp)
set(SRC ${SRC}
src/watchdog.h
src/watchdog.cpp
src/gameparser.h
src/gameparser.cpp)
endif()
if(UNIX)
set(LIBRARIES ${LIBRARIES} set(LIBRARIES ${LIBRARIES}
tesseract
lept
X11 X11
Xcomposite Xcomposite
Xrender) Xrender)
@ -51,6 +61,12 @@ target_include_directories(xivlauncher PRIVATE
${CMAKE_BINARY_DIR}/_deps/qtkeychain-build ${CMAKE_BINARY_DIR}/_deps/qtkeychain-build
${CMAKE_BINARY_DIR}/_deps/quazip-src) ${CMAKE_BINARY_DIR}/_deps/quazip-src)
if(ENABLE_WATCHDOG)
target_include_directories(xivlauncher PRIVATE ${TESSERACT_INCLUDE_DIRS} ${LEPTONICA_INCLUDE_DIRS})
target_compile_definitions(xivlauncher PRIVATE ENABLE_WATCHDOG)
endif()
install(TARGETS xivlauncher install(TARGETS xivlauncher
DESTINATION "${INSTALL_BIN_PATH}" DESTINATION "${INSTALL_BIN_PATH}"
) )
@ -67,4 +83,4 @@ if(WIN32)
POST_BUILD POST_BUILD
COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$<TARGET_FILE:xivlauncher>\" COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$<TARGET_FILE:xivlauncher>\"
) )
endif() endif()

View file

@ -34,7 +34,10 @@
#include "settingswindow.h" #include "settingswindow.h"
#include "blowfish.h" #include "blowfish.h"
#include "assetupdater.h" #include "assetupdater.h"
#ifdef ENABLE_WATCHDOG
#include "watchdog.h" #include "watchdog.h"
#endif
void LauncherCore::setSSL(QNetworkRequest& request) { void LauncherCore::setSSL(QNetworkRequest& request) {
QSslConfiguration config; QSslConfiguration config;
@ -370,7 +373,10 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco
squareLauncher = new SquareLauncher(*this); squareLauncher = new SquareLauncher(*this);
squareBoot = new SquareBoot(*this, *squareLauncher); squareBoot = new SquareBoot(*this, *squareLauncher);
assetUpdater = new AssetUpdater(*this); assetUpdater = new AssetUpdater(*this);
#ifdef ENABLE_WATCHDOG
watchdog = new Watchdog(*this); watchdog = new Watchdog(*this);
#endif
readInitialInformation(); readInitialInformation();
@ -382,7 +388,9 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco
} }
LauncherCore::~LauncherCore() noexcept { LauncherCore::~LauncherCore() noexcept {
#ifdef ENABLE_WATCHDOG
delete watchdog; delete watchdog;
#endif
} }
ProfileSettings LauncherCore::getProfile(int index) const { ProfileSettings LauncherCore::getProfile(int index) const {

View file

@ -91,7 +91,7 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg
}); });
gameBoxLayout->addWidget(gameDirectoryButton); gameBoxLayout->addWidget(gameDirectoryButton);
#if defined(Q_OS_LINUX) #ifdef ENABLE_WATCHDOG
enableWatchdog = new QCheckBox("Enable Watchdog (X11 only)"); enableWatchdog = new QCheckBox("Enable Watchdog (X11 only)");
gameBoxLayout->addWidget(enableWatchdog); gameBoxLayout->addWidget(enableWatchdog);
@ -354,6 +354,9 @@ void SettingsWindow::reloadControls() {
useEsync->setChecked(profile.useEsync); useEsync->setChecked(profile.useEsync);
useGamescope->setChecked(profile.useGamescope); useGamescope->setChecked(profile.useGamescope);
useGamemode->setChecked(profile.useGamemode); useGamemode->setChecked(profile.useGamemode);
#endif
#ifdef ENABLE_WATCHDOG
enableWatchdog->setChecked(profile.enableWatchdog); enableWatchdog->setChecked(profile.enableWatchdog);
#endif #endif
@ -385,4 +388,4 @@ void SettingsWindow::openPath(const QString path) {
#else #else
QDesktopServices::openUrl("file://" + path); QDesktopServices::openUrl("file://" + path);
#endif #endif
} }

View file

@ -9,7 +9,10 @@
#include <QJsonObject> #include <QJsonObject>
#include "launchercore.h" #include "launchercore.h"
#ifdef ENABLE_WATCHDOG
#include "watchdog.h" #include "watchdog.h"
#endif
SquareLauncher::SquareLauncher(LauncherCore& window) : window(window) { SquareLauncher::SquareLauncher(LauncherCore& window) : window(window) {
@ -124,11 +127,15 @@ void SquareLauncher::registerSession(const LoginInformation& info) {
if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) { if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) {
auth.SID = reply->rawHeader("X-Patch-Unique-Id"); auth.SID = reply->rawHeader("X-Patch-Unique-Id");
#ifdef ENABLE_WATCHDOG
if(info.settings->enableWatchdog) { if(info.settings->enableWatchdog) {
window.watchdog->launchGame(*info.settings, auth); window.watchdog->launchGame(*info.settings, auth);
} else { } else {
window.launchGame(*info.settings, auth); window.launchGame(*info.settings, auth);
} }
#else
window.launchGame(*info.settings, auth);
#endif
} else { } else {
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed the anti-tamper check. Please restore your game to the original state or update the game."); auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed the anti-tamper check. Please restore your game to the original state or update the game.");
window.addUpdateButtons(*info.settings, *messageBox); window.addUpdateButtons(*info.settings, *messageBox);