Debian Codegraph @

plugins/plugman/src/PluginRegistry.h

raw symbols SCIP
1 /* Copyright (C) 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef PLUGINREGISTRY_H
19 #define PLUGINREGISTRY_H
20
21 #include <QLoggingCategory>
22 #include <QObject>
23 #include <QMultiMap>
24 #include <QSharedPointer>
25 #include <QSettings>
26 #include "PluginLoader.h"
27
28 Q_DECLARE_LOGGING_CATEGORY(PLUGIN_REGISTRY)
29
30 // key is plugin location i.e "Composer::ContextAction"
31 // we use a multimap as we may have multiple plugins for the same location
32 typedef QMultiMap<QString, PluginInfo *> Registry;
33
34 class PluginRegistry : public QObject
35 {
36 Q_OBJECT
37 public:
38 explicit PluginRegistry(QObject *parent = 0);
39 ~PluginRegistry();
40
41 static PluginRegistry *instance();
42
43 Registry registry() const;
44 bool supportsLocation(const QString &location);
45 QStringList pluginLocations() const;
46 void setPluginLocations(const QStringList &locations);
47 void loadPlugins(const QStringList &paths = QStringList());
48
49 QList<PluginInfo *> getAllPlugins(const bool enabledOnly = true);
50 QList<PluginInfo *> getByLocation(const QString &key, const bool enabledOnly = true);
51
52 signals:
53 void pluginsLoaded();
54
55 public slots:
56 void enablePlugin(const QString &id);
57 void disablePlugin(const QString &id);
58
59 protected:
60 void updateRegistryConf();
61
62 private:
63 Registry m_registry;
64 QScopedPointer<PluginLoader> m_loader;
65 QStringList m_locations;
66 QSettings m_regConf;
67 };
68
69 #endif // PLUGINREGISTRY_H