diff options
Diffstat (limited to 'PluginsManager.cpp')
-rw-r--r-- | PluginsManager.cpp | 527 |
1 files changed, 267 insertions, 260 deletions
diff --git a/PluginsManager.cpp b/PluginsManager.cpp index 1a8ad42..95c158d 100644 --- a/PluginsManager.cpp +++ b/PluginsManager.cpp @@ -9,22 +9,26 @@ #include <QFile> #include <QFileInfo> +#include <iterator> + #include "PluginsManager.h" +#include "cpp11addition.h" +#include "FacilityEngine.h" /// \brief Create the manager and load the defaults variables PluginsManager::PluginsManager() { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); //load the overall instance pluginLoaded = false; - language = QStringLiteral("en"); + language = "en"; stopIt = false; pluginInformation = NULL; #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE importingPlugin = false; #endif editionSemList.release(); - englishPluginType << QStringLiteral("CopyEngine") << QStringLiteral("Languages") << QStringLiteral("Listener") << QStringLiteral("PluginLoader") << QStringLiteral("SessionLoader") << QStringLiteral("Themes"); + englishPluginType.push_back("CopyEngine");englishPluginType.push_back("Languages");englishPluginType.push_back("Listener");englishPluginType.push_back("PluginLoader");englishPluginType.push_back("SessionLoader");englishPluginType.push_back("Themes"); //catPlugin << tr("CopyEngine") << tr("Languages") << tr("Listener") << tr("PluginLoader") << tr("SessionLoader") << tr("Themes"); #ifdef ULTRACOPIER_PLUGIN_IMPORT_SUPPORT connect(&decodeThread, &QXzDecodeThread::decodedIsFinish, this, &PluginsManager::decodingFinished,Qt::QueuedConnection); @@ -48,7 +52,7 @@ PluginsManager::~PluginsManager() } /// \brief set current language -void PluginsManager::setLanguage(const QString &language) +void PluginsManager::setLanguage(const std::string &language) { this->language=language; } @@ -76,50 +80,50 @@ void PluginsManager::unlockPluginListEdition() void PluginsManager::run() { - regexp_to_clean_1=QRegularExpression(QStringLiteral("[\n\r]+")); - regexp_to_clean_2=QRegularExpression(QStringLiteral("[ \t]+")); - regexp_to_clean_3=QRegularExpression(QStringLiteral("(&&)+")); - regexp_to_clean_4=QRegularExpression(QStringLiteral("^&&")); - regexp_to_clean_5=QRegularExpression(QStringLiteral("&&$")); - regexp_to_dep_1=QRegularExpression(QStringLiteral("(&&|\\|\\||\\(|\\))")); - regexp_to_dep_2=QRegularExpression(QStringLiteral("^(<=|<|=|>|>=)[a-zA-Z0-9\\-]+-([0-9]+\\.)*[0-9]+$")); - regexp_to_dep_3=QRegularExpression(QStringLiteral("(<=|<|=|>|>=)")); - regexp_to_dep_4=QRegularExpression(QStringLiteral("-([0-9]+\\.)*[0-9]+")); - regexp_to_dep_5=QRegularExpression(QStringLiteral("[a-zA-Z0-9\\-]+-")); - regexp_to_dep_6=QRegularExpression(QStringLiteral("[a-zA-Z0-9\\-]+-([0-9]+\\.)*[0-9]+")); + regexp_to_clean_1=std::regex("[\n\r]+"); + regexp_to_clean_2=std::regex("[ \t]+"); + regexp_to_clean_3=std::regex("(&&)+"); + regexp_to_clean_4=std::regex("^&&"); + regexp_to_clean_5=std::regex("&&$"); + regexp_to_dep_1=std::regex("(&&|\\|\\||\\(|\\))"); + regexp_to_dep_2=std::regex("^(<=|<|=|>|>=)[a-zA-Z0-9\\-]+-([0-9]+\\.)*[0-9]+$"); + regexp_to_dep_3=std::regex("(<=|<|=|>|>=)"); + regexp_to_dep_4=std::regex("-([0-9]+\\.)*[0-9]+"); + regexp_to_dep_5=std::regex("[a-zA-Z0-9\\-]+-"); + regexp_to_dep_6=std::regex("[a-zA-Z0-9\\-]+-([0-9]+\\.)*[0-9]+"); //load the path and plugins into the path - QStringList readPath; - readPath << ResourcesManager::resourcesManager->getReadPath(); + const std::string &separator=FacilityEngine::separator(); + std::vector<std::string> readPath; + readPath=ResourcesManager::resourcesManager->getReadPath(); pluginsList.clear(); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("pluginsList.size(): ")+QString::number(pluginsList.size())); - foreach(QString basePath,readPath) + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"pluginsList.size(): "+std::to_string(pluginsList.size())); + foreach(std::string basePath,readPath) { - foreach(QString dirSub,englishPluginType) + foreach(std::string dirSub,englishPluginType) { - QString pluginComposed=basePath+dirSub+QDir::separator(); - QDir dir(pluginComposed); + std::string pluginComposed=basePath+dirSub+separator; + QDir dir(QString::fromStdString(pluginComposed)); if(stopIt) return; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("search plugin into: ")+pluginComposed); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"search plugin into: "+pluginComposed); if(dir.exists()) { foreach(QString dirName, dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot)) { if(stopIt) return; - loadPluginInformation(pluginComposed+dirName+QDir::separator()); + loadPluginInformation(pluginComposed+dirName.toStdString()+separator); } } } } #ifdef ULTRACOPIER_DEBUG - int index_debug=0; - const int &loop_size=pluginsList.size(); - while(index_debug<loop_size) + unsigned int index_debug=0; + while(index_debug<pluginsList.size()) { - QString category=categoryToString(pluginsList.at(index_debug).category); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,QStringLiteral("Plugin ")+QString::number(index_debug)+QStringLiteral(" loaded (")+category+QStringLiteral("): ")+pluginsList.at(index_debug).path); + std::string category=categoryToString(pluginsList.at(index_debug).category); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"Plugin "+std::to_string(index_debug)+" loaded ("+category+"): "+pluginsList.at(index_debug).path); index_debug++; } #endif @@ -127,45 +131,45 @@ void PluginsManager::run() while(checkDependencies()!=0){}; #endif //QList<PluginsAvailable> list; - int index=0; + unsigned int index=0; while(index<pluginsList.size()) { - if(pluginsList.at(index).errorString.isEmpty()) + if(pluginsList.at(index).errorString.empty()) emit onePluginAdded(pluginsList.at(index)); index++; } } -QString PluginsManager::categoryToString(const PluginType &category) const +std::string PluginsManager::categoryToString(const PluginType &category) const { switch(category) { case PluginType_CopyEngine: - return QStringLiteral("CopyEngine"); + return "CopyEngine"; break; case PluginType_Languages: - return QStringLiteral("Languages"); + return "Languages"; break; case PluginType_Listener: - return QStringLiteral("Listener"); + return "Listener"; break; case PluginType_PluginLoader: - return QStringLiteral("PluginLoader"); + return "PluginLoader"; break; case PluginType_SessionLoader: - return QStringLiteral("SessionLoader"); + return "SessionLoader"; break; case PluginType_Themes: - return QStringLiteral("Themes"); + return "Themes"; break; default: - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("cat text not found: ")+QString::number(category)); - return QStringLiteral("Unknown"); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"cat text not found: "+std::to_string(category)); + return "Unknown"; break; } } -QString PluginsManager::categoryToTranslation(const PluginType &category) +std::string PluginsManager::categoryToTranslation(const PluginType &category) { if(pluginInformation==NULL) { @@ -195,20 +199,20 @@ bool PluginsManager::isSamePlugin(const PluginsAvailable &pluginA,const PluginsA return true; } -bool PluginsManager::loadPluginInformation(const QString &path) +bool PluginsManager::loadPluginInformation(const std::string &path) { PluginsAvailable tempPlugin; tempPlugin.isAuth = false; tempPlugin.path = path; tempPlugin.category = PluginType_Unknow; - QDir pluginPath(path); + QDir pluginPath(QString::fromStdString(path)); if(pluginPath.cdUp() && pluginPath.cdUp() && - ResourcesManager::resourcesManager->getWritablePath()!="" && - pluginPath==QDir(ResourcesManager::resourcesManager->getWritablePath())) + !ResourcesManager::resourcesManager->getWritablePath().empty() && + pluginPath==QDir(QString::fromStdString(ResourcesManager::resourcesManager->getWritablePath()))) tempPlugin.isWritable=true; else tempPlugin.isWritable=false; - QFile xmlMetaData(path+QStringLiteral("informations.xml")); + QFile xmlMetaData(QString::fromStdString(path)+"informations.xml"); if(xmlMetaData.exists()) { if(xmlMetaData.open(QIODevice::ReadOnly)) @@ -218,26 +222,26 @@ bool PluginsManager::loadPluginInformation(const QString &path) } else { - tempPlugin.errorString=tr("informations.xml is not accessible"); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("informations.xml is not accessible into the plugin: ")+path); + tempPlugin.errorString=tr("informations.xml is not accessible").toStdString(); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"informations.xml is not accessible into the plugin: "+path); } } else { - tempPlugin.errorString=tr("informations.xml not found for the plugin"); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("informations.xml not found for the plugin: ")+path); + tempPlugin.errorString=tr("informations.xml not found for the plugin").toStdString(); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"informations.xml not found for the plugin: "+path); } editionSemList.acquire(); - pluginsList << tempPlugin; - if(tempPlugin.errorString==QStringLiteral("")) - pluginsListIndexed.insert(tempPlugin.category,tempPlugin); + pluginsList.push_back(tempPlugin); + if(tempPlugin.errorString.empty()) + pluginsListIndexed[tempPlugin.category].push_back(tempPlugin); editionSemList.release(); - if(tempPlugin.errorString==QStringLiteral("")) + if(tempPlugin.errorString.empty()) return true; else { emit onePluginInErrorAdded(tempPlugin); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Error detected, the not loaded: ")+tempPlugin.errorString+QStringLiteral(", for path: ")+tempPlugin.path); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error detected, the not loaded: "+tempPlugin.errorString+", for path: "+tempPlugin.path); return false; } } @@ -250,91 +254,88 @@ void PluginsManager::loadPluginXml(PluginsAvailable * thePlugin,const QByteArray QDomDocument domDocument; if (!domDocument.setContent(xml, false, &errorStr,&errorLine,&errorColumn)) { - thePlugin->errorString=tr("%1, parse error at line %2, column %3: %4").arg(QStringLiteral("informations.xml")).arg(errorLine).arg(errorColumn).arg(errorStr); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("%1, Parse error at line %2, column %3: %4").arg(QStringLiteral("informations.xml")).arg(errorLine).arg(errorColumn).arg(errorStr)); + thePlugin->errorString=tr("%1, parse error at line %2, column %3: %4").arg("informations.xml").arg(errorLine).arg(errorColumn).arg(errorStr).toStdString(); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"informations.xml, Parse error at line "+std::to_string(errorLine)+", column "+std::to_string(errorColumn)+": "+errorStr.toStdString()); } else { QDomElement root = domDocument.documentElement(); if (root.tagName() != QStringLiteral("package")) { - thePlugin->errorString=tr("\"package\" root tag not found for the xml file"); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("\"package\" root balise not found for the xml file")); + thePlugin->errorString=tr("\"package\" root tag not found for the xml file").toStdString(); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"\"package\" root balise not found for the xml file"); } //load the variable - if(thePlugin->errorString.isEmpty()) - loadBalise(root,QStringLiteral("title"),&(thePlugin->informations),&(thePlugin->errorString),true,true,true); - if(thePlugin->errorString.isEmpty()) - loadBalise(root,QStringLiteral("website"),&(thePlugin->informations),&(thePlugin->errorString),false,true); - if(thePlugin->errorString.isEmpty()) - loadBalise(root,QStringLiteral("description"),&(thePlugin->informations),&(thePlugin->errorString),true,true,true); - if(thePlugin->errorString.isEmpty()) - loadBalise(root,QStringLiteral("author"),&(thePlugin->informations),&(thePlugin->errorString),true,false); - if(thePlugin->errorString.isEmpty()) - loadBalise(root,QStringLiteral("pubDate"),&(thePlugin->informations),&(thePlugin->errorString),true,false); - if(thePlugin->errorString.isEmpty()) + if(thePlugin->errorString.empty()) + loadBalise(root,"title",&(thePlugin->informations),&(thePlugin->errorString),true,true,true); + if(thePlugin->errorString.empty()) + loadBalise(root,"website",&(thePlugin->informations),&(thePlugin->errorString),false,true); + if(thePlugin->errorString.empty()) + loadBalise(root,"description",&(thePlugin->informations),&(thePlugin->errorString),true,true,true); + if(thePlugin->errorString.empty()) + loadBalise(root,"author",&(thePlugin->informations),&(thePlugin->errorString),true,false); + if(thePlugin->errorString.empty()) + loadBalise(root,"pubDate",&(thePlugin->informations),&(thePlugin->errorString),true,false); + if(thePlugin->errorString.empty()) { - loadBalise(root,QStringLiteral("version"),&(thePlugin->informations),&(thePlugin->errorString),true,false); - if(thePlugin->errorString.isEmpty()) - thePlugin->version=thePlugin->informations.last().last(); + loadBalise(root,"version",&(thePlugin->informations),&(thePlugin->errorString),true,false); + if(thePlugin->errorString.empty()) + thePlugin->version=thePlugin->informations.back().back(); } - if(thePlugin->errorString.isEmpty()) + if(thePlugin->errorString.empty()) { - loadBalise(root,QStringLiteral("category"),&(thePlugin->informations),&(thePlugin->errorString),true,false); - if(thePlugin->errorString.isEmpty()) + loadBalise(root,"category",&(thePlugin->informations),&(thePlugin->errorString),true,false); + if(thePlugin->errorString.empty()) { - QString tempCat=thePlugin->informations.last().last(); - if(tempCat==QStringLiteral("Languages")) + std::string tempCat=thePlugin->informations.back().back(); + if(tempCat=="Languages") thePlugin->category=PluginType_Languages; - else if(tempCat==QStringLiteral("CopyEngine")) + else if(tempCat=="CopyEngine") thePlugin->category=PluginType_CopyEngine; - else if(tempCat==QStringLiteral("Listener")) + else if(tempCat=="Listener") thePlugin->category=PluginType_Listener; - else if(tempCat==QStringLiteral("PluginLoader")) + else if(tempCat=="PluginLoader") thePlugin->category=PluginType_PluginLoader; - else if(tempCat==QStringLiteral("SessionLoader")) + else if(tempCat=="SessionLoader") thePlugin->category=PluginType_SessionLoader; - else if(tempCat==QStringLiteral("Themes")) + else if(tempCat=="Themes") thePlugin->category=PluginType_Themes; else - thePlugin->errorString=QStringLiteral("Unknow category: ")+QString::number((int)thePlugin->category); - if(thePlugin->errorString.isEmpty()) + thePlugin->errorString="Unknow category: "+std::to_string((int)thePlugin->category); + if(thePlugin->errorString.empty()) { if(thePlugin->category!=PluginType_Languages) { #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE - loadBalise(root,QStringLiteral("architecture"),&(thePlugin->informations),&(thePlugin->errorString),true,false); - if(thePlugin->errorString.isEmpty()) + loadBalise(root,"architecture",&(thePlugin->informations),&(thePlugin->errorString),true,false); + if(thePlugin->errorString.empty()) { - if(thePlugin->informations.last().last()!=ULTRACOPIER_PLATFORM_CODE) - thePlugin->errorString=QStringLiteral("Wrong platform code: ")+thePlugin->informations.last().last(); + if(thePlugin->informations.back().back()!=ULTRACOPIER_PLATFORM_CODE) + thePlugin->errorString="Wrong platform code: "+thePlugin->informations.back().back(); } #endif } } } } - if(thePlugin->errorString.isEmpty()) + if(thePlugin->errorString.empty()) { - loadBalise(root,QStringLiteral("name"),&(thePlugin->informations),&(thePlugin->errorString),true,false); - if(thePlugin->errorString.isEmpty()) + loadBalise(root,"name",&(thePlugin->informations),&(thePlugin->errorString),true,false); + if(thePlugin->errorString.empty()) { - thePlugin->name=thePlugin->informations.last().last(); - int index=0; - const int &loop_size=pluginsList.size(); - int sub_index,loop_sub_size; - while(index<loop_size) + thePlugin->name=thePlugin->informations.back().back(); + size_t index=0; + while(index<pluginsList.size()) { - sub_index=0; - loop_sub_size=pluginsList.at(index).informations.size(); - while(sub_index<loop_sub_size) + size_t sub_index=0; + while(sub_index<pluginsList.at(index).informations.size()) { - if(pluginsList.at(index).informations.at(sub_index).first()==QStringLiteral("name") && + if(pluginsList.at(index).informations.at(sub_index).front()=="name" && pluginsList.at(index).name==thePlugin->name && pluginsList.at(index).category==thePlugin->category) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Plugin duplicate found ("+QString::number((int)thePlugin->category)+"/"+pluginsList.at(index).informations.at(sub_index).last()+"), already loaded, actual version skipped: "+thePlugin->version); - thePlugin->errorString=tr("Duplicated plugin found, already loaded!"); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Plugin duplicate found ("+std::to_string((int)thePlugin->category)+"/"+pluginsList.at(index).informations.at(sub_index).back()+"), already loaded, actual version skipped: "+thePlugin->version); + thePlugin->errorString=tr("Duplicated plugin found, already loaded!").toStdString(); break; break; } @@ -344,11 +345,11 @@ void PluginsManager::loadPluginXml(PluginsAvailable * thePlugin,const QByteArray } } } - if(thePlugin->errorString.isEmpty()) - loadBalise(root,QStringLiteral("dependencies"),&(thePlugin->informations),&(thePlugin->errorString),true,false); - if(thePlugin->errorString.isEmpty()) + if(thePlugin->errorString.empty()) + loadBalise(root,"dependencies",&(thePlugin->informations),&(thePlugin->errorString),true,false); + if(thePlugin->errorString.empty()) { - QDomElement child = root.firstChildElement(QStringLiteral("categorySpecific")); + QDomElement child = root.firstChildElement("categorySpecific"); if(!child.isNull() && child.isElement()) thePlugin->categorySpecific=child; } @@ -356,16 +357,16 @@ void PluginsManager::loadPluginXml(PluginsAvailable * thePlugin,const QByteArray } /// \brief to load the multi-language balise -void PluginsManager::loadBalise(const QDomElement &root,const QString &name,QList<QStringList> *informations,QString *errorString,bool needHaveOneEntryMinimum,bool multiLanguage,bool englishNeedBeFound) +void PluginsManager::loadBalise(const QDomElement &root,const std::string &name,std::vector<std::vector<std::string> > *informations,std::string *errorString,bool needHaveOneEntryMinimum,bool multiLanguage,bool englishNeedBeFound) { int foundElement=0; bool englishTextIsFoundForThisChild=false; - QDomElement child = root.firstChildElement(name); + QDomElement child = root.firstChildElement(QString::fromStdString(name)); while(!child.isNull()) { if(child.isElement()) { - QStringList newInformations; + std::vector<std::string> newInformations; if(multiLanguage) { if(child.hasAttribute(QStringLiteral("xml:lang"))) @@ -373,53 +374,55 @@ void PluginsManager::loadBalise(const QDomElement &root,const QString &name,QLis if(child.attribute(QStringLiteral("xml:lang"))==QStringLiteral("en")) englishTextIsFoundForThisChild=true; foundElement++; - newInformations << child.tagName() << child.attribute(QStringLiteral("xml:lang")) << child.text(); + newInformations.push_back(child.tagName().toStdString()); + newInformations.push_back(child.attribute(QStringLiteral("xml:lang")).toStdString()); + newInformations.push_back(child.text().toStdString()); } else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Have not the attribute xml:lang: child.tagName(): %1, child.text(): %2").arg(child.tagName()).arg(child.text())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Have not the attribute xml:lang: child.tagName(): "+child.tagName().toStdString()+", child.text(): "+child.text().toStdString()); } else { foundElement++; - newInformations << child.tagName() << child.text(); + newInformations.push_back(child.tagName().toStdString()); + newInformations.push_back(child.text().toStdString()); } - *informations << newInformations; + informations->push_back(newInformations); } else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Is not Element: child.tagName(): %1").arg(child.tagName())); - child = child.nextSiblingElement(name); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Is not Element: child.tagName(): "+child.tagName().toStdString()); + child = child.nextSiblingElement(QString::fromStdString(name)); } if(multiLanguage && englishTextIsFoundForThisChild==false && englishNeedBeFound) { informations->clear(); - *errorString=tr("English text missing in the informations.xml for the tag: %1").arg(name); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("English text missing into the informations.xml for the tag: %1").arg(name)); + *errorString=tr("English text missing in the informations.xml for the tag: %1").arg(QString::fromStdString(name)).toStdString(); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"English text missing into the informations.xml for the tag: "+name); return; } if(needHaveOneEntryMinimum && foundElement==0) { informations->clear(); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Tag not found: %1").arg(name)); - *errorString=tr("Tag not found: %1").arg(name); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Tag not found: "+name); + *errorString=tr("Tag not found: %1").arg(QString::fromStdString(name)).toStdString(); } } /// \brief to load the get dom specific -QString PluginsManager::getDomSpecific(const QDomElement &root,const QString &name,const QList<QPair<QString,QString> > &listChildAttribute) const +std::string PluginsManager::getDomSpecific(const QDomElement &root,const std::string &name,const std::vector<std::pair<std::string,std::string> > &listChildAttribute) const { - QDomElement child = root.firstChildElement(name); - int index,loop_size; + QDomElement child = root.firstChildElement(QString::fromStdString(name)); bool allIsFound; while(!child.isNull()) { if(child.isElement()) { allIsFound=true; - index=0; - loop_size=listChildAttribute.size(); - while(index<loop_size) + size_t index=0; + while(index<listChildAttribute.size()) { - if(child.attribute(listChildAttribute.at(index).first)!=listChildAttribute.at(index).second) + const std::pair<std::string,std::string> &entry=listChildAttribute.at(index); + if(child.attribute(QString::fromStdString(entry.first))!=QString::fromStdString(entry.second)) { allIsFound=false; break; @@ -427,92 +430,89 @@ QString PluginsManager::getDomSpecific(const QDomElement &root,const QString &na index++; } if(allIsFound) - return child.text(); + return child.text().toStdString(); } else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Is not Element: child.tagName(): %1").arg(child.tagName())); - child = child.nextSiblingElement(name); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Is not Element: child.tagName(): "+child.tagName().toStdString()); + child = child.nextSiblingElement(QString::fromStdString(name)); } - return QString(); + return std::string(); } /// \brief to load the get dom specific -QString PluginsManager::getDomSpecific(const QDomElement &root,const QString &name) const +std::string PluginsManager::getDomSpecific(const QDomElement &root,const std::string &name) const { - QDomElement child = root.firstChildElement(name); + QDomElement child = root.firstChildElement(QString::fromStdString(name)); while(!child.isNull()) { if(child.isElement()) - return child.text(); + return child.text().toStdString(); else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("Is not Element: child.tagName(): %1").arg(child.tagName())); - child = child.nextSiblingElement(name); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Is not Element: child.tagName(): "+child.tagName().toStdString()); + child = child.nextSiblingElement(QString::fromStdString(name)); } - return QString(); + return std::string(); } #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE /// \brief check the dependencies -quint32 PluginsManager::checkDependencies() +uint32_t PluginsManager::checkDependencies() { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); - quint32 errors=0; - int index=0; - const int &loop_size=pluginsList.size(); - int sub_index,loop_sub_size,resolv_size,indexOfDependencies; + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); + uint32_t errors=0; + unsigned int index=0; bool depCheck; - while(index<loop_size) + while(index<pluginsList.size()) { - sub_index=0; - loop_sub_size=pluginsList.at(index).informations.size(); - while(sub_index<loop_sub_size) + unsigned int sub_index=0; + while(sub_index<pluginsList.at(index).informations.size()) { - if(pluginsList.at(index).informations.at(sub_index).size()==2 && pluginsList.at(index).informations.at(sub_index).at(0)==QStringLiteral("dependencies")) + if(pluginsList.at(index).informations.at(sub_index).size()==2 && pluginsList.at(index).informations.at(sub_index).at(0)=="dependencies") { - QString dependencies=pluginsList.at(index).informations.at(sub_index).at(1); - dependencies=dependencies.replace(regexp_to_clean_1,QStringLiteral("&&")); - dependencies=dependencies.replace(regexp_to_clean_2,QStringLiteral("")); - dependencies=dependencies.replace(regexp_to_clean_3,QStringLiteral("&&")); - dependencies=dependencies.replace(regexp_to_clean_4,QStringLiteral("")); - dependencies=dependencies.replace(regexp_to_clean_5,QStringLiteral("")); - QStringList dependenciesToResolv=dependencies.split(regexp_to_dep_1,QString::SkipEmptyParts); - indexOfDependencies=0; - resolv_size=dependenciesToResolv.size(); - while(indexOfDependencies<resolv_size) + std::string dependencies = pluginsList.at(index).informations.at(sub_index).at(1); + dependencies=std::regex_replace(dependencies, regexp_to_clean_1,"&&"); + dependencies=std::regex_replace(dependencies, regexp_to_clean_2,""); + dependencies=std::regex_replace(dependencies, regexp_to_clean_3,"&&"); + dependencies=std::regex_replace(dependencies, regexp_to_clean_4,""); + dependencies=std::regex_replace(dependencies, regexp_to_clean_5,""); + std::sregex_token_iterator iter(dependencies.begin(), dependencies.end(), regexp_to_dep_1, -1), end; + for ( ; iter != end; ++iter) { - QString dependenciesToParse=dependenciesToResolv.at(indexOfDependencies); - if(!dependenciesToParse.contains(regexp_to_dep_2)) + std::string dependenciesToParse=trim(*iter); + if(dependenciesToParse.empty()) { + continue; + } + if(!std::regex_match(dependenciesToParse, regexp_to_dep_2)) { pluginsList[index].informations.clear(); - pluginsList[index].errorString=tr("Dependencies part is wrong"); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Dependencies part is wrong: %1").arg(dependenciesToParse)); + pluginsList[index].errorString=tr("Dependencies part is wrong").toStdString(); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Dependencies part is wrong: "+dependenciesToParse); emit onePluginInErrorAdded(pluginsList.at(index)); errors++; break; } - QString partName=dependenciesToParse; - partName=partName.remove(regexp_to_dep_3); - partName=partName.remove(regexp_to_dep_4); - QString partVersion=dependenciesToParse; - partVersion=partVersion.remove(regexp_to_dep_3); - partVersion=partVersion.remove(regexp_to_dep_5); - QString partComp=dependenciesToParse; - partComp=partComp.remove(regexp_to_dep_6); + std::string partName=dependenciesToParse; + partName=std::regex_replace(partName, regexp_to_dep_3, ""); + partName=std::regex_replace(partName, regexp_to_dep_4, ""); + std::string partVersion=dependenciesToParse; + partVersion=std::regex_replace(partVersion, regexp_to_dep_3, ""); + partVersion=std::regex_replace(partVersion, regexp_to_dep_5, ""); + std::string partComp=dependenciesToParse; + partComp=std::regex_replace(partComp, regexp_to_dep_6, ""); //current version soft - QString pluginVersion=getPluginVersion(partName); + std::string pluginVersion=getPluginVersion(partName); depCheck=compareVersion(pluginVersion,partComp,partVersion); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("dependencies to resolv, partName: ")+partName+QStringLiteral(", partVersion: ")+partVersion+QStringLiteral(", partComp: ")+partComp+QStringLiteral(", pluginVersion: ")+pluginVersion+QStringLiteral(", depCheck: ")+QString::number(depCheck)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"dependencies to resolv, partName: "+partName+", partVersion: "+partVersion+", partComp: "+partComp+", pluginVersion: "+pluginVersion+", depCheck: "+std::to_string(depCheck)); if(!depCheck) { pluginsList[index].informations.clear(); - pluginsList[index].errorString=tr("Dependencies %1 are not satisfied, for plugin: %2").arg(dependenciesToParse).arg(pluginsList[index].path); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Dependencies %1 are not satisfied, for plugin: %2").arg(dependenciesToParse).arg(pluginsList[index].path)); - pluginsListIndexed.remove(pluginsList.at(index).category,pluginsList.at(index)); + pluginsList[index].errorString=tr("Dependencies %1 are not satisfied, for plugin: %2").arg(QString::fromStdString(dependenciesToParse)).arg(QString::fromStdString(pluginsList[index].path)).toStdString(); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Dependencies "+dependenciesToParse+" are not satisfied, for plugin: "+pluginsList[index].path); + pluginsListIndexed.erase(pluginsListIndexed.find(pluginsList.at(index).category)); emit onePluginInErrorAdded(pluginsList.at(index)); errors++; break; } - indexOfDependencies++; } } sub_index++; @@ -524,26 +524,26 @@ quint32 PluginsManager::checkDependencies() #endif /// \brief get the version -QString PluginsManager::getPluginVersion(const QString &pluginName) const +std::string PluginsManager::getPluginVersion(const std::string &pluginName) const { #ifdef ULTRACOPIER_MODE_SUPERCOPIER - if(pluginName==QStringLiteral("supercopier")) - return ULTRACOPIER_VERSION; - #else - if(pluginName==QStringLiteral("ultracopier")) - return ULTRACOPIER_VERSION; - #endif - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); - int index=0; + if(pluginName=="supercopier") + return ULTRACOPIER_VERSION; + #else + if(pluginName=="ultracopier") + return ULTRACOPIER_VERSION; + #endif + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); + unsigned int index=0; while(index<pluginsList.size()) { - QString version,internalName; - int sub_index=0; + std::string version,internalName; + unsigned int sub_index=0; while(sub_index<pluginsList.at(index).informations.size()) { - if(pluginsList.at(index).informations.at(sub_index).size()==2 && pluginsList.at(index).informations.at(sub_index).at(0)==QStringLiteral("version")) + if(pluginsList.at(index).informations.at(sub_index).size()==2 && pluginsList.at(index).informations.at(sub_index).at(0)=="version") version=pluginsList.at(index).informations.at(sub_index).at(1); - if(pluginsList.at(index).informations.at(sub_index).size()==2 && pluginsList.at(index).informations.at(sub_index).at(0)==QStringLiteral("internalName")) + if(pluginsList.at(index).informations.at(sub_index).size()==2 && pluginsList.at(index).informations.at(sub_index).at(0)=="internalName") internalName=pluginsList.at(index).informations.at(sub_index).at(1); sub_index++; } @@ -554,45 +554,50 @@ QString PluginsManager::getPluginVersion(const QString &pluginName) const return ""; } -/// \brief To compare version -bool PluginsManager::compareVersion(const QString &versionA,const QString &sign,const QString &versionB) +/// \brief To compare version, \return true is case of error +bool PluginsManager::compareVersion(const std::string &versionA,const std::string &sign,const std::string &versionB) { - QStringList versionANumber=versionA.split(QStringLiteral(".")); - QStringList versionBNumber=versionB.split(QStringLiteral(".")); - int index=0; - int defaultReturnValue=true; - if(sign==QStringLiteral("<")) + std::vector<std::string> versionANumber=stringsplit(versionA,'.'); + std::vector<std::string> versionBNumber=stringsplit(versionB,'.'); + unsigned int index=0; + unsigned int defaultReturnValue=true; + if(sign=="<") defaultReturnValue=false; - if(sign==QStringLiteral(">")) + if(sign==">") defaultReturnValue=false; + bool ok; while(index<versionANumber.size() && index<versionBNumber.size()) { - unsigned int reaNumberA=versionANumber.at(index).toUInt(); - unsigned int reaNumberB=versionBNumber.at(index).toUInt(); - if(sign==QStringLiteral("=") && reaNumberA!=reaNumberB) + unsigned int reaNumberA=stringtouint8(versionANumber.at(index),&ok); + if(!ok) + return true; + unsigned int reaNumberB=stringtouint8(versionBNumber.at(index),&ok); + if(!ok) + return true; + if(sign=="=" && reaNumberA!=reaNumberB) return false; - if(sign==QStringLiteral("<")) + if(sign=="<") { if(reaNumberA>reaNumberB) return false; if(reaNumberA<reaNumberB) return true; } - if(sign==QStringLiteral(">")) + if(sign==">") { if(reaNumberA<reaNumberB) return false; if(reaNumberA>reaNumberB) return true; } - if(sign==QStringLiteral("<=")) + if(sign=="<=") { if(reaNumberA>reaNumberB) return false; if(reaNumberA<reaNumberB) return true; } - if(sign==QStringLiteral(">=")) + if(sign==">=") { if(reaNumberA<reaNumberB) return false; @@ -604,29 +609,31 @@ bool PluginsManager::compareVersion(const QString &versionA,const QString &sign, return defaultReturnValue; } -QList<PluginsAvailable> PluginsManager::getPluginsByCategory(const PluginType &category) const +std::vector<PluginsAvailable> PluginsManager::getPluginsByCategory(const PluginType &category) const { - return pluginsListIndexed.values(category); + if(pluginsListIndexed.find(category)==pluginsListIndexed.cend()) + return std::vector<PluginsAvailable>(); + return pluginsListIndexed.at(category); } -QList<PluginsAvailable> PluginsManager::getPlugins(bool withError) const +std::vector<PluginsAvailable> PluginsManager::getPlugins(bool withError) const { - QList<PluginsAvailable> list; - int index=0; + std::vector<PluginsAvailable> list; + unsigned int index=0; while(index<pluginsList.size()) { - if(withError || pluginsList.at(index).errorString.isEmpty()) - list<<pluginsList.at(index); + if(withError || pluginsList.at(index).errorString.empty()) + list.push_back(pluginsList.at(index)); index++; } return list; } /// \brief show the information -void PluginsManager::showInformation(const QString &path) +void PluginsManager::showInformation(const std::string &path) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); - int index=0; + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); + unsigned int index=0; while(index<pluginsList.size()) { if(pluginsList.at(index).path==path) @@ -643,7 +650,7 @@ void PluginsManager::showInformation(const QString &path) } index++; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("item not selected")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"item not selected"); } void PluginsManager::showInformationDoubleClick() @@ -652,17 +659,17 @@ void PluginsManager::showInformationDoubleClick() } #ifdef ULTRACOPIER_PLUGIN_IMPORT_SUPPORT -void PluginsManager::removeThePluginSelected(const QString &path) +void PluginsManager::removeThePluginSelected(const std::string &path) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); - int index=0; + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); + unsigned int index=0; while(index<pluginsList.size()) { if(pluginsList.at(index).path==path) { QMessageBox::StandardButton reply; // if(pluginsList.at(index).internalVersionAlternative.isEmpty()) - reply = QMessageBox::question(NULL,tr("Remove %1").arg(pluginsList.at(index).name),tr("Are you sure about removing \"%1\" in version %2?").arg(pluginsList.at(index).name).arg(pluginsList.at(index).version),QMessageBox::Yes|QMessageBox::No,QMessageBox::No); + reply = QMessageBox::question(NULL,tr("Remove %1").arg(QString::fromStdString(pluginsList.at(index).name)),tr("Are you sure about removing \"%1\" in version %2?").arg(QString::fromStdString(pluginsList.at(index).name)).arg(QString::fromStdString(pluginsList.at(index).version)),QMessageBox::Yes|QMessageBox::No,QMessageBox::No); // else // reply = QMessageBox::question(NULL,tr("Remove %1").arg(getTranslatedText(pluginsList.at(index),"name",mainShortName)),tr("Are you sure to wish remove \"%1\" in version %2 for the internal version %3?").arg(getTranslatedText(pluginsList.at(index),"name",mainShortName)).arg(pluginsList.at(index).version).arg(pluginsList.at(index).internalVersionAlternative),QMessageBox::Yes|QMessageBox::No,QMessageBox::No); if(reply==QMessageBox::Yes) @@ -673,17 +680,17 @@ void PluginsManager::removeThePluginSelected(const QString &path) if(!ResourcesManager::removeFolder(pluginsList.at(index).path)) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to remove the plugin"); - QMessageBox::critical(NULL,tr("Error"),tr("Error while the removing plugin, please check the rights on the folder: \n%1").arg(pluginsList.at(index).path)); + QMessageBox::critical(NULL,tr("Error"),tr("Error while the removing plugin, please check the rights on the folder: \n%1").arg(QString::fromStdString(pluginsList.at(index).path))); } - pluginsListIndexed.remove(pluginsList.at(index).category,pluginsList.at(index)); - pluginsList.removeAt(index); + pluginsListIndexed.erase(pluginsListIndexed.find(pluginsList.at(index).category)); + pluginsList.erase(pluginsList.begin()+index); while(checkDependencies()!=0){}; } return; } index++; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("item not selected")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"item not selected"); } void PluginsManager::addPlugin(const ImportBackend &backend) @@ -694,20 +701,20 @@ void PluginsManager::addPlugin(const ImportBackend &backend) void PluginsManager::executeTheFileBackendLoader() { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); if(importingPlugin) { QMessageBox::information(NULL,tr("Information"),tr("Previous import is in progress...")); return; } - QString fileName = QFileDialog::getOpenFileName(NULL,tr("Open Ultracopier plugin"),QString(),tr("Ultracopier plugin (*.urc)")); + std::string fileName = QFileDialog::getOpenFileName(NULL,tr("Open Ultracopier plugin"),QString(),tr("Ultracopier plugin (*.urc)")).toStdString(); if(fileName!="") tryLoadPlugin(fileName); } -void PluginsManager::tryLoadPlugin(const QString &file) +void PluginsManager::tryLoadPlugin(const std::string &file) { - QFile temp(file); + QFile temp(QString::fromStdString(file)); if(temp.open(QIODevice::ReadOnly)) { importingPlugin=true; @@ -716,32 +723,32 @@ void PluginsManager::tryLoadPlugin(const QString &file) } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"unable to open the file: "+temp.errorString()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"unable to open the file: "+temp.errorString().toStdString()); QMessageBox::critical(NULL,tr("Plugin loader"),tr("Unable to open the plugin: %1").arg(temp.errorString())); } } void PluginsManager::lunchDecodeThread(const QByteArray &data) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); decodeThread.setData(data); decodeThread.start(QThread::LowestPriority); } void PluginsManager::decodingFinished() { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); if(!decodeThread.errorFound()) { QByteArray data=decodeThread.decodedData(); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"data.size(): "+QString::number(data.size())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"data.size(): "+std::to_string(data.size())); QTarDecode tarFile; std::vector<char> cppdata; cppdata.resize(data.size()); memcpy(cppdata.data(),data.data(),data.size()); if(!tarFile.decodeData(cppdata)) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"tarFile.errorString(): "+QString::fromStdString(tarFile.errorString())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"tarFile.errorString(): "+tarFile.errorString()); QMessageBox::critical(NULL,tr("Plugin loader"),tr("Unable to load the plugin content, please check it: %1").arg(QString::fromStdString(tarFile.errorString()))); } else @@ -750,16 +757,16 @@ void PluginsManager::decodingFinished() std::vector<std::vector<char> > dataList = tarFile.getDataList(); if(fileList.size()>1) { - QString basePluginArchive=QStringLiteral(""); + std::string basePluginArchive=""; /* block use less for tar? if(fileList.at(0).contains(QRegularExpression("[\\/]"))) { bool folderFoundEveryWhere=true; basePluginArchive=fileList.at(0); - basePluginArchive.remove(QRegularExpression("[\\/].*$")); + basePluginArchive=std::regex_replace(basePluginArchive, std::regex("[\\/].*$"), ""); for (int i = 0; i < list.size(); ++i) { - if(!fileList.at(i).startsWith(basePluginArchive)) + if(!stringStartWith(fileList.at(i),basePluginArchive)) { folderFoundEveryWhere=false; break; @@ -768,17 +775,17 @@ void PluginsManager::decodingFinished() if(folderFoundEveryWhere) { for (int i = 0; i < fileList.size(); ++i) - fileList[i].remove(0,basePluginArchive.size()); + fileList[i].substr(basePluginArchive.size()); } else basePluginArchive=""; }*/ PluginsAvailable tempPlugin; - QString categoryFinal=QStringLiteral(""); + std::string categoryFinal=""; for (unsigned int i = 0; i < fileList.size(); ++i) if(fileList.at(i)=="informations.xml") { - loadPluginXml(&tempPlugin,QByteArray(dataList.at(i).data(),dataList.at(i).size())); + loadPluginXml(&tempPlugin,QByteArray(dataList.at(i).data(),static_cast<int>(dataList.at(i).size()))); break; } if(tempPlugin.errorString=="") @@ -786,43 +793,43 @@ void PluginsManager::decodingFinished() categoryFinal=categoryToString(tempPlugin.category); if(categoryFinal!="") { - QString writablePath=ResourcesManager::resourcesManager->getWritablePath(); + std::string writablePath=ResourcesManager::resourcesManager->getWritablePath(); if(writablePath!="") { QDir dir; - QString finalPluginPath=writablePath+categoryFinal+QDir::separator()+tempPlugin.name+QDir::separator(); + std::string finalPluginPath=writablePath+categoryFinal+FacilityEngine::separator()+tempPlugin.name+FacilityEngine::separator(); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"writablePath: \""+writablePath+"\""); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"basePluginArchive: \""+basePluginArchive+"\""); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"categoryFinal: \""+categoryFinal+"\""); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"finalPluginPath: \""+finalPluginPath+"\""); - if(!dir.exists(finalPluginPath)) + if(!dir.exists(QString::fromStdString(finalPluginPath))) { bool errorFound=false; for (unsigned int i = 0; i < fileList.size(); ++i) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"file "+QString::number(i)+": "+finalPluginPath+QString::fromStdString(fileList.at(i))); - QString fileListEntry=QString::fromStdString(fileList[i]); - fileListEntry.remove(QRegularExpression("^(..?[\\/])+")); - QFile currentFile(finalPluginPath+fileListEntry); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"file "+std::to_string(i)+": "+finalPluginPath+fileList.at(i)); + std::string fileListEntry=fileList[i]; + fileListEntry=std::regex_replace(fileListEntry, std::regex("^(..?[\\/])+"), ""); + QFile currentFile(QString::fromStdString(finalPluginPath+fileListEntry)); QFileInfo info(currentFile); if(!dir.exists(info.absolutePath())) if(!dir.mkpath(info.absolutePath())) { ResourcesManager::resourcesManager->disableWritablePath(); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"Unable to make the path: "+info.absolutePath()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"Unable to make the path: "+info.absolutePath().toStdString()); QMessageBox::critical(NULL,tr("Plugin loader"),tr("Unable to create a folder to install the plugin:\n%1").arg(info.absolutePath())); errorFound=true; break; } if(currentFile.open(QIODevice::ReadWrite)) { - currentFile.write(QByteArray(dataList.at(i).data(),dataList.at(i).size())); + currentFile.write(QByteArray(dataList.at(i).data(),static_cast<int>(dataList.at(i).size()))); currentFile.close(); } else { ResourcesManager::resourcesManager->disableWritablePath(); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"Unable to make the file: "+info.absolutePath()+", error:"+currentFile.errorString()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"Unable to make the file: "+info.absolutePath().toStdString()+", error:"+currentFile.errorString().toStdString()); QMessageBox::critical(NULL,tr("Plugin loader"),tr("Unable to create a file to install the plugin:\n%1\nsince:%2").arg(info.absolutePath()).arg(currentFile.errorString())); errorFound=true; break; @@ -842,7 +849,7 @@ void PluginsManager::decodingFinished() else { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"Folder with same name is present, skip the plugin installation: "+finalPluginPath); - QMessageBox::critical(NULL,tr("Plugin loader"),tr("Folder with same name is present, skip the plugin installation:\n%1").arg(finalPluginPath)); + QMessageBox::critical(NULL,tr("Plugin loader"),tr("Folder with same name is present, skip the plugin installation:\n%1").arg(QString::fromStdString(finalPluginPath))); } } else @@ -860,7 +867,7 @@ void PluginsManager::decodingFinished() else { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error in the xml: "+tempPlugin.errorString); - QMessageBox::critical(NULL,tr("Plugin loader"),tr("Unable to load the plugin content, please check it: %1").arg(tempPlugin.errorString)); + QMessageBox::critical(NULL,tr("Plugin loader"),tr("Unable to load the plugin content, please check it: %1").arg(QString::fromStdString(tempPlugin.errorString))); } } else @@ -872,7 +879,7 @@ void PluginsManager::decodingFinished() } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"decodeThread.errorFound(), error: "+decodeThread.errorString()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"decodeThread.errorFound(), error: "+decodeThread.errorString().toStdString()); QMessageBox::critical(NULL,tr("Plugin loader"),tr("Unable to load the plugin content, please check it: %1").arg(decodeThread.errorString())); } importingPlugin=false; @@ -880,10 +887,10 @@ void PluginsManager::decodingFinished() #endif #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE -void PluginsManager::newAuthPath(const QString &path) +void PluginsManager::newAuthPath(const std::string &path) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); - int index=0; + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); + unsigned int index=0; while(index<pluginsList.size()) { if(pluginsList.at(index).path==path) @@ -898,21 +905,21 @@ void PluginsManager::newAuthPath(const QString &path) #endif /// \brief transfor short plugin name into file name -QString PluginsManager::getResolvedPluginName(const QString &name) +std::string PluginsManager::getResolvedPluginName(const std::string &name) { #if defined(Q_OS_LINUX) - return QStringLiteral("lib")+name+QStringLiteral(".so"); + return "lib"+name+".so"; #elif defined(Q_OS_MAC) #if defined(QT_DEBUG) - return QStringLiteral("lib")+name+QStringLiteral("_debug.dylib"); + return "lib"+name+"_debug.dylib"; #else - return QStringLiteral("lib")+name+QStringLiteral(".dylib"); + return "lib"+name+".dylib"; #endif #elif defined(Q_OS_WIN32) #if defined(QT_DEBUG) - return name+QStringLiteral("d.dll"); + return name+"d.dll"; #else - return name+QStringLiteral(".dll"); + return name+".dll"; #endif #else #error "Platform not supported" |