Commit 2e8e78b2 authored by Laurent Montel's avatar Laurent Montel 😁

Load plugins

parent 62732ad5
......@@ -18,6 +18,11 @@
*/
#include "transportpluginmanager.h"
#include <kpluginmetadata.h>
#include <KPluginLoader>
#include <KPluginFactory>
#include <MailTransport/TransportAbstractPlugin>
using namespace MailTransport;
......@@ -43,13 +48,15 @@ class MailTransportPluginInfo
{
public:
MailTransportPluginInfo()
: /*plugin(nullptr),*/
: plugin(nullptr),
isEnabled(true)
{
}
QString metaDataFileNameBaseName;
QString metaDataFileName;
MailTransport::TransportAbstractPlugin *plugin;
bool isEnabled;
};
......@@ -70,10 +77,23 @@ public:
}
void loadPlugin(MailTransportPluginInfo *item);
QVector<MailTransport::TransportAbstractPlugin *> pluginsList() const;
QVector<MailTransportPluginInfo> mPluginList;
private:
TransportPluginManager *q;
};
QVector<MailTransport::TransportAbstractPlugin *> TransportPluginManagerPrivate::pluginsList() const
{
QVector<MailTransport::TransportAbstractPlugin *> lst;
QVector<MailTransportPluginInfo>::ConstIterator end(mPluginList.constEnd());
for (QVector<MailTransportPluginInfo>::ConstIterator it = mPluginList.constBegin(); it != end; ++it) {
if (auto plugin = (*it).plugin) {
lst << plugin;
}
}
return lst;
}
TransportPluginManager::TransportPluginManager(QObject *parent)
: QObject(parent),
......@@ -87,9 +107,13 @@ TransportPluginManager::~TransportPluginManager()
delete d;
}
TransportPluginManager *TransportPluginManager::self()
{
return sInstance->transportPluginManager;
}
QVector<MailTransport::TransportAbstractPlugin *> TransportPluginManager::pluginsList() const
{
return d->pluginsList();
}
......@@ -22,6 +22,7 @@
#include <QObject>
namespace MailTransport {
class TransportAbstractPlugin;
class TransportPluginManagerPrivate;
class TransportPluginManager : public QObject
{
......@@ -31,6 +32,7 @@ public:
~TransportPluginManager();
static TransportPluginManager *self();
QVector<MailTransport::TransportAbstractPlugin *> pluginsList() const;
private:
TransportPluginManagerPrivate *const d;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment