1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef PLUGINMANAGER_P_H |
6 | #define PLUGINMANAGER_P_H |
7 | |
8 | #include "framework/lifecycle/pluginsetting.h" |
9 | #include "framework/framework_global.h" |
10 | |
11 | #include <QQueue> |
12 | #include <QStringList> |
13 | #include <QPluginLoader> |
14 | #include <QObject> |
15 | #include <QJsonArray> |
16 | #include <QSettings> |
17 | #include <QDirIterator> |
18 | #include <QDebug> |
19 | #include <QWriteLocker> |
20 | #include <QtConcurrent> |
21 | |
22 | DPF_BEGIN_NAMESPACE |
23 | |
24 | class PluginMetaObject; |
25 | class PluginManager; |
26 | |
27 | class PluginManagerPrivate : public QSharedData |
28 | { |
29 | Q_DISABLE_COPY(PluginManagerPrivate) |
30 | friend class PluginManager; |
31 | PluginManager *const q; |
32 | QString pluginLoadIID; |
33 | QStringList pluginLoadPaths; |
34 | QStringList serviceLoadPaths; |
35 | QStringList disabledPlugins; |
36 | QStringList enabledPlugins; |
37 | QHash<QString, QQueue<PluginMetaObjectPointer>> pluginCategories; |
38 | QList<PluginMetaObjectPointer> plugins; |
39 | QQueue<PluginMetaObjectPointer> readQueue; |
40 | QQueue<PluginMetaObjectPointer> loadQueue; |
41 | PluginSetting *setting = nullptr; |
42 | public: |
43 | typedef QQueue<PluginMetaObjectPointer> PluginMetaQueue; |
44 | explicit PluginManagerPrivate(PluginManager *qq); |
45 | virtual ~PluginManagerPrivate(); |
46 | QString pluginIID() const; |
47 | void setPluginIID(const QString &pluginIID); |
48 | QStringList pluginPaths() const; |
49 | void setPluginPaths(const QStringList &pluginPaths); |
50 | QStringList servicePaths() const; |
51 | void setServicePaths(const QStringList &servicePaths); |
52 | void setPluginEnable(const PluginMetaObject& meta, bool enabled); |
53 | PluginMetaObjectPointer pluginMetaObj(const QString &name,const QString &version = ""); |
54 | bool loadPlugin(PluginMetaObjectPointer &pluginMetaObj); |
55 | bool initPlugin(PluginMetaObjectPointer &pluginMetaObj); |
56 | bool startPlugin(PluginMetaObjectPointer &pluginMetaObj); |
57 | void stopPlugin(PluginMetaObjectPointer &pluginMetaObj); |
58 | bool readPlugins(); |
59 | bool loadPlugins(); |
60 | void initPlugins(); |
61 | void startPlugins(); |
62 | void stopPlugins(); |
63 | void setSettings(PluginSetting *s); |
64 | void readSettings(); |
65 | void writeSettings(); |
66 | static void scanfAllPlugin(PluginMetaQueue &destQueue, |
67 | const QStringList& pluginPaths, |
68 | const QString &pluginIID); |
69 | static void readJsonToMeta(const PluginMetaObjectPointer &metaObject); |
70 | QHash<QString, QQueue<PluginMetaObjectPointer>> categories(); |
71 | static PluginMetaQueue dependsSort(const PluginMetaQueue &srcQueue); |
72 | }; |
73 | |
74 | DPF_END_NAMESPACE |
75 | |
76 | #endif // PLUGINMANAGER_P_H |
77 |