PluginManager.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2014-2021 Jolla Ltd.
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H
#include <QString>
#include <QMap>
#include <QReadWriteLock>
#include <QProcess>
#include <QPointer>
class QPluginLoader;
class QProcess;
namespace Buteo {
class StorageChangeNotifierPlugin;
class StoragePlugin;
class ClientPlugin;
class ServerPlugin;
class PluginCbInterface;
class SyncProfile;
class Profile;
class ClientPluginTest;
class ServerPluginTest;
class StoragePluginTest;
class PluginManager : public QObject
{
Q_OBJECT
public:
PluginManager();
PluginManager(const QString &aPluginPath);
~PluginManager();
StorageChangeNotifierPlugin *createStorageChangeNotifier(const QString &aStorageName);
void destroyStorageChangeNotifier(StorageChangeNotifierPlugin *aPlugin);
StoragePlugin *createStorage(const QString &aPluginName);
void destroyStorage(StoragePlugin *aPlugin);
ClientPlugin *createClient(const QString &aPluginName,
const SyncProfile &aProfile,
PluginCbInterface *aCbInterface);
void destroyClient(ClientPlugin *aPlugin);
ServerPlugin *createServer(const QString &aPluginName,
const Profile &aProfile,
PluginCbInterface *aCbInterface);
void destroyServer(ServerPlugin *aPlugin);
protected slots:
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
private:
class DllInfo
{
public:
void cleanUp();
QString iPath;
QProcess *iHandle = nullptr;
QPluginLoader *iPluginLoader = nullptr;
QPointer<QObject> iLoadedPlugin;
int iRefCount = 0;
};
void loadPluginMaps(const QString &pluginDirPath, const QString &aFilter, QMap<QString, QString> &aTargetMap);
QProcess *startOOPPlugin(const QString &aPluginName, const QString &aProfileName, const QString &aPluginFilePath);
void stopOOPPlugin(const QString &aPath);
void addLoadedPlugin(const QString &libraryName,
QPluginLoader *pluginLoader,
QObject *plugin);
QObject *acquireLoadedPlugin(const QString &libraryName);
void unloadPlugin(const QString &libraryName);
QString iPluginPath;
QMap<QString, QString> iStorageChangeNotifierMaps;
QMap<QString, QString> iStorageMaps;
QMap<QString, QString> iClientMaps;
QMap<QString, QString> iServerMaps;
QMap<QString, QString> iOopClientMaps;
QMap<QString, QString> iOoPServerMaps;
QList<DllInfo> iLoadedDlls;
QReadWriteLock iDllLock;
QString iProcBinaryPath;
#ifdef SYNCFW_UNIT_TESTS
friend class ClientPluginTest;
friend class ServerPluginTest;
friend class StoragePluginTest;
#endif
};
}
#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::createStorage
StoragePlugin * createStorage(const QString &aPluginName)
Creates a new storage plugin instance.
Definition PluginManager.cpp:171
Buteo::PluginManager::createServer
ServerPlugin * createServer(const QString &aPluginName, const Profile &aProfile, PluginCbInterface *aCbInterface)
Creates a new server plugin instance.
Definition PluginManager.cpp:294
Buteo::PluginManager::destroyServer
void destroyServer(ServerPlugin *aPlugin)
Destroys a server plugin.
Definition PluginManager.cpp:347
Buteo::PluginManager::destroyStorage
void destroyStorage(StoragePlugin *aPlugin)
Destroys a storage plugin instance.
Definition PluginManager.cpp:202
Buteo::PluginManager::createClient
ClientPlugin * createClient(const QString &aPluginName, const SyncProfile &aProfile, PluginCbInterface *aCbInterface)
Creates a new client plugin instance.
Definition PluginManager.cpp:219
Buteo::PluginManager::destroyStorageChangeNotifier
void destroyStorageChangeNotifier(StorageChangeNotifierPlugin *aPlugin)
Destroys a storage change notifier plugin instance.
Definition PluginManager.cpp:154
Buteo::PluginManager::createStorageChangeNotifier
StorageChangeNotifierPlugin * createStorageChangeNotifier(const QString &aStorageName)
Creates a new storage change notifier plugin for the storage aStoragName.
Definition PluginManager.cpp:122
Buteo::PluginManager::destroyClient
void destroyClient(ClientPlugin *aPlugin)
Destroys a client plugin instance.
Definition PluginManager.cpp:268
Buteo::PluginManager::~PluginManager
~PluginManager()
Destructor.
Definition PluginManager.cpp:113
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
Definition SyncBackupAdaptor.h:40
QMap
Definition SyncBackupAdaptor.h:41