File indexing completed on 2024-05-19 15:15:29
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2020 Henri Chain <henri.chain@enioka.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef SYSTEMDPROCESSRUNNER_H 0009 #define SYSTEMDPROCESSRUNNER_H 0010 #include "kprocessrunner_p.h" 0011 0012 class OrgFreedesktopSystemd1ManagerInterface; 0013 class OrgFreedesktopDBusPropertiesInterface; 0014 class QDBusObjectPath; 0015 class QDBusPendingCallWatcher; 0016 0017 const auto systemdService = QStringLiteral("org.freedesktop.systemd1"); 0018 const auto systemdPath = QStringLiteral("/org/freedesktop/systemd1"); 0019 0020 class SystemdProcessRunner : public KProcessRunner 0021 { 0022 Q_OBJECT 0023 0024 public: 0025 explicit SystemdProcessRunner(); 0026 void startProcess() override; 0027 bool waitForStarted(int timeout) override; 0028 static bool isAvailable(); 0029 0030 private: 0031 void handleProperties(QDBusPendingCallWatcher *watcher); 0032 void handleUnitNew(const QString &newName, const QDBusObjectPath &newPath); 0033 void systemdError(const QString &error); 0034 0035 bool m_exited = false; 0036 QString m_serviceName; 0037 QString m_servicePath; 0038 QString m_jobPath; 0039 OrgFreedesktopSystemd1ManagerInterface *m_manager = nullptr; 0040 OrgFreedesktopDBusPropertiesInterface *m_serviceProperties = nullptr; 0041 }; 0042 #endif // SYSTEMDPROCESSRUNNER_H