diff --git a/SocExplorer.pro b/SocExplorer.pro --- a/SocExplorer.pro +++ b/SocExplorer.pro @@ -22,6 +22,8 @@ socexplorercfg.files = \ unix{ SocExplorer.path = /usr/share/applications/ SocExplorer.files = unixcfg/SocExplorer.desktop + PluginConfPath.path = /etc/SocExplorer/plugin.conf.d/ + PluginConfPath.files = unixcfg/plugins.conf icon.path = /usr/share/SocExplorer icon.files = ressources/images/Indiana_Jones_cappello.png Wizard.path = /usr/share/qtcreator/templates/wizards/SocExplorerPlugin @@ -30,7 +32,7 @@ unix{ Qt_Creator_Wizard/SocExplorerPlugin/plugin.h \ Qt_Creator_Wizard/SocExplorerPlugin/project.pro \ Qt_Creator_Wizard/SocExplorerPlugin/wizard.xml - INSTALLS+=Wizard SocExplorer icon + INSTALLS+=Wizard SocExplorer icon PluginConfPath } INSTALLS+=socexplorercfg diff --git a/build_cfg/socexplorer.pri b/build_cfg/socexplorer.pri --- a/build_cfg/socexplorer.pri +++ b/build_cfg/socexplorer.pri @@ -4,11 +4,6 @@ contains(QT_MAJOR_VERSION, 5) { QT += widgets QT += printsupport } -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} SOCEXPLORER_SDK_BUILD="SOCEXPLORER_SDK_BUILD" DEFINES += SOCEXPLORER_SDK_BUILD diff --git a/src/SocExplorerEngine/engine/socexplorerengine.cpp b/src/SocExplorerEngine/engine/socexplorerengine.cpp --- a/src/SocExplorerEngine/engine/socexplorerengine.cpp +++ b/src/SocExplorerEngine/engine/socexplorerengine.cpp @@ -57,6 +57,40 @@ QString SocExplorerEngine::configFolder( return QString(SOCEXPLORER_CONFIG_PATH); } +QStringList SocExplorerEngine::pluginFolders() +{ + if(!_self) + init(); + QStringList folders; + QDir pluginFolders(QString(SOCEXPLORER_CONFIG_PATH)+"/plugin.conf.d"); + if(pluginFolders.exists()) + { + pluginFolders.setFilter(QDir::Files | QDir::NoSymLinks); + QFileInfoList list = pluginFolders.entryInfoList(); + for (int i = 0; i < list.size(); ++i) + { + QFileInfo fileInfo = list.at(i); + if(fileInfo.suffix()=="conf") + { + QFile confFile(fileInfo.absoluteFilePath()); + if(confFile.open(QIODevice::ReadOnly)) + { + while (!confFile.atEnd()) + { + QString line = confFile.readLine(); + QDir plugDir(line.remove("\n")); + if(plugDir.exists() && !folders.contains(plugDir.absolutePath())) + { + folders.append(plugDir.absolutePath()); + } + } + } + } + } + } + return folders; +} + SOCModel *SocExplorerEngine::plugin2Soc(socexplorerplugin *plugin) { if(!_self) diff --git a/src/SocExplorerEngine/engine/socexplorerengine.h b/src/SocExplorerEngine/engine/socexplorerengine.h --- a/src/SocExplorerEngine/engine/socexplorerengine.h +++ b/src/SocExplorerEngine/engine/socexplorerengine.h @@ -90,8 +90,9 @@ public: //! Return the configuration folder path, OS dependant. SOCEXPLORER_SDK_EXPORT static QString configFolder(); //! Return the default plugin folder path, OS dependant. - static QString pluginFolder(){return QString(SOCEXPLORER_PLUGINS_INSTALL_PATH);} - + //static QString pluginFolder(){return QString(SOCEXPLORER_PLUGINS_INSTALL_PATH);} + static QStringList pluginFolders(); + static QString configPath(){return QString(SOCEXPLORER_CONFIG_PATH);} static int addEnumDevice(socexplorerplugin* rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name); static QList* getSOCs(); static QString getDevName(int VID, int PID); diff --git a/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp b/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp --- a/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp +++ b/src/SocExplorerEngine/pluginManagerWdgt/pluginmanagerWDGT.cpp @@ -99,42 +99,43 @@ void pluginmanagerWDGT::setChildLoadable void pluginmanagerWDGT::addPlugin() { - QString fileName = QFileDialog::getOpenFileName(this,tr("Open Plugin"), QDir::homePath(), tr("Plugin Files Files (*.dll *.so *.so.*)")); - if(pluginloader::checklibrary(fileName)) - { - QFile::copy(fileName,QString(SocExplorerEngine::pluginFolder())+"/"+ fileName.section('/',-1)); - } - this->pluginTable->refreshPluginList(); +// /!\ TODO update it remove maximum operation from widget +// QString fileName = QFileDialog::getOpenFileName(this,tr("Open Plugin"), QDir::homePath(), tr("Plugin Files Files (*.dll *.so *.so.*)")); +// if(pluginloader::checklibrary(fileName)) +// { +// QFile::copy(fileName,QString(SocExplorerEngine::pluginFolder())+"/"+ fileName.section('/',-1)); +// } +// this->pluginTable->refreshPluginList(); } void pluginmanagerWDGT::removePlugin() { - for(int i=0;ipluginTable->selectedItems().count();i++) - { - QListWidgetItem* item = this->pluginTable->selectedItems().at(i); - if(item!=NULL) - { - QFile::remove(QString(SocExplorerEngine::pluginFolder())+"/"+item->text()); - } - } - this->pluginTable->refreshPluginList(); +// for(int i=0;ipluginTable->selectedItems().count();i++) +// { +// QListWidgetItem* item = this->pluginTable->selectedItems().at(i); +// if(item!=NULL) +// { +// QFile::remove(QString(SocExplorerEngine::pluginFolder())+"/"+item->text()); +// } +// } +// this->pluginTable->refreshPluginList(); } void pluginmanagerWDGT::loadplugin() { - for(int i=0;ipluginTable->selectedItems().count();i++) - { - QListWidgetItem* item = this->pluginTable->selectedItems().at(i); - if(item!=NULL) - { - QString plugin = QString(SocExplorerEngine::pluginFolder())+"/"+item->text(); - emit this->loadSysDrviver(plugin); - } - } - this->pluginTable->refreshPluginList(); +// for(int i=0;ipluginTable->selectedItems().count();i++) +// { +// QListWidgetItem* item = this->pluginTable->selectedItems().at(i); +// if(item!=NULL) +// { +// QString plugin = QString(SocExplorerEngine::pluginFolder())+"/"+item->text(); +// emit this->loadSysDrviver(plugin); +// } +// } +// this->pluginTable->refreshPluginList(); } diff --git a/src/SocExplorerEngine/pluginloader/pluginloader.cpp b/src/SocExplorerEngine/pluginloader/pluginloader.cpp --- a/src/SocExplorerEngine/pluginloader/pluginloader.cpp +++ b/src/SocExplorerEngine/pluginloader/pluginloader.cpp @@ -23,19 +23,7 @@ pluginloader::pluginloader() { _cache = new PluginsCache(); _folderList = new QStringList(); - QDir pluginPath(QString(SocExplorerEngine::pluginFolder())); - if(!pluginPath.exists()) - { - pluginPath.mkpath(QString(SocExplorerEngine::pluginFolder())); - } - QFile pluginsFolders(QString(SocExplorerEngine::pluginFolder())+"/plugins.conf"); - *_folderList << QString(SocExplorerEngine::pluginFolder()); //default place - if(!pluginsFolders.exists()) - { - pluginsFolders.open(QIODevice::WriteOnly); //if file doesn't exist create it - pluginsFolders.close(); - } - *_folderList<< readFoldersList(QStringList()<< QString(SocExplorerEngine::pluginFolder())+"/plugins.conf"); + _folderList->append(SocExplorerEngine::pluginFolders()); scanFolders(); } diff --git a/src/SocExplorerEngine/plugins/socexplorerplugin.prf b/src/SocExplorerEngine/plugins/socexplorerplugin.prf --- a/src/SocExplorerEngine/plugins/socexplorerplugin.prf +++ b/src/SocExplorerEngine/plugins/socexplorerplugin.prf @@ -15,8 +15,9 @@ unix { DEFINES += SOCEXPLORER_TRANSLATION_PATH="\"\\\"/etc/SocExplorer/translations"\\\"\" SOCEXPLORER_TRANSLATION_INSTALL_PATH = /etc/SocExplorer/translations SOCEXPLORER_INSTALL_PATH = /usr/local/SocExplorer - SOCEXPLORER_ROOT_PLUGINS_INSTALL_PATH = $$system(echo $HOME) - SOCEXPLORER_PLUGINS_INSTALL_PATH = $${SOCEXPLORER_ROOT_PLUGINS_INSTALL_PATH}"/.SocExplorer/plugins" + SOCEXPLORER_PLUGINS_INSTALL_PATH = $$[QT_INSTALL_LIBS]"/SocExplorer/plugins" + DEFINES += SOCEXPLORER_CONFIG_PATH="\"\\\"/etc/SocExplorer"\\\"\" + SOCEXPLORER_CONFIG_PATH=/etc/SocExplorer } isEmpty( SOCEXPLORER_SDK_BUILD ){ @@ -32,11 +33,11 @@ isEmpty( SOCEXPLORER_SDK_BUILD ){ OBJECTS_DIR = obj MOC_DIR = moc DESTDIR = bin - CONFIG(debug, debug|release) { - DEBUG_EXT = _d - } else { - DEBUG_EXT = - } +# CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +# } else { +# DEBUG_EXT = +# } unix{ target.path = $${SOCEXPLORER_PLUGINS_INSTALL_PATH} INSTALLS += target diff --git a/src/socexplorer.h b/src/socexplorer.h --- a/src/socexplorer.h +++ b/src/socexplorer.h @@ -50,7 +50,7 @@ #else #ifdef UNIX #define SOCEXPLORER_PLUGINS_INSTALL_PATH QDir::homePath()+"/.SocExplorer/plugins" - #define SOCEXPLORER_CONFIG_PATH QDir::homePath()+"/.SocExplorer/config" + //#define SOCEXPLORER_CONFIG_PATH QDir::homePath()+"/.SocExplorer/config" #define PYMODULES "/etc/SocExplorer/python" #endif #endif diff --git a/unixcfg/plugins.conf b/unixcfg/plugins.conf new file mode 100644 --- /dev/null +++ b/unixcfg/plugins.conf @@ -0,0 +1,3 @@ +/usr/lib/SocExplorer/plugins +/usr/lib64/SocExplorer/plugins +