##// END OF EJS Templates
Some more cleaning....
Jeandet Alexis -
r100:11a895cff789 pre-0.7
parent child
Show More
@@ -289,13 +289,29 void SocExplorerEngine::removeSOC(socexp
289 289 delete soc;
290 290 }
291 291
292
292 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 309 // TODO add multi output message manager IE also log in files
310 static QTextStream SocExplorerEngineStdout(stdout);
295 311 if(!_self)
296 312 init();
297 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 317 void SocExplorerEngine::setLogLevel(int level)
@@ -109,6 +109,8 public:
109 109 static void addSOC(socexplorerplugin* rootPlugin);
110 110 static void removeSOC(socexplorerplugin* rootPlugin);
111 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 114 static void setLogLevel(int level);
113 115 static bool isSocLitleEndian(socexplorerplugin* plugin);
114 116 signals:
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 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 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
@@ -13,6 +13,8
13 13 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
14 14 #include "unix/unixpluginloader.h"
15 15 #endif
16 #include <socexplorerengine.h>
17 #include <socexplorersettings.h>
16 18
17 19 pluginloader* pluginloader::_self = NULL;
18 20 PluginsCache* pluginloader::_cache = NULL;
@@ -27,38 +29,6 pluginloader::pluginloader()
27 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 32 void pluginloader::scanFolders()
63 33 {
64 34 QDir dir;
@@ -74,6 +44,7 void pluginloader::scanFolders()
74 44 for (int i = 0; i < list.size(); ++i)
75 45 {
76 46 QFileInfo fileInfo = list.at(i);
47 SocExplorerEngine::message("pluginloader::scanFolders","Checking "+ fileInfo.filePath(),3);
77 48 if(checklibrary(fileInfo.filePath())!=0)
78 49 {
79 50 _cache->append(fileInfo.fileName(),fileInfo.path(),_getlibName(fileInfo.filePath()),_getlibPID(fileInfo.filePath()),_getlibPID(fileInfo.filePath()));
@@ -90,7 +61,7 int pluginloader::p_checklibraryQlib(con
90 61 lib->load();
91 62 if(!lib->isLoaded())
92 63 {
93 qDebug()<<lib->errorString();
64 SocExplorerEngine::message("pluginloader::p_checklibraryQlib",lib->errorString(),3);
94 65 lib->~QLibrary();
95 66 lib = new QLibrary(fileName);
96 67 lib->load();
@@ -81,7 +81,6 private:
81 81 int p_checklibraryCustom(const QString fileName);
82 82 socexplorerplugin* p_newsocexplorerpluginQlib(const QString Name);
83 83 socexplorerplugin* p_newsocexplorerpluginCustom(const QString Name);
84 static QStringList readFoldersList(const QStringList confFiles);
85 84 static QString* _cacheLookup(const QString Name);
86 85 static QString _getlibName(const QString fileName);
87 86 static int _getlibPID(const QString fileName);
@@ -1,5 +1,6
1 1 #include "pluginscache.h"
2 2 #include <QDebug>
3 #include <socexplorerengine.h>
3 4
4 5 PluginsCacheItem::PluginsCacheItem(const QString &fileName, const QString &path, const QString &pluginName, int VID, int PID)
5 6 {
@@ -56,12 +57,12 void PluginsCache::append(const QString
56 57 {
57 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 61 delete item;
61 62 return;
62 63 }
63 64 }
64 qDebug()<< fileName << "added to cache";
65 SocExplorerEngine::message("PluginsCache",fileName + " added to cache",3);
65 66 this->items->append(item);
66 67 }
67 68
@@ -1,15 +1,16
1 1 #include "unixpluginloader.h"
2 2 #include <stdio.h>
3 3 #include <QDebug>
4 #include <socexplorerengine.h>
4 5
5 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 9 dlHandle = dlopen(libPath.toStdString().c_str(),RTLD_LAZY|RTLD_GLOBAL);
9 10 if(dlHandle==NULL)
10 qDebug() << "Failed"<< dlerror();
11 SocExplorerEngine::message("unixPluginLoader::unixPluginLoader",QString("Failed ") + dlerror(),3);
11 12 else
12 qDebug() << "Success";
13 SocExplorerEngine::message("unixPluginLoader::unixPluginLoader","Success " ,3);
13 14 this->libPath = libPath;
14 15 }
15 16
@@ -17,12 +18,12 void *unixPluginLoader::resolve(const QS
17 18 {
18 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 22 void* sym = dlsym (dlHandle, symbol.toStdString().c_str());
22 23 if(sym==NULL)
23 qDebug() << "Failed"<< dlerror();
24 SocExplorerEngine::message("unixPluginLoader::resolve",QString("Failed")+ dlerror() ,3);
24 25 else
25 qDebug() << "Success";
26 SocExplorerEngine::message("unixPluginLoader::resolve","Success",3);
26 27 return sym;
27 28 }
28 29 return NULL;
@@ -33,6 +34,6 void unixPluginLoader::close()
33 34 if(dlHandle!=NULL)
34 35 {
35 36 dlclose(dlHandle);
36 qDebug() << dlerror();
37 SocExplorerEngine::message("unixPluginLoader::close",dlerror(),3);
37 38 }
38 39 }
General Comments 0
You need to be logged in to leave comments. Login now