Merge remote-tracking branch 'origin/Applications/16.08'
[kdepim.git] / akregator / src / pluginmanager.h
blob410c3bc8b7c91d33abd6757d184b6a628417d0ef
1 /***************************************************************************
2 begin : 2004/03/12
3 copyright : (C) Mark Kretschmann
4 email : markey@web.de
5 ***************************************************************************/
7 /***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
16 #ifndef AKREGATOR_PLUGINMANAGER_H
17 #define AKREGATOR_PLUGINMANAGER_H
19 #include "akregatorpart_export.h"
21 #include <kservice.h>
22 #include <kservicetypetrader.h>
24 #include <vector>
26 namespace Akregator
29 class Plugin;
30 class AKREGATORPART_EXPORT PluginManager
32 public:
34 /**
35 * It will return a list of services that match your
36 * specifications. The only required parameter is the service
37 * type. This is something like 'text/plain' or 'text/html'. The
38 * constraint parameter is used to limit the possible choices
39 * returned based on the constraints you give it.
41 * The @p constraint language is rather full. The most common
42 * keywords are AND, OR, NOT, IN, and EXIST, all used in an
43 * almost spoken-word form. An example is:
44 * \code
45 * (Type == 'Service') and (('KParts/ReadOnlyPart' in ServiceTypes) or (exist Exec))
46 * \endcode
48 * The keys used in the query (Type, ServiceType, Exec) are all
49 * fields found in the .desktop files.
51 * @param constraint A constraint to limit the choices returned, QString() to
52 * get all services of the given @p servicetype
54 * @return A list of services that satisfy the query
55 * @see http://developer.kde.org/documentation/library/kdeqt/tradersyntax.html
57 static KService::List query(const QString &constraint = QString());
59 /**
60 * Load and instantiate plugin from query
61 * @param constraint A constraint to limit the choices returned, QString() to
62 * get all services of the given @p servicetype
63 * @return Pointer to Plugin, or NULL if error
64 * @see http://developer.kde.org/documentation/library/kdeqt/tradersyntax.html
66 static Akregator::Plugin *createFromQuery(const QString &constraint = QString());
68 /**
69 * Load and instantiate plugin from service
70 * @param service Pointer to KService
71 * @return Pointer to Plugin, or NULL if error
73 static Akregator::Plugin *createFromService(const KService::Ptr &service, QObject *parent = Q_NULLPTR);
75 /**
76 * Remove library and delete plugin
77 * @param plugin Pointer to plugin
79 static void unload(Akregator::Plugin *plugin);
81 /**
82 * Look up service for loaded plugin from store
83 * @param pointer Pointer to plugin
84 * @return KService, or 0 if not found
86 static KService::Ptr getService(const Akregator::Plugin *plugin);
88 /**
89 * Dump properties from a service to stdout for debugging
90 * @param service Pointer to KService
92 static void dump(const KService::Ptr &service);
94 /**
95 * Show modal info dialog about plugin
96 * @param constraint A constraint to limit the choices returned
98 static void showAbout(const QString &constraint);
100 private:
101 struct StoreItem {
102 Akregator::Plugin *plugin;
103 KService::Ptr service;
106 static std::vector<StoreItem>::iterator lookupPlugin(const Akregator::Plugin *plugin);
108 //attributes:
109 static std::vector<StoreItem> m_store;
112 } // namespace Akregator
114 #endif // AKREGATOR_PLUGINMANAGER_H