Plasma
service.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2008 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 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 00091 class PLASMA_EXPORT Service : public QObject 00092 { 00093 Q_OBJECT 00094 Q_DECLARE_PRIVATE(Service) 00095 Q_PROPERTY(QString destination READ destination WRITE setDestination) 00096 Q_PROPERTY(QStringList operationNames READ operationNames) 00097 Q_PROPERTY(QString name READ name) 00098 00099 public: 00103 ~Service(); 00104 00115 static Service *load(const QString &name, const QVariantList &args, QObject *parent = 0); 00116 00125 static Service *load(const QString &name, QObject *parent = 0); 00126 00131 static Service *access(const KUrl &url, QObject *parent = 0); 00132 00139 Q_INVOKABLE void setDestination(const QString &destination); 00140 00144 Q_INVOKABLE QString destination() const; 00145 00149 Q_INVOKABLE QStringList operationNames() const; 00150 00157 Q_INVOKABLE KConfigGroup operationDescription(const QString &operationName); 00158 00166 Q_INVOKABLE ServiceJob *startOperationCall(const KConfigGroup &description, QObject *parent = 0); 00167 00174 Q_INVOKABLE bool isOperationEnabled(const QString &operation) const; 00175 00179 Q_INVOKABLE QString name() const; 00180 00191 Q_INVOKABLE void associateWidget(QWidget *widget, const QString &operation); 00192 00201 Q_INVOKABLE void disassociateWidget(QWidget *widget); 00202 00213 Q_INVOKABLE void associateWidget(QGraphicsWidget *widget, const QString &operation); 00214 00223 Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget); 00224 00230 Q_INVOKABLE QMap<QString, QVariant> parametersFromDescription(const KConfigGroup &description); 00231 00232 Q_SIGNALS: 00236 void finished(Plasma::ServiceJob *job); 00237 00243 void operationsChanged(); 00244 00248 void serviceReady(Plasma::Service *service); 00249 00250 protected: 00256 explicit Service(QObject *parent = 0); 00257 00261 Service(QObject *parent, const QVariantList &args); 00262 00270 virtual ServiceJob *createJob(const QString &operation, 00271 QMap<QString, QVariant> ¶meters) = 0; 00272 00279 virtual void registerOperationsScheme(); 00280 00285 void setOperationsScheme(QIODevice *xml); 00286 00293 void setName(const QString &name); 00294 00301 void setOperationEnabled(const QString &operation, bool enable); 00302 00303 private: 00304 Q_PRIVATE_SLOT(d, void jobFinished(KJob *)) 00305 Q_PRIVATE_SLOT(d, void associatedWidgetDestroyed(QObject *)) 00306 Q_PRIVATE_SLOT(d, void associatedGraphicsWidgetDestroyed(QObject *)) 00307 00308 ServicePrivate * const d; 00309 00310 friend class Applet; 00311 friend class DataEnginePrivate; 00312 friend class GetSource; 00313 friend class PackagePrivate; 00314 friend class ServiceProvider; 00315 friend class RemoveService; 00316 friend class PluginLoader; 00317 }; 00318 00319 } // namespace Plasma 00320 00324 #define K_EXPORT_PLASMA_SERVICE(libname, classname) \ 00325 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00326 K_EXPORT_PLUGIN(factory("plasma_service_" #libname)) \ 00327 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) 00328 00329 #endif // multiple inclusion guard 00330
KDE 4.6 API Reference