diff --git a/api/dbus/org.desktopspec.ApplicationManager1.Instance.xml b/api/dbus/org.desktopspec.ApplicationManager1.Instance.xml
index d8eadff..2292a4e 100644
--- a/api/dbus/org.desktopspec.ApplicationManager1.Instance.xml
+++ b/api/dbus/org.desktopspec.ApplicationManager1.Instance.xml
@@ -41,5 +41,12 @@
to which the instance belonged has been removed."
/>
+
+
+
+
diff --git a/src/constant.h b/src/constant.h
index 4f3e707..8f65cc8 100644
--- a/src/constant.h
+++ b/src/constant.h
@@ -8,6 +8,7 @@
constexpr auto SystemdService = u8"org.freedesktop.systemd1";
constexpr auto SystemdObjectPath = u8"/org/freedesktop/systemd1";
constexpr auto SystemdInterfaceName = u8"org.freedesktop.systemd1.Manager";
+constexpr auto SystemdUnitInterfaceName = u8"org.freedesktop.systemd1.Unit";
constexpr auto DDEApplicationManager1ServiceName =
#ifdef DDE_AM_USE_DEBUG_DBUS_NAME
u8"org.desktopspec.debug.ApplicationManager1";
diff --git a/src/dbus/instanceservice.cpp b/src/dbus/instanceservice.cpp
index 21231de..549d7cc 100644
--- a/src/dbus/instanceservice.cpp
+++ b/src/dbus/instanceservice.cpp
@@ -3,8 +3,10 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "dbus/instanceservice.h"
+#include "constant.h"
#include "propertiesForwarder.h"
-#include
+#include
+#include "global.h"
InstanceService::InstanceService(QString instanceId, QString application, QString systemdUnitPath, QString launcher)
: m_Launcher(std::move(launcher))
@@ -16,3 +18,18 @@ InstanceService::InstanceService(QString instanceId, QString application, QStrin
}
InstanceService::~InstanceService() = default;
+
+void InstanceService::KillAll(int signal)
+{
+ auto killMsg = QDBusMessage::createMethodCall(SystemdService, m_SystemdUnitPath.path(), SystemdUnitInterfaceName, "Kill");
+ killMsg << QString{"all"} << signal;
+
+ auto &con = ApplicationManager1DBus::instance().globalDestBus();
+ auto reply = con.call(killMsg);
+
+ if (reply.type() == QDBusMessage::ReplyMessage) {
+ return;
+ }
+
+ sendErrorReply(reply.errorName(), reply.errorMessage());
+}
diff --git a/src/dbus/instanceservice.h b/src/dbus/instanceservice.h
index 95c7c2c..c47ba34 100644
--- a/src/dbus/instanceservice.h
+++ b/src/dbus/instanceservice.h
@@ -7,8 +7,9 @@
#include
#include
+#include
-class InstanceService : public QObject
+class InstanceService : public QObject, protected QDBusContext
{
Q_OBJECT
public:
@@ -25,6 +26,9 @@ public:
[[nodiscard]] const QString &instanceId() const noexcept { return m_instanceId; }
+public Q_SLOTS:
+ void KillAll(int signal);
+
Q_SIGNALS:
void orphanedChanged();