##// END OF EJS Templates
Working snapshot.
jeandet -
r5:483cfe27e044 Working snapshot default
parent child
Show More
@@ -1,86 +1,86
1 #-------------------------------------------------
1 #-------------------------------------------------
2 #
2 #
3 # Project created by QtCreator 2011-09-19T22:52:10
3 # Project created by QtCreator 2011-09-19T22:52:10
4 #
4 #
5 #-------------------------------------------------
5 #-------------------------------------------------
6
6
7 TEMPLATE = subdirs
7 TEMPLATE = subdirs
8 CONFIG += ordered release
8 CONFIG += ordered release
9
9
10 SUBDIRS = \
10 SUBDIRS = \
11 src/common \
11 src/common \
12 src/SocExplorerEngine \
12 src/SocExplorerEngine \
13 src \
13 src \
14 src/SocExplorer_TCP_Terminal
14 src/SocExplorer_TCP_Terminal
15
15
16
16
17 SocExplorer.path = $$[QT_INSTALL_PREFIX]/mkspecs/features
17 socexplorercfg.path = $$[QT_INSTALL_PREFIX]/mkspecs/features
18 SocExplorer.files = \
18 socexplorercfg.files = \
19 src/SocExplorerEngine/plugins/socexplorerplugin.prf
19 src/SocExplorerEngine/plugins/socexplorerplugin.prf
20
20
21
21
22 unix{
22 unix{
23 SocExplorer.path = /usr/share/applications/
23 SocExplorer.path = /usr/share/applications/
24 SocExplorer.files = unixcfg/SocExplorer.desktop
24 SocExplorer.files = unixcfg/SocExplorer.desktop
25 icon.path = /etc/SocExplorer
25 icon.path = /etc/SocExplorer
26 icon.files = ressources/images/logo-lpp-cutted.png
26 icon.files = ressources/images/logo-lpp-cutted.png
27 Wizard.path = /usr/share/qtcreator/templates/wizards/SocExplorerPlugin
27 Wizard.path = /usr/share/qtcreator/templates/wizards/SocExplorerPlugin
28 Wizard.files = Qt_Creator_Wizard/SocExplorerPlugin/logo-lpp-cutted.png \
28 Wizard.files = Qt_Creator_Wizard/SocExplorerPlugin/logo-lpp-cutted.png \
29 Qt_Creator_Wizard/SocExplorerPlugin/plugin.cpp \
29 Qt_Creator_Wizard/SocExplorerPlugin/plugin.cpp \
30 Qt_Creator_Wizard/SocExplorerPlugin/plugin.h \
30 Qt_Creator_Wizard/SocExplorerPlugin/plugin.h \
31 Qt_Creator_Wizard/SocExplorerPlugin/project.pro \
31 Qt_Creator_Wizard/SocExplorerPlugin/project.pro \
32 Qt_Creator_Wizard/SocExplorerPlugin/wizard.xml
32 Qt_Creator_Wizard/SocExplorerPlugin/wizard.xml
33 INSTALLS+=Wizard SocExplorer icon
33 INSTALLS+=Wizard SocExplorer icon
34 }
34 }
35 INSTALLS+=SocExplorer
35 INSTALLS+=socexplorercfg
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
49
50
50
51
51
52
52
53
53
54
54
55
55
56
56
57
57
58
58
59
59
60
60
61
61
62
62
63
63
64
64
65
65
66
66
67
67
68
68
69
69
70
70
71
71
72
72
73
73
74
74
75
75
76
76
77
77
78
78
79
79
80
80
81
81
82
82
83
83
84
84
85
85
86
86
@@ -1,572 +1,572
1 #include "pluginloader.h"
1 #include "pluginloader.h"
2 #include <QDir>
2 #include <QDir>
3 #include <QFile>
3 #include <QFile>
4 #include <QFileInfoList>
4 #include <QFileInfoList>
5 #include <QFileInfo>
5 #include <QFileInfo>
6 #include <QString>
6 #include <QString>
7 #include <QStringList>
7 #include <QStringList>
8 #include <QLabel>
8 #include <QLabel>
9 #include <QSettings>
9 #include <QSettings>
10 #include <QApplication>
10 #include <QApplication>
11 #include <QCoreApplication>
11 #include <QCoreApplication>
12 #include <socexplorerengine.h>
12 #include <socexplorerengine.h>
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
16
17 pluginloader* pluginloader::_self = NULL;
17 pluginloader* pluginloader::_self = NULL;
18 PluginsCache* pluginloader::_cache = NULL;
18 PluginsCache* pluginloader::_cache = NULL;
19 QStringList* pluginloader::_folderList = NULL;
19 QStringList* pluginloader::_folderList = NULL;
20
20
21
21
22 pluginloader::pluginloader()
22 pluginloader::pluginloader()
23 {
23 {
24 _cache = new PluginsCache();
24 _cache = new PluginsCache();
25 _folderList = new QStringList();
25 _folderList = new QStringList();
26 QDir pluginPath(QString(SocExplorerEngine::pluginFolder()));
26 QDir pluginPath(QString(SocExplorerEngine::pluginFolder()));
27 if(!pluginPath.exists())
27 if(!pluginPath.exists())
28 {
28 {
29 pluginPath.mkpath(QString(SocExplorerEngine::pluginFolder()));
29 pluginPath.mkpath(QString(SocExplorerEngine::pluginFolder()));
30 }
30 }
31 QFile pluginsFolders(QString(SocExplorerEngine::pluginFolder())+"/plugins.conf");
31 QFile pluginsFolders(QString(SocExplorerEngine::pluginFolder())+"/plugins.conf");
32 *_folderList << QString(SocExplorerEngine::pluginFolder()); //default place
32 *_folderList << QString(SocExplorerEngine::pluginFolder()); //default place
33 if(!pluginsFolders.exists())
33 if(!pluginsFolders.exists())
34 {
34 {
35 pluginsFolders.open(QIODevice::WriteOnly); //if file doesn't exist create it
35 pluginsFolders.open(QIODevice::WriteOnly); //if file doesn't exist create it
36 pluginsFolders.close();
36 pluginsFolders.close();
37 }
37 }
38 *_folderList<< readFoldersList(QStringList()<< QString(SocExplorerEngine::pluginFolder())+"/plugins.conf");
38 *_folderList<< readFoldersList(QStringList()<< QString(SocExplorerEngine::pluginFolder())+"/plugins.conf");
39 scanFolders();
39 scanFolders();
40 }
40 }
41
41
42
42
43 QStringList pluginloader::readFoldersList(const QStringList confFiles)
43 QStringList pluginloader::readFoldersList(const QStringList confFiles)
44 {
44 {
45 QDir testDir;
45 QDir testDir;
46 QStringList folders;
46 QStringList folders;
47 QFile confFile;
47 QFile confFile;
48 for(int i=0;i<confFiles.count();i++)
48 for(int i=0;i<confFiles.count();i++)
49 {
49 {
50 confFile.setFileName(confFiles.at(i));
50 confFile.setFileName(confFiles.at(i));
51 if(confFile.exists())
51 if(confFile.exists())
52 {
52 {
53 if (confFile.open(QIODevice::ReadOnly | QIODevice::Text))
53 if (confFile.open(QIODevice::ReadOnly | QIODevice::Text))
54 {
54 {
55 QTextStream in(&confFile);
55 QTextStream in(&confFile);
56 QString line = in.readLine();
56 QString line = in.readLine();
57 while (!line.isNull())
57 while (!line.isNull())
58 {
58 {
59 testDir.setPath(line);
59 testDir.setPath(line);
60 if(testDir.exists())
60 if(testDir.exists())
61 {
61 {
62 if(!folders.contains(line))
62 if(!folders.contains(line))
63 folders << line;
63 folders << line;
64 }
64 }
65 line = in.readLine();
65 line = in.readLine();
66 }
66 }
67 }
67 }
68 }
68 }
69 }
69 }
70 return folders;
70 return folders;
71 }
71 }
72
72
73
73
74 void pluginloader::scanFolders()
74 void pluginloader::scanFolders()
75 {
75 {
76 QDir dir;
76 QDir dir;
77 QStringList filters;
77 QStringList filters;
78 filters <<"*.so"<< "*.dll";
78 filters <<"*.so"<< "*.dll";
79 _cache->flush();
79 _cache->flush();
80 for(int d=0;d<_folderList->count();d++)
80 for(int d=0;d<_folderList->count();d++)
81 {
81 {
82 dir.setPath(_folderList->at(d));
82 dir.setPath(_folderList->at(d));
83 dir.setFilter(QDir::Files);
83 dir.setFilter(QDir::Files);
84 dir.setNameFilters(filters);
84 dir.setNameFilters(filters);
85 QFileInfoList list = dir.entryInfoList();
85 QFileInfoList list = dir.entryInfoList();
86 for (int i = 0; i < list.size(); ++i)
86 for (int i = 0; i < list.size(); ++i)
87 {
87 {
88 QFileInfo fileInfo = list.at(i);
88 QFileInfo fileInfo = list.at(i);
89 if(checklibrary(fileInfo.filePath())!=0)
89 if(checklibrary(fileInfo.filePath())!=0)
90 {
90 {
91 _cache->append(fileInfo.fileName(),fileInfo.path(),_getlibName(fileInfo.filePath()),_getlibPID(fileInfo.filePath()),_getlibPID(fileInfo.filePath()));
91 _cache->append(fileInfo.fileName(),fileInfo.path(),_getlibName(fileInfo.filePath()),_getlibPID(fileInfo.filePath()),_getlibPID(fileInfo.filePath()));
92 }
92 }
93 }
93 }
94 }
94 }
95 }
95 }
96
96
97 int pluginloader::p_checklibraryQlib(const QString fileName)
97 int pluginloader::p_checklibraryQlib(const QString fileName)
98 {
98 {
99 QLibrary* lib = new QLibrary;
99 QLibrary* lib = new QLibrary;
100 lib->setFileName(fileName);
100 lib->setFileName(fileName);
101 lib->setLoadHints(QLibrary::PreventUnloadHint);
101 lib->setLoadHints(QLibrary::PreventUnloadHint);
102 lib->load();
102 lib->load();
103 if(!lib->isLoaded())
103 if(!lib->isLoaded())
104 {
104 {
105 qDebug()<<lib->errorString();
105 qDebug()<<lib->errorString();
106 lib->~QLibrary();
106 lib->~QLibrary();
107 lib = new QLibrary(fileName);
107 lib = new QLibrary(fileName);
108 lib->load();
108 lib->load();
109 }
109 }
110 delete lib;
110 delete lib;
111 if(QLibrary::resolve(fileName,"socexplorerpluginCreateObject"))
111 if(QLibrary::resolve(fileName,"socexplorerpluginCreateObject"))
112 {
112 {
113 if(QLibrary::resolve(fileName,"socexplorerpluginpid"))
113 if(QLibrary::resolve(fileName,"socexplorerpluginpid"))
114 {
114 {
115 if(QLibrary::resolve(fileName,"socexplorerpluginvid"))
115 if(QLibrary::resolve(fileName,"socexplorerpluginvid"))
116 {
116 {
117 if(QLibrary::resolve(fileName,"socexplorerpluginVersion"))
117 if(QLibrary::resolve(fileName,"socexplorerpluginVersion"))
118 {
118 {
119 if(QLibrary::resolve(fileName,"socexplorerpluginAuthor"))
119 if(QLibrary::resolve(fileName,"socexplorerpluginAuthor"))
120 {
120 {
121 if(QLibrary::resolve(fileName,"socexplorerpluginDescription"))
121 if(QLibrary::resolve(fileName,"socexplorerpluginDescription"))
122 {
122 {
123 return 1;
123 return 1;
124 }
124 }
125 }
125 }
126 }
126 }
127 }
127 }
128 }
128 }
129 }
129 }
130 return 0;
130 return 0;
131 }
131 }
132
132
133 int pluginloader::p_checklibraryCustom(const QString fileName)
133 int pluginloader::p_checklibraryCustom(const QString fileName)
134 {
134 {
135 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
135 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
136 unixPluginLoader lib(fileName);
136 unixPluginLoader lib(fileName);
137 if(NULL!=lib.resolve("socexplorerpluginCreateObject"))
137 if(NULL!=lib.resolve("socexplorerpluginCreateObject"))
138 {
138 {
139 if(NULL!=lib.resolve("socexplorernpluginpid"))
139 if(NULL!=lib.resolve("socexplorerpluginpid"))
140 {
140 {
141 if(NULL!=lib.resolve("socexplorerpluginvid"))
141 if(NULL!=lib.resolve("socexplorerpluginvid"))
142 {
142 {
143 if(NULL!=lib.resolve("socexplorerpluginVersion"))
143 if(NULL!=lib.resolve("socexplorerpluginVersion"))
144 {
144 {
145 if(NULL!=lib.resolve("socexplorerpluginAuthor"))
145 if(NULL!=lib.resolve("socexplorerpluginAuthor"))
146 {
146 {
147 if(NULL!=lib.resolve("socexplorerpluginDescription"))
147 if(NULL!=lib.resolve("socexplorerpluginDescription"))
148 {
148 {
149 return 1;
149 return 1;
150 }
150 }
151 }
151 }
152 }
152 }
153 }
153 }
154 }
154 }
155 }
155 }
156 #endif
156 #endif
157 return 0;
157 return 0;
158 }
158 }
159
159
160 socexplorerplugin *pluginloader::p_newsocexplorerpluginQlib(const QString Name)
160 socexplorerplugin *pluginloader::p_newsocexplorerpluginQlib(const QString Name)
161 {
161 {
162 QString* libfile= _cacheLookup(Name);
162 QString* libfile= _cacheLookup(Name);
163 if(libfile==NULL)return NULL;
163 if(libfile==NULL)return NULL;
164 QLibrary* lib = new QLibrary(*libfile);
164 QLibrary* lib = new QLibrary(*libfile);
165 delete libfile;
165 delete libfile;
166 socexplorerpluginCreateObjectT newDrvr = NULL;
166 socexplorerpluginCreateObjectT newDrvr = NULL;
167 newDrvr=(socexplorerpluginCreateObjectT)lib->resolve("socexplorerpluginCreateObject");
167 newDrvr=(socexplorerpluginCreateObjectT)lib->resolve("socexplorerpluginCreateObject");
168 if(newDrvr==NULL)
168 if(newDrvr==NULL)
169 {
169 {
170 return NULL;
170 return NULL;
171 }
171 }
172 return (socexplorerplugin*) newDrvr();
172 return (socexplorerplugin*) newDrvr();
173 }
173 }
174
174
175 socexplorerplugin *pluginloader::p_newsocexplorerpluginCustom(const QString Name)
175 socexplorerplugin *pluginloader::p_newsocexplorerpluginCustom(const QString Name)
176 {
176 {
177 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
177 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
178 QString* libfile= _cacheLookup(Name);
178 QString* libfile= _cacheLookup(Name);
179 if(libfile==NULL)return NULL;
179 if(libfile==NULL)return NULL;
180 unixPluginLoader lib(*libfile);
180 unixPluginLoader lib(*libfile);
181 delete libfile;
181 delete libfile;
182 socexplorerpluginCreateObjectT newDrvr = NULL;
182 socexplorerpluginCreateObjectT newDrvr = NULL;
183 newDrvr=(socexplorerpluginCreateObjectT)lib.resolve("socexplorerpluginCreateObject");
183 newDrvr=(socexplorerpluginCreateObjectT)lib.resolve("socexplorerpluginCreateObject");
184 if(newDrvr==NULL)
184 if(newDrvr==NULL)
185 {
185 {
186 return NULL;
186 return NULL;
187 }
187 }
188 return (socexplorerplugin*) newDrvr();
188 return (socexplorerplugin*) newDrvr();
189 #endif
189 #endif
190 }
190 }
191
191
192 QList<PluginsCacheItem*> pluginloader::listAvailiables(bool rescan)
192 QList<PluginsCacheItem*> pluginloader::listAvailiables(bool rescan)
193 {
193 {
194 if(_self==NULL)
194 if(_self==NULL)
195 {
195 {
196 init();
196 init();
197 return _cache->listDrivers();
197 return _cache->listDrivers();
198 }
198 }
199 if(rescan)
199 if(rescan)
200 {
200 {
201 scanFolders();
201 scanFolders();
202 }
202 }
203
203
204 return _cache->listDrivers();
204 return _cache->listDrivers();
205 }
205 }
206
206
207
207
208 void pluginloader::init()
208 void pluginloader::init()
209 {
209 {
210 if(_self==NULL)
210 if(_self==NULL)
211 {
211 {
212 _self=new pluginloader();
212 _self=new pluginloader();
213 }
213 }
214 }
214 }
215
215
216
216
217 pluginloader* pluginloader::self()
217 pluginloader* pluginloader::self()
218 {
218 {
219 if(_self==NULL)
219 if(_self==NULL)
220 {
220 {
221 init();
221 init();
222 }
222 }
223 return _self;
223 return _self;
224 }
224 }
225
225
226 bool pluginloader::isvalid(QString Name)
226 bool pluginloader::isvalid(QString Name)
227 {
227 {
228 if(_self==NULL)init();
228 if(_self==NULL)init();
229 QString* libfile= _cacheLookup(Name);
229 QString* libfile= _cacheLookup(Name);
230 if(libfile==NULL)return false;
230 if(libfile==NULL)return false;
231 else
231 else
232 {
232 {
233 delete libfile;
233 delete libfile;
234 return true;
234 return true;
235 }
235 }
236
236
237 }
237 }
238
238
239 int pluginloader::checklibrary(const QString fileName)
239 int pluginloader::checklibrary(const QString fileName)
240 {
240 {
241 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
241 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
242 return _self->p_checklibraryCustom(fileName);
242 return _self->p_checklibraryCustom(fileName);
243 #else
243 #else
244 return _self->p_checklibraryQlib(fileName);
244 return _self->p_checklibraryQlib(fileName);
245 #endif
245 #endif
246 }
246 }
247
247
248
248
249
249
250
250
251
251
252 socexplorerplugin* pluginloader::newsocexplorerplugin(const QString Name)
252 socexplorerplugin* pluginloader::newsocexplorerplugin(const QString Name)
253 {
253 {
254 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
254 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
255 return _self->p_newsocexplorerpluginCustom(Name);
255 return _self->p_newsocexplorerpluginCustom(Name);
256 #else
256 #else
257 return _self->p_newsocexplorerpluginQlib(Name);
257 return _self->p_newsocexplorerpluginQlib(Name);
258 #endif
258 #endif
259 }
259 }
260
260
261
261
262 QString pluginloader::getlibTypeStr(QString Name)
262 QString pluginloader::getlibTypeStr(QString Name)
263 {
263 {
264 if(_self==NULL)init();
264 if(_self==NULL)init();
265 QString* libfile= _cacheLookup(Name);
265 QString* libfile= _cacheLookup(Name);
266 if(libfile==NULL)return NULL;
266 if(libfile==NULL)return NULL;
267 QLibrary* lib = new QLibrary(*libfile);
267 QLibrary* lib = new QLibrary(*libfile);
268 delete libfile;
268 delete libfile;
269 lib->load();
269 lib->load();
270 if(lib->isLoaded())
270 if(lib->isLoaded())
271 {
271 {
272 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
272 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
273 if(plugintype!=NULL)
273 if(plugintype!=NULL)
274 {
274 {
275 pluginT type = plugintype();
275 pluginT type = plugintype();
276 switch(type)
276 switch(type)
277 {
277 {
278 case ComDriverT:
278 case ComDriverT:
279 ////lib->unload();
279 ////lib->unload();
280 lib->~QLibrary();
280 lib->~QLibrary();
281 return QObject::tr("Comunaication Driver Plugin.");
281 return QObject::tr("Comunaication Driver Plugin.");
282 break;
282 break;
283 case PerifDriverT:
283 case PerifDriverT:
284 ////lib->unload();
284 ////lib->unload();
285 lib->~QLibrary();
285 lib->~QLibrary();
286 return QObject::tr("Periferial Driver Plugin.");
286 return QObject::tr("Periferial Driver Plugin.");
287 break;
287 break;
288 default:
288 default:
289 ////lib->unload();
289 ////lib->unload();
290 lib->~QLibrary();
290 lib->~QLibrary();
291 return QObject::tr("Unknow Plugin.");
291 return QObject::tr("Unknow Plugin.");
292 break;
292 break;
293 }
293 }
294 }
294 }
295 }
295 }
296 lib->~QLibrary();
296 lib->~QLibrary();
297 return QObject::tr("Can't load Plugin.");
297 return QObject::tr("Can't load Plugin.");
298 }
298 }
299
299
300
300
301
301
302
302
303 pluginT pluginloader::getlibType(QString Name)
303 pluginT pluginloader::getlibType(QString Name)
304 {
304 {
305 if(_self==NULL)init();
305 if(_self==NULL)init();
306 QString* libfile= _cacheLookup(Name);
306 QString* libfile= _cacheLookup(Name);
307 if(libfile==NULL)return (pluginT)NULL;
307 if(libfile==NULL)return (pluginT)NULL;
308 QLibrary* lib = new QLibrary(*libfile);
308 QLibrary* lib = new QLibrary(*libfile);
309 delete libfile;
309 delete libfile;
310 lib->load();
310 lib->load();
311 if(lib->isLoaded())
311 if(lib->isLoaded())
312 {
312 {
313 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
313 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
314 if(plugintype!=NULL)
314 if(plugintype!=NULL)
315 {
315 {
316 return plugintype();
316 return plugintype();
317 }
317 }
318 }
318 }
319 lib->~QLibrary();
319 lib->~QLibrary();
320 return -1;
320 return -1;
321 }
321 }
322
322
323
323
324 QString pluginloader::getlibVersion(const QString Name)
324 QString pluginloader::getlibVersion(const QString Name)
325 {
325 {
326 if(_self==NULL)init();
326 if(_self==NULL)init();
327 QString* libfile= _cacheLookup(Name);
327 QString* libfile= _cacheLookup(Name);
328 if(libfile==NULL)return NULL;
328 if(libfile==NULL)return NULL;
329 QLibrary* lib = new QLibrary(*libfile);
329 QLibrary* lib = new QLibrary(*libfile);
330 delete libfile;
330 delete libfile;
331 lib->load();
331 lib->load();
332 if(lib->isLoaded())
332 if(lib->isLoaded())
333 {
333 {
334 socexplorerpluginVersionT pluginversion = (socexplorerpluginVersionT)lib->resolve("socexplorerpluginVersion");
334 socexplorerpluginVersionT pluginversion = (socexplorerpluginVersionT)lib->resolve("socexplorerpluginVersion");
335 if(pluginversion!=NULL)
335 if(pluginversion!=NULL)
336 {
336 {
337 QString version = pluginversion();
337 QString version = pluginversion();
338 ////lib->unload();
338 ////lib->unload();
339 lib->~QLibrary();
339 lib->~QLibrary();
340 return version;
340 return version;
341 }
341 }
342 }
342 }
343 lib->~QLibrary();
343 lib->~QLibrary();
344 return QObject::tr("Can't load Plugin.");
344 return QObject::tr("Can't load Plugin.");
345 }
345 }
346
346
347
347
348
348
349 QString pluginloader::getlibPIDstr(const QString Name)
349 QString pluginloader::getlibPIDstr(const QString Name)
350 {
350 {
351 return QString("0x" + QString::number(pluginloader::getlibPID(Name) , 16));
351 return QString("0x" + QString::number(pluginloader::getlibPID(Name) , 16));
352 }
352 }
353
353
354 QString pluginloader::getlibVIDstr(const QString Name)
354 QString pluginloader::getlibVIDstr(const QString Name)
355 {
355 {
356 return QString("0x" + QString::number(pluginloader::getlibVID(Name) , 16));
356 return QString("0x" + QString::number(pluginloader::getlibVID(Name) , 16));
357 }
357 }
358
358
359
359
360
360
361 int pluginloader::libcanbechild(const QString Name)
361 int pluginloader::libcanbechild(const QString Name)
362 {
362 {
363 if(_self==NULL)init();
363 if(_self==NULL)init();
364 QString* libfile= _cacheLookup(Name);
364 QString* libfile= _cacheLookup(Name);
365 if(libfile==NULL)return (int)NULL;
365 if(libfile==NULL)return (int)NULL;
366 QLibrary* lib = new QLibrary(*libfile);
366 QLibrary* lib = new QLibrary(*libfile);
367 delete libfile;
367 delete libfile;
368 lib->load();
368 lib->load();
369 if(lib->isLoaded())
369 if(lib->isLoaded())
370 {
370 {
371 socexplorerplugincanbechildT canbechild = (socexplorerplugincanbechildT)lib->resolve("socexplorerplugincanbechild");
371 socexplorerplugincanbechildT canbechild = (socexplorerplugincanbechildT)lib->resolve("socexplorerplugincanbechild");
372 if(canbechild!=NULL)
372 if(canbechild!=NULL)
373 {
373 {
374 int value = canbechild();
374 int value = canbechild();
375 ////lib->unload();
375 ////lib->unload();
376 //lib->~QLibrary();
376 //lib->~QLibrary();
377 return value;
377 return value;
378 }
378 }
379 }
379 }
380 //lib->~QLibrary();
380 //lib->~QLibrary();
381 return 0;
381 return 0;
382 }
382 }
383
383
384
384
385
385
386
386
387 int pluginloader::libcanberoot(const QString Name)
387 int pluginloader::libcanberoot(const QString Name)
388 {
388 {
389 if(_self==NULL)init();
389 if(_self==NULL)init();
390 QString* libfile= _cacheLookup(Name);
390 QString* libfile= _cacheLookup(Name);
391 if(libfile==NULL)return (int)NULL;
391 if(libfile==NULL)return (int)NULL;
392 QLibrary* lib = new QLibrary(*libfile);
392 QLibrary* lib = new QLibrary(*libfile);
393 delete libfile;
393 delete libfile;
394 lib->load();
394 lib->load();
395 if(lib->isLoaded())
395 if(lib->isLoaded())
396 {
396 {
397 socexplorerplugincanberootT canberoot = (socexplorerplugincanberootT)lib->resolve("socexplorerplugincanberoot");
397 socexplorerplugincanberootT canberoot = (socexplorerplugincanberootT)lib->resolve("socexplorerplugincanberoot");
398 if(canberoot!=NULL)
398 if(canberoot!=NULL)
399 {
399 {
400 int value = canberoot();
400 int value = canberoot();
401 ////lib->unload();
401 ////lib->unload();
402 //lib->~QLibrary();
402 //lib->~QLibrary();
403 return value;
403 return value;
404 }
404 }
405 }
405 }
406 delete lib;
406 delete lib;
407 //lib->~QLibrary();
407 //lib->~QLibrary();
408 return 0;
408 return 0;
409 }
409 }
410
410
411 int pluginloader::getlibVID(const QString Name)
411 int pluginloader::getlibVID(const QString Name)
412 {
412 {
413 if(_self==NULL)init();
413 if(_self==NULL)init();
414 QString* libfile= _cacheLookup(Name);
414 QString* libfile= _cacheLookup(Name);
415 if(libfile==NULL)return 0;
415 if(libfile==NULL)return 0;
416 QString file(*libfile);
416 QString file(*libfile);
417 delete libfile;
417 delete libfile;
418 return _getlibVID(file);
418 return _getlibVID(file);
419 }
419 }
420
420
421
421
422 int pluginloader::getlibPID(const QString Name)
422 int pluginloader::getlibPID(const QString Name)
423 {
423 {
424 if(_self==NULL)init();
424 if(_self==NULL)init();
425 QString* libfile= _cacheLookup(Name);
425 QString* libfile= _cacheLookup(Name);
426 if(libfile==NULL)return 0;
426 if(libfile==NULL)return 0;
427 QString file(*libfile);
427 QString file(*libfile);
428 delete libfile;
428 delete libfile;
429 return _getlibPID(file);
429 return _getlibPID(file);
430 }
430 }
431
431
432 QString pluginloader::getlibAuthor(const QString Name)
432 QString pluginloader::getlibAuthor(const QString Name)
433 {
433 {
434 if(_self==NULL)init();
434 if(_self==NULL)init();
435 QString* libfile= _cacheLookup(Name);
435 QString* libfile= _cacheLookup(Name);
436 if(libfile==NULL)return NULL;
436 if(libfile==NULL)return NULL;
437 QLibrary* lib = new QLibrary(*libfile);
437 QLibrary* lib = new QLibrary(*libfile);
438 delete libfile;
438 delete libfile;
439 lib->load();
439 lib->load();
440 if(lib->isLoaded())
440 if(lib->isLoaded())
441 {
441 {
442 socexplorerpluginAuthorT pluginauthor = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginAuthor");
442 socexplorerpluginAuthorT pluginauthor = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginAuthor");
443 if(pluginauthor!=NULL)
443 if(pluginauthor!=NULL)
444 {
444 {
445 QString author = pluginauthor();
445 QString author = pluginauthor();
446 ////lib->unload();
446 ////lib->unload();
447 lib->~QLibrary();
447 lib->~QLibrary();
448 return author;
448 return author;
449 }
449 }
450 }
450 }
451 lib->~QLibrary();
451 lib->~QLibrary();
452 return QObject::tr("Can't load Plugin.");
452 return QObject::tr("Can't load Plugin.");
453 }
453 }
454
454
455 QString pluginloader::getlibName(const QString Name)
455 QString pluginloader::getlibName(const QString Name)
456 {
456 {
457 if(_self==NULL)init();
457 if(_self==NULL)init();
458 QString* libfile= _cacheLookup(Name);
458 QString* libfile= _cacheLookup(Name);
459 if(libfile==NULL)return QString("");
459 if(libfile==NULL)return QString("");
460 QString file(*libfile);
460 QString file(*libfile);
461 delete libfile;
461 delete libfile;
462 return _getlibName(file);
462 return _getlibName(file);
463 }
463 }
464
464
465 QString pluginloader::getlibDescription(const QString Name)
465 QString pluginloader::getlibDescription(const QString Name)
466 {
466 {
467 if(_self==NULL)init();
467 if(_self==NULL)init();
468 QString* libfile= _cacheLookup(Name);
468 QString* libfile= _cacheLookup(Name);
469 if(libfile==NULL)return NULL;
469 if(libfile==NULL)return NULL;
470 QLibrary* lib = new QLibrary(*libfile);
470 QLibrary* lib = new QLibrary(*libfile);
471 delete libfile;
471 delete libfile;
472 lib->load();
472 lib->load();
473 if(lib->isLoaded())
473 if(lib->isLoaded())
474 {
474 {
475 socexplorerpluginDescriptionT plugindescription = (socexplorerpluginDescriptionT)lib->resolve("socexplorerpluginDescription");
475 socexplorerpluginDescriptionT plugindescription = (socexplorerpluginDescriptionT)lib->resolve("socexplorerpluginDescription");
476 if(plugindescription!=NULL)
476 if(plugindescription!=NULL)
477 {
477 {
478 QString description = plugindescription();
478 QString description = plugindescription();
479 ////lib->unload();
479 ////lib->unload();
480 lib->~QLibrary();
480 lib->~QLibrary();
481 return description;
481 return description;
482 }
482 }
483 }
483 }
484 lib->~QLibrary();
484 lib->~QLibrary();
485 return QObject::tr("Can't load Plugin.");
485 return QObject::tr("Can't load Plugin.");
486 }
486 }
487
487
488 QString pluginloader::getlibDir(const QString Name)
488 QString pluginloader::getlibDir(const QString Name)
489 {
489 {
490 if(_self==NULL)init();
490 if(_self==NULL)init();
491 return *_cacheLookup(Name);
491 return *_cacheLookup(Name);
492 }
492 }
493
493
494 QString pluginloader::_getlibName(const QString fileName)
494 QString pluginloader::_getlibName(const QString fileName)
495 {
495 {
496 QLibrary* lib = new QLibrary(fileName);
496 QLibrary* lib = new QLibrary(fileName);
497 lib->load();
497 lib->load();
498 if(lib->isLoaded())
498 if(lib->isLoaded())
499 {
499 {
500 socexplorerpluginNameT pluginName = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginName");
500 socexplorerpluginNameT pluginName = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginName");
501 if(pluginName!=NULL)
501 if(pluginName!=NULL)
502 {
502 {
503 QString name = pluginName();
503 QString name = pluginName();
504 //lib->unload();
504 //lib->unload();
505 lib->~QLibrary();
505 lib->~QLibrary();
506 return name;
506 return name;
507 }
507 }
508 }
508 }
509 lib->~QLibrary();
509 lib->~QLibrary();
510 return QObject::tr("Can't load Plugin.");
510 return QObject::tr("Can't load Plugin.");
511 }
511 }
512
512
513 int pluginloader::_getlibPID(const QString fileName)
513 int pluginloader::_getlibPID(const QString fileName)
514 {
514 {
515 QLibrary* lib = new QLibrary(fileName);
515 QLibrary* lib = new QLibrary(fileName);
516 lib->load();
516 lib->load();
517 if(lib->isLoaded())
517 if(lib->isLoaded())
518 {
518 {
519 socexplorerpluginpidT pluginpid = (socexplorerpluginpidT)lib->resolve("socexplorerpluginpid");
519 socexplorerpluginpidT pluginpid = (socexplorerpluginpidT)lib->resolve("socexplorerpluginpid");
520 if(pluginpid!=NULL)
520 if(pluginpid!=NULL)
521 {
521 {
522 int pid = pluginpid();
522 int pid = pluginpid();
523 //lib->unload();
523 //lib->unload();
524 lib->~QLibrary();
524 lib->~QLibrary();
525 return pid;
525 return pid;
526 }
526 }
527 }
527 }
528 lib->~QLibrary();
528 lib->~QLibrary();
529 return 0;
529 return 0;
530 }
530 }
531
531
532 int pluginloader::_getlibVID(const QString fileName)
532 int pluginloader::_getlibVID(const QString fileName)
533 {
533 {
534 QLibrary* lib = new QLibrary(fileName);
534 QLibrary* lib = new QLibrary(fileName);
535 lib->load();
535 lib->load();
536 if(lib->isLoaded())
536 if(lib->isLoaded())
537 {
537 {
538 socexplorerpluginvidT pluginvid = (socexplorerpluginvidT)lib->resolve("socexplorerpluginvid");
538 socexplorerpluginvidT pluginvid = (socexplorerpluginvidT)lib->resolve("socexplorerpluginvid");
539 if(pluginvid!=NULL)
539 if(pluginvid!=NULL)
540 {
540 {
541 int vid = pluginvid();
541 int vid = pluginvid();
542 //lib->unload();
542 //lib->unload();
543 lib->~QLibrary();
543 lib->~QLibrary();
544 return vid;
544 return vid;
545 }
545 }
546 }
546 }
547 lib->~QLibrary();
547 lib->~QLibrary();
548 return 0;
548 return 0;
549 }
549 }
550
550
551 QString* pluginloader::_cacheLookup(const QString Name)
551 QString* pluginloader::_cacheLookup(const QString Name)
552 {
552 {
553 QString* libfile= new QString(_cache->first(Name));
553 QString* libfile= new QString(_cache->first(Name));
554 if(!QFile::exists(*libfile))
554 if(!QFile::exists(*libfile))
555 {
555 {
556 scanFolders();
556 scanFolders();
557 *libfile = _cache->first(Name);
557 *libfile = _cache->first(Name);
558 if(QFile::exists(*libfile))return libfile;
558 if(QFile::exists(*libfile))return libfile;
559 }
559 }
560 else
560 else
561 {
561 {
562 return libfile;
562 return libfile;
563 }
563 }
564 delete libfile;
564 delete libfile;
565 return NULL;
565 return NULL;
566 }
566 }
567
567
568 /*QString findlib(QString name)
568 /*QString findlib(QString name)
569 {
569 {
570
570
571 }*/
571 }*/
572
572
General Comments 0
You need to be logged in to leave comments. Login now