From b366c046e03e143424f4855996b4af96cbb23f97 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 6 Oct 2023 18:07:44 -0400 Subject: [PATCH] Remove mentions of Watchdog It's currently bitrotting anyway, no reason to keep it for the next release --- BUILDING.md | 1 - CMakeLists.txt | 6 - launcher/include/launchercore.h | 2 - launcher/include/profile.h | 5 - launcher/include/watchdog.h | 39 ----- launcher/profileconfig.kcfg | 3 - launcher/src/launchercore.cpp | 16 --- launcher/src/profile.cpp | 14 -- launcher/src/watchdog.cpp | 173 ----------------------- launcher/ui/Settings/ProfileSettings.qml | 16 --- 10 files changed, 275 deletions(-) delete mode 100644 launcher/include/watchdog.h delete mode 100644 launcher/src/watchdog.cpp diff --git a/BUILDING.md b/BUILDING.md index 32534d3..2799e36 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -52,7 +52,6 @@ Remember that unless you're running in a kdesrc-build session you need to set so When configuring Astra, there are several optional features you may want to enable or disable: -* `ENABLE_WATCHDOG`: Watchdog support, requires Tesseract and X11. * `ENABLE_STEAM`: Steam integration, requires the Steamworks SDK. * `ENABLE_GAMEMODE`: Gamemode integration, reqires Gamemode. diff --git a/CMakeLists.txt b/CMakeLists.txt index 821f720..ebb0eef 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ project(Astra VERSION 0.5.0 LANGUAGES CXX) option(BUILD_FLATPAK "Build for Flatpak." OFF) # options for features you may want or need -option(ENABLE_WATCHDOG "Build support for Watchdog, requires X11." OFF) option(ENABLE_STEAM "Build with Steam support, requires supplying the Steam SDK yourself." OFF) option(ENABLE_GAMEMODE "Build with Feral GameMode support, requires the daemon to be installed." ON) @@ -56,11 +55,6 @@ qcoro_enable_coroutines() qt_policy(SET QTP0001 NEW) -if (ENABLE_WATCHDOG) - pkg_search_module(TESSERACT REQUIRED tesseract) - pkg_search_module(LEPTONICA REQUIRED lept) -endif () - if (ENABLE_GAMEMODE) pkg_search_module(GAMEMODE REQUIRED gamemode) endif () diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 723d608..7f2f544 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -19,7 +19,6 @@ class SapphireLauncher; class SquareLauncher; class AssetUpdater; -class Watchdog; class GameInstaller; class CompatibilityToolInstaller; @@ -223,7 +222,6 @@ private: SapphireLauncher *m_sapphireLauncher = nullptr; SquareBoot *m_squareBoot = nullptr; SquareLauncher *m_squareLauncher = nullptr; - Watchdog *m_watchdog = nullptr; Headline *m_headline = nullptr; diff --git a/launcher/include/profile.h b/launcher/include/profile.h index 3382d2a..f03f9ae 100644 --- a/launcher/include/profile.h +++ b/launcher/include/profile.h @@ -21,7 +21,6 @@ class Profile : public QObject Q_PROPERTY(QString gamePath READ gamePath WRITE setGamePath NOTIFY gamePathChanged) Q_PROPERTY(QString winePath READ winePath WRITE setWinePath NOTIFY winePathChanged) Q_PROPERTY(QString winePrefixPath READ winePrefixPath WRITE setWinePrefixPath NOTIFY winePrefixPathChanged) - Q_PROPERTY(bool watchdogEnabled READ watchdogEnabled WRITE setWatchdogEnabled NOTIFY enableWatchdogChanged) Q_PROPERTY(WineType wineType READ wineType WRITE setWineType NOTIFY wineTypeChanged) Q_PROPERTY(bool esyncEnabled READ esyncEnabled WRITE setESyncEnabled NOTIFY useESyncChanged) Q_PROPERTY(bool gamescopeEnabled READ gamescopeEnabled WRITE setGamescopeEnabled NOTIFY useGamescopeChanged) @@ -75,9 +74,6 @@ public: [[nodiscard]] QString winePrefixPath() const; void setWinePrefixPath(const QString &path); - [[nodiscard]] bool watchdogEnabled() const; - void setWatchdogEnabled(bool value); - [[nodiscard]] WineType wineType() const; void setWineType(WineType type); @@ -165,7 +161,6 @@ Q_SIGNALS: void gamePathChanged(); void winePathChanged(); void winePrefixPathChanged(); - void enableWatchdogChanged(); void wineTypeChanged(); void useESyncChanged(); void useGamescopeChanged(); diff --git a/launcher/include/watchdog.h b/launcher/include/watchdog.h deleted file mode 100644 index 24c4cf1..0000000 --- a/launcher/include/watchdog.h +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Joshua Goins -// SPDX-License-Identifier: GPL-3.0-or-later - -#pragma once - -#include - -#include "launchercore.h" - -#if defined(Q_OS_LINUX) -#include "gameparser.h" -#endif - -#include - -class Watchdog : public QObject -{ - Q_OBJECT -public: - Watchdog(LauncherCore &core) - : core(core) - , QObject(&core) - { - } - - void launchGame(const ProfileSettings &settings, const LoginAuth &auth); - -private: - LauncherCore &core; - QSystemTrayIcon *icon = nullptr; - - int processWindowId = -1; - -#if defined(Q_OS_LINUX) - GameParseResult lastResult; -#endif - - std::unique_ptr parser; -}; \ No newline at end of file diff --git a/launcher/profileconfig.kcfg b/launcher/profileconfig.kcfg index 56df2a7..c9be64a 100644 --- a/launcher/profileconfig.kcfg +++ b/launcher/profileconfig.kcfg @@ -23,9 +23,6 @@ SPDX-License-Identifier: CC0-1.0 - - false - diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index d4894f1..8bd544a 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -26,10 +26,6 @@ #include "squarelauncher.h" #include "utility.h" -#ifdef ENABLE_WATCHDOG -#include "watchdog.h" -#endif - void LauncherCore::setSSL(QNetworkRequest &request) { QSslConfiguration config; @@ -60,15 +56,7 @@ void LauncherCore::launchGame(Profile &profile, const LoginAuth &auth) { m_steamApi->setLauncherMode(false); -#ifdef ENABLE_WATCHDOG - if (profile.enableWatchdog) { - watchdog->launchGame(profile, auth); - } else { - beginGameExecutable(profile, auth); - } -#else beginGameExecutable(profile, auth); -#endif } QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) @@ -401,10 +389,6 @@ LauncherCore::LauncherCore() m_profileManager = new ProfileManager(*this, this); m_accountManager = new AccountManager(*this, this); -#ifdef ENABLE_WATCHDOG - watchdog = new Watchdog(*this); -#endif - readInitialInformation(); m_steamApi->setLauncherMode(true); diff --git a/launcher/src/profile.cpp b/launcher/src/profile.cpp index b18b5b2..73d3e82 100644 --- a/launcher/src/profile.cpp +++ b/launcher/src/profile.cpp @@ -182,20 +182,6 @@ void Profile::setWinePrefixPath(const QString &path) } } -bool Profile::watchdogEnabled() const -{ - return m_config->enableWatchdog(); -} - -void Profile::setWatchdogEnabled(const bool value) -{ - if (m_config->enableWatchdog() != value) { - m_config->setEnableWatchdog(value); - m_config->save(); - Q_EMIT enableWatchdogChanged(); - } -} - Profile::WineType Profile::wineType() const { return static_cast(m_config->wineType()); diff --git a/launcher/src/watchdog.cpp b/launcher/src/watchdog.cpp deleted file mode 100644 index 24d1ef2..0000000 --- a/launcher/src/watchdog.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Joshua Goins -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "watchdog.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -// from https://github.com/adobe/webkit/blob/master/Source/WebCore/plugins/qt/QtX11ImageConversion.cpp -// code is licensed under GPLv2 -// Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) -QImage qimageFromXImage(XImage *xi) -{ - QImage::Format format = QImage::Format_ARGB32_Premultiplied; - if (xi->depth == 24) - format = QImage::Format_RGB32; - else if (xi->depth == 16) - format = QImage::Format_RGB16; - - QImage image = QImage(reinterpret_cast(xi->data), xi->width, xi->height, xi->bytes_per_line, format).copy(); - - // we may have to swap the byte order - if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst) - || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst)) { - for (int i = 0; i < image.height(); i++) { - if (xi->depth == 16) { - ushort *p = reinterpret_cast(image.scanLine(i)); - ushort *end = p + image.width(); - while (p < end) { - *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff); - p++; - } - } else { - uint *p = reinterpret_cast(image.scanLine(i)); - uint *end = p + image.width(); - while (p < end) { - *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000) | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff); - p++; - } - } - } - } - - // fix-up alpha channel - if (format == QImage::Format_RGB32) { - QRgb *p = reinterpret_cast(image.bits()); - for (int y = 0; y < xi->height; ++y) { - for (int x = 0; x < xi->width; ++x) - p[x] |= 0xff000000; - p += xi->bytes_per_line / 4; - } - } - - return image; -} - -void Watchdog::launchGame(const ProfileSettings &settings, const LoginAuth &auth) -{ - if (icon == nullptr) { - icon = new QSystemTrayIcon(); - } - - icon->setToolTip("Queue Status"); - icon->show(); - icon->showMessage("Watchdog", "Watchdog service has started. Waiting for you to connect to data center..."); - - auto timer = new QTimer(this); - - auto menu = new QMenu(); - - auto stopAction = menu->addAction("Stop"); - connect(stopAction, &QAction::triggered, [=] { - timer->stop(); - processWindowId = -1; - icon->hide(); - }); - - icon->setContextMenu(menu); - - core.launchGame(settings, auth); - - if (parser == nullptr) { - parser = std::make_unique(); - } - - connect(timer, &QTimer::timeout, [=] { - if (processWindowId == -1) { - auto xdoProcess = new QProcess(); - - connect(xdoProcess, static_cast(&QProcess::finished), [=](int, QProcess::ExitStatus) { - QString output = xdoProcess->readAllStandardOutput(); - qDebug() << "Found XIV Window: " << output.toInt(); - - processWindowId = output.toInt(); - }); - - // TODO: don't use xdotool for this, find a better way to - xdoProcess->start("bash", {"-c", "xdotool search --name \"FINAL FANTASY XIV\""}); - } else { - Display *display = XOpenDisplay(nullptr); - - XSynchronize(display, True); - - XWindowAttributes attr; - Status status = XGetWindowAttributes(display, processWindowId, &attr); - if (status == 0) { - qDebug() << "Failed to get window attributes! The window is possibly closed now."; - processWindowId = -1; - timer->stop(); - icon->hide(); - } else { - XCompositeRedirectWindow(display, processWindowId, CompositeRedirectAutomatic); - XCompositeNameWindowPixmap(display, processWindowId); - - XRenderPictFormat *format = XRenderFindVisualFormat(display, attr.visual); - - XRenderPictureAttributes pa; - pa.subwindow_mode = IncludeInferiors; - - Picture picture = XRenderCreatePicture(display, processWindowId, format, CPSubwindowMode, &pa); - XFlush(display); // TODO: does this actually make a difference? - - XImage *image = XGetImage(display, processWindowId, 0, 0, attr.width, attr.height, AllPlanes, ZPixmap); - if (!image) { - qDebug() << "Unable to get image..."; - } else { - auto result = parser->parseImage(qimageFromXImage(image)); - if (result != lastResult) { - // skip OCR errors (TODO: should be handled by GameParser itself) - if (result.state == ScreenState::InLoginQueue && result.playersInQueue == 0) - return; - - switch (result.state) { - case ScreenState::InLoginQueue: { - icon->showMessage("Watchdog", - QString("You are now at position %1 (moved %2 spots)") - .arg(result.playersInQueue) - .arg(lastResult.playersInQueue - result.playersInQueue)); - - icon->setToolTip(QString("Queue Status (%1)").arg(result.playersInQueue)); - } break; - case ScreenState::LobbyError: { - // TODO: kill game? - icon->showMessage("Watchdog", "You have been disconnected due to a lobby error."); - } break; - case ScreenState::ConnectingToDataCenter: { - icon->showMessage("Watchdog", "You are in the process of being connected to the data center."); - } break; - case ScreenState::WorldFull: { - icon->showMessage("Watchdog", "You have been disconnected due to a lobby error."); - } break; - } - - lastResult = result; - } - - XFreePixmap(display, picture); - } - } - - XCompositeUnredirectWindow(display, processWindowId, CompositeRedirectAutomatic); - } - }); - - timer->start(5000); -} diff --git a/launcher/ui/Settings/ProfileSettings.qml b/launcher/ui/Settings/ProfileSettings.qml index 4133d74..0b2e5d2 100644 --- a/launcher/ui/Settings/ProfileSettings.qml +++ b/launcher/ui/Settings/ProfileSettings.qml @@ -78,22 +78,6 @@ FormCard.FormCardPage { FormCard.FormDelegateSeparator { above: encryptArgDelegate - below: enableWatchdogDelegate - } - - FormCard.FormCheckDelegate { - id: enableWatchdogDelegate - - text: i18n("Enable Watchdog") - description: i18n("Gives real-time queue updates. X11 only.") - checked: page.profile.watchdogEnabled - onCheckedChanged: page.profile.watchdogEnabled = checked - enabled: false - visible: false - } - - FormCard.FormDelegateSeparator { - visible: false } FormCard.FormTextDelegate {