diff options
Diffstat (limited to 'CopyListener.cpp')
-rwxr-xr-x | CopyListener.cpp | 75 |
1 files changed, 27 insertions, 48 deletions
diff --git a/CopyListener.cpp b/CopyListener.cpp index 4387156..c648b97 100755 --- a/CopyListener.cpp +++ b/CopyListener.cpp @@ -7,11 +7,11 @@ #include "CopyListener.h" - -CopyListener::CopyListener(QObject *parent) : - QObject(parent) +CopyListener::CopyListener(OptionDialog *optionDialog) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); + this->optionDialog=optionDialog; + pluginLoader=new PluginLoader(optionDialog); //load the options tryListen=false; QList<QPair<QString, QVariant> > KeysList; @@ -19,14 +19,15 @@ CopyListener::CopyListener(QObject *parent) : options->addOptionGroup("CopyListener",KeysList); plugins->lockPluginListEdition(); QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_Listener); - foreach(PluginsAvailable currentPlugin,list) - onePluginAdded(currentPlugin); qRegisterMetaType<PluginsAvailable>("PluginsAvailable"); qRegisterMetaType<ListeningState>("ListeningState"); - connect(plugins,SIGNAL(onePluginAdded(PluginsAvailable)), this,SLOT(onePluginAdded(PluginsAvailable))); + connect(this,SIGNAL(previouslyPluginAdded(PluginsAvailable)), this,SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection); + connect(plugins,SIGNAL(onePluginAdded(PluginsAvailable)), this,SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection); connect(plugins,SIGNAL(onePluginWillBeRemoved(PluginsAvailable)), this,SLOT(onePluginWillBeRemoved(PluginsAvailable)),Qt::DirectConnection); - connect(plugins,SIGNAL(pluginListingIsfinish()), this,SLOT(allPluginIsloaded())); - connect(&pluginLoader,SIGNAL(pluginLoaderReady(CatchState,bool,bool)), this,SIGNAL(pluginLoaderReady(CatchState,bool,bool))); + connect(plugins,SIGNAL(pluginListingIsfinish()), this,SLOT(allPluginIsloaded()),Qt::QueuedConnection); + connect(pluginLoader,SIGNAL(pluginLoaderReady(CatchState,bool,bool)), this,SIGNAL(pluginLoaderReady(CatchState,bool,bool))); + foreach(PluginsAvailable currentPlugin,list) + emit previouslyPluginAdded(currentPlugin); plugins->unlockPluginListEdition(); last_state=NotListening; last_have_plugin=false; @@ -39,6 +40,7 @@ CopyListener::~CopyListener() QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_Listener); foreach(PluginsAvailable currentPlugin,list) onePluginWillBeRemoved(currentPlugin); + delete pluginLoader; } void CopyListener::resendState() @@ -46,7 +48,7 @@ void CopyListener::resendState() if(plugins->allPluginHaveBeenLoaded()) { sendState(true); - pluginLoader.resendState(); + pluginLoader->resendState(); } } @@ -56,8 +58,8 @@ void CopyListener::onePluginAdded(const PluginsAvailable &plugin) return; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"try load: "+plugin.path+PluginsManager::getResolvedPluginName("listener")); //setFileName - QPluginLoader *pluginLoader=new QPluginLoader(plugin.path+PluginsManager::getResolvedPluginName("listener")); - QObject *pluginInstance = pluginLoader->instance(); + QPluginLoader *pluginOfPluginLoader=new QPluginLoader(plugin.path+PluginsManager::getResolvedPluginName("listener")); + QObject *pluginInstance = pluginOfPluginLoader->instance(); if(pluginInstance) { PluginInterface_Listener *listen = qobject_cast<PluginInterface_Listener *>(pluginInstance); @@ -67,8 +69,8 @@ void CopyListener::onePluginAdded(const PluginsAvailable &plugin) { if(pluginList.at(index).listenInterface==listen) { - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("Plugin already found")); - pluginLoader->unload(); + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("Plugin already found %1 for %2").arg(pluginList.at(index).path).arg(plugin.path)); + pluginOfPluginLoader->unload(); return; } index++; @@ -85,12 +87,14 @@ void CopyListener::onePluginAdded(const PluginsAvailable &plugin) connect(listen,SIGNAL(newMove(quint32,QStringList,QString)), this,SLOT(newPluginMove(quint32,QStringList,QString))); PluginListener newPluginListener; newPluginListener.listenInterface = listen; - newPluginListener.pluginLoader = pluginLoader; + newPluginListener.pluginLoader = pluginOfPluginLoader; newPluginListener.path = plugin.path+PluginsManager::getResolvedPluginName("listener"); newPluginListener.state = NotListening; newPluginListener.inWaitOfReply = false; newPluginListener.options=new LocalPluginOptions("Listener-"+plugin.name); newPluginListener.listenInterface->setResources(newPluginListener.options,plugin.writablePath,plugin.path,ULTRACOPIER_VERSION_PORTABLE_BOOL); + optionDialog->addPluginOptionWidget(PluginType_Listener,plugin.name,newPluginListener.listenInterface->options()); + connect(languages,SIGNAL(newLanguageLoaded(QString)),newPluginListener.listenInterface,SLOT(newLanguageLoaded())); pluginList << newPluginListener; connect(pluginList.last().listenInterface,SIGNAL(newState(ListeningState)),this,SLOT(newState(ListeningState))); if(tryListen) @@ -100,10 +104,10 @@ void CopyListener::onePluginAdded(const PluginsAvailable &plugin) } } else - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to cast the plugin: "+pluginLoader->errorString()); + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to cast the plugin: "+pluginOfPluginLoader->errorString()); } else - ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to load the plugin: "+pluginLoader->errorString()); + ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to load the plugin: "+pluginOfPluginLoader->errorString()); } #ifdef ULTRACOPIER_DEBUG @@ -184,14 +188,14 @@ void CopyListener::listen() pluginList.at(index).listenInterface->listen(); index++; } - pluginLoader.load(); + pluginLoader->load(); } void CopyListener::close() { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); tryListen=false; - pluginLoader.unload(); + pluginLoader->unload(); int index=0; while(index<pluginList.size()) { @@ -202,31 +206,6 @@ void CopyListener::close() copyRunningList.clear(); } -QStringList CopyListener::parseWildcardSources(QStringList sources) -{ - QStringList returnList; - int index=0; - while(index<sources.size()) - { - if(sources.at(index).contains("*")) - { - QFileInfo info(sources.at(index)); - QDir folder(info.absoluteDir()); - QFileInfoList fileFile=folder.entryInfoList(QStringList() << info.fileName()); - int index=0; - while(index<fileFile.size()) - { - returnList << fileFile.at(index).absoluteFilePath(); - index++; - } - } - else - returnList << sources.at(index); - index++; - } - return returnList; -} - QStringList CopyListener::stripSeparator(QStringList sources) { int index=0; @@ -242,28 +221,28 @@ QStringList CopyListener::stripSeparator(QStringList sources) void CopyListener::newCopy(QStringList sources) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - emit newCopy(incrementOrderId(),QStringList() << "file",stripSeparator(parseWildcardSources(sources))); + emit newCopy(incrementOrderId(),QStringList() << "file",stripSeparator(sources)); } /** new copy with destination have been pased by the CLI */ void CopyListener::newCopy(QStringList sources,QString destination) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - emit newCopy(incrementOrderId(),QStringList() << "file",stripSeparator(parseWildcardSources(sources)),"file",destination); + emit newCopy(incrementOrderId(),QStringList() << "file",stripSeparator(sources),"file",destination); } /** new move without destination have been pased by the CLI */ void CopyListener::newMove(QStringList sources) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - emit newMove(incrementOrderId(),QStringList() << "file",stripSeparator(parseWildcardSources(sources))); + emit newMove(incrementOrderId(),QStringList() << "file",stripSeparator(sources)); } /** new move with destination have been pased by the CLI */ void CopyListener::newMove(QStringList sources,QString destination) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); - emit newMove(incrementOrderId(),QStringList() << "file",stripSeparator(parseWildcardSources(sources)),"file",destination); + emit newMove(incrementOrderId(),QStringList() << "file",stripSeparator(sources),"file",destination); } void CopyListener::copyFinished(const quint32 & orderId,const bool &withError) @@ -407,7 +386,7 @@ void CopyListener::sendState(bool force) } else ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("Skip the signal sending")); - last_state=NotListening; + last_state=current_state; last_have_plugin=have_plugin; last_inWaitOfReply=found_inWaitOfReply; } |