Commit d2fc3522 authored by Julien Wadel's avatar Julien Wadel

Pass a QPluginLoader instance to work with it later for dynamic loading

parent dbe187f1
......@@ -4,13 +4,15 @@
#include <QVariantMap>
#include <QJsonDocument>
#include <QPluginLoader>
// This class regroup Data interface for importing contacts
#include "ContactsImporterPlugin.hpp"
ContactsImporterDataAPI::ContactsImporterDataAPI(ContactsImporterPlugin * plugin, std::shared_ptr<linphone::Core> core) : mPlugin(plugin), mCore(core){
QVariantMap defaultValues;
ContactsImporterDataAPI::ContactsImporterDataAPI(ContactsImporterPlugin * plugin, std::shared_ptr<linphone::Core> core, QPluginLoader * pluginLoader) : mPlugin(plugin), mCore(core), mPluginLoader(pluginLoader){
QVariantMap defaultValues;
QJsonDocument doc = QJsonDocument::fromJson(mPlugin->descriptionToJson().toUtf8());
QVariantMap description = doc.toVariant().toMap();
mPluginLoader->setLoadHints(0);
for(auto field : description["fields"].toList()){
auto details = field.toMap();
if( details.contains("fieldId") && details.contains("defaultData")){
......@@ -19,7 +21,8 @@ ContactsImporterDataAPI::ContactsImporterDataAPI(ContactsImporterPlugin * plugin
}
mInputFields["enabled"] = 0;
}
ContactsImporterDataAPI::~ContactsImporterDataAPI(){}
ContactsImporterDataAPI::~ContactsImporterDataAPI(){
}
void ContactsImporterDataAPI::setInputFields(const QVariantMap &inputFields){
if(mInputFields != inputFields) {
......@@ -66,4 +69,6 @@ void ContactsImporterDataAPI::saveConfiguration(){
//----------------------------- -------------------------------------------------------
QPluginLoader * ContactsImporterDataAPI::getPluginLoader(){
return mPluginLoader;
}
......@@ -5,11 +5,12 @@
#include <linphone++/core.hh>
class ContactsImporterPlugin;
class QPluginLoader;
// This class regroup Data interface for importing contacts
class ContactsImporterDataAPI : public QObject {
Q_OBJECT
public:
ContactsImporterDataAPI(ContactsImporterPlugin * plugin, std::shared_ptr<linphone::Core> core);
ContactsImporterDataAPI(ContactsImporterPlugin * plugin, std::shared_ptr<linphone::Core> core, QPluginLoader * pluginLoader);
virtual ~ContactsImporterDataAPI();
virtual bool isValid(const bool &pRequestData=true, QString * pError= nullptr) = 0; // Test if the passed data is valid. Used for saving.
......@@ -21,6 +22,8 @@ public:
virtual void loadConfiguration();
virtual void saveConfiguration();
QPluginLoader * getPluginLoader();// Used to retrieve the loader that created this instance, in order to unload it
signals:
void inputFieldsChanged(const QVariantMap &inputFields);
......@@ -33,6 +36,7 @@ protected:
QVariantMap mInputFields;
std::shared_ptr<linphone::Core> mCore;
ContactsImporterPlugin * mPlugin;
QPluginLoader * mPluginLoader;
private:
std::string mSectionConfigurationName;
};
......
......@@ -7,13 +7,14 @@
#include <linphone++/core.hh>
class ContactsImporterDataAPI;
class QPluginLoader;
class ContactsImporterPlugin
{
public:
virtual ~ContactsImporterPlugin() {}
virtual QString descriptionToJson() const = 0;// Describe the plugin. Json are in Utf8
virtual ContactsImporterDataAPI * createInstance(std::shared_ptr<linphone::Core> core) = 0;
virtual ContactsImporterDataAPI * createInstance(std::shared_ptr<linphone::Core> core, QPluginLoader * pluginLoader) = 0;
};
#define ContactsImporterPlugin_iid "linphone.ContactsImporterPlugin"
......
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