feat: add Method "KillAll"
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
a330ad8f2b
commit
03deb2c935
@ -41,5 +41,12 @@
|
|||||||
to which the instance belonged has been removed."
|
to which the instance belonged has been removed."
|
||||||
/>
|
/>
|
||||||
</property>
|
</property>
|
||||||
|
<method name="KillAll">
|
||||||
|
<arg type="i" name="signal" direction="in"/>
|
||||||
|
<annotation name="org.freedesktop.DBus.Description"
|
||||||
|
value="Force kill this instance.
|
||||||
|
ATTENTION: All processes which launched by
|
||||||
|
this instance will be killed." />
|
||||||
|
</method>
|
||||||
</interface>
|
</interface>
|
||||||
</node>
|
</node>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
constexpr auto SystemdService = u8"org.freedesktop.systemd1";
|
constexpr auto SystemdService = u8"org.freedesktop.systemd1";
|
||||||
constexpr auto SystemdObjectPath = u8"/org/freedesktop/systemd1";
|
constexpr auto SystemdObjectPath = u8"/org/freedesktop/systemd1";
|
||||||
constexpr auto SystemdInterfaceName = u8"org.freedesktop.systemd1.Manager";
|
constexpr auto SystemdInterfaceName = u8"org.freedesktop.systemd1.Manager";
|
||||||
|
constexpr auto SystemdUnitInterfaceName = u8"org.freedesktop.systemd1.Unit";
|
||||||
constexpr auto DDEApplicationManager1ServiceName =
|
constexpr auto DDEApplicationManager1ServiceName =
|
||||||
#ifdef DDE_AM_USE_DEBUG_DBUS_NAME
|
#ifdef DDE_AM_USE_DEBUG_DBUS_NAME
|
||||||
u8"org.desktopspec.debug.ApplicationManager1";
|
u8"org.desktopspec.debug.ApplicationManager1";
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
#include "dbus/instanceservice.h"
|
#include "dbus/instanceservice.h"
|
||||||
|
#include "constant.h"
|
||||||
#include "propertiesForwarder.h"
|
#include "propertiesForwarder.h"
|
||||||
#include <QCoreApplication>
|
#include <QDBusMessage>
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
InstanceService::InstanceService(QString instanceId, QString application, QString systemdUnitPath, QString launcher)
|
InstanceService::InstanceService(QString instanceId, QString application, QString systemdUnitPath, QString launcher)
|
||||||
: m_Launcher(std::move(launcher))
|
: m_Launcher(std::move(launcher))
|
||||||
@ -16,3 +18,18 @@ InstanceService::InstanceService(QString instanceId, QString application, QStrin
|
|||||||
}
|
}
|
||||||
|
|
||||||
InstanceService::~InstanceService() = default;
|
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());
|
||||||
|
}
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDBusObjectPath>
|
#include <QDBusObjectPath>
|
||||||
|
#include <QDBusContext>
|
||||||
|
|
||||||
class InstanceService : public QObject
|
class InstanceService : public QObject, protected QDBusContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -25,6 +26,9 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] const QString &instanceId() const noexcept { return m_instanceId; }
|
[[nodiscard]] const QString &instanceId() const noexcept { return m_instanceId; }
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void KillAll(int signal);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void orphanedChanged();
|
void orphanedChanged();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user