summaryrefslogtreecommitdiff
path: root/PluginLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'PluginLoader.cpp')
-rw-r--r--PluginLoader.cpp111
1 files changed, 74 insertions, 37 deletions
diff --git a/PluginLoader.cpp b/PluginLoader.cpp
index 7577885..36101a4 100644
--- a/PluginLoader.cpp
+++ b/PluginLoader.cpp
@@ -6,9 +6,15 @@
#include "PluginLoader.h"
#include "LanguagesManager.h"
+#ifdef ULTRACOPIER_PLUGIN_ALL_IN_ONE
+#ifdef Q_OS_WIN32
+#include "plugins/PluginLoader/catchcopy-v0002/pluginLoader.h"
+#endif
+#endif
+
PluginLoader::PluginLoader(OptionDialog *optionDialog)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
this->optionDialog=optionDialog;
//load the overall instance
//load the plugin
@@ -19,7 +25,7 @@ PluginLoader::PluginLoader(OptionDialog *optionDialog)
connect(PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeRemoved,this,&PluginLoader::onePluginWillBeRemoved,Qt::DirectConnection);
#endif
connect(PluginsManager::pluginsManager,&PluginsManager::pluginListingIsfinish, this,&PluginLoader::allPluginIsloaded,Qt::QueuedConnection);
- QList<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_PluginLoader);
+ std::vector<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_PluginLoader);
foreach(PluginsAvailable currentPlugin,list)
emit previouslyPluginAdded(currentPlugin);
PluginsManager::pluginsManager->unlockPluginListEdition();
@@ -66,14 +72,19 @@ void PluginLoader::resendState()
void PluginLoader::onePluginAdded(const PluginsAvailable &plugin)
{
+ #ifdef ULTRACOPIER_PLUGIN_ALL_IN_ONE
+ #ifdef Q_OS_WIN32
+ PluginInterface_PluginLoader *factory;
+ #endif
+ #endif
#ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE_DIRECT
if(stopIt)
return;
if(plugin.category!=PluginType_PluginLoader)
return;
LocalPlugin newEntry;
- QString pluginPath=plugin.path+PluginsManager::getResolvedPluginName(QStringLiteral("pluginLoader"));
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("try load: ")+pluginPath);
+ std::string pluginPath=plugin.path+PluginsManager::getResolvedPluginName("pluginLoader");
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"try load: "+pluginPath);
#ifdef ULTRACOPIER_PLUGIN_ALL_IN_ONE
PluginInterface_PluginLoader *pluginLoaderInstance;
QObjectList objectList=QPluginLoader::staticInstances();
@@ -89,33 +100,32 @@ void PluginLoader::onePluginAdded(const PluginsAvailable &plugin)
}
if(index==objectList.size())
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("static listener not found"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"static listener not found");
return;
}
newEntry.pluginLoader=NULL;
#else
- QPluginLoader *pluginLoader= new QPluginLoader(pluginPath);
+ QPluginLoader *pluginLoader= new QPluginLoader(QString::fromStdString(pluginPath));
QObject *pluginInstance = pluginLoader->instance();
if(!pluginInstance)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to load the plugin: ")+pluginLoader->errorString());
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to load the plugin: "+pluginLoader->errorString().toStdString());
return;
}
PluginInterface_PluginLoader *pluginLoaderInstance = qobject_cast<PluginInterface_PluginLoader *>(pluginInstance);
if(!pluginLoaderInstance)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to cast the plugin: ")+pluginLoader->errorString());
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to cast the plugin: "+pluginLoader->errorString().toStdString());
return;
}
newEntry.pluginLoader = pluginLoader;
//check if found
- int index=0;
- const int &loop_size=pluginList.size();
- while(index<loop_size)
+ unsigned int index=0;
+ while(index<pluginList.size())
{
if(pluginList.at(index).pluginLoaderInterface==pluginLoaderInstance)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Plugin already found"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Plugin already found");
pluginLoader->unload();
return;
}
@@ -126,22 +136,50 @@ void PluginLoader::onePluginAdded(const PluginsAvailable &plugin)
connect(pluginLoaderInstance,&PluginInterface_PluginLoader::debugInformation,this,&PluginLoader::debugInformation,Qt::DirectConnection);
#endif // ULTRACOPIER_DEBUG
- newEntry.options=new LocalPluginOptions(QStringLiteral("PluginLoader-")+plugin.name);
+ newEntry.options=new LocalPluginOptions("PluginLoader-"+plugin.name);
newEntry.pluginLoaderInterface = pluginLoaderInstance;
newEntry.path = plugin.path;
newEntry.state = Ultracopier::Uncaught;
newEntry.inWaitOfReply = false;
- pluginList << newEntry;
+ pluginList.push_back(newEntry);
pluginLoaderInstance->setResources(newEntry.options,plugin.writablePath,plugin.path,ULTRACOPIER_VERSION_PORTABLE_BOOL);
optionDialog->addPluginOptionWidget(PluginType_PluginLoader,plugin.name,newEntry.pluginLoaderInterface->options());
- connect(pluginList.last().pluginLoaderInterface,&PluginInterface_PluginLoader::newState,this,&PluginLoader::newState,Qt::DirectConnection);
+ connect(pluginList.back().pluginLoaderInterface,&PluginInterface_PluginLoader::newState,this,&PluginLoader::newState,Qt::DirectConnection);
connect(LanguagesManager::languagesManager,&LanguagesManager::newLanguageLoaded,newEntry.pluginLoaderInterface,&PluginInterface_PluginLoader::newLanguageLoaded,Qt::DirectConnection);
if(needEnable)
{
- pluginList.last().inWaitOfReply=true;
+ pluginList.back().inWaitOfReply=true;
newEntry.pluginLoaderInterface->setEnabled(needEnable);
}
#else
+ #ifdef Q_OS_WIN32
+ factory=new WindowsExplorerLoader();
+ LocalPlugin newEntry;
+ #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE_DIRECT
+ newEntry.pluginLoader=NULL;
+ #endif
+
+ newEntry.options=new LocalPluginOptions("PluginLoader-"+plugin.name);
+ newEntry.pluginLoaderInterface = new WindowsExplorerLoader();
+ newEntry.path = plugin.path;
+ newEntry.state = Ultracopier::Uncaught;
+ newEntry.inWaitOfReply = false;
+ #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE_DIRECT
+ #ifdef ULTRACOPIER_DEBUG
+ connect(newEntry.pluginLoaderInterface,&PluginInterface_PluginLoader::debugInformation,this,&PluginLoader::debugInformation,Qt::DirectConnection);
+ #endif // ULTRACOPIER_DEBUG
+ #endif
+ pluginList.push_back(newEntry);
+ newEntry.pluginLoaderInterface->setResources(newEntry.options,plugin.writablePath,plugin.path,ULTRACOPIER_VERSION_PORTABLE_BOOL);
+ optionDialog->addPluginOptionWidget(PluginType_PluginLoader,plugin.name,newEntry.pluginLoaderInterface->options());
+ connect(pluginList.back().pluginLoaderInterface,&PluginInterface_PluginLoader::newState,this,&PluginLoader::newState,Qt::DirectConnection);
+ connect(LanguagesManager::languagesManager,&LanguagesManager::newLanguageLoaded,newEntry.pluginLoaderInterface,&PluginInterface_PluginLoader::newLanguageLoaded,Qt::DirectConnection);
+ if(needEnable)
+ {
+ pluginList.back().inWaitOfReply=true;
+ newEntry.pluginLoaderInterface->setEnabled(needEnable);
+ }
+ #endif
Q_UNUSED(plugin);
#endif
}
@@ -153,10 +191,9 @@ void PluginLoader::onePluginWillBeRemoved(const PluginsAvailable &plugin)
return;
if(plugin.category!=PluginType_PluginLoader)
return;
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));
- int index=0;
- const int &loop_size=pluginList.size();
- while(index<loop_size)
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
+ unsigned int index=0;
+ while(index<pluginList.size())
{
if(plugin.path==pluginList.at(index).path)
{
@@ -166,7 +203,7 @@ void PluginLoader::onePluginWillBeRemoved(const PluginsAvailable &plugin)
if(!pluginList.at(index).pluginLoader->isLoaded() || pluginList.at(index).pluginLoader->unload())
{
delete pluginList.at(index).options;
- pluginList.removeAt(index);
+ pluginList.erase(pluginList.cbegin()+index);
}
}
sendState();
@@ -182,8 +219,8 @@ void PluginLoader::load()
if(stopIt)
return;
needEnable=true;
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));
- int index=0;
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
+ unsigned int index=0;
while(index<pluginList.size())
{
pluginList[index].inWaitOfReply=true;
@@ -197,9 +234,9 @@ void PluginLoader::unload()
{
if(stopIt)
return;
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
needEnable=false;
- int index=0;
+ unsigned int index=0;
while(index<pluginList.size())
{
pluginList[index].inWaitOfReply=true;
@@ -210,9 +247,9 @@ void PluginLoader::unload()
}
#ifdef ULTRACOPIER_DEBUG
-void PluginLoader::debugInformation(const Ultracopier::DebugLevel &level,const QString& fonction,const QString& text,const QString& file,const int& ligne)
+void PluginLoader::debugInformation(const Ultracopier::DebugLevel &level,const std::string& fonction,const std::string& text,const std::string& file,const unsigned int& ligne)
{
- DebugEngine::addDebugInformationStatic(level,fonction,text,file,ligne,QStringLiteral("Plugin loader plugin"));
+ DebugEngine::addDebugInformationStatic(level,fonction,text,file,ligne,"Plugin loader plugin");
}
#endif // ULTRACOPIER_DEBUG
@@ -220,7 +257,7 @@ void PluginLoader::allPluginIsloaded()
{
if(stopIt)
return;
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("with value: ")+QString::number(pluginList.size()>0));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"with value: "+std::to_string(pluginList.size()>0));
sendState(true);
}
@@ -228,10 +265,10 @@ void PluginLoader::sendState(bool force)
{
if(stopIt)
return;
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start, pluginList.size(): %1, force: %2").arg(pluginList.size()).arg(force));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start, pluginList.size(): "+std::to_string(pluginList.size())+", force: "+std::to_string(force));
Ultracopier::CatchState current_state=Ultracopier::Uncaught;
bool found_not_listen=false,found_listen=false,found_inWaitOfReply=false;
- int index=0;
+ unsigned int index=0;
while(index<pluginList.size())
{
if(current_state==Ultracopier::Uncaught)
@@ -247,7 +284,7 @@ void PluginLoader::sendState(bool force)
found_inWaitOfReply=true;
index++;
}
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("current_state: %1").arg(current_state));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"current_state: "+std::to_string(current_state));
if(current_state==Ultracopier::Uncaught)
{
if(!found_not_listen && !found_listen)
@@ -265,11 +302,11 @@ void PluginLoader::sendState(bool force)
bool have_plugin=pluginList.size()>0;
if(force || current_state!=last_state || have_plugin!=last_have_plugin || found_inWaitOfReply!=last_inWaitOfReply)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("send pluginLoaderReady(%1,%2,%3)").arg(current_state).arg(have_plugin).arg(found_inWaitOfReply));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"send pluginLoaderReady("+std::to_string(current_state)+","+std::to_string(have_plugin)+","+std::to_string(found_inWaitOfReply)+")");
emit pluginLoaderReady(current_state,have_plugin,found_inWaitOfReply);
}
else
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Skip the signal sending"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Skip the signal sending");
last_state=current_state;
last_have_plugin=have_plugin;
last_inWaitOfReply=found_inWaitOfReply;
@@ -279,14 +316,14 @@ void PluginLoader::newState(const Ultracopier::CatchState &state)
{
if(stopIt)
return;
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start, state: %1").arg(state));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start, state: "+std::to_string(state));
PluginInterface_PluginLoader *temp=qobject_cast<PluginInterface_PluginLoader *>(QObject::sender());
if(temp==NULL)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("listener not located!"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"listener not located!");
return;
}
- int index=0;
+ unsigned int index=0;
while(index<pluginList.size())
{
if(temp==pluginList.at(index).pluginLoaderInterface)
@@ -298,5 +335,5 @@ void PluginLoader::newState(const Ultracopier::CatchState &state)
}
index++;
}
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("listener not found!"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"listener not found!");
}