Some more cleaning....
Jeandet Alexis -
r100:11a895cff789 pre-0.7
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -289,13 +289,29
289 delete soc;
289 delete soc;
290 }
290 }
291
291
292
292 void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel)
293 void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel)
293 {
294 {
295 if(!_self)
296 init();
297 SocExplorerEngine::message(sender->instanceName(),message,debugLevel);
298 }
299
300 void SocExplorerEngine::message(QObject *sender, const QString &message, int debugLevel)
301 {
302 if(!_self)
303 init();
304 SocExplorerEngine::message(sender->objectName(),message,debugLevel);
305 }
306
307 void SocExplorerEngine::message(const QString &sender, const QString &message, int debugLevel)
308 {
294 // TODO add multi output message manager IE also log in files
309 // TODO add multi output message manager IE also log in files
310 static QTextStream SocExplorerEngineStdout(stdout);
295 if(!_self)
311 if(!_self)
296 init();
312 init();
297 if(loglvl>=debugLevel)
313 if(loglvl>=debugLevel)
298 qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName()+":"+message;
314 SocExplorerEngineStdout << QTime::currentTime().toString()+" " + sender+":"+message << endl;
299 }
315 }
300
316
301 void SocExplorerEngine::setLogLevel(int level)
317 void SocExplorerEngine::setLogLevel(int level)
@@ -109,6 +109,8
109 static void addSOC(socexplorerplugin* rootPlugin);
109 static void addSOC(socexplorerplugin* rootPlugin);
110 static void removeSOC(socexplorerplugin* rootPlugin);
110 static void removeSOC(socexplorerplugin* rootPlugin);
111 static void message(socexplorerplugin* sender,const QString& message,int debugLevel=0);
111 static void message(socexplorerplugin* sender,const QString& message,int debugLevel=0);
112 static void message(QObject* sender,const QString& message,int debugLevel=0);
113 static void message(const QString& sender,const QString& message,int debugLevel=0);
112 static void setLogLevel(int level);
114 static void setLogLevel(int level);
113 static bool isSocLitleEndian(socexplorerplugin* plugin);
115 static bool isSocLitleEndian(socexplorerplugin* plugin);
114 signals:
116 signals:
@@ -1,6 +1,6
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
@@ -13,6 +13,8
13 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
13 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
14 #include "unix/unixpluginloader.h"
14 #include "unix/unixpluginloader.h"
15 #endif
15 #endif
16 #include <socexplorerengine.h>
17 #include <socexplorersettings.h>
16
18
17 pluginloader* pluginloader::_self = NULL;
19 pluginloader* pluginloader::_self = NULL;
18 PluginsCache* pluginloader::_cache = NULL;
20 PluginsCache* pluginloader::_cache = NULL;
@@ -27,38 +29,6
27 scanFolders();
29 scanFolders();
28 }
30 }
29
31
30
31 QStringList pluginloader::readFoldersList(const QStringList confFiles)
32 {
33 QDir testDir;
34 QStringList folders;
35 QFile confFile;
36 for(int i=0;i<confFiles.count();i++)
37 {
38 confFile.setFileName(confFiles.at(i));
39 if(confFile.exists())
40 {
41 if (confFile.open(QIODevice::ReadOnly | QIODevice::Text))
42 {
43 QTextStream in(&confFile);
44 QString line = in.readLine();
45 while (!line.isNull())
46 {
47 testDir.setPath(line);
48 if(testDir.exists())
49 {
50 if(!folders.contains(line))
51 folders << line;
52 }
53 line = in.readLine();
54 }
55 }
56 }
57 }
58 return folders;
59 }
60
61
62 void pluginloader::scanFolders()
32 void pluginloader::scanFolders()
63 {
33 {
64 QDir dir;
34 QDir dir;
@@ -74,6 +44,7
74 for (int i = 0; i < list.size(); ++i)
44 for (int i = 0; i < list.size(); ++i)
75 {
45 {
76 QFileInfo fileInfo = list.at(i);
46 QFileInfo fileInfo = list.at(i);
47 SocExplorerEngine::message("pluginloader::scanFolders","Checking "+ fileInfo.filePath(),3);
77 if(checklibrary(fileInfo.filePath())!=0)
48 if(checklibrary(fileInfo.filePath())!=0)
78 {
49 {
79 _cache->append(fileInfo.fileName(),fileInfo.path(),_getlibName(fileInfo.filePath()),_getlibPID(fileInfo.filePath()),_getlibPID(fileInfo.filePath()));
50 _cache->append(fileInfo.fileName(),fileInfo.path(),_getlibName(fileInfo.filePath()),_getlibPID(fileInfo.filePath()),_getlibPID(fileInfo.filePath()));
@@ -90,7 +61,7
90 lib->load();
61 lib->load();
91 if(!lib->isLoaded())
62 if(!lib->isLoaded())
92 {
63 {
93 qDebug()<<lib->errorString();
64 SocExplorerEngine::message("pluginloader::p_checklibraryQlib",lib->errorString(),3);
94 lib->~QLibrary();
65 lib->~QLibrary();
95 lib = new QLibrary(fileName);
66 lib = new QLibrary(fileName);
96 lib->load();
67 lib->load();
@@ -81,7 +81,6
81 int p_checklibraryCustom(const QString fileName);
81 int p_checklibraryCustom(const QString fileName);
82 socexplorerplugin* p_newsocexplorerpluginQlib(const QString Name);
82 socexplorerplugin* p_newsocexplorerpluginQlib(const QString Name);
83 socexplorerplugin* p_newsocexplorerpluginCustom(const QString Name);
83 socexplorerplugin* p_newsocexplorerpluginCustom(const QString Name);
84 static QStringList readFoldersList(const QStringList confFiles);
85 static QString* _cacheLookup(const QString Name);
84 static QString* _cacheLookup(const QString Name);
86 static QString _getlibName(const QString fileName);
85 static QString _getlibName(const QString fileName);
87 static int _getlibPID(const QString fileName);
86 static int _getlibPID(const QString fileName);
@@ -1,5 +1,6
1 #include "pluginscache.h"
1 #include "pluginscache.h"
2 #include <QDebug>
2 #include <QDebug>
3 #include <socexplorerengine.h>
3
4
4 PluginsCacheItem::PluginsCacheItem(const QString &fileName, const QString &path, const QString &pluginName, int VID, int PID)
5 PluginsCacheItem::PluginsCacheItem(const QString &fileName, const QString &path, const QString &pluginName, int VID, int PID)
5 {
6 {
@@ -56,12 +57,12
56 {
57 {
57 if(this->items->at(i)->compare(item))
58 if(this->items->at(i)->compare(item))
58 {
59 {
59 qDebug()<< fileName << "already in the cache";
60 SocExplorerEngine::message("PluginsCache",fileName + " already in the cache",3);
60 delete item;
61 delete item;
61 return;
62 return;
62 }
63 }
63 }
64 }
64 qDebug()<< fileName << "added to cache";
65 SocExplorerEngine::message("PluginsCache",fileName + " added to cache",3);
65 this->items->append(item);
66 this->items->append(item);
66 }
67 }
67
68
@@ -1,15 +1,16
1 #include "unixpluginloader.h"
1 #include "unixpluginloader.h"
2 #include <stdio.h>
2 #include <stdio.h>
3 #include <QDebug>
3 #include <QDebug>
4 #include <socexplorerengine.h>
4
5
5 unixPluginLoader::unixPluginLoader(const QString &libPath)
6 unixPluginLoader::unixPluginLoader(const QString &libPath)
6 {
7 {
7 qDebug()<<"try to open "+libPath;
8 SocExplorerEngine::message("unixPluginLoader::unixPluginLoader","try to open "+libPath,3);
8 dlHandle = dlopen(libPath.toStdString().c_str(),RTLD_LAZY|RTLD_GLOBAL);
9 dlHandle = dlopen(libPath.toStdString().c_str(),RTLD_LAZY|RTLD_GLOBAL);
9 if(dlHandle==NULL)
10 if(dlHandle==NULL)
10 qDebug() << "Failed"<< dlerror();
11 SocExplorerEngine::message("unixPluginLoader::unixPluginLoader",QString("Failed ") + dlerror(),3);
11 else
12 else
12 qDebug() << "Success";
13 SocExplorerEngine::message("unixPluginLoader::unixPluginLoader","Success " ,3);
13 this->libPath = libPath;
14 this->libPath = libPath;
14 }
15 }
15
16
@@ -17,12 +18,12
17 {
18 {
18 if(dlHandle!=NULL)
19 if(dlHandle!=NULL)
19 {
20 {
20 qDebug()<<"try to resolve "+symbol+" in "+libPath;
21 SocExplorerEngine::message("unixPluginLoader::resolve","try to resolve "+symbol+" in "+libPath ,3);
21 void* sym = dlsym (dlHandle, symbol.toStdString().c_str());
22 void* sym = dlsym (dlHandle, symbol.toStdString().c_str());
22 if(sym==NULL)
23 if(sym==NULL)
23 qDebug() << "Failed"<< dlerror();
24 SocExplorerEngine::message("unixPluginLoader::resolve",QString("Failed")+ dlerror() ,3);
24 else
25 else
25 qDebug() << "Success";
26 SocExplorerEngine::message("unixPluginLoader::resolve","Success",3);
26 return sym;
27 return sym;
27 }
28 }
28 return NULL;
29 return NULL;
@@ -33,6 +34,6
33 if(dlHandle!=NULL)
34 if(dlHandle!=NULL)
34 {
35 {
35 dlclose(dlHandle);
36 dlclose(dlHandle);
36 qDebug() << dlerror();
37 SocExplorerEngine::message("unixPluginLoader::close",dlerror(),3);
37 }
38 }
38 }
39 }
Comments 0
You need to be logged in to leave comments. Login now