QtService  1.1.0
A platform independent library to easily create system services and use some of their features
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | List of all members
QtService::ServiceControl Class Referenceabstract

A class to interact with the systems service manager. More...

#include <servicecontrol.h>

+ Inheritance diagram for QtService::ServiceControl:

Public Types

enum  SupportFlag {
  SupportsStart = 0x0001, SupportsStop = 0x0002, SupportsPause = 0x0004, SupportsResume = 0x0008,
  SupportsReload = 0x0010, SupportsGetAutostart = 0x0020, SupportsSetAutostart = 0x0040, SupportsBlocking = 0x0080,
  SupportsNonBlocking = 0x0100, SupportsStatus = 0x0200, SupportsCustomCommands = 0x0400, SupportsStartStop = (SupportsStart | SupportsStop),
  SupportsPauseResume = (SupportsPause | SupportsResume), SupportsAutostart = (SupportsGetAutostart | SupportsSetAutostart), SupportsBlockingNonBlocking = (SupportsBlocking | SupportsNonBlocking)
}
 Flags that indicate what kind of queries and commands the specific control implementation provides. More...
 
enum  ServiceStatus {
  ServiceStatusUnknown = 0, ServiceStopped, ServiceStarting, ServiceRunning,
  ServicePausing, ServicePaused, ServiceResuming, ServiceReloading,
  ServiceStopping, ServiceErrored
}
 The different states a service can be in. More...
 

Public Slots

virtual bool start ()
 Send a start command for the controls service to the service manager. More...
 
virtual bool stop ()
 Send a stop command for the controls service to the service manager. More...
 
virtual bool pause ()
 Send a pause command for the controls service to the service manager. More...
 
virtual bool resume ()
 Send a resume command for the controls service to the service manager. More...
 
virtual bool reload ()
 Send a reload command for the controls service to the service manager. More...
 
virtual bool enableAutostart ()
 Enables autostart for the controls service. More...
 
virtual bool disableAutostart ()
 Disables autostart for the controls service. More...
 
void setBlocking (bool blocking)
 WRITE accessor for ServiceControl::blocking.
 
void clearError ()
 RESET accessor for ServiceControl::error.
 

Signals

void blockingChanged (bool blocking, QPrivateSignal)
 NOTIFY accessor for ServiceControl::blocking.
 
void errorChanged (QString error, QPrivateSignal)
 NOTIFY accessor for ServiceControl::error.
 

Public Member Functions

virtual QString backend () const =0
 READ accessor for ServiceControl::backend.
 
QString serviceId () const
 READ accessor for ServiceControl::serviceId.
 
virtual SupportFlags supportFlags () const =0
 READ accessor for ServiceControl::supportFlags.
 
bool isBlocking () const
 READ accessor for ServiceControl::blocking.
 
QString error () const
 READ accessor for ServiceControl::error.
 
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. More...
 
template<typename TRet , typename... TArgs>
TRet callCommand (const QByteArray &kind, TArgs... args)
 Calls the command of kind with the given arguments and returns it's result. More...
 
template<typename... TArgs>
void callCommand (const QByteArray &kind, TArgs... args)
 Calls the command of kind with the given arguments and returns it's result. More...
 
virtual Q_INVOKABLE bool serviceExists () const =0
 Checks if the service this control was created for actually exists. More...
 
virtual Q_INVOKABLE QtService::ServiceControl::ServiceStatus status () const
 Returns the current status of the service. More...
 
virtual Q_INVOKABLE bool isAutostartEnabled () const
 Returns the current autostart state of the service. More...
 
Q_INVOKABLE QDir runtimeDir () const
 Returns the runtime directory of this controls service. More...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
virtual void * qt_metacast (const char *)
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 

Static Public Member Functions

static QStringList listBackends ()
 Returns a list of all available backends.
 
static QString likelyBackend ()
 Returns the backend that is most likely to be used on the current platform. More...
 
static ServiceControlcreate (const QString &backend, QString serviceId, QObject *parent=nullptr)
 Creates a new ServiceControl for the given service on the service manager defined by backend. More...
 
static ServiceControlcreateFromName (const QString &backend, const QString &serviceName, QObject *parent=nullptr)
 Creates a new ServiceControl by guessing the service id from the given name and this applications domain. More...
 
static ServiceControlcreateFromName (const QString &backend, const QString &serviceName, const QString &domain, QObject *parent=nullptr)
 Creates a new ServiceControl by guessing the service id from the given name and domain. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Protected Member Functions

virtual QString serviceName () const
 Returns the common name of the controls service. More...
 
void setError (QString error) const
 WRITE accessor for ServiceControl::error.
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Properties

QString backend
 The service backend this control interacts with. More...
 
QString serviceId
 The ID of the service this control manages. More...
 
QtService::ServiceControl::SupportFlags supportFlags
 The features that this implementation supports. More...
 
bool blocking
 Specifies if service control commands are blocking. More...
 
QString error
 A string describing the last error that occured. More...
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A class to interact with the systems service manager.

This class can be used to get information about a specific service and control it by sending service commands to it through the service manager. This can be used for all services of the corresponding manager, not only services created by this library.

The concrete instances are implemented by each service backend plugin, thus the creation via a helper method.

Attention
Not all service backends support all kinds of service operations. This class is a common interface, but to find out which methods actually work, you need to query the ServiceControl::supportFlags property for a concrete backend. Those flags however are typically (but not neccessarily) static per plugin. You can check the what each backends implementation supports on the Supported Service Backends page.
See also
Supported Service Backends, ServiceControl::supportFlags

Definition at line 16 of file servicecontrol.h.

Member Enumeration Documentation

◆ ServiceStatus

The different states a service can be in.

Enumerator
ServiceStatusUnknown 

The control is unable to determine the services state.

ServiceStopped 

The service is not running.

ServiceStarting 

The service is currently trying to start.

ServiceRunning 

The service is running.

ServicePausing 

The service is currently trying to pause.

ServicePaused 

The service is paused.

ServiceResuming 

The service is currently trying to resume.

ServiceReloading 

The service is currently reloading it's configuration.

ServiceStopping 

The service is currently trying to stop.

ServiceErrored 

The service is not running and exited in an error state.

Definition at line 58 of file servicecontrol.h.

◆ SupportFlag

Flags that indicate what kind of queries and commands the specific control implementation provides.

Enumerator
SupportsStart 

Can start services via ServiceControl::start.

SupportsStop 

Can stop services via ServiceControl::stop.

SupportsPause 

Can pause services via ServiceControl::pause.

SupportsResume 

Can resume services via ServiceControl::resume.

SupportsReload 

Can reload services via ServiceControl::reload.

SupportsGetAutostart 

Can read the autostart state of a service.

SupportsSetAutostart 

Can write the autostart state of a service.

SupportsBlocking 

Supports service commands that block for the execution.

SupportsNonBlocking 

Supports service commands the only trigger execution without blocking.

SupportsStatus 

Can read the current status of a service.

SupportsCustomCommands 

Supports the execution of specific custom commands.

SupportsStartStop 

SupportsStart | SupportsStop.

SupportsPauseResume 

SupportsPause | SupportsResume.

SupportsAutostart 

SupportsGetAutostart | SupportsSetAutostart.

SupportsBlockingNonBlocking 

SupportsBlocking | SupportsNonBlocking.

Definition at line 35 of file servicecontrol.h.

Member Function Documentation

◆ callCommand() [1/2]

template<typename TRet , typename... TArgs>
TRet QtService::ServiceControl::callCommand ( const QByteArray kind,
TArgs...  args 
)

Calls the command of kind with the given arguments and returns it's result.

Template Parameters
TRetThe return value of the command
TArgsThe arguments passed to the command
Parameters
kindThe kind of command to be called
argsThe arguments of the command
Returns
The return of the command

Custom commands can only be used if the control supports the ServiceControl::SupportsCustomCommands flag is set. If the operation is not supported, an invalid variant will be returned and ServiceControl::error is set.

This method can be used to execute a custom command, i.e. one that is not a standard command. Each backend can define it's own custom commands. The kind is what should be done and the arguments are parameters for the execution of that command. The command will follow the standard blocking rules and return a value of whatever kind.

The commands that are possible are defined by each backend. For the standard backends you can find the commans on the Supported Service Backends Page.

This generic variant will automatically convert the arguments to variant types and pass the to the callGenericCommand() method.

See also
Supported Service Backends, ServiceControl::callGenericCommand, ServiceControl::blocking, Service::onCallback, Service::addCallback

Definition at line 179 of file servicecontrol.h.

◆ callCommand() [2/2]

template<typename... TArgs>
void QtService::ServiceControl::callCommand ( const QByteArray kind,
TArgs...  args 
)

Calls the command of kind with the given arguments and returns it's result.

Template Parameters
TArgsThe arguments passed to the command
Parameters
kindThe kind of command to be called
argsThe arguments of the command
Returns
The return of the command

Custom commands can only be used if the control supports the ServiceControl::SupportsCustomCommands flag is set. If the operation is not supported, an invalid variant will be returned and ServiceControl::error is set.

This method can be used to execute a custom command, i.e. one that is not a standard command. Each backend can define it's own custom commands. The kind is what should be done and the arguments are parameters for the execution of that command. The command will follow the standard blocking rules and return a value of whatever kind.

The commands that are possible are defined by each backend. For the standard backends you can find the commans on the Supported Service Backends Page.

This generic variant will automatically convert the arguments to variant types and pass the to the callGenericCommand() method.

See also
Supported Service Backends, ServiceControl::callGenericCommand, ServiceControl::blocking, Service::onCallback, Service::addCallback

Definition at line 185 of file servicecontrol.h.

◆ callGenericCommand()

QtService::ServiceControl::callGenericCommand ( const QByteArray kind,
const QVariantList &  args = {} 
)
virtual

Calls the command of kind with the given arguments and returns it's result.

Parameters
kindThe kind of command to be called
argsThe arguments of the command
Returns
The return of the command

Custom commands can only be used if the control supports the ServiceControl::SupportsCustomCommands flag is set. If the operation is not supported, an invalid variant will be returned and ServiceControl::error is set.

This method can be used to execute a custom command, i.e. one that is not a standard command. Each backend can define it's own custom commands. The kind is what should be done and the arguments are parameters for the execution of that command. The command will follow the standard blocking rules and return a value of whatever kind.

The commands that are possible are defined by each backend. For the standard backends you can find the commans on the Supported Service Backends Page.

◆ create()

QtService::ServiceControl::create ( const QString backend,
QString  serviceId,
QObject parent = nullptr 
)
static

Creates a new ServiceControl for the given service on the service manager defined by backend.

Parameters
backendThe backend to create a control from
serviceIdThe id of the service to control
parentThe parent object of the new control
Returns
The newly created backend, or nullptr
Exceptions
QExceptionIn case loading fails

Uses the plugin defined by backend to create a service control for the given service. If no plugin can be found that provides this backend, nullptr is returned. If a plugin was found, but actually loading it and creating the control failed, an exception is thrown.

The returned instance is owned by the caller. To check if the control operates on a valid service, use ServiceControl::serviceExists

See also
ServiceControl::createFromName, ServiceControl::serviceExists, ServiceControl::supportFlags, ServiceControl::likelyBackend

◆ createFromName() [1/2]

QtService::ServiceControl::createFromName ( const QString backend,
const QString serviceName,
QObject parent = nullptr 
)
static

Creates a new ServiceControl by guessing the service id from the given name and this applications domain.

Parameters
backendThe backend to create a control from
serviceNameThe generic name of the service to control
parentThe parent object of the new control
Returns
The newly created backend, or nullptr
Exceptions
QExceptionIn case loading fails

Uses the plugin defined by backend to create a service control for the given service. If no plugin can be found that provides this backend, nullptr is returned. If a plugin was found, but actually loading it and creating the control failed, an exception is thrown.

The service identity is derived from the name and domain. The actual method depends on the backend:

Backend Deriviation method
standard Searches for an executable named <serviceName> next to the app and in the path
systemd First tries <domain>.<serviceName>.service, if not found <serviceName>.service
windows Simply <serviceName>
launchd Uses <domain>.<serviceName>
android Generates the java class name <domain>.<serviceName>

The returned instance is owned by the caller. To check if the control operates on a valid service, use ServiceControl::serviceExists

See also
ServiceControl::create, mServiceControl::serviceExists, ServiceControl::supportFlags, ServiceControl::likelyBackend

◆ createFromName() [2/2]

QtService::ServiceControl::createFromName ( const QString backend,
const QString serviceName,
const QString domain,
QObject parent = nullptr 
)
static

Creates a new ServiceControl by guessing the service id from the given name and domain.

Parameters
domainThe domain of the service, instead of the domain of this application
backendThe backend to create a control from
serviceNameThe generic name of the service to control
parentThe parent object of the new control
Returns
The newly created backend, or nullptr
Exceptions
QExceptionIn case loading fails

Uses the plugin defined by backend to create a service control for the given service. If no plugin can be found that provides this backend, nullptr is returned. If a plugin was found, but actually loading it and creating the control failed, an exception is thrown.

The service identity is derived from the name and domain. The actual method depends on the backend:

Backend Deriviation method
standard Searches for an executable named <serviceName> next to the app and in the path
systemd First tries <domain>.<serviceName>.service, if not found <serviceName>.service
windows Simply <serviceName>
launchd Uses <domain>.<serviceName>
android Generates the java class name <domain>.<serviceName>

The returned instance is owned by the caller. To check if the control operates on a valid service, use ServiceControl::serviceExists

See also
ServiceControl::create, mServiceControl::serviceExists, ServiceControl::supportFlags, ServiceControl::likelyBackend

◆ disableAutostart

QtService::ServiceControl::disableAutostart ( )
virtualslot

Disables autostart for the controls service.

Returns
true if autostart was disabled, false if not

The command can only be used if the control supports the ServiceControl::SupportsSetAutostart flag is set. If the operation is not supported, false will be returned and ServiceControl::error is set.

The method will only set the autostart state. This will not stop a service that is currently running.

See also
ServiceControl::SupportsSetAutostart, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::enableAutostart, ServiceControl::isAutostartEnabled

◆ enableAutostart

QtService::ServiceControl::enableAutostart ( )
virtualslot

Enables autostart for the controls service.

Returns
true if autostart was enabled, false if not

The command can only be used if the control supports the ServiceControl::SupportsSetAutostart flag is set. If the operation is not supported, false will be returned and ServiceControl::error is set.

The method will only set the autostart state. This will not start a service that is currently not running.

See also
ServiceControl::SupportsSetAutostart, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::disableAutostart, ServiceControl::isAutostartEnabled

◆ isAutostartEnabled()

QtService::ServiceControl::isAutostartEnabled ( ) const
virtual

Returns the current autostart state of the service.

Returns
true if the service will start automatically with the system, false if not

The status can only be returned if the control supports the ServiceControl::SupportsGetAutostart flag is set.

Note
When using socket activation, the autostart is reported as false, as the service itself will not start until someone tries to connect to the socket. So activated services should not be autostart enabled. Instead try to connect to them, and if it fails start them explicitly.

A backend should query the manager from this method in a synchronous manner to get and return the autostart status. If the backend fails to find out, ServiceControl::setError can be used to set an error string and false should be returned.

See also
ServiceControl::SupportsGetAutostart, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::enableAutostart, ServiceControl::disableAutostart

◆ likelyBackend()

QtService::ServiceControl::likelyBackend ( )
static

Returns the backend that is most likely to be used on the current platform.

Returns
The most likely backend for the current platform
Platform Backend
Android android
Linux systemd
Windows windows
MacOs launchd
Others standard
See also
ServiceControl::listBackends, ServiceControl::create

◆ pause

QtService::ServiceControl::pause ( )
virtualslot

Send a pause command for the controls service to the service manager.

Returns
true if successfully paused, false if not

The command can only be used if the control supports the ServiceControl::SupportsPause flag is set. If the operation is not supported, false will be returned and ServiceControl::error is set.

The command will follow the standard blocking rules and return true either after successfully pausing or dispatching the pause command.

See also
ServiceControl::SupportsPause, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::blocking, ServiceControl::resume

◆ reload

QtService::ServiceControl::reload ( )
virtualslot

Send a reload command for the controls service to the service manager.

Returns
true if successfully reloaded, false if not

The command can only be used if the control supports the ServiceControl::SupportsReload flag is set. If the operation is not supported, false will be returned and ServiceControl::error is set.

The command will follow the standard blocking rules and return true either after successfully reloading or dispatching the reload command.

See also
ServiceControl::SupportsReload, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::blocking

◆ resume

QtService::ServiceControl::resume ( )
virtualslot

Send a resume command for the controls service to the service manager.

Returns
true if successfully resumed, false if not

The command can only be used if the control supports the ServiceControl::SupportsResume flag is set. If the operation is not supported, false will be returned and ServiceControl::error is set.

The command will follow the standard blocking rules and return true either after successfully resuming or dispatching the resume command.

See also
ServiceControl::SupportsResume, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::blocking, ServiceControl::pause

◆ runtimeDir()

QtService::ServiceControl::runtimeDir ( ) const

Returns the runtime directory of this controls service.

Returns
The runtime directory to be used to place sockets, lockfiles and other temporary stuff

This directoy is determined by the service engine to find the runtime directory of a service on each platform. This should always be the same value as the Service::runtimeDir for the service controlled by this instance.

See also
Service::runtimeDir

◆ serviceExists()

QtService::ServiceControl::serviceExists ( ) const
pure virtual

Checks if the service this control was created for actually exists.

Returns
true if the service exists, false if not

This method uses the service backend to perform a check whether the service defined by ServiceControl::serviceId actually exists. On errors, ServiceControl::error will be set.

For backends that cannot determine this they should simply always return true. If the backend fails to find out, ServiceControl::setError can be used to set an error string.

See also
ServiceControl::serviceId, ServiceControl::error

◆ serviceName()

QtService::ServiceControl::serviceName ( ) const
protectedvirtual

Returns the common name of the controls service.

Returns
The services common name

This should be the QCoreApplication::name of the target service. This however is only a guessed value and is only valid if the service follows the standard naming rules.

See also
ServiceControl::serviceId

◆ start

QtService::ServiceControl::start ( )
virtualslot

Send a start command for the controls service to the service manager.

Returns
true if successfully started, false if not

The command can only be used if the control supports the ServiceControl::SupportsStart flag is set. If the operation is not supported, false will be returned and ServiceControl::error is set.

The command will follow the standard blocking rules and return true either after successfully starting or dispatching the start command.

See also
ServiceControl::SupportsStart, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::blocking, ServiceControl::stop

◆ status()

QtService::ServiceControl::status ( ) const
virtual

Returns the current status of the service.

Returns
The current status of the service

The status can only be returned if the control supports the ServiceControl::SupportsStatus flag is set. The kinds of status returned differ on the capabilities of each service manager. If the operation is not supported, ServiceControl::ServiceStatusUnknown will be returned and ServiceControl::error is set.

A backend should query the manager from this method in a synchronous manner to get and return the service status. If the backend fails to find out, ServiceControl::setError can be used to set an error string and ServiceControl::ServiceStatusUnknown should be returned to indicate the error.

See also
ServiceControl::SupportsStatus, ServiceControl::supportFlags, ServiceControl::error

◆ stop

QtService::ServiceControl::stop ( )
virtualslot

Send a stop command for the controls service to the service manager.

Returns
true if successfully stopped, false if not

The command can only be used if the control supports the ServiceControl::SupportsStop flag is set. If the operation is not supported, false will be returned and ServiceControl::error is set.

The command will follow the standard blocking rules and return true either after successfully stopping or dispatching the stop command.

See also
ServiceControl::SupportsStop, ServiceControl::supportFlags, ServiceControl::error, ServiceControl::blocking, ServiceControl::start

Property Documentation

◆ backend

QtService::ServiceControl::backend
read

The service backend this control interacts with.

Default: Set on creation

This is simply the backend this control was created by. Typically this is exactly the same as what was passed to the ServiceControl::create function - allthough for backends that have multiple names this may not be the case.

Accessors
READbackend()
CONSTANT
See also
ServiceControl::create, ServiceControl::serviceId

Definition at line 21 of file servicecontrol.h.

◆ blocking

QtService::ServiceControl::blocking
readwrite

Specifies if service control commands are blocking.

Default: supportFlags().testFlag(SupportsBlocking)

Whether a backend supports either of those modes depends on the support flags. The following combinations are possible:

SupportsBlocking SupportsNonBlocking Behaviour
yes yes The behaviour of all commands is determined by this property
yes no This property is ignored - services will always behave blocking
no yes This property is ignored - services will always behave non blocking
no no This property is ignored - the services behaviour is undefined - some methods may be blocking, other unblocking

If commands are blocking, it means that the control won't return from a command until it's execution has been completed. So if you for example start a service in blocking mode, the method will return only after the service reached the running state or error. In this case the method will return the actual result of the operation.

In nonblocking mode the command is only dispatched to the service manager and true is returned if the manager accepted the command. You will have to use ServiceControl::status to check the services state, if available.

Accessors
READisBlocking()
WRITEsetBlocking()
NOTIFYblockingChanged()
See also
ServiceControl::SupportsBlocking, ServiceControl::SupportsNonBlocking

Definition at line 28 of file servicecontrol.h.

◆ error

QtService::ServiceControl::error
read

A string describing the last error that occured.

Default: null string

This error can be set form the implementations in case an operation or query failed. It is a localized string describing what went wrong. The error message is not cleared automatically. Use clearError() to clear it.

Use setError() to set an error from the implementation

Accessors
READerror()
RESETclearError()
NOTIFYerrorChanged()
See also
ServiceControl::setError

Definition at line 31 of file servicecontrol.h.

◆ serviceId

QtService::ServiceControl::serviceId
read

The ID of the service this control manages.

Default: Set on creation

This is simply the service id this control was created by. Typically this is exactly the same as what was passed to the ServiceControl::create function, but backends may normalize the name if applicable.

Accessors
READserviceId()
CONSTANT
See also
ServiceControl::create, ServiceControl::backend

Definition at line 23 of file servicecontrol.h.

◆ supportFlags

QtService::ServiceControl::supportFlags
read

The features that this implementation supports.

Default: Depends on backend

The support flags indicate what this concrete implementation is capable of doing. The flags returned depend on the backend and should be checked before performing an operation, as performing an unsupported operation will cause an error.

Accessors
READsupportFlags()
CONSTANT
See also
ServiceControl::backend, ServiceControl::SupportFlag, ServiceControl::create

Definition at line 26 of file servicecontrol.h.


The documentation for this class was generated from the following files: