QtService
1.1.0
A platform independent library to easily create system services and use some of their features
|
The plugin interface to implement as primary interface of a servicebackend plugin. More...
#include <serviceplugin.h>
Public Member Functions | |
virtual QString | currentServiceId () const =0 |
Return the ID of the currently setup service. | |
virtual ServiceBackend * | createServiceBackend (const QString &backend, Service *service)=0 |
Create a new service backend for the given backend and service. More... | |
virtual ServiceControl * | createServiceControl (const QString &backend, QString &&serviceId, QObject *parent)=0 |
Create a new service backend for the given backend, name and parent. More... | |
Protected Member Functions | |
QPair< QString, QString > | detectNamedService (const QString &serviceId) const |
Check if the given service id is an encoded name and domain, and if yes decode them. More... | |
The plugin interface to implement as primary interface of a servicebackend plugin.
The plugin that must be implemented to create a Service plugin. The plugins IID is QtService_ServicePlugin_Iid. The plugin most have a json file with the following layout:
Each string in the Keys
array is the name of a kind of backend that is provided from that plugin. Most plugins provide only one type of backend, so for most cases you have only 1 element in the list. Please note that the plugin must be able to handle all these providers when passed to it's methods.
For more details on how to implement such a plugin, have a look at: The High-Level API: Writing Qt Extensions
Definition at line 14 of file serviceplugin.h.
|
pure virtual |
Create a new service backend for the given backend and service.
backend | The service manager backend to create a service for |
service | The service instance that will use the backend to run as a service |
This method is only called from the service instance to create the backend used to run the service. This method is called before any Qt-related stuff has been done - so there is not QCoreApplication yet.
|
pure virtual |
Create a new service backend for the given backend, name and parent.
backend | The service manager backend to create a control for |
serviceId | The identifier of the service to create the control for |
parent | The parent for the control. Should be set as the QObject::parent of the newly created control |
This method must be threadsafe
You should always return a valid backend for all valid providers and don't need to perform additional validity checks. It is save to return nullptr
in case the store cannot be created. The backends passed to this method are the ones defined in the json file.
|
protected |
Check if the given service id is an encoded name and domain, and if yes decode them.
This method was only introduced to keep binary compability. For now, it is used to differentiate between a service control created from the service id and one created from a name.
You should call this method at the beginning of createServiceControl(). If the pair is empty, you can assume an actual service id was passed and treat it like that. If the pair however does hold something and thus is not empty, first will be the services name and second the domain. You should then use these two to generate a valid service id and try to create a service control from it.