Debian Codegraph @

plugins/plugman/src/PluginInfo.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 PLUGININFO_H
19 #define PLUGININFO_H
20
21 #include <QLoggingCategory>
22 #include <QObject>
23 #include <QVariantMap>
24 #include <QJsonObject>
25 #include <QDebug>
26
27 Q_DECLARE_LOGGING_CATEGORY(PLUGIN_INFO)
28
29 class PluginInfo : public QObject
30 {
31 Q_OBJECT
32 Q_PROPERTY(QString pluginId READ pluginId CONSTANT)
33 Q_PROPERTY(QString location READ location CONSTANT)
34 Q_PROPERTY(QVariantMap documentation READ documentation CONSTANT)
35 Q_PROPERTY(QVariantMap settings READ settings CONSTANT)
36
37 public:
38 explicit PluginInfo(QObject *parent = 0);
39
40 virtual QString pluginId() const = 0;
41 virtual QString location() const = 0;
42 virtual QString i18n() const = 0;
43 virtual QVariantMap documentation() const = 0;
44 virtual QVariantMap settings() const { return QVariantMap();}
45
46 };
47
48 class DekkoPlugin : public PluginInfo
49 {
50 Q_OBJECT
51 Q_PROPERTY(QString component READ component CONSTANT)
52 public:
53 explicit DekkoPlugin(QObject *parent = 0);
54
55 static DekkoPlugin* fromSpec(const QString &specPath, QObject *parent = 0);
56
57 QString pluginId() const;
58 QString location() const;
59 QString component();
60 QString i18n() const;
61 QVariantMap documentation() const;
62 QVariantMap settings() const;
63
64 QString pluginPath() const;
65
66 void setSpec(const QJsonObject &spec);
67 void setPluginDirectory(const QString &path);
68
69 private:
70 QJsonObject m_spec;
71 QString m_pluginPath;
72 };
73
74 class ServicePlugin : public PluginInfo
75 {
76 Q_OBJECT
77 public:
78 explicit ServicePlugin(QObject *parent = 0);
79
80 // PluginInfo interface
81 public:
82 virtual QString pluginId() const override {
83 qWarning() << "Not implemented here";
84 return QString();
85 }
86 virtual QString location() const override {
87 qWarning() << "Not implemented here";
88 return QString();
89 }
90 virtual QString i18n() const override {
91 qWarning() << "Not implemented here";
92 return QString();
93 }
94 virtual QVariantMap documentation() const override {
95 qWarning() << "Not implemented here";
96 return QVariantMap();
97 }
98
99 virtual void start() {}
100 virtual void stop() {}
101
102 virtual void messageReceived(const QString &key, const QVariant &value);
103 };
104
105 #endif // PLUGININFO_H