Relicense all GPLv2 only code to GPLv2+.
[kdenetwork.git] / kget / core / plugin / plugin.h
blob042f816a49b5108a0e06f8623225c0821075f5f9
1 /* This file is part of the KDE project
3 Copyright (C) 2005 by Enrico Ros <eros.kde@email.it>
4 based on amarok code Copyright (C) 2004 by Mark Kretschmann <markey@web.de>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
12 #ifndef KGET_PLUGIN_H
13 #define KGET_PLUGIN_H
15 /* KGet plugins -How they work- [enrico: 0.6]
17 * Here is a generic framework for plugins usage. Since the purpose of a
18 * plugin is providing some type of well known functionality, there are
19 * some requirements that must be satisfied. In fact a plugin must:
20 * - inherit KGetPlugin interface or a subclass of that
21 * - declare that the class IS a kget plugin (using a macro)
22 * - declare its 'type' to the loader (using a .desktop file)
24 * Plugins providing the same functionality (TransferFactory for example)
25 * must inherit the same interface and be declared as plugins of the same
26 * type. In that case all the plugins will inherit and implement the
27 * TransferFactory class and provide a .desktop file that identify them
28 * as belonging to the same type (X-KDE-KGet-pluginType=TransferFactory).
30 * Loading. This operation is done by using KDE framework. So we define a
31 * new ServiceType in the kget_plugin.desktop file. KGet plugins service
32 * is called "KGet/Plugin". In the Desktop file that describes a plugin
33 * the "X-KDE-ServiceType" is set to to "KGet/Plugin" and other fields
34 * are set as described in the service type definition.
35 * As an example say that we need "InputFilter" plugins. In that case we
36 * can use KTrader to enumerate the plugins of that type installed in the
37 * system and after getting the name of the libraries they're in, load
38 * them. In that case the Input object that loaded the plugins must know
39 * how to treat them (and that is easy, since they all reimplemented an
40 * 'input plugin class' providing necessary information).
42 * @see: kget_plugin.desktop - for servicetype definition.
43 * @see: other headers in the dir - for plugin types definition.
46 #include "kget_export.h"
48 /**
49 * Bump this number whenever the plugin framework gets
50 * incompatible with older versions
52 const int FrameworkVersion = 1;
54 /**
55 * @short Base class for kget plugins.
56 * ...
58 class KGET_EXPORT KGetPlugin
60 public:
61 KGetPlugin();
62 virtual ~KGetPlugin();
65 // set and retrieve properties
66 void addPluginProperty( const QString & key, const QString & value );
67 bool hasPluginProperty( const QString & key );
68 QString pluginProperty( const QString & key );
70 reimplement this to set the type of the plugin
71 enum PluginType { PreProcessing, Factory, PostProcessing }
72 virtual PluginType pluginType() = 0;
75 private:
76 //QMap< QString, QString > m_properties;
81 #endif