Plasma
service.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PLASMA_SERVICE_H
00021 #define PLASMA_SERVICE_H
00022
00023 #include <QtCore/QMap>
00024 #include <QtCore/QObject>
00025 #include <QtCore/QVariant>
00026
00027 #include <kconfiggroup.h>
00028
00029 #include <plasma/plasma_export.h>
00030 #include <plasma/plasma.h>
00031 #include "packagemetadata.h"
00032
00033 class QGraphicsWidget;
00034 class QIODevice;
00035 class QWidget;
00036
00037 namespace Plasma
00038 {
00039
00040 class ServiceJob;
00041 class ServicePrivate;
00042
00077 class PLASMA_EXPORT Service : public QObject
00078 {
00079 Q_OBJECT
00080 Q_DECLARE_PRIVATE(Service)
00081 public:
00085 ~Service();
00086
00095 static Service *load(const QString &name, QObject *parent = 0);
00096
00101 static Service *access(const KUrl &url, QObject *parent = 0);
00102
00109 Q_INVOKABLE void setDestination(const QString &destination);
00110
00114 Q_INVOKABLE QString destination() const;
00115
00119 Q_INVOKABLE QStringList operationNames() const;
00120
00127 Q_INVOKABLE KConfigGroup operationDescription(const QString &operationName);
00128
00136 Q_INVOKABLE ServiceJob *startOperationCall(const KConfigGroup &description, QObject *parent = 0);
00137
00144 Q_INVOKABLE bool isOperationEnabled(const QString &operation) const;
00145
00149 Q_INVOKABLE QString name() const;
00150
00161 Q_INVOKABLE void associateWidget(QWidget *widget, const QString &operation);
00162
00171 Q_INVOKABLE void disassociateWidget(QWidget *widget);
00172
00183 Q_INVOKABLE void associateWidget(QGraphicsWidget *widget, const QString &operation);
00184
00193 Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget);
00194
00200 Q_INVOKABLE QMap<QString, QVariant> parametersFromDescription(const KConfigGroup &description);
00201
00202 Q_SIGNALS:
00206 void finished(Plasma::ServiceJob *job);
00207
00213 void operationsChanged();
00214
00218 void serviceReady(Plasma::Service *service);
00219
00220 protected:
00226 explicit Service(QObject *parent = 0);
00227
00231 Service(QObject *parent, const QVariantList &args);
00232
00240 virtual ServiceJob *createJob(const QString &operation,
00241 QMap<QString, QVariant> ¶meters) = 0;
00242
00249 virtual void registerOperationsScheme();
00250
00255 void setOperationsScheme(QIODevice *xml);
00256
00263 void setName(const QString &name);
00264
00271 void setOperationEnabled(const QString &operation, bool enable);
00272
00273 private:
00274 Q_PRIVATE_SLOT(d, void jobFinished(KJob *))
00275 Q_PRIVATE_SLOT(d, void associatedWidgetDestroyed(QObject *))
00276 Q_PRIVATE_SLOT(d, void associatedGraphicsWidgetDestroyed(QObject *))
00277
00278 ServicePrivate * const d;
00279
00280 friend class Applet;
00281 friend class DataEnginePrivate;
00282 friend class GetSource;
00283 friend class PackagePrivate;
00284 friend class ServiceProvider;
00285 friend class RemoveService;
00286 };
00287
00288 }
00289
00293 #define K_EXPORT_PLASMA_SERVICE(libname, classname) \
00294 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00295 K_EXPORT_PLUGIN(factory("plasma_service_" #libname)) \
00296 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00297
00298 #endif // multiple inclusion guard
00299