libplasma
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 <KDE/KConfigGroup> 00028 00029 class QIODevice; 00030 00031 namespace Plasma 00032 { 00033 00034 class ServiceJob; 00035 class ServicePrivate; 00036 00067 class Service : public QObject 00068 { 00069 Q_OBJECT 00070 public: 00074 ~Service(); 00075 00084 static Service* load(const QString &name, QObject *parent = 0); 00085 00092 void setDestination(const QString &destination); 00093 00097 QString destination() const; 00098 00102 QStringList operationNames() const; 00103 00110 KConfigGroup operationDescription(const QString &operationName); 00111 00119 ServiceJob* startOperationCall(const KConfigGroup &description); 00120 00124 QString name() const; 00125 00126 Q_SIGNALS: 00127 void finished(ServiceJob* job); 00128 00129 protected: 00135 explicit Service(QObject *parent = 0); 00136 00140 Service(QObject *parent, const QVariantList &args); 00141 00149 virtual ServiceJob* createJob(const QString &operation, 00150 QMap<QString, QVariant> ¶meters) = 0; 00151 00158 virtual void registerOperationsScheme(); 00159 00164 void setOperationsScheme(QIODevice *xml); 00165 00172 void setName(const QString &name); 00173 00174 private: 00175 Q_PRIVATE_SLOT(d, void jobFinished(KJob*)) 00176 00177 ServicePrivate * const d; 00178 00179 friend class ServicePrivate; 00180 }; 00181 00182 } // namespace Plasma 00183 00184 #define K_EXPORT_PLASMA_SERVICE(libname, classname) \ 00185 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00186 K_EXPORT_PLUGIN(factory("plasma_service_" #libname)) \ 00187 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) 00188 00189 #endif // multiple inclusion guard 00190