Buteo Synchronization Framework: PluginManager.h Source File

Buteo Synchronization Framework

PluginManager.h
1 /*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Copyright (C) 2014-2021 Jolla Ltd.
6 *
7 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24 #ifndef PLUGINMANAGER_H
25 #define PLUGINMANAGER_H
26
27 #include <QString>
28 #include <QMap>
29 #include <QReadWriteLock>
30 #include <QProcess>
31 #include <QPointer>
32
33 class QPluginLoader;
34 class QProcess;
35
36 namespace Buteo {
37
38 class StorageChangeNotifierPlugin;
39 class StoragePlugin;
40 class ClientPlugin;
41 class ServerPlugin;
42 class PluginCbInterface;
43 class SyncProfile;
44 class Profile;
45
46 class ClientPluginTest;
47 class ServerPluginTest;
48 class StoragePluginTest;
49
55 class PluginManager : public QObject
56 {
57 Q_OBJECT
58
59 public:
60 PluginManager();
65 PluginManager(const QString &aPluginPath);
66
70 ~PluginManager();
71
77 StorageChangeNotifierPlugin *createStorageChangeNotifier(const QString &aStorageName);
78
83 void destroyStorageChangeNotifier(StorageChangeNotifierPlugin *aPlugin);
84
90 StoragePlugin *createStorage(const QString &aPluginName);
91
96 void destroyStorage(StoragePlugin *aPlugin);
97
105 ClientPlugin *createClient(const QString &aPluginName,
106 const SyncProfile &aProfile,
107 PluginCbInterface *aCbInterface);
108
113 void destroyClient(ClientPlugin *aPlugin);
114
122 ServerPlugin *createServer(const QString &aPluginName,
123 const Profile &aProfile,
124 PluginCbInterface *aCbInterface);
125
130 void destroyServer(ServerPlugin *aPlugin);
131
132 protected slots:
133
134 void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
135
136 private:
137
138 class DllInfo
139 {
140 public:
141 void cleanUp();
142
143 QString iPath;
144 QProcess *iHandle = nullptr;
145 QPluginLoader *iPluginLoader = nullptr;
146 QPointer<QObject> iLoadedPlugin;
147 int iRefCount = 0;
148 };
149
150 void loadPluginMaps(const QString &pluginDirPath, const QString &aFilter, QMap<QString, QString> &aTargetMap);
151
152 QProcess *startOOPPlugin(const QString &aPluginName, const QString &aProfileName, const QString &aPluginFilePath);
153
154 void stopOOPPlugin(const QString &aPath);
155
156 void addLoadedPlugin(const QString &libraryName,
157 QPluginLoader *pluginLoader,
158 QObject *plugin);
159 QObject *acquireLoadedPlugin(const QString &libraryName);
160 void unloadPlugin(const QString &libraryName);
161
162 QString iPluginPath;
163
164 QMap<QString, QString> iStorageChangeNotifierMaps;
165 QMap<QString, QString> iStorageMaps;
166 QMap<QString, QString> iClientMaps;
167 QMap<QString, QString> iServerMaps;
168
169 QMap<QString, QString> iOopClientMaps;
170 QMap<QString, QString> iOoPServerMaps;
171
172 QList<DllInfo> iLoadedDlls;
173
174 QReadWriteLock iDllLock;
175
176 QString iProcBinaryPath;
177
178 #ifdef SYNCFW_UNIT_TESTS
179 friend class ClientPluginTest;
180 friend class ServerPluginTest;
181 friend class StoragePluginTest;
182 #endif
183
184 };
185
186 }
187
188 #endif
Buteo::ClientPlugin
Base class for client plugins.
Definition: ClientPlugin.h:38
Buteo::PluginCbInterface
Interface which client and server plugins can use to communicate with synchronization daemon.
Definition: PluginCbInterface.h:39
Buteo::PluginManager
Manages plugins.
Definition: PluginManager.h:56
Buteo::PluginManager::createStorage
StoragePlugin * createStorage(const QString &aPluginName)
Creates a new storage plugin instance.
Definition: PluginManager.cpp:172
Buteo::PluginManager::createServer
ServerPlugin * createServer(const QString &aPluginName, const Profile &aProfile, PluginCbInterface *aCbInterface)
Creates a new server plugin instance.
Definition: PluginManager.cpp:300
Buteo::PluginManager::destroyServer
void destroyServer(ServerPlugin *aPlugin)
Destroys a server plugin.
Definition: PluginManager.cpp:355
Buteo::PluginManager::destroyStorage
void destroyStorage(StoragePlugin *aPlugin)
Destroys a storage plugin instance.
Definition: PluginManager.cpp:204
Buteo::PluginManager::createClient
ClientPlugin * createClient(const QString &aPluginName, const SyncProfile &aProfile, PluginCbInterface *aCbInterface)
Creates a new client plugin instance.
Definition: PluginManager.cpp:221
Buteo::PluginManager::destroyStorageChangeNotifier
void destroyStorageChangeNotifier(StorageChangeNotifierPlugin *aPlugin)
Destroys a storage change notifier plugin instance.
Definition: PluginManager.cpp:155
Buteo::PluginManager::createStorageChangeNotifier
StorageChangeNotifierPlugin * createStorageChangeNotifier(const QString &aStorageName)
Creates a new storage change notifier plugin for the storage aStoragName.
Definition: PluginManager.cpp:123
Buteo::PluginManager::destroyClient
void destroyClient(ClientPlugin *aPlugin)
Destroys a client plugin instance.
Definition: PluginManager.cpp:273
Buteo::PluginManager::~PluginManager
~PluginManager()
Destructor.
Definition: PluginManager.cpp:114
Buteo::Profile
This class represents a single profile, a collection of settings or data releated to some entity.
Definition: Profile.h:53
Buteo::ServerPlugin
Base class for server plugins.
Definition: ServerPlugin.h:37
Buteo::StorageChangeNotifierPlugin
Implement this class to notify about changes in a specific storage - contacts/calendar/sms,...
Definition: StorageChangeNotifierPlugin.h:15
Buteo::StoragePlugin
Base class for storage plugins.
Definition: StoragePlugin.h:39
Buteo::SyncProfile
A top level synchronization profile.
Definition: SyncProfile.h:49
QList< DllInfo >
QMap< QString, QString >