Plasma5Support::Service

Search for usage in LXR

Plasma5Support::Service Class Referenceabstract

#include <Plasma5Support/Service>

Inheritance diagram for Plasma5Support::Service:

Properties

QString destination
 
QString name
 
QStringList operationNames
 
- Properties inherited from QObject
 objectName
 

Signals

void operationEnabledChanged (const QString &operation, bool enabled)
 
void serviceReady (Plasma5Support::Service *service)
 

Public Member Functions

 ~Service ()
 
Q_INVOKABLE QString destination () const
 
Q_INVOKABLE bool isOperationEnabled (const QString &operation) const
 
Q_INVOKABLE QString name () const
 
Q_INVOKABLE QVariantMap operationDescription (const QString &operationName)
 
Q_INVOKABLE QStringList operationNames () const
 
Q_INVOKABLE void setDestination (const QString &destination)
 
Q_INVOKABLE ServiceJobstartOperationCall (const QVariantMap &description, QObject *parent=nullptr)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

 Service (QObject *parent=nullptr)
 
virtual ServiceJobcreateJob (const QString &operation, QVariantMap &parameters)=0
 
virtual void registerOperationsScheme ()
 
void setName (const QString &name)
 
void setOperationEnabled (const QString &operation, bool enable)
 
void setOperationsScheme (QIODevice *xml)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from QObject
typedef  QObjectList
 
- Static Public Member Functions inherited from QObject
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 *context, Functor functor, 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)
 
bool disconnect (const QMetaObject::Connection &connection)
 
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 QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Detailed Description

This class provides a generic API for write access to settings or services.

Plasma5Support::Service allows interaction with a "destination", the definition of which depends on the Service itself. For a network settings Service this might be a profile name ("Home", "Office", "Road Warrior") while a web based Service this might be a username ("aseigo", "stranger65").

A Service provides one or more operations, each of which provides some sort of interaction with the destination. Operations are described using config XML which is used to create a KConfig object with one group per operation. The group names are used as the operation names, and the defined items in the group are the parameters available to be set when using that operation.

A service is started with a KConfigGroup (representing a ready to be serviced operation) and automatically deletes itself after completion and signaling success or failure. See KJob for more information on this part of the process.

Services may either be loaded "stand alone" from plugins, or from a DataEngine by passing in a source name to be used as the destination.

Sample use might look like:

Plasma5Support::DataEngine *twitter = dataEngine("twitter");
Plasma5Support::Service *service = twitter.serviceForSource("aseigo");
QVariantMap op = service->operationDescription("update");
op.insert("tweet", "Hacking on plasma!");
connect(job, SIGNAL(finished(KJob*)), this, SLOT(jobCompeted()));
Data provider for plasmoids (Plasma plugins)
Definition dataengine.h:45
virtual Q_INVOKABLE Service * serviceForSource(const QString &source)
This class provides jobs for use with Plasma5Support::Service.
Definition servicejob.h:39
This class provides a generic API for write access to settings or services.
Definition service.h:78
Q_INVOKABLE QVariantMap operationDescription(const QString &operationName)
Retrieves the parameters for a given operation.
Definition service.cpp:61
Q_INVOKABLE ServiceJob * startOperationCall(const QVariantMap &description, QObject *parent=nullptr)
Called to create a ServiceJob which is associated with a given operation and parameter set.
Definition service.cpp:75
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)

Please remember, the service needs to be deleted when it will no longer be used. This can be done manually or by these (perhaps easier) alternatives:

If it is needed throughout the lifetime of the object:

service->setParent(this);
void setParent(QObject *parent)

If the service will not be used after just one operation call, use:

connect(job, SIGNAL(finished(KJob*)), service, SLOT(deleteLater()));
void deleteLater()

Definition at line 77 of file service.h.

Property Documentation

◆ destination

QString Plasma5Support::Service::destination
readwrite

Definition at line 81 of file service.h.

◆ name

QString Plasma5Support::Service::name
read

Definition at line 83 of file service.h.

◆ operationNames

QStringList Plasma5Support::Service::operationNames
read

Definition at line 82 of file service.h.

Constructor & Destructor Documentation

◆ ~Service()

Plasma5Support::Service::~Service ( )

Destructor.

Definition at line 34 of file service.cpp.

◆ Service()

Plasma5Support::Service::Service ( QObject * parent = nullptr)
explicitprotected
Parameters
parentthe parent object for this service

Definition at line 28 of file service.cpp.

Member Function Documentation

◆ createJob()

virtual ServiceJob * Plasma5Support::Service::createJob ( const QString & operation,
QVariantMap & parameters )
protectedpure virtual

Called when a job should be created by the Service.

Parameters
operationwhich operation to work on
parametersthe parameters set by the user for the operation
Returns
a ServiceJob that can be started and monitored by the consumer

◆ destination()

QString Plasma5Support::Service::destination ( ) const
Returns
the target destination, if any, that this service is associated with

Definition at line 44 of file service.cpp.

◆ isOperationEnabled()

bool Plasma5Support::Service::isOperationEnabled ( const QString & operation) const

Query to find if an operation is enabled or not.

Parameters
operationthe name of the operation to check
Returns
true if the operation is enabled, false otherwise

Definition at line 141 of file service.cpp.

◆ name()

QString Plasma5Support::Service::name ( ) const

The name of this service.

Definition at line 109 of file service.cpp.

◆ operationDescription()

QVariantMap Plasma5Support::Service::operationDescription ( const QString & operationName)

Retrieves the parameters for a given operation.

Parameters
operationNamethe operation to retrieve parameters for
Returns
QVariantMap containing the parameters

Definition at line 61 of file service.cpp.

◆ operationEnabledChanged

void Plasma5Support::Service::operationEnabledChanged ( const QString & operation,
bool enabled )
signal

Emitted when an operation got enabled or disabled.

◆ operationNames()

QStringList Plasma5Support::Service::operationNames ( ) const
Returns
the possible operations for this profile

Definition at line 49 of file service.cpp.

◆ registerOperationsScheme()

void Plasma5Support::Service::registerOperationsScheme ( )
protectedvirtual

By default this is based on the file in plasma5support/services/name.operations, but can be reimplemented to use a different mechanism.

It should result in a call to setOperationsScheme(QIODevice *);

Definition at line 167 of file service.cpp.

◆ serviceReady

void Plasma5Support::Service::serviceReady ( Plasma5Support::Service * service)
signal

Emitted when this service is ready for use.

◆ setDestination()

void Plasma5Support::Service::setDestination ( const QString & destination)

Sets the destination for this Service to operate on.

Parameters
destinationspecific to each Service, this sets which target or address for ServiceJobs to operate on

Definition at line 39 of file service.cpp.

◆ setName()

void Plasma5Support::Service::setName ( const QString & name)
protected

Sets the name of the Service; useful for Services not loaded from plugins, which use the plugin name for this.

Parameters
namethe name to use for this service

Definition at line 114 of file service.cpp.

◆ setOperationEnabled()

void Plasma5Support::Service::setOperationEnabled ( const QString & operation,
bool enable )
protected

Enables a given service by name.

Parameters
operationthe name of the operation to enable or disable
enabletrue if the operation should be enabled, false if disabled

Definition at line 126 of file service.cpp.

◆ setOperationsScheme()

void Plasma5Support::Service::setOperationsScheme ( QIODevice * xml)
protected

Sets the XML used to define the operation schema for this Service.

Definition at line 146 of file service.cpp.

◆ startOperationCall()

ServiceJob * Plasma5Support::Service::startOperationCall ( const QVariantMap & description,
QObject * parent = nullptr )

Called to create a ServiceJob which is associated with a given operation and parameter set.

Returns
a started ServiceJob; the consumer may connect to relevant signals before returning to the event loop

Definition at line 75 of file service.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.