From 0f3d090bd1dc9a6b912eb0b1e587602573304b4a Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 17 Feb 2016 20:41:52 +0100 Subject: First attempt at QML hacking. Main and ServiceControl adapted. Project files --- rockwork/servicecontrol.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'rockwork/servicecontrol.h') diff --git a/rockwork/servicecontrol.h b/rockwork/servicecontrol.h index 4689506..ebab061 100644 --- a/rockwork/servicecontrol.h +++ b/rockwork/servicecontrol.h @@ -1,38 +1,37 @@ #ifndef SERVICECONTROL_H #define SERVICECONTROL_H +#include #include +static const QString ROCKPOOLD_SYSTEMD_UNIT("rockpoold.service"); + class ServiceControl : public QObject { Q_OBJECT - Q_PROPERTY(QString serviceName READ serviceName WRITE setServiceName NOTIFY serviceNameChanged) - Q_PROPERTY(bool serviceFileInstalled READ serviceFileInstalled NOTIFY serviceFileInstalledChanged) Q_PROPERTY(bool serviceRunning READ serviceRunning WRITE setServiceRunning NOTIFY serviceRunningChanged) public: explicit ServiceControl(QObject *parent = 0); - QString serviceName() const; - void setServiceName(const QString &serviceName); - - bool serviceFileInstalled() const; - Q_INVOKABLE bool installServiceFile(); - Q_INVOKABLE bool removeServiceFile(); - bool serviceRunning() const; bool setServiceRunning(bool running); Q_INVOKABLE bool startService(); Q_INVOKABLE bool stopService(); Q_INVOKABLE bool restartService(); +private slots: + void getUnitProperties(); + void onPropertiesChanged(QString interface, QMap changed, QStringList invalidated); + signals: - void serviceNameChanged(); - void serviceFileInstalledChanged(); void serviceRunningChanged(); private: - QString m_serviceName; + QDBusInterface *systemd; + QDBusObjectPath unitPath; + QVariantMap unitProperties; + }; #endif // SERVICECONTROL_H -- cgit v1.2.3