QtService  1.1.0
A platform independent library to easily create system services and use some of their features
Public Member Functions | Properties | List of all members
de::skycoder42::QtService::QtService Class Reference

A QML singleton to create service controls and access the service instance. More...

#include <qmlservicesingleton.h>

+ Inheritance diagram for de::skycoder42::QtService::QtService:

Public Member Functions

Q_INVOKABLE QtService::ServiceControlcreateControl (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::ServiceControlcreateControlFromName (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::ServiceControlcreateControlFromName (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...
 

Detailed Description

A QML singleton to create service controls and access the service instance.

Since
1.0
See also
QtService::Service, QtService::ServiceControl

Definition at line 18 of file qmlservicesingleton.h.

Member Function Documentation

◆ createControl()

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.

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

◆ createControlFromName() [1/2]

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.

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

◆ createControlFromName() [2/2]

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.

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

Property Documentation

◆ service

QtService::Service de::skycoder42::QtService::QtService::service
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
MEMBERservice
READ-ONLY
CONSTANT
See also
QtService::Service

Definition at line 42 of file qmlservicesingleton.h.


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