mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-03-27 09:13:09 +00:00
ui: drop system-bus GameCenter fallback
This commit is contained in:
parent
8891e85dbc
commit
f3b130008f
6 changed files with 6 additions and 56 deletions
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE busconfig PUBLIC
|
|
||||||
"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
|
||||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
|
||||||
<busconfig>
|
|
||||||
<policy user="root">
|
|
||||||
<allow own="org.kde.GameCenter1"/>
|
|
||||||
</policy>
|
|
||||||
|
|
||||||
<policy context="default">
|
|
||||||
<allow send_destination="org.kde.GameCenter1"/>
|
|
||||||
<allow receive_sender="org.kde.GameCenter1"/>
|
|
||||||
</policy>
|
|
||||||
</busconfig>
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
[D-BUS Service]
|
|
||||||
Name=org.kde.GameCenter1
|
|
||||||
Exec=@CMAKE_INSTALL_PREFIX@/@KDE_INSTALL_BINDIR@/alakarte-gamecenter --system
|
|
||||||
SystemdService=org.kde.GameCenter1.service
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=A-La-Karte Game Center
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=@CMAKE_INSTALL_PREFIX@/@KDE_INSTALL_BINDIR@/alakarte-gamecenter --system
|
|
||||||
Type=dbus
|
|
||||||
BusName=org.kde.GameCenter1
|
|
||||||
Restart=no
|
|
||||||
|
|
@ -270,7 +270,6 @@ static QStringList steamCandidateRoots()
|
||||||
GameLauncher::GameLauncher(QObject *parent)
|
GameLauncher::GameLauncher(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_daemonAvailable(false)
|
, m_daemonAvailable(false)
|
||||||
, m_usingSystemBus(false)
|
|
||||||
{
|
{
|
||||||
if (auto *app = qobject_cast<App *>(parent)) {
|
if (auto *app = qobject_cast<App *>(parent)) {
|
||||||
connect(app->gameModel(), &GameModel::countChanged, this, [this]() {
|
connect(app->gameModel(), &GameModel::countChanged, this, [this]() {
|
||||||
|
|
@ -557,10 +556,7 @@ void GameLauncher::launchGame(Game *game)
|
||||||
|
|
||||||
// Always try daemon first — for all launch types
|
// Always try daemon first — for all launch types
|
||||||
{
|
{
|
||||||
QDBusInterface iface(kGameCenterService,
|
QDBusInterface iface(kGameCenterService, kGameCenterPath, kGameCenterInterface, QDBusConnection::sessionBus());
|
||||||
kGameCenterPath,
|
|
||||||
kGameCenterInterface,
|
|
||||||
m_usingSystemBus ? QDBusConnection::systemBus() : QDBusConnection::sessionBus());
|
|
||||||
QVariantMap launchSpec = {
|
QVariantMap launchSpec = {
|
||||||
{QStringLiteral("command"), launchCommand},
|
{QStringLiteral("command"), launchCommand},
|
||||||
{QStringLiteral("gameId"), game->id()},
|
{QStringLiteral("gameId"), game->id()},
|
||||||
|
|
@ -631,10 +627,7 @@ void GameLauncher::stopGame(Game *game)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusInterface iface(kGameCenterService,
|
QDBusInterface iface(kGameCenterService, kGameCenterPath, kGameCenterInterface, QDBusConnection::sessionBus());
|
||||||
kGameCenterPath,
|
|
||||||
kGameCenterInterface,
|
|
||||||
m_usingSystemBus ? QDBusConnection::systemBus() : QDBusConnection::sessionBus());
|
|
||||||
iface.call(QStringLiteral("StopByGameId"), game->id());
|
iface.call(QStringLiteral("StopByGameId"), game->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -765,10 +758,7 @@ void GameLauncher::onDaemonLaunchFailed(const QVariantMap &error)
|
||||||
|
|
||||||
void GameLauncher::syncDaemonSessions()
|
void GameLauncher::syncDaemonSessions()
|
||||||
{
|
{
|
||||||
QDBusInterface iface(kGameCenterService,
|
QDBusInterface iface(kGameCenterService, kGameCenterPath, kGameCenterInterface, QDBusConnection::sessionBus());
|
||||||
kGameCenterPath,
|
|
||||||
kGameCenterInterface,
|
|
||||||
m_usingSystemBus ? QDBusConnection::systemBus() : QDBusConnection::sessionBus());
|
|
||||||
|
|
||||||
const QDBusReply<QVariantList> reply = iface.call(QStringLiteral("ListSessions"));
|
const QDBusReply<QVariantList> reply = iface.call(QStringLiteral("ListSessions"));
|
||||||
if (!reply.isValid()) {
|
if (!reply.isValid()) {
|
||||||
|
|
@ -805,28 +795,14 @@ void GameLauncher::applyRunningStateToLibrary()
|
||||||
|
|
||||||
void GameLauncher::checkDaemonAvailability()
|
void GameLauncher::checkDaemonAvailability()
|
||||||
{
|
{
|
||||||
const bool systemAvailable = pingDaemon(QDBusConnection::systemBus());
|
const bool available = pingDaemon(QDBusConnection::sessionBus());
|
||||||
const bool sessionAvailable = systemAvailable ? false : pingDaemon(QDBusConnection::sessionBus());
|
|
||||||
const bool available = systemAvailable || sessionAvailable;
|
|
||||||
const bool useSystemBus = systemAvailable;
|
|
||||||
|
|
||||||
disconnectDaemonSignals(QDBusConnection::systemBus(), this);
|
|
||||||
disconnectDaemonSignals(QDBusConnection::sessionBus(), this);
|
disconnectDaemonSignals(QDBusConnection::sessionBus(), this);
|
||||||
|
|
||||||
if (available) {
|
if (available) {
|
||||||
connectDaemonSignals(useSystemBus ? QDBusConnection::systemBus() : QDBusConnection::sessionBus(), this);
|
connectDaemonSignals(QDBusConnection::sessionBus(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool busChanged = m_usingSystemBus != useSystemBus;
|
|
||||||
if (busChanged) {
|
|
||||||
m_daemonGameToSession.clear();
|
|
||||||
m_daemonSessionToGame.clear();
|
|
||||||
Q_EMIT runningGamesChanged();
|
|
||||||
applyRunningStateToLibrary();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_usingSystemBus = useSystemBus;
|
|
||||||
|
|
||||||
if (available != m_daemonAvailable) {
|
if (available != m_daemonAvailable) {
|
||||||
m_daemonAvailable = available;
|
m_daemonAvailable = available;
|
||||||
Q_EMIT daemonAvailableChanged();
|
Q_EMIT daemonAvailableChanged();
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ private:
|
||||||
QHash<QString, QString> m_daemonGameToSession;
|
QHash<QString, QString> m_daemonGameToSession;
|
||||||
QHash<QString, QString> m_daemonSessionToGame;
|
QHash<QString, QString> m_daemonSessionToGame;
|
||||||
bool m_daemonAvailable = false;
|
bool m_daemonAvailable = false;
|
||||||
bool m_usingSystemBus = false;
|
|
||||||
|
|
||||||
void checkDaemonAvailability();
|
void checkDaemonAvailability();
|
||||||
void syncDaemonSessions();
|
void syncDaemonSessions();
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ void AlakarteRunner::run(const KRunner::RunnerContext &context, const KRunner::Q
|
||||||
{QStringLiteral("origin"), QStringLiteral("krunner")},
|
{QStringLiteral("origin"), QStringLiteral("krunner")},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (launchViaDaemon(QDBusConnection::systemBus(), launchSpec) || launchViaDaemon(QDBusConnection::sessionBus(), launchSpec)) {
|
if (launchViaDaemon(QDBusConnection::sessionBus(), launchSpec)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue