| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2020 Henri Chain <henri.chain@enioka.com> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #ifndef SYSTEMDPROCESSRUNNER_H |
| 9 | #define SYSTEMDPROCESSRUNNER_H |
| 10 | #include "kprocessrunner_p.h" |
| 11 | |
| 12 | class OrgFreedesktopSystemd1ManagerInterface; |
| 13 | class OrgFreedesktopDBusPropertiesInterface; |
| 14 | class QDBusObjectPath; |
| 15 | class QDBusPendingCallWatcher; |
| 16 | |
| 17 | const auto systemdService = QStringLiteral("org.freedesktop.systemd1" ); |
| 18 | const auto systemdPath = QStringLiteral("/org/freedesktop/systemd1" ); |
| 19 | |
| 20 | class SystemdProcessRunner : public KProcessRunner |
| 21 | { |
| 22 | Q_OBJECT |
| 23 | |
| 24 | public: |
| 25 | explicit SystemdProcessRunner(); |
| 26 | void startProcess() override; |
| 27 | bool waitForStarted(int timeout) override; |
| 28 | static KProcessRunner::LaunchMode modeAvailable(); |
| 29 | |
| 30 | private: |
| 31 | void handleProperties(QDBusPendingCallWatcher *watcher); |
| 32 | void handleUnitNew(const QString &newName, const QDBusObjectPath &newPath); |
| 33 | void systemdError(const QString &error); |
| 34 | |
| 35 | bool m_exited = false; |
| 36 | QString m_serviceName; |
| 37 | QString m_servicePath; |
| 38 | QString m_jobPath; |
| 39 | OrgFreedesktopSystemd1ManagerInterface *m_manager = nullptr; |
| 40 | OrgFreedesktopDBusPropertiesInterface *m_serviceProperties = nullptr; |
| 41 | }; |
| 42 | #endif // SYSTEMDPROCESSRUNNER_H |
| 43 | |