QtService
1.1.0
A platform independent library to easily create system services and use some of their features
|
A QML singleton to create service controls and access the service instance. More...
#include <qmlservicesingleton.h>
Public Member Functions | |
Q_INVOKABLE QtService::ServiceControl * | createControl (const QString &backend, QString serviceId, QObject *parent=nullptr) const |
Creates a new ServiceControl for the given service on the service manager defined by backend. More... | |
Q_INVOKABLE QtService::ServiceControl * | createControlFromName (const QString &backend, const QString &serviceName, QObject *parent=nullptr) const |
Creates a new ServiceControl by guessing the service id from the given name and this applications domain. More... | |
Q_INVOKABLE QtService::ServiceControl * | createControlFromName (const QString &backend, const QString &serviceName, const QString &domain, QObject *parent=nullptr) const |
Creates a new ServiceControl by guessing the service id from the given name and domain. More... | |
Properties | |
QtService::Service | service |
A reference to the current service instance, if accessed from within a service. More... | |
A QML singleton to create service controls and access the service instance.
Definition at line 18 of file qmlservicesingleton.h.
Q_INVOKABLE QtService::ServiceControl* de::skycoder42::QtService::QtService::createControl | ( | const QString & | backend, |
QString | serviceId, | ||
QObject * | parent = nullptr |
||
) | const |
Creates a new ServiceControl for the given service on the service manager defined by backend.
backend | The backend to create a control from |
serviceId | The id of the service to control |
parent | The parent object of the new control |
QException | In 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
Q_INVOKABLE QtService::ServiceControl* de::skycoder42::QtService::QtService::createControlFromName | ( | const QString & | backend, |
const QString & | serviceName, | ||
QObject * | parent = nullptr |
||
) | const |
Creates a new ServiceControl by guessing the service id from the given name and this applications domain.
backend | The backend to create a control from |
serviceName | The generic name of the service to control |
parent | The parent object of the new control |
QException | In 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
Q_INVOKABLE QtService::ServiceControl* de::skycoder42::QtService::QtService::createControlFromName | ( | const QString & | backend, |
const QString & | serviceName, | ||
const QString & | domain, | ||
QObject * | parent = nullptr |
||
) | const |
Creates a new ServiceControl by guessing the service id from the given name and domain.
domain | The domain of the service, instead of the domain of this application |
backend | The backend to create a control from |
serviceName | The generic name of the service to control |
parent | The parent object of the new control |
QException | In 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
|
read |
A reference to the current service instance, if accessed from within a service.
Default: nullptr
If you are using qml in a service, you can use this property to get a reference to the current service instance. If not used from within a service, nullptr is returned.
Accessors | |
---|---|
MEMBER | service |
READ-ONLY | |
CONSTANT |
Definition at line 42 of file qmlservicesingleton.h.