File indexing completed on 2024-05-05 09:11:04
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> 0004 based on amarok code Copyright (C) 2004 by Mark Kretschmann <markey@web.de> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 */ 0011 0012 #ifndef KGET_PLUGIN_H 0013 #define KGET_PLUGIN_H 0014 0015 /* KGet plugins -How they work- [enrico: 0.6] 0016 * 0017 * Here is a generic framework for plugins usage. Since the purpose of a 0018 * plugin is providing some type of well known functionality, there are 0019 * some requirements that must be satisfied. In fact a plugin must: 0020 * - inherit KGetPlugin interface or a subclass of that 0021 * - declare that the class IS a kget plugin (using a macro) 0022 * - declare its 'type' to the loader (using a .desktop file) 0023 * 0024 * Plugins providing the same functionality (TransferFactory for example) 0025 * must inherit the same interface and be declared as plugins of the same 0026 * type. In that case all the plugins will inherit and implement the 0027 * TransferFactory class and provide a .desktop file that identify them 0028 * as belonging to the same type (X-KDE-KGet-pluginType=TransferFactory). 0029 * 0030 * Loading. This operation is done by using KDE framework. So we define a 0031 * new ServiceType in the kget_plugin.desktop file. KGet plugins service 0032 * is called "KGet/Plugin". In the Desktop file that describes a plugin 0033 * the "X-KDE-ServiceType" is set to to "KGet/Plugin" and other fields 0034 * are set as described in the service type definition. 0035 * As an example say that we need "InputFilter" plugins. In that case we 0036 * can use KTrader to enumerate the plugins of that type installed in the 0037 * system and after getting the name of the libraries they're in, load 0038 * them. In that case the Input object that loaded the plugins must know 0039 * how to treat them (and that is easy, since they all reimplemented an 0040 * 'input plugin class' providing necessary information). 0041 * 0042 * @see: kget_plugin.desktop - for servicetype definition. 0043 * @see: other headers in the dir - for plugin types definition. 0044 */ 0045 0046 #include "kget_export.h" 0047 0048 #include <QObject> 0049 #include <QVariantList> 0050 0051 /** 0052 * Bump this number whenever the plugin framework gets 0053 * incompatible with older versions 0054 */ 0055 const int FrameworkVersion = 2; 0056 0057 /** 0058 * @short Base class for kget plugins. 0059 * ... 0060 */ 0061 class KGET_EXPORT KGetPlugin : public QObject 0062 { 0063 Q_OBJECT 0064 public: 0065 KGetPlugin(QObject *parent, const QVariantList &args); 0066 ~KGetPlugin() override; 0067 0068 /* 0069 // set and retrieve properties 0070 void addPluginProperty( const QString & key, const QString & value ); 0071 bool hasPluginProperty( const QString & key ); 0072 QString pluginProperty( const QString & key ); 0073 0074 reimplement this to set the type of the plugin 0075 enum PluginType { PreProcessing, Factory, PostProcessing } 0076 virtual PluginType pluginType() = 0; 0077 */ 0078 0079 private: 0080 // QMap< QString, QString > m_properties; 0081 }; 0082 0083 #endif