1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Remove mentions of Watchdog

It's currently bitrotting anyway, no reason to keep it for the next
release
This commit is contained in:
Joshua Goins 2023-10-06 18:07:44 -04:00
parent f84be41c45
commit b366c046e0
10 changed files with 0 additions and 275 deletions

View file

@ -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: 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_STEAM`: Steam integration, requires the Steamworks SDK.
* `ENABLE_GAMEMODE`: Gamemode integration, reqires Gamemode. * `ENABLE_GAMEMODE`: Gamemode integration, reqires Gamemode.

View file

@ -8,7 +8,6 @@ project(Astra VERSION 0.5.0 LANGUAGES CXX)
option(BUILD_FLATPAK "Build for Flatpak." OFF) option(BUILD_FLATPAK "Build for Flatpak." OFF)
# options for features you may want or need # 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_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) 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) qt_policy(SET QTP0001 NEW)
if (ENABLE_WATCHDOG)
pkg_search_module(TESSERACT REQUIRED tesseract)
pkg_search_module(LEPTONICA REQUIRED lept)
endif ()
if (ENABLE_GAMEMODE) if (ENABLE_GAMEMODE)
pkg_search_module(GAMEMODE REQUIRED gamemode) pkg_search_module(GAMEMODE REQUIRED gamemode)
endif () endif ()

View file

@ -19,7 +19,6 @@
class SapphireLauncher; class SapphireLauncher;
class SquareLauncher; class SquareLauncher;
class AssetUpdater; class AssetUpdater;
class Watchdog;
class GameInstaller; class GameInstaller;
class CompatibilityToolInstaller; class CompatibilityToolInstaller;
@ -223,7 +222,6 @@ private:
SapphireLauncher *m_sapphireLauncher = nullptr; SapphireLauncher *m_sapphireLauncher = nullptr;
SquareBoot *m_squareBoot = nullptr; SquareBoot *m_squareBoot = nullptr;
SquareLauncher *m_squareLauncher = nullptr; SquareLauncher *m_squareLauncher = nullptr;
Watchdog *m_watchdog = nullptr;
Headline *m_headline = nullptr; Headline *m_headline = nullptr;

View file

@ -21,7 +21,6 @@ class Profile : public QObject
Q_PROPERTY(QString gamePath READ gamePath WRITE setGamePath NOTIFY gamePathChanged) Q_PROPERTY(QString gamePath READ gamePath WRITE setGamePath NOTIFY gamePathChanged)
Q_PROPERTY(QString winePath READ winePath WRITE setWinePath NOTIFY winePathChanged) Q_PROPERTY(QString winePath READ winePath WRITE setWinePath NOTIFY winePathChanged)
Q_PROPERTY(QString winePrefixPath READ winePrefixPath WRITE setWinePrefixPath NOTIFY winePrefixPathChanged) 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(WineType wineType READ wineType WRITE setWineType NOTIFY wineTypeChanged)
Q_PROPERTY(bool esyncEnabled READ esyncEnabled WRITE setESyncEnabled NOTIFY useESyncChanged) Q_PROPERTY(bool esyncEnabled READ esyncEnabled WRITE setESyncEnabled NOTIFY useESyncChanged)
Q_PROPERTY(bool gamescopeEnabled READ gamescopeEnabled WRITE setGamescopeEnabled NOTIFY useGamescopeChanged) Q_PROPERTY(bool gamescopeEnabled READ gamescopeEnabled WRITE setGamescopeEnabled NOTIFY useGamescopeChanged)
@ -75,9 +74,6 @@ public:
[[nodiscard]] QString winePrefixPath() const; [[nodiscard]] QString winePrefixPath() const;
void setWinePrefixPath(const QString &path); void setWinePrefixPath(const QString &path);
[[nodiscard]] bool watchdogEnabled() const;
void setWatchdogEnabled(bool value);
[[nodiscard]] WineType wineType() const; [[nodiscard]] WineType wineType() const;
void setWineType(WineType type); void setWineType(WineType type);
@ -165,7 +161,6 @@ Q_SIGNALS:
void gamePathChanged(); void gamePathChanged();
void winePathChanged(); void winePathChanged();
void winePrefixPathChanged(); void winePrefixPathChanged();
void enableWatchdogChanged();
void wineTypeChanged(); void wineTypeChanged();
void useESyncChanged(); void useESyncChanged();
void useGamescopeChanged(); void useGamescopeChanged();

View file

@ -1,39 +0,0 @@
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <memory>
#include "launchercore.h"
#if defined(Q_OS_LINUX)
#include "gameparser.h"
#endif
#include <QSystemTrayIcon>
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<GameParser> parser;
};

View file

@ -23,9 +23,6 @@ SPDX-License-Identifier: CC0-1.0
</entry> </entry>
<entry key="WinePrefixPath" type="Path"> <entry key="WinePrefixPath" type="Path">
</entry> </entry>
<entry key="EnableWatchdog" type="bool">
<default>false</default>
</entry>
<entry key="WineType" type="Enum"> <entry key="WineType" type="Enum">
<choices> <choices>
<choice name="System"> <choice name="System">

View file

@ -26,10 +26,6 @@
#include "squarelauncher.h" #include "squarelauncher.h"
#include "utility.h" #include "utility.h"
#ifdef ENABLE_WATCHDOG
#include "watchdog.h"
#endif
void LauncherCore::setSSL(QNetworkRequest &request) void LauncherCore::setSSL(QNetworkRequest &request)
{ {
QSslConfiguration config; QSslConfiguration config;
@ -60,15 +56,7 @@ void LauncherCore::launchGame(Profile &profile, const LoginAuth &auth)
{ {
m_steamApi->setLauncherMode(false); m_steamApi->setLauncherMode(false);
#ifdef ENABLE_WATCHDOG
if (profile.enableWatchdog) {
watchdog->launchGame(profile, auth);
} else {
beginGameExecutable(profile, auth);
}
#else
beginGameExecutable(profile, auth); beginGameExecutable(profile, auth);
#endif
} }
QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info)
@ -401,10 +389,6 @@ LauncherCore::LauncherCore()
m_profileManager = new ProfileManager(*this, this); m_profileManager = new ProfileManager(*this, this);
m_accountManager = new AccountManager(*this, this); m_accountManager = new AccountManager(*this, this);
#ifdef ENABLE_WATCHDOG
watchdog = new Watchdog(*this);
#endif
readInitialInformation(); readInitialInformation();
m_steamApi->setLauncherMode(true); m_steamApi->setLauncherMode(true);

View file

@ -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 Profile::WineType Profile::wineType() const
{ {
return static_cast<WineType>(m_config->wineType()); return static_cast<WineType>(m_config->wineType());

View file

@ -1,173 +0,0 @@
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "watchdog.h"
#include <QGuiApplication>
#include <QMenu>
#include <QScreen>
#include <QTimer>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
// 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<uchar *>(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<ushort *>(image.scanLine(i));
ushort *end = p + image.width();
while (p < end) {
*p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);
p++;
}
} else {
uint *p = reinterpret_cast<uint *>(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<QRgb *>(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<GameParser>();
}
connect(timer, &QTimer::timeout, [=] {
if (processWindowId == -1) {
auto xdoProcess = new QProcess();
connect(xdoProcess, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&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);
}

View file

@ -78,22 +78,6 @@ FormCard.FormCardPage {
FormCard.FormDelegateSeparator { FormCard.FormDelegateSeparator {
above: encryptArgDelegate 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 { FormCard.FormTextDelegate {