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

Load plugins

parent 62732ad5
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
*/ */
#include "transportpluginmanager.h" #include "transportpluginmanager.h"
#include <kpluginmetadata.h>
#include <KPluginLoader>
#include <KPluginFactory>
#include <MailTransport/TransportAbstractPlugin>
using namespace MailTransport; using namespace MailTransport;
...@@ -43,13 +48,15 @@ class MailTransportPluginInfo ...@@ -43,13 +48,15 @@ class MailTransportPluginInfo
{ {
public: public:
MailTransportPluginInfo() MailTransportPluginInfo()
: /*plugin(nullptr),*/ : plugin(nullptr),
isEnabled(true) isEnabled(true)
{ {
} }
QString metaDataFileNameBaseName; QString metaDataFileNameBaseName;
QString metaDataFileName; QString metaDataFileName;
MailTransport::TransportAbstractPlugin *plugin;
bool isEnabled; bool isEnabled;
}; };
...@@ -70,10 +77,23 @@ public: ...@@ -70,10 +77,23 @@ public:
} }
void loadPlugin(MailTransportPluginInfo *item); void loadPlugin(MailTransportPluginInfo *item);
QVector<MailTransport::TransportAbstractPlugin *> pluginsList() const;
QVector<MailTransportPluginInfo> mPluginList;
private: private:
TransportPluginManager *q; 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) TransportPluginManager::TransportPluginManager(QObject *parent)
: QObject(parent), : QObject(parent),
...@@ -87,9 +107,13 @@ TransportPluginManager::~TransportPluginManager() ...@@ -87,9 +107,13 @@ TransportPluginManager::~TransportPluginManager()
delete d; delete d;
} }
TransportPluginManager *TransportPluginManager::self() TransportPluginManager *TransportPluginManager::self()
{ {
return sInstance->transportPluginManager; return sInstance->transportPluginManager;
} }
QVector<MailTransport::TransportAbstractPlugin *> TransportPluginManager::pluginsList() const
{
return d->pluginsList();
}
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QObject> #include <QObject>
namespace MailTransport { namespace MailTransport {
class TransportAbstractPlugin;
class TransportPluginManagerPrivate; class TransportPluginManagerPrivate;
class TransportPluginManager : public QObject class TransportPluginManager : public QObject
{ {
...@@ -31,6 +32,7 @@ public: ...@@ -31,6 +32,7 @@ public:
~TransportPluginManager(); ~TransportPluginManager();
static TransportPluginManager *self(); static TransportPluginManager *self();
QVector<MailTransport::TransportAbstractPlugin *> pluginsList() const;
private: private:
TransportPluginManagerPrivate *const d; 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