1 #ifndef QTSERVICE_SERVICECONTROL_H 2 #define QTSERVICE_SERVICECONTROL_H 4 #include <QtCore/qobject.h> 5 #include <QtCore/qscopedpointer.h> 6 #include <QtCore/qdir.h> 7 #include <QtCore/qvariant.h> 8 #include <QtCore/qexception.h> 10 #include "QtService/qtservice_global.h" 14 class ServiceControlPrivate;
21 Q_PROPERTY(
QString backend READ backend CONSTANT)
23 Q_PROPERTY(
QString serviceId READ serviceId CONSTANT)
28 Q_PROPERTY(
bool blocking READ isBlocking WRITE setBlocking NOTIFY blockingChanged)
31 Q_PROPERTY(
QString error READ error RESET clearError NOTIFY errorChanged)
36 SupportsStart = 0x0001,
37 SupportsStop = 0x0002,
38 SupportsPause = 0x0004,
39 SupportsResume = 0x0008,
40 SupportsReload = 0x0010,
41 SupportsGetAutostart = 0x0020,
42 SupportsSetAutostart = 0x0040,
43 SupportsBlocking = 0x0080,
44 SupportsNonBlocking = 0x0100,
46 SupportsStatus = 0x0200,
47 SupportsCustomCommands = 0x0400,
49 SupportsStartStop = (SupportsStart | SupportsStop),
50 SupportsPauseResume = (SupportsPause | SupportsResume),
51 SupportsAutostart = (SupportsGetAutostart | SupportsSetAutostart),
52 SupportsBlockingNonBlocking = (SupportsBlocking | SupportsNonBlocking)
54 Q_DECLARE_FLAGS(SupportFlags, SupportFlag)
59 ServiceStatusUnknown = 0,
89 virtual QString backend()
const = 0;
93 virtual SupportFlags supportFlags()
const = 0;
95 bool isBlocking()
const;
100 Q_INVOKABLE
virtual QVariant callGenericCommand(
const QByteArray &kind,
const QVariantList &args = {});
112 template <
typename TRet,
typename... TArgs>
113 TRet callCommand(
const QByteArray &kind, TArgs... args);
123 template <
typename... TArgs>
124 void callCommand(
const QByteArray &kind, TArgs... args);
127 Q_INVOKABLE
virtual bool serviceExists()
const = 0;
131 Q_INVOKABLE
virtual bool isAutostartEnabled()
const;
133 Q_INVOKABLE
QDir runtimeDir()
const;
137 virtual bool start();
142 virtual bool pause();
144 virtual bool resume();
147 virtual bool reload();
150 virtual bool enableAutostart();
152 virtual bool disableAutostart();
155 void setBlocking(
bool blocking);
161 void blockingChanged(
bool blocking, QPrivateSignal);
163 void errorChanged(
QString error, QPrivateSignal);
167 virtual QString serviceName()
const;
170 void setError(
QString error)
const;
178 template<
typename TRet,
typename... TArgs>
184 template<
typename... TArgs>
192 Q_DECLARE_OPERATORS_FOR_FLAGS(QtService::ServiceControl::SupportFlags)
194 #endif // QTSERVICE_SERVICECONTROL_H
ServiceStatus
The different states a service can be in.
The service is currently trying to resume.
The service is currently reloading it's configuration.
The service is not running.
The primary namespace of the QtService library.
QVariant fromValue(const T &value)
A class to interact with the systems service manager.
The service is currently trying to start.
SupportFlag
Flags that indicate what kind of queries and commands the specific control implementation provides...
The service is currently trying to stop.
The service is currently trying to pause.
TRet callCommand(const QByteArray &kind, TArgs... args)
Calls the command of kind with the given arguments and returns it's result.
virtual Q_INVOKABLE QVariant callGenericCommand(const QByteArray &kind, const QVariantList &args={})
Calls the command of kind with the given arguments and returns it's result.