##// END OF EJS Templates
New Plugin Manager and interface to remove all the previous crap!...
jeandet -
r118:de85e8465e67 tip 1.0 draft
parent child
Show More
@@ -0,0 +1,117
1 /*------------------------------------------------------------------------------
2 ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗
3 ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗
4 ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝
5 ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗
6 ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║
7 ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
8
9 -- This file is a part of the SOC Explorer Software
10 -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS
11 --
12 -- This program is free software; you can redistribute it and/or modify
13 -- it under the terms of the GNU General Public License as published by
14 -- the Free Software Foundation; either version 2 of the License, or
15 -- (at your option) any later version.
16 --
17 -- This program is distributed in the hope that it will be useful,
18 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
19 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 -- GNU General Public License for more details.
21 --
22 -- You should have received a copy of the GNU General Public License
23 -- along with this program; if not, write to the Free Software
24 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 -------------------------------------------------------------------------------*/
26 /*-- Author : Alexis Jeandet
27 -- Mail : alexis.jeandet@lpp.polytechnique.fr
28 ----------------------------------------------------------------------------*/
29
30 #include "pluginmanager.h"
31 #include <QDir>
32 #include <QLibrary>
33 #include <QPluginLoader>
34 #include <socexplorerengine.h>
35
36 void PluginManager::loadPluginMetaData(const QString &pluginPath)
37 {
38 if(!this->plugins_metada_cache.contains(pluginPath))
39 {
40 if (QLibrary::isLibrary(pluginPath))
41 {
42 QPluginLoader pluginLoader{pluginPath};
43 if(pluginLoader.isLoaded())
44 {
45 auto metadata = pluginLoader.metaData().value("MetaData").toObject();
46 for (auto key:pluginKeys::all)
47 {
48 if(metadata.contains(key))
49 this->plugins_metada_cache[pluginPath][key] = metadata.value(key).toString();
50 }
51 }
52
53 }
54 }
55 }
56
57 bool PluginManager::isPlugin(const QString &pluginPath)const
58 {
59 if(!this->plugins_metada_cache.contains(pluginPath))
60 {
61 if (QLibrary::isLibrary(pluginPath))
62 {
63 QPluginLoader pluginLoader{pluginPath};
64 if(pluginLoader.isLoaded())
65 {
66 return true;
67 }
68 }
69 }
70 return false;
71 }
72
73
74 PluginManager::PluginManager(const QStringList &folderList)
75 :folderList(folderList)
76 {
77 scanFolders();
78 }
79
80 ISocexplorerPlugin *PluginManager::makeInstance(const QString& pluginName)
81 {
82 auto plugin = resolvePluginName(pluginName);
83 if (QLibrary::isLibrary(plugin))
84 {
85 QPluginLoader pluginLoader{plugin};
86 if (auto pluginInstance = qobject_cast<ISocexplorerPlugin *>(pluginLoader.instance())) {
87 return pluginInstance;
88 }
89 }
90 return Q_NULLPTR;
91 }
92
93
94 void PluginManager::scanFolders()
95 {
96 QDir dir;
97 QStringList filters{"*.so", "*.dll"};
98 pluginTable.clear();
99 for(auto&& folder:folderList)
100 {
101 dir.setPath(folder);
102 dir.setFilter(QDir::Files);
103 dir.setNameFilters(filters);
104 QFileInfoList list = dir.entryInfoList();
105 for (auto&& fileInfo:list)
106 {
107 auto path = fileInfo.filePath();
108 SocExplorerEngine::message("pluginloader::scanFolders","Checking "+ path,3);
109 if(isPlugin(path))
110 {
111 loadPluginMetaData(path);
112 auto name = plugins_metada_cache[path][pluginKeys::Name];
113 pluginTable[name].append(path);
114 }
115 }
116 }
117 }
@@ -0,0 +1,122
1 /*------------------------------------------------------------------------------
2 ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗
3 ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗
4 ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝
5 ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗
6 ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║
7 ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
8
9 -- This file is a part of the SOC Explorer Software
10 -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS
11 --
12 -- This program is free software; you can redistribute it and/or modify
13 -- it under the terms of the GNU General Public License as published by
14 -- the Free Software Foundation; either version 2 of the License, or
15 -- (at your option) any later version.
16 --
17 -- This program is distributed in the hope that it will be useful,
18 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
19 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 -- GNU General Public License for more details.
21 --
22 -- You should have received a copy of the GNU General Public License
23 -- along with this program; if not, write to the Free Software
24 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 -------------------------------------------------------------------------------*/
26 /*-- Author : Alexis Jeandet
27 -- Mail : alexis.jeandet@lpp.polytechnique.fr
28 ----------------------------------------------------------------------------*/
29 #ifndef PLUGINLOADER_H
30 #define PLUGINLOADER_H
31 #include <isocexplorerplugin.h>
32 #include <QHash>
33 #include <QStringLiteral>
34
35 template<typename T>
36 auto loadMetadata(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache);
37
38 template<>
39 auto loadMetadata<QString>(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache)
40 {
41 if(plugins_metada_cache.contains(pluginName))
42 {
43 return plugins_metada_cache[pluginName][name];
44 }
45 return QString();
46 }
47
48 template<>
49 auto loadMetadata<int>(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache)
50 {
51 if(plugins_metada_cache.contains(pluginName))
52 {
53 return plugins_metada_cache[pluginName][name].toInt();
54 }
55 return -1;
56 }
57
58 template<>
59 auto loadMetadata<bool>(const QString& name, const QString &pluginName,const QHash<QString, QHash<QString,QString>>& plugins_metada_cache)
60 {
61 if(plugins_metada_cache.contains(pluginName))
62 {
63 return bool(plugins_metada_cache[pluginName][name].toInt());
64 }
65 return false;
66 }
67
68 namespace pluginKeys
69 {
70 const auto Name=QStringLiteral("Name");
71 const auto Author=QStringLiteral("Author");
72 const auto Version=QStringLiteral("Version");
73 const auto Description=QStringLiteral("Description");
74 const auto CanBeRoot=QStringLiteral("root");
75 const auto CanBeChild=QStringLiteral("child");
76 const auto VID=QStringLiteral("VID");
77 const auto PID=QStringLiteral("PID");
78
79 const auto all={Name, Author, Version, Description, CanBeRoot, CanBeChild, VID, PID};
80 };
81
82 class PluginManager
83 {
84 void loadPluginMetaData(const QString &pluginPath);
85 bool isPlugin(const QString &pluginPath)const;
86
87 QString resolvePluginName(const QString &pluginName)const
88 {
89 if( plugins_metada_cache.contains(pluginName))
90 return pluginName;
91 else if (pluginTable.contains(pluginName)) {
92 return pluginTable[pluginName].last();
93 }
94 return QString();
95 }
96 public:
97 PluginManager(const QStringList& folderList);
98 ISocexplorerPlugin* makeInstance(const QString &pluginName);
99
100 #define METADATA_GETTER(type, name)\
101 type plugin##name(const QString &pluginName)const{return loadMetadata<type>(pluginKeys::name, resolvePluginName(pluginName), plugins_metada_cache);}
102
103 METADATA_GETTER(QString, Name)
104 METADATA_GETTER(QString, Author)
105 METADATA_GETTER(QString, Description)
106 METADATA_GETTER(QString, Version)
107
108 METADATA_GETTER(bool, CanBeRoot)
109 METADATA_GETTER(bool, CanBeChild)
110
111 METADATA_GETTER(int, VID)
112 METADATA_GETTER(int, PID)
113
114 void scanFolders();
115 private:
116 QHash<QString, QHash<QString,QString>> plugins_metada_cache;
117 QHash<QString, QStringList> pluginTable;
118
119 QStringList folderList;
120 };
121
122 #endif // PLUGINLOADER_H
@@ -0,0 +1,334
1 /*------------------------------------------------------------------------------
2 ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗
3 ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗
4 ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝
5 ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗
6 ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║
7 ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
8
9 -- This file is a part of the SOC Explorer Software
10 -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS
11 --
12 -- This program is free software; you can redistribute it and/or modify
13 -- it under the terms of the GNU General Public License as published by
14 -- the Free Software Foundation; either version 2 of the License, or
15 -- (at your option) any later version.
16 --
17 -- This program is distributed in the hope that it will be useful,
18 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
19 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 -- GNU General Public License for more details.
21 --
22 -- You should have received a copy of the GNU General Public License
23 -- along with this program; if not, write to the Free Software
24 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 -------------------------------------------------------------------------------*/
26 /*-- Author : Alexis Jeandet
27 -- Mail : alexis.jeandet@lpp.polytechnique.fr
28 ----------------------------------------------------------------------------*/
29 #ifndef ISOCEXPLORERPLUGIN_H
30 #define ISOCEXPLORERPLUGIN_H
31 #include <QtPlugin>
32 #include <QWidget>
33 #include <QAction>
34 #include <QDockWidget>
35 #include <QMainWindow>
36 #include <QList>
37 #include <QMenu>
38 #include <socexplorer.h>
39 #include <QObject>
40 #include <QVariant>
41 #include <QVariantList>
42 #include <malloc.h>
43 #include <QFile>
44 #include <stdint.h>
45 #include <QTextStream>
46 #include <abstractbinfile.h>
47 #include <srec/srecfile.h>
48 #include <BinFile/binaryfile.h>
49
50 class ISocexplorerPlugin : public QDockWidget
51 {
52 Q_OBJECT
53 public:
54 //! Default plugin constructor, any plugin should call this constructor.
55 ISocexplorerPlugin(QWidget *parent = Q_NULLPTR,bool createPyObject=true):QDockWidget(parent)
56 {
57 Q_UNUSED(createPyObject)
58 closeAction=Q_NULLPTR;
59 menu=Q_NULLPTR;
60 ChildsMenu=Q_NULLPTR;
61 this->Connected = false;
62 this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetVerticalTitleBar);
63 }
64 //! Tells if the plugin is connected, it is used to enable or disable all childrens interfaces.
65 virtual bool isConnected(){return this->Connected;}
66 //! Gives the associated Vendor IDentifier, usefull to automatically associate plugins with found
67 //! hardware while board enumeration.
68 virtual uint64_t baseAddress(){return this->BaseAddress;}
69 //! Sets the base address of the current instance, for example if your plugin is supposed to drive
70 //! an UART it will correspond to the address of it's first register. This address have at least to
71 //! be set by SocExplorer and it can be user accessible if you want.
72 virtual void setBaseAddress(uint64_t baseAddress){this->BaseAddress = baseAddress;}
73
74 QList<ISocexplorerPlugin*> childs;
75 ISocexplorerPlugin* parent;
76 QAction* closeAction;
77 QString instanceName(){return _instanceName;}
78 QString instance(){return instanceName();}
79 QMenu* menu;
80 QMenu* ChildsMenu;
81
82 signals:
83 //! Signal emited each time the plugin is about to be closed.
84 void closePlugin(ISocexplorerPlugin* driver);
85 void activateSig(bool flag);
86 void registerObject(QObject* object,const QString& instanceName);
87
88 public slots:
89 virtual int registermenu(QMenu* menu)
90 {
91 this->menu = menu->addMenu(this->_instanceName);
92 this->closeAction = this->menu->addAction(tr("Close plugin"));
93 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
94 this->ChildsMenu = this->menu->addMenu(QString("Childs"));
95 for(int i=0;i<this->childs.count();i++)
96 {
97 this->childs.at(i)->registermenu(this->ChildsMenu);
98 }
99 emit this->registerObject((QObject*)this,this->instanceName());
100 return 0;
101 }
102 virtual void postInstantiationTrigger(){}
103 //! Write slot this is the way your children plugins ask you for writing data.
104 //! If your plugin is supposed to have childern drivers you should implement this methode.
105 //! By default this methode forward the write request to the parent plugin.
106 //! \param Value Pointer the data buffer.
107 //! \param count Number of 32 bits words you should to write.
108 //! \param address Address from where you should to start to write.
109 //! \return Quantity of 32 bits words writtens.
110 virtual unsigned int Write(unsigned int* Value, int count, uint64_t address)
111 {
112 if(parent!=Q_NULLPTR)
113 {
114 return parent->Write(Value,count,address);
115 }
116 return 0;
117 }
118
119 void Write(uint64_t address, QList<QVariant> dataList)
120 {
121 unsigned int data[dataList.count()];
122 for(int i = 0;i<dataList.count();i++)
123 {
124 data[i] = (unsigned int)dataList.at(i).toUInt();
125 }
126 Write(data,dataList.count(),address);
127 }
128 //! Read slot this is the way your children plugins ask you for reading data.
129 //! If your plugin is supposed to have childern drivers you should implement this methode.
130 //! By default this methode forward the write request to the parent plugin.
131 //! \param Value Pointer the data buffer.
132 //! \param count Number of 32 bits words you should to read.
133 //! \param address Address from where you should to start to read.
134 //! \return Quantity of 32 bits words read.
135 virtual unsigned int Read(unsigned int* Value, int count, uint64_t address)
136 {
137 if(parent!=Q_NULLPTR)
138 {
139 return parent->Read(Value,count,address);
140 }
141 return 0;
142 }
143 QVariantList Read(uint64_t address, int count)
144 {
145 unsigned int data[count];
146 QVariantList result;
147 Read(data,count,address);
148 for(int i = 0;i<count;i++)
149 {
150 result.append(QVariant(static_cast<int>(data[i])));
151 }
152 return result;
153 }
154
155 virtual void closeMe(){emit this->closePlugin(this);}
156
157 virtual void activate(bool flag)
158 {
159 this->setEnabled(flag);
160 emit this->activateSig(flag);
161 }
162
163 virtual void setInstanceName(const QString& newName)
164 {
165 this->_instanceName = newName;
166 if(this->menu)
167 this->menu->setTitle(this->_instanceName);
168 this->setWindowTitle(newName);
169 this->setObjectName(newName);
170 }
171
172 virtual bool dumpMemory(uint64_t address, unsigned int count, QString file)
173 {
174 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
175 if(buffer!=NULL)
176 {
177 this->Read(buffer,count,address);
178 QFile outfile(file);
179 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
180 return false;
181 QTextStream out(&outfile);
182 for(int i=0;(unsigned int)i<count;i++)
183 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
184 free(buffer);
185 out.flush();
186 outfile.close();
187 return true;
188 }
189 return false;
190 }
191
192 virtual bool dumpMemory(uint64_t address,unsigned int count,QString file,const QString& format)
193 {
194 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
195 if(buffer!=NULL)
196 {
197 this->Read(buffer,count,address);
198 if(!format.compare("srec",Qt::CaseInsensitive))
199 {
200 //need to convert from in memory endianness to file endianness
201 //SREC is always big endian
202 #if __BYTE_ORDER == __LITTLE_ENDIAN
203 for(int l=0;l<(count);l++)
204 {
205 buffer[l] = socexplorerBswap32(buffer[l]);
206 }
207 #elif __BYTE_ORDER == __BIG_ENDIAN
208
209 #endif
210 codeFragment fragment((char*)buffer,count*4,address);
211 srecFile::toSrec(QList<codeFragment*>()<<&fragment,file);
212 }
213 if(!format.compare("bin",Qt::CaseInsensitive))
214 {
215 //beware this format is not portable from a big endian host to a litle endian one
216 codeFragment fragment((char*)buffer,count*4,address);
217 binaryFile::toBinary(QList<codeFragment*>()<<&fragment,file);
218 }
219 if(!format.compare("hexa",Qt::CaseInsensitive))
220 {
221 QFile outfile(file);
222 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
223 return false;
224 QTextStream out(&outfile);
225 for(int i=0;(unsigned int)i<count;i++)
226 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
227 free(buffer);
228 out.flush();
229 outfile.close();
230 }
231 return true;
232 }
233 return false;
234 }
235
236 virtual bool memSet(uint64_t address, int value, unsigned int count)
237 {
238 unsigned int* buffer = static_cast<unsigned int*>(malloc(count*sizeof(unsigned int)));
239 if(buffer!=Q_NULLPTR)
240 {
241 memset(static_cast<void*>(buffer),value,count*sizeof(unsigned int));
242 this->Write(buffer,count,address);
243 free(buffer );
244 return true;
245 }
246 return false;
247 }
248
249 virtual bool loadbin(uint64_t address,QString file)
250 {
251 QFile infile(file);
252 if (!infile.open(QIODevice::ReadOnly))
253 return false;
254 uint32_t* buffer = (uint32_t*)malloc(infile.size());
255 if(buffer!=NULL)
256 {
257 infile.read((char*)buffer,infile.size());
258 for(int i=0;i<(infile.size()/4);i++)
259 {
260 buffer[i] = socexplorerBswap32(buffer[i]);
261 }
262 this->Write(buffer,infile.size()/4,address);
263 free(buffer);
264 return true;
265 }
266 return false;
267
268 }
269
270 virtual bool loadfile(abstractBinFile* file)
271 {
272 {
273 if(file->isopened())
274 {
275 QList<codeFragment*> fragments= file->getFragments();
276 for(int i=0;i<fragments.count();i++)
277 {
278 int size = fragments.at(i)->size/4;
279 // TODO fixme, should be the oposite
280 #if __BYTE_ORDER == __LITTLE_ENDIAN
281 if(!file->litleendian)
282 {
283 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
284 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
285 if(buffer!=NULL)
286 {
287 for(int l=0;l<(size);l++)
288 {
289 buffer[l] = socexplorerBswap32(buffer[l]);
290 }
291 this->Write(buffer,size,fragments.at(i)->address);
292 free(buffer);
293 }
294 }
295 else
296 {
297 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
298 }
299 #elif __BYTE_ORDER == __BIG_ENDIAN
300 if(file->litleendian)
301 {
302 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
303 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
304 if(buffer!=NULL)
305 {
306 for(int l=0;l<(size);l++)
307 {
308 buffer[l] = socexplorerBswap32(buffer[l]);
309 }
310 this->Write(buffer,size,fragments.at(i)->address);
311 free(buffer);
312 }
313 }
314 else
315 {
316 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
317 }
318 #endif
319 }
320 }
321 return true;
322 }
323 }
324 ISocexplorerPlugin* parentPlugin(){return this->parent;}
325 ISocexplorerPlugin* toPlugin(){return static_cast<ISocexplorerPlugin*>(this);}
326 protected:
327 QString _instanceName;
328 uint64_t BaseAddress;
329 bool Connected;
330 };
331
332 Q_DECLARE_INTERFACE(ISocexplorerPlugin, "socexplorer.plugins.ISocexplorerPlugin")
333
334 #endif // ISOCEXPLORERPLUGIN_H
@@ -1,186 +1,189
1 SOCEXPLORER_ROOT = \"$${PWD}/../..\"
1 SOCEXPLORER_ROOT = \"$${PWD}/../..\"
2
2
3 include($${PWD}/../../build_cfg/socexplorer.pri)
3 include($${PWD}/../../build_cfg/socexplorer.pri)
4
4
5 TARGET = socexplorerengine$${DEBUG_EXT}
5 TARGET = socexplorerengine$${DEBUG_EXT}
6 TEMPLATE = lib
6 TEMPLATE = lib
7
7
8 #more verbose plugin loader to debug plugin loading issues such as dependencies issues
8 #more verbose plugin loader to debug plugin loading issues such as dependencies issues
9 SOCEXPLORER_PLUGIN_LOADER="custom"
9 SOCEXPLORER_PLUGIN_LOADER="custom"
10
10
11 SOCEXPLORER_CHAGESETNUM=$$system(hg id)
11 SOCEXPLORER_CHAGESETNUM=$$system(hg id)
12 isEmpty(SOCEXPLORER_CHAGESETNUM){
12 isEmpty(SOCEXPLORER_CHAGESETNUM){
13 SOCEXPLORER_CHAGESETNUM=c459540a6dbdcbb4e17f204685fce02c070ba971+
13 SOCEXPLORER_CHAGESETNUM=c459540a6dbdcbb4e17f204685fce02c070ba971+
14 }
14 }
15 SOCEXPLORER_CHAGESETNUMSTR = '\\"$${SOCEXPLORER_CHAGESETNUM}\\"'
15 SOCEXPLORER_CHAGESETNUMSTR = '\\"$${SOCEXPLORER_CHAGESETNUM}\\"'
16 SOCEXPLORER_BRANCH=$$system(hg branch)
16 SOCEXPLORER_BRANCH=$$system(hg branch)
17 isEmpty(SOCEXPLORER_BRANCH){
17 isEmpty(SOCEXPLORER_BRANCH){
18 SOCEXPLORER_BRANCH=default
18 SOCEXPLORER_BRANCH=default
19 }
19 }
20 SOCEXPLORER_BRANCHSTR = '\\"$${SOCEXPLORER_BRANCH}\\"'
20 SOCEXPLORER_BRANCHSTR = '\\"$${SOCEXPLORER_BRANCH}\\"'
21
21
22 DEFINES += SOCEXPLORER_VERSION="\"\\\"0.7.0"\\\"\"
22 DEFINES += SOCEXPLORER_VERSION="\"\\\"0.7.0"\\\"\"
23 DEFINES += SOCEXPLORER_CHAGESET=\"$${SOCEXPLORER_CHAGESETNUMSTR}\"
23 DEFINES += SOCEXPLORER_CHAGESET=\"$${SOCEXPLORER_CHAGESETNUMSTR}\"
24 DEFINES += SOCEXPLORER_BRANCH=\"$${SOCEXPLORER_BRANCHSTR}\"
24 DEFINES += SOCEXPLORER_BRANCH=\"$${SOCEXPLORER_BRANCHSTR}\"
25
25
26
26
27 message("Building SOCEXPLORER changeset $${SOCEXPLORER_CHAGESETNUM}")
27 message("Building SOCEXPLORER changeset $${SOCEXPLORER_CHAGESETNUM}")
28
28
29 DEFINES += SOCEXPLORER_EXPORTS
29 DEFINES += SOCEXPLORER_EXPORTS
30
30
31 include ( plugins/socexplorerplugin.prf )
31 include ( plugins/socexplorerplugin.prf )
32 include ( PeripheralWidget/PeripheralWidget.pri)
32 include ( PeripheralWidget/PeripheralWidget.pri)
33
33
34 win32:CONFIG += dll
34 win32:CONFIG += dll
35 win32:CONFIG -= static
35 win32:CONFIG -= static
36 win32:LIBS+=-L$${SOCEXPLORER_ROOT}/bin/win32 -lsocexplorercommon$${DEBUG_EXT}
36 win32:LIBS+=-L$${SOCEXPLORER_ROOT}/bin/win32 -lsocexplorercommon$${DEBUG_EXT}
37
37
38 contains(SOCEXPLORER_PLUGIN_LOADER,"custom")
38 contains(SOCEXPLORER_PLUGIN_LOADER,"custom")
39 {
39 {
40 unix:LIBS+= -ldl
40 unix:LIBS+= -ldl
41 unix:DEFINES += SOCEXPLORER_CUSTOM_PLUGIN_LOADER
41 unix:DEFINES += SOCEXPLORER_CUSTOM_PLUGIN_LOADER
42 unix:HEADERS += \
42 unix:HEADERS += \
43 pluginloader/unix/unixpluginloader.h
43 pluginloader/unix/unixpluginloader.h
44 unix:SOURCES += \
44 unix:SOURCES += \
45 pluginloader/unix/unixpluginloader.cpp
45 pluginloader/unix/unixpluginloader.cpp
46 }
46 }
47
47
48 target.path = $$[QT_INSTALL_LIBS]
48 target.path = $$[QT_INSTALL_LIBS]
49 isEmpty(target.path) {
49 isEmpty(target.path) {
50 error(can\'t get QT_INSTALL_LIBS)
50 error(can\'t get QT_INSTALL_LIBS)
51 }
51 }
52
52
53 header.path = $$[QT_INSTALL_HEADERS]/SocExplorer
53 header.path = $$[QT_INSTALL_HEADERS]/SocExplorer
54 header.files = engine/socexplorerengine.h \
54 header.files = engine/socexplorerengine.h \
55 pluginloader/pluginscache.h \
55 pluginloader/pluginscache.h \
56 plugins/socexplorerplugin.h \
56 plugins/socexplorerplugin.h \
57 proxy/socexplorerproxy.h \
57 proxy/socexplorerproxy.h \
58 engine/socexplorerxmlfile.h \
58 engine/socexplorerxmlfile.h \
59 SOC/socexplorerenumdevice.h \
59 SOC/socexplorerenumdevice.h \
60 XmlEngine/XMLmodel.h \
60 XmlEngine/XMLmodel.h \
61 XmlEngine/XMLdata.h \
61 XmlEngine/XMLdata.h \
62 XmlEngine/xmldriver.h \
62 XmlEngine/xmldriver.h \
63 SOC/socmodel.h \
63 SOC/socmodel.h \
64 SOC/registerdata.h \
64 SOC/registerdata.h \
65 SOC/socclk.h \
65 SOC/socclk.h \
66 PeripheralWidget/src/peripheralwidget.h \
66 PeripheralWidget/src/peripheralwidget.h \
67 PeripheralWidget/src/registerwidget.h \
67 PeripheralWidget/src/registerwidget.h \
68 PeripheralWidget/src/socregsviewer.h \
68 PeripheralWidget/src/socregsviewer.h \
69 PeripheralWidget/src/socregsviewernew.h \
69 PeripheralWidget/src/socregsviewernew.h \
70 memtester/memtester.h \
70 memtester/memtester.h \
71 engine/socexplorersettings.h \
71 engine/socexplorersettings.h \
72 engine/socexplorersettingsdialog.h \
72 engine/socexplorersettingsdialog.h \
73 engine/socexplorergui.h\
73 engine/socexplorergui.h\
74 engine/socexplorerconfigkeys.h
74 engine/socexplorerconfigkeys.h
75
75
76
76
77
77
78 isEmpty(header.path) {
78 isEmpty(header.path) {
79 error(can\'t get QT_INSTALL_HEADERS)
79 error(can\'t get QT_INSTALL_HEADERS)
80 }
80 }
81
81
82 pluginif.files = pluginsInterface/*.h \
82 pluginif.files = pluginsInterface/*.h \
83 pluginsInterface/*.cpp
83 pluginsInterface/*.cpp
84
84
85 pluginif.path = $$[QT_INSTALL_HEADERS]/SocExplorer/pluginsInterface
85 pluginif.path = $$[QT_INSTALL_HEADERS]/SocExplorer/pluginsInterface
86
86
87
87
88 INSTALLS += target header pluginif
88 INSTALLS += target header pluginif
89
89
90 INCLUDEPATH += engine \
90 INCLUDEPATH += engine \
91 pluginloader \
91 pluginloader \
92 pluginsInterface \
92 pluginsInterface \
93 proxy \
93 proxy \
94 plugins \
94 plugins \
95 pluginManagerWdgt \
95 pluginManagerWdgt \
96 ../common \
96 ../common \
97 ../common/genericBinaryFiles \
97 ../common/genericBinaryFiles \
98 ../ \
98 ../ \
99 RegisterMVS \
99 RegisterMVS \
100 XmlEngine \
100 XmlEngine \
101 SOC \
101 SOC \
102 PeripheralWidget/src \
102 PeripheralWidget/src \
103 memtester
103 memtester
104
104
105
105
106 HEADERS += \
106 HEADERS += \
107 pluginloader/pluginscache.h \
107 pluginloader/pluginscache.h \
108 pluginloader/pluginloader.h \
108 pluginloader/pluginloader.h \
109 pluginManagerWdgt/plugintree.h \
109 pluginManagerWdgt/plugintree.h \
110 pluginManagerWdgt/pluginmanagerWDGT.h \
110 pluginManagerWdgt/pluginmanagerWDGT.h \
111 pluginManagerWdgt/pluginlist.h \
111 pluginManagerWdgt/pluginlist.h \
112 pluginManagerWdgt/plugininfoswdgt.h \
112 pluginManagerWdgt/plugininfoswdgt.h \
113 XmlEngine/XMLmodel.h \
113 XmlEngine/XMLmodel.h \
114 XmlEngine/XMLdata.h \
114 XmlEngine/XMLdata.h \
115 SOC/socmodel.h \
115 SOC/socmodel.h \
116 SOC/registerdata.h \
116 SOC/registerdata.h \
117 XmlEngine/xmldriver.h \
117 XmlEngine/xmldriver.h \
118 PeripheralWidget/src/peripheralwidget.h \
118 PeripheralWidget/src/peripheralwidget.h \
119 PeripheralWidget/src/registerwidget.h \
119 PeripheralWidget/src/registerwidget.h \
120 PeripheralWidget/src/socregsviewer.h \
120 PeripheralWidget/src/socregsviewer.h \
121 SOC/socclk.h \
121 SOC/socclk.h \
122 engine/socexplorerengine.h \
122 engine/socexplorerengine.h \
123 engine/socexplorerxmlfile.h \
123 engine/socexplorerxmlfile.h \
124 plugins/socexplorerplugin.h \
124 plugins/socexplorerplugin.h \
125 pluginsInterface/socexplorerplugininterface.h \
125 pluginsInterface/socexplorerplugininterface.h \
126 pluginsInterface/socexplorerplugininterface_global.h \
126 pluginsInterface/socexplorerplugininterface_global.h \
127 proxy/socexplorerproxy.h \
127 proxy/socexplorerproxy.h \
128 SOC/socexplorerenumdevice.h \
128 SOC/socexplorerenumdevice.h \
129 PySocExplorerEngine.h \
129 PySocExplorerEngine.h \
130 memtester/memtester.h\
130 memtester/memtester.h\
131 PeripheralWidget/src/socregsviewernew.h \
131 PeripheralWidget/src/socregsviewernew.h \
132 PeripheralWidget/src/collapsableperipheralwidget.h \
132 PeripheralWidget/src/collapsableperipheralwidget.h \
133 engine/socexplorersettings.h \
133 engine/socexplorersettings.h \
134 engine/socexplorersettingsdialog.h \
134 engine/socexplorersettingsdialog.h \
135 engine/socexplorergui.h \
135 engine/socexplorergui.h \
136 engine/socexplorerconfigkeys.h
136 engine/socexplorerconfigkeys.h \
137 pluginsInterface/isocexplorerplugin.h \
138 pluginloaderV2/pluginmanager.h
137
139
138
140
139
141
140
142
141
143
142
144
143 SOURCES += \
145 SOURCES += \
144 pluginloader/pluginscache.cpp \
146 pluginloader/pluginscache.cpp \
145 pluginloader/pluginloader.cpp \
147 pluginloader/pluginloader.cpp \
146 pluginManagerWdgt/plugintree.cpp \
148 pluginManagerWdgt/plugintree.cpp \
147 pluginManagerWdgt/pluginmanagerWDGT.cpp \
149 pluginManagerWdgt/pluginmanagerWDGT.cpp \
148 pluginManagerWdgt/pluginlist.cpp \
150 pluginManagerWdgt/pluginlist.cpp \
149 pluginManagerWdgt/plugininfoswdgt.cpp \
151 pluginManagerWdgt/plugininfoswdgt.cpp \
150 XmlEngine/XMLmodel.cpp \
152 XmlEngine/XMLmodel.cpp \
151 XmlEngine/XMLdata.cpp \
153 XmlEngine/XMLdata.cpp \
152 SOC/socmodel.cpp \
154 SOC/socmodel.cpp \
153 SOC/registerdata.cpp \
155 SOC/registerdata.cpp \
154 XmlEngine/xmldriver.cpp \
156 XmlEngine/xmldriver.cpp \
155 PeripheralWidget/src/peripheralwidget.cpp \
157 PeripheralWidget/src/peripheralwidget.cpp \
156 PeripheralWidget/src/registerwidget.cpp \
158 PeripheralWidget/src/registerwidget.cpp \
157 PeripheralWidget/src/socregsviewer.cpp \
159 PeripheralWidget/src/socregsviewer.cpp \
158 SOC/socclk.cpp \
160 SOC/socclk.cpp \
159 engine/socexplorerengine.cpp \
161 engine/socexplorerengine.cpp \
160 engine/socexplorerxmlfile.cpp \
162 engine/socexplorerxmlfile.cpp \
161 proxy/socexplorerproxy.cpp \
163 proxy/socexplorerproxy.cpp \
162 SOC/socexplorerenumdevice.cpp \
164 SOC/socexplorerenumdevice.cpp \
163 plugins/socexplorerplugin.cpp \
165 plugins/socexplorerplugin.cpp \
164 memtester/memtester.cpp \
166 memtester/memtester.cpp \
165 PeripheralWidget/src/socregsviewernew.cpp \
167 PeripheralWidget/src/socregsviewernew.cpp \
166 PeripheralWidget/src/collapsableperipheralwidget.cpp \
168 PeripheralWidget/src/collapsableperipheralwidget.cpp \
167 engine/socexplorersettings.cpp \
169 engine/socexplorersettings.cpp \
168 engine/socexplorersettingsdialog.cpp \
170 engine/socexplorersettingsdialog.cpp \
169 engine/socexplorergui.cpp
171 engine/socexplorergui.cpp \
172 pluginloaderV2/pluginmanager.cpp
170
173
171
174
172 OTHER_FILES += \
175 OTHER_FILES += \
173 plugins/socexplorerplugin.cpp \
176 plugins/socexplorerplugin.cpp \
174 pluginsInterface/socexplorerplugininterface.cpp \
177 pluginsInterface/socexplorerplugininterface.cpp \
175 plugins/socexplorerplugin.prf \
178 plugins/socexplorerplugin.prf \
176 pythongenerator.sh \
179 pythongenerator.sh \
177 pythonQtgeneratorCfg.txt
180 pythonQtgeneratorCfg.txt
178
181
179 FORMS += \
182 FORMS += \
180 PeripheralWidget/src/socregsviewernew.ui \
183 PeripheralWidget/src/socregsviewernew.ui \
181 PeripheralWidget/src/collapsableperipheralwidget.ui \
184 PeripheralWidget/src/collapsableperipheralwidget.ui \
182 engine/socexplorersettingsdialog.ui
185 engine/socexplorersettingsdialog.ui
183
186
184
187
185 RESOURCES += \
188 RESOURCES += \
186 PeripheralWidget/ressources/peripheralwidget.qrc
189 PeripheralWidget/ressources/peripheralwidget.qrc
@@ -1,531 +1,468
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 #include <socexplorerengine.h>
16 #include <socexplorerengine.h>
17 #include <socexplorersettings.h>
17 #include <socexplorersettings.h>
18
18
19 pluginloader* pluginloader::_self = NULL;
19 pluginloader* pluginloader::_self = NULL;
20 PluginsCache* pluginloader::_cache = NULL;
20 PluginsCache* pluginloader::_cache = NULL;
21 QStringList* pluginloader::_folderList = NULL;
21 QStringList* pluginloader::_folderList = NULL;
22
22
23
23
24 pluginloader::pluginloader()
24 pluginloader::pluginloader()
25 {
25 {
26 _cache = new PluginsCache();
26 _cache = new PluginsCache();
27 _folderList = new QStringList();
27 _folderList = new QStringList();
28 _folderList->append(SocExplorerEngine::pluginFolders());
28 _folderList->append(SocExplorerEngine::pluginFolders());
29 scanFolders();
29 scanFolders();
30 }
30 }
31
31
32 void pluginloader::scanFolders()
32 void pluginloader::scanFolders()
33 {
33 {
34 QDir dir;
34 QDir dir;
35 QStringList filters;
35 QStringList filters;
36 filters <<"*.so"<< "*.dll";
36 filters <<"*.so"<< "*.dll";
37 _cache->flush();
37 _cache->flush();
38 for(int d=0;d<_folderList->count();d++)
38 for(int d=0;d<_folderList->count();d++)
39 {
39 {
40 dir.setPath(_folderList->at(d));
40 dir.setPath(_folderList->at(d));
41 dir.setFilter(QDir::Files);
41 dir.setFilter(QDir::Files);
42 dir.setNameFilters(filters);
42 dir.setNameFilters(filters);
43 QFileInfoList list = dir.entryInfoList();
43 QFileInfoList list = dir.entryInfoList();
44 for (int i = 0; i < list.size(); ++i)
44 for (int i = 0; i < list.size(); ++i)
45 {
45 {
46 QFileInfo fileInfo = list.at(i);
46 QFileInfo fileInfo = list.at(i);
47 SocExplorerEngine::message("pluginloader::scanFolders","Checking "+ fileInfo.filePath(),3);
47 SocExplorerEngine::message("pluginloader::scanFolders","Checking "+ fileInfo.filePath(),3);
48 if(checklibrary(fileInfo.filePath())!=0)
48 if(checklibrary(fileInfo.filePath())!=0)
49 {
49 {
50 _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()));
51 }
51 }
52 }
52 }
53 }
53 }
54 }
54 }
55
55
56 int pluginloader::p_checklibraryQlib(const QString fileName)
56 int pluginloader::p_checklibraryQlib(const QString fileName)
57 {
57 {
58 QLibrary* lib = new QLibrary;
58 QLibrary* lib = new QLibrary;
59 lib->setFileName(fileName);
59 lib->setFileName(fileName);
60 lib->setLoadHints(QLibrary::PreventUnloadHint);
60 lib->setLoadHints(QLibrary::PreventUnloadHint);
61 lib->load();
61 lib->load();
62 if(!lib->isLoaded())
62 if(!lib->isLoaded())
63 {
63 {
64 SocExplorerEngine::message("pluginloader::p_checklibraryQlib",lib->errorString(),3);
64 SocExplorerEngine::message("pluginloader::p_checklibraryQlib",lib->errorString(),3);
65 lib->~QLibrary();
65 lib->~QLibrary();
66 lib = new QLibrary(fileName);
66 lib = new QLibrary(fileName);
67 lib->load();
67 lib->load();
68 }
68 }
69 delete lib;
69 delete lib;
70 if(QLibrary::resolve(fileName,"socexplorerpluginCreateObject"))
70 if(QLibrary::resolve(fileName,"socexplorerpluginCreateObject"))
71 {
71 {
72 if(QLibrary::resolve(fileName,"socexplorerpluginpid"))
72 if(QLibrary::resolve(fileName,"socexplorerpluginpid"))
73 {
73 {
74 if(QLibrary::resolve(fileName,"socexplorerpluginvid"))
74 if(QLibrary::resolve(fileName,"socexplorerpluginvid"))
75 {
75 {
76 if(QLibrary::resolve(fileName,"socexplorerpluginVersion"))
76 if(QLibrary::resolve(fileName,"socexplorerpluginVersion"))
77 {
77 {
78 if(QLibrary::resolve(fileName,"socexplorerpluginAuthor"))
78 if(QLibrary::resolve(fileName,"socexplorerpluginAuthor"))
79 {
79 {
80 if(QLibrary::resolve(fileName,"socexplorerpluginDescription"))
80 if(QLibrary::resolve(fileName,"socexplorerpluginDescription"))
81 {
81 {
82 return 1;
82 return 1;
83 }
83 }
84 }
84 }
85 }
85 }
86 }
86 }
87 }
87 }
88 }
88 }
89 return 0;
89 return 0;
90 }
90 }
91
91
92 int pluginloader::p_checklibraryCustom(const QString fileName)
92 int pluginloader::p_checklibraryCustom(const QString fileName)
93 {
93 {
94 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
94 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
95 unixPluginLoader lib(fileName);
95 unixPluginLoader lib(fileName);
96 if(NULL!=lib.resolve("socexplorerpluginCreateObject"))
96 if(NULL!=lib.resolve("socexplorerpluginCreateObject"))
97 {
97 {
98 if(NULL!=lib.resolve("socexplorerpluginpid"))
98 if(NULL!=lib.resolve("socexplorerpluginpid"))
99 {
99 {
100 if(NULL!=lib.resolve("socexplorerpluginvid"))
100 if(NULL!=lib.resolve("socexplorerpluginvid"))
101 {
101 {
102 if(NULL!=lib.resolve("socexplorerpluginVersion"))
102 if(NULL!=lib.resolve("socexplorerpluginVersion"))
103 {
103 {
104 if(NULL!=lib.resolve("socexplorerpluginAuthor"))
104 if(NULL!=lib.resolve("socexplorerpluginAuthor"))
105 {
105 {
106 if(NULL!=lib.resolve("socexplorerpluginDescription"))
106 if(NULL!=lib.resolve("socexplorerpluginDescription"))
107 {
107 {
108 return 1;
108 return 1;
109 }
109 }
110 }
110 }
111 }
111 }
112 }
112 }
113 }
113 }
114 }
114 }
115 #endif
115 #endif
116 return 0;
116 return 0;
117 }
117 }
118
118
119 socexplorerplugin *pluginloader::p_newsocexplorerpluginQlib(const QString Name)
119 socexplorerplugin *pluginloader::p_newsocexplorerpluginQlib(const QString Name)
120 {
120 {
121 QString* libfile= _cacheLookup(Name);
121 QString* libfile= _cacheLookup(Name);
122 if(libfile==NULL)return NULL;
122 if(libfile==NULL)return NULL;
123 QLibrary* lib = new QLibrary(*libfile);
123 QLibrary* lib = new QLibrary(*libfile);
124 delete libfile;
124 delete libfile;
125 socexplorerpluginCreateObjectT newDrvr = NULL;
125 socexplorerpluginCreateObjectT newDrvr = NULL;
126 newDrvr=(socexplorerpluginCreateObjectT)lib->resolve("socexplorerpluginCreateObject");
126 newDrvr=(socexplorerpluginCreateObjectT)lib->resolve("socexplorerpluginCreateObject");
127 if(newDrvr==NULL)
127 if(newDrvr==NULL)
128 {
128 {
129 return NULL;
129 return NULL;
130 }
130 }
131 return (socexplorerplugin*) newDrvr();
131 return (socexplorerplugin*) newDrvr();
132 }
132 }
133
133
134 socexplorerplugin *pluginloader::p_newsocexplorerpluginCustom(const QString Name)
134 socexplorerplugin *pluginloader::p_newsocexplorerpluginCustom(const QString Name)
135 {
135 {
136 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
136 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
137 QString* libfile= _cacheLookup(Name);
137 QString* libfile= _cacheLookup(Name);
138 if(libfile==NULL)return NULL;
138 if(libfile==NULL)return NULL;
139 unixPluginLoader lib(*libfile);
139 unixPluginLoader lib(*libfile);
140 delete libfile;
140 delete libfile;
141 socexplorerpluginCreateObjectT newDrvr = NULL;
141 socexplorerpluginCreateObjectT newDrvr = NULL;
142 newDrvr=(socexplorerpluginCreateObjectT)lib.resolve("socexplorerpluginCreateObject");
142 newDrvr=(socexplorerpluginCreateObjectT)lib.resolve("socexplorerpluginCreateObject");
143 if(newDrvr==NULL)
143 if(newDrvr==NULL)
144 {
144 {
145 return NULL;
145 return NULL;
146 }
146 }
147 return (socexplorerplugin*) newDrvr();
147 return (socexplorerplugin*) newDrvr();
148 #endif
148 #endif
149 }
149 }
150
150
151 QList<PluginsCacheItem*> pluginloader::listAvailiables(bool rescan)
151 QList<PluginsCacheItem*> pluginloader::listAvailiables(bool rescan)
152 {
152 {
153 if(_self==NULL)
153 if(_self==NULL)
154 {
154 {
155 init();
155 init();
156 return _cache->listDrivers();
156 return _cache->listDrivers();
157 }
157 }
158 if(rescan)
158 if(rescan)
159 {
159 {
160 scanFolders();
160 scanFolders();
161 }
161 }
162
162
163 return _cache->listDrivers();
163 return _cache->listDrivers();
164 }
164 }
165
165
166
166
167 void pluginloader::init()
167 void pluginloader::init()
168 {
168 {
169 if(_self==NULL)
169 if(_self==NULL)
170 {
170 {
171 _self=new pluginloader();
171 _self=new pluginloader();
172 }
172 }
173 }
173 }
174
174
175
175
176 pluginloader* pluginloader::self()
176 pluginloader* pluginloader::self()
177 {
177 {
178 if(_self==NULL)
178 if(_self==NULL)
179 {
179 {
180 init();
180 init();
181 }
181 }
182 return _self;
182 return _self;
183 }
183 }
184
184
185 bool pluginloader::isvalid(QString Name)
185 bool pluginloader::isvalid(QString Name)
186 {
186 {
187 if(_self==NULL)init();
187 if(_self==NULL)init();
188 QString* libfile= _cacheLookup(Name);
188 QString* libfile= _cacheLookup(Name);
189 if(libfile==NULL)return false;
189 if(libfile==NULL)return false;
190 else
190 else
191 {
191 {
192 delete libfile;
192 delete libfile;
193 return true;
193 return true;
194 }
194 }
195
195
196 }
196 }
197
197
198 int pluginloader::checklibrary(const QString fileName)
198 int pluginloader::checklibrary(const QString fileName)
199 {
199 {
200 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
200 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
201 return _self->p_checklibraryCustom(fileName);
201 return _self->p_checklibraryCustom(fileName);
202 #else
202 #else
203 return _self->p_checklibraryQlib(fileName);
203 return _self->p_checklibraryQlib(fileName);
204 #endif
204 #endif
205 }
205 }
206
206
207
207
208
208
209
209
210
210
211 socexplorerplugin* pluginloader::newsocexplorerplugin(const QString Name)
211 socexplorerplugin* pluginloader::newsocexplorerplugin(const QString Name)
212 {
212 {
213 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
213 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
214 return _self->p_newsocexplorerpluginCustom(Name);
214 return _self->p_newsocexplorerpluginCustom(Name);
215 #else
215 #else
216 return _self->p_newsocexplorerpluginQlib(Name);
216 return _self->p_newsocexplorerpluginQlib(Name);
217 #endif
217 #endif
218 }
218 }
219
219
220
221 QString pluginloader::getlibTypeStr(QString Name)
222 {
223 if(_self==NULL)init();
224 QString* libfile= _cacheLookup(Name);
225 if(libfile==NULL)return NULL;
226 QLibrary* lib = new QLibrary(*libfile);
227 delete libfile;
228 lib->load();
229 if(lib->isLoaded())
230 {
231 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
232 if(plugintype!=NULL)
233 {
234 pluginT type = plugintype();
235 switch(type)
236 {
237 case ComDriverT:
238 ////lib->unload();
239 lib->~QLibrary();
240 return QObject::tr("Comunaication Driver Plugin.");
241 break;
242 case PerifDriverT:
243 ////lib->unload();
244 lib->~QLibrary();
245 return QObject::tr("Periferial Driver Plugin.");
246 break;
247 default:
248 ////lib->unload();
249 lib->~QLibrary();
250 return QObject::tr("Unknow Plugin.");
251 break;
252 }
253 }
254 }
255 lib->~QLibrary();
256 return QObject::tr("Can't load Plugin.");
257 }
258
259
260
261
262 pluginT pluginloader::getlibType(QString Name)
263 {
264 if(_self==NULL)init();
265 QString* libfile= _cacheLookup(Name);
266 if(libfile==NULL)return (pluginT)NULL;
267 QLibrary* lib = new QLibrary(*libfile);
268 delete libfile;
269 lib->load();
270 if(lib->isLoaded())
271 {
272 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
273 if(plugintype!=NULL)
274 {
275 return plugintype();
276 }
277 }
278 lib->~QLibrary();
279 return -1;
280 }
281
282
283 QString pluginloader::getlibVersion(const QString Name)
220 QString pluginloader::getlibVersion(const QString Name)
284 {
221 {
285 if(_self==NULL)init();
222 if(_self==NULL)init();
286 QString* libfile= _cacheLookup(Name);
223 QString* libfile= _cacheLookup(Name);
287 if(libfile==NULL)return NULL;
224 if(libfile==NULL)return NULL;
288 QLibrary* lib = new QLibrary(*libfile);
225 QLibrary* lib = new QLibrary(*libfile);
289 delete libfile;
226 delete libfile;
290 lib->load();
227 lib->load();
291 if(lib->isLoaded())
228 if(lib->isLoaded())
292 {
229 {
293 socexplorerpluginVersionT pluginversion = (socexplorerpluginVersionT)lib->resolve("socexplorerpluginVersion");
230 socexplorerpluginVersionT pluginversion = (socexplorerpluginVersionT)lib->resolve("socexplorerpluginVersion");
294 if(pluginversion!=NULL)
231 if(pluginversion!=NULL)
295 {
232 {
296 QString version = pluginversion();
233 QString version = pluginversion();
297 ////lib->unload();
234 ////lib->unload();
298 lib->~QLibrary();
235 lib->~QLibrary();
299 return version;
236 return version;
300 }
237 }
301 }
238 }
302 lib->~QLibrary();
239 lib->~QLibrary();
303 return QObject::tr("Can't load Plugin.");
240 return QObject::tr("Can't load Plugin.");
304 }
241 }
305
242
306
243
307
244
308 QString pluginloader::getlibPIDstr(const QString Name)
245 QString pluginloader::getlibPIDstr(const QString Name)
309 {
246 {
310 return QString("0x" + QString::number(pluginloader::getlibPID(Name) , 16));
247 return QString("0x" + QString::number(pluginloader::getlibPID(Name) , 16));
311 }
248 }
312
249
313 QString pluginloader::getlibVIDstr(const QString Name)
250 QString pluginloader::getlibVIDstr(const QString Name)
314 {
251 {
315 return QString("0x" + QString::number(pluginloader::getlibVID(Name) , 16));
252 return QString("0x" + QString::number(pluginloader::getlibVID(Name) , 16));
316 }
253 }
317
254
318
255
319
256
320 int pluginloader::libcanbechild(const QString Name)
257 int pluginloader::libcanbechild(const QString Name)
321 {
258 {
322 if(_self==NULL)init();
259 if(_self==NULL)init();
323 QString* libfile= _cacheLookup(Name);
260 QString* libfile= _cacheLookup(Name);
324 if(libfile==NULL)return (int)NULL;
261 if(libfile==NULL)return (int)NULL;
325 QLibrary* lib = new QLibrary(*libfile);
262 QLibrary* lib = new QLibrary(*libfile);
326 delete libfile;
263 delete libfile;
327 lib->load();
264 lib->load();
328 if(lib->isLoaded())
265 if(lib->isLoaded())
329 {
266 {
330 socexplorerplugincanbechildT canbechild = (socexplorerplugincanbechildT)lib->resolve("socexplorerplugincanbechild");
267 socexplorerplugincanbechildT canbechild = (socexplorerplugincanbechildT)lib->resolve("socexplorerplugincanbechild");
331 if(canbechild!=NULL)
268 if(canbechild!=NULL)
332 {
269 {
333 int value = canbechild();
270 int value = canbechild();
334 ////lib->unload();
271 ////lib->unload();
335 //lib->~QLibrary();
272 //lib->~QLibrary();
336 return value;
273 return value;
337 }
274 }
338 }
275 }
339 //lib->~QLibrary();
276 //lib->~QLibrary();
340 return 0;
277 return 0;
341 }
278 }
342
279
343
280
344
281
345
282
346 int pluginloader::libcanberoot(const QString Name)
283 int pluginloader::libcanberoot(const QString Name)
347 {
284 {
348 if(_self==NULL)init();
285 if(_self==NULL)init();
349 QString* libfile= _cacheLookup(Name);
286 QString* libfile= _cacheLookup(Name);
350 if(libfile==NULL)return (int)NULL;
287 if(libfile==NULL)return (int)NULL;
351 QLibrary* lib = new QLibrary(*libfile);
288 QLibrary* lib = new QLibrary(*libfile);
352 delete libfile;
289 delete libfile;
353 lib->load();
290 lib->load();
354 if(lib->isLoaded())
291 if(lib->isLoaded())
355 {
292 {
356 socexplorerplugincanberootT canberoot = (socexplorerplugincanberootT)lib->resolve("socexplorerplugincanberoot");
293 socexplorerplugincanberootT canberoot = (socexplorerplugincanberootT)lib->resolve("socexplorerplugincanberoot");
357 if(canberoot!=NULL)
294 if(canberoot!=NULL)
358 {
295 {
359 int value = canberoot();
296 int value = canberoot();
360 ////lib->unload();
297 ////lib->unload();
361 //lib->~QLibrary();
298 //lib->~QLibrary();
362 return value;
299 return value;
363 }
300 }
364 }
301 }
365 delete lib;
302 delete lib;
366 //lib->~QLibrary();
303 //lib->~QLibrary();
367 return 0;
304 return 0;
368 }
305 }
369
306
370 int pluginloader::getlibVID(const QString Name)
307 int pluginloader::getlibVID(const QString Name)
371 {
308 {
372 if(_self==NULL)init();
309 if(_self==NULL)init();
373 QString* libfile= _cacheLookup(Name);
310 QString* libfile= _cacheLookup(Name);
374 if(libfile==NULL)return 0;
311 if(libfile==NULL)return 0;
375 QString file(*libfile);
312 QString file(*libfile);
376 delete libfile;
313 delete libfile;
377 return _getlibVID(file);
314 return _getlibVID(file);
378 }
315 }
379
316
380
317
381 int pluginloader::getlibPID(const QString Name)
318 int pluginloader::getlibPID(const QString Name)
382 {
319 {
383 if(_self==NULL)init();
320 if(_self==NULL)init();
384 QString* libfile= _cacheLookup(Name);
321 QString* libfile= _cacheLookup(Name);
385 if(libfile==NULL)return 0;
322 if(libfile==NULL)return 0;
386 QString file(*libfile);
323 QString file(*libfile);
387 delete libfile;
324 delete libfile;
388 return _getlibPID(file);
325 return _getlibPID(file);
389 }
326 }
390
327
391 QString pluginloader::getlibAuthor(const QString Name)
328 QString pluginloader::getlibAuthor(const QString Name)
392 {
329 {
393 if(_self==NULL)init();
330 if(_self==NULL)init();
394 QString* libfile= _cacheLookup(Name);
331 QString* libfile= _cacheLookup(Name);
395 if(libfile==NULL)return NULL;
332 if(libfile==NULL)return NULL;
396 QLibrary* lib = new QLibrary(*libfile);
333 QLibrary* lib = new QLibrary(*libfile);
397 delete libfile;
334 delete libfile;
398 lib->load();
335 lib->load();
399 if(lib->isLoaded())
336 if(lib->isLoaded())
400 {
337 {
401 socexplorerpluginAuthorT pluginauthor = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginAuthor");
338 socexplorerpluginAuthorT pluginauthor = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginAuthor");
402 if(pluginauthor!=NULL)
339 if(pluginauthor!=NULL)
403 {
340 {
404 QString author = pluginauthor();
341 QString author = pluginauthor();
405 ////lib->unload();
342 ////lib->unload();
406 lib->~QLibrary();
343 lib->~QLibrary();
407 return author;
344 return author;
408 }
345 }
409 }
346 }
410 lib->~QLibrary();
347 lib->~QLibrary();
411 return QObject::tr("Can't load Plugin.");
348 return QObject::tr("Can't load Plugin.");
412 }
349 }
413
350
414 QString pluginloader::getlibName(const QString Name)
351 QString pluginloader::getlibName(const QString Name)
415 {
352 {
416 if(_self==NULL)init();
353 if(_self==NULL)init();
417 QString* libfile= _cacheLookup(Name);
354 QString* libfile= _cacheLookup(Name);
418 if(libfile==NULL)return QString("");
355 if(libfile==NULL)return QString("");
419 QString file(*libfile);
356 QString file(*libfile);
420 delete libfile;
357 delete libfile;
421 return _getlibName(file);
358 return _getlibName(file);
422 }
359 }
423
360
424 QString pluginloader::getlibDescription(const QString Name)
361 QString pluginloader::getlibDescription(const QString Name)
425 {
362 {
426 if(_self==NULL)init();
363 if(_self==NULL)init();
427 QString* libfile= _cacheLookup(Name);
364 QString* libfile= _cacheLookup(Name);
428 if(libfile==NULL)return NULL;
365 if(libfile==NULL)return NULL;
429 QLibrary* lib = new QLibrary(*libfile);
366 QLibrary* lib = new QLibrary(*libfile);
430 delete libfile;
367 delete libfile;
431 lib->load();
368 lib->load();
432 if(lib->isLoaded())
369 if(lib->isLoaded())
433 {
370 {
434 socexplorerpluginDescriptionT plugindescription = (socexplorerpluginDescriptionT)lib->resolve("socexplorerpluginDescription");
371 socexplorerpluginDescriptionT plugindescription = (socexplorerpluginDescriptionT)lib->resolve("socexplorerpluginDescription");
435 if(plugindescription!=NULL)
372 if(plugindescription!=NULL)
436 {
373 {
437 QString description = plugindescription();
374 QString description = plugindescription();
438 ////lib->unload();
375 ////lib->unload();
439 lib->~QLibrary();
376 lib->~QLibrary();
440 return description;
377 return description;
441 }
378 }
442 }
379 }
443 lib->~QLibrary();
380 lib->~QLibrary();
444 return QObject::tr("Can't load Plugin.");
381 return QObject::tr("Can't load Plugin.");
445 }
382 }
446
383
447 QString pluginloader::getlibDir(const QString Name)
384 QString pluginloader::getlibDir(const QString Name)
448 {
385 {
449 if(_self==NULL)init();
386 if(_self==NULL)init();
450 return *_cacheLookup(Name);
387 return *_cacheLookup(Name);
451 }
388 }
452
389
453 QString pluginloader::_getlibName(const QString fileName)
390 QString pluginloader::_getlibName(const QString fileName)
454 {
391 {
455 QLibrary* lib = new QLibrary(fileName);
392 QLibrary* lib = new QLibrary(fileName);
456 lib->load();
393 lib->load();
457 if(lib->isLoaded())
394 if(lib->isLoaded())
458 {
395 {
459 socexplorerpluginNameT pluginName = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginName");
396 socexplorerpluginNameT pluginName = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginName");
460 if(pluginName!=NULL)
397 if(pluginName!=NULL)
461 {
398 {
462 QString name = pluginName();
399 QString name = pluginName();
463 //lib->unload();
400 //lib->unload();
464 lib->~QLibrary();
401 lib->~QLibrary();
465 return name;
402 return name;
466 }
403 }
467 }
404 }
468 lib->~QLibrary();
405 lib->~QLibrary();
469 return QObject::tr("Can't load Plugin.");
406 return QObject::tr("Can't load Plugin.");
470 }
407 }
471
408
472 int pluginloader::_getlibPID(const QString fileName)
409 int pluginloader::_getlibPID(const QString fileName)
473 {
410 {
474 QLibrary* lib = new QLibrary(fileName);
411 QLibrary* lib = new QLibrary(fileName);
475 lib->load();
412 lib->load();
476 if(lib->isLoaded())
413 if(lib->isLoaded())
477 {
414 {
478 socexplorerpluginpidT pluginpid = (socexplorerpluginpidT)lib->resolve("socexplorerpluginpid");
415 socexplorerpluginpidT pluginpid = (socexplorerpluginpidT)lib->resolve("socexplorerpluginpid");
479 if(pluginpid!=NULL)
416 if(pluginpid!=NULL)
480 {
417 {
481 int pid = pluginpid();
418 int pid = pluginpid();
482 //lib->unload();
419 //lib->unload();
483 lib->~QLibrary();
420 lib->~QLibrary();
484 return pid;
421 return pid;
485 }
422 }
486 }
423 }
487 lib->~QLibrary();
424 lib->~QLibrary();
488 return 0;
425 return 0;
489 }
426 }
490
427
491 int pluginloader::_getlibVID(const QString fileName)
428 int pluginloader::_getlibVID(const QString fileName)
492 {
429 {
493 QLibrary* lib = new QLibrary(fileName);
430 QLibrary* lib = new QLibrary(fileName);
494 lib->load();
431 lib->load();
495 if(lib->isLoaded())
432 if(lib->isLoaded())
496 {
433 {
497 socexplorerpluginvidT pluginvid = (socexplorerpluginvidT)lib->resolve("socexplorerpluginvid");
434 socexplorerpluginvidT pluginvid = (socexplorerpluginvidT)lib->resolve("socexplorerpluginvid");
498 if(pluginvid!=NULL)
435 if(pluginvid!=NULL)
499 {
436 {
500 int vid = pluginvid();
437 int vid = pluginvid();
501 //lib->unload();
438 //lib->unload();
502 lib->~QLibrary();
439 lib->~QLibrary();
503 return vid;
440 return vid;
504 }
441 }
505 }
442 }
506 lib->~QLibrary();
443 lib->~QLibrary();
507 return 0;
444 return 0;
508 }
445 }
509
446
510 QString* pluginloader::_cacheLookup(const QString Name)
447 QString* pluginloader::_cacheLookup(const QString Name)
511 {
448 {
512 QString* libfile= new QString(_cache->first(Name));
449 QString* libfile= new QString(_cache->first(Name));
513 if(!QFile::exists(*libfile))
450 if(!QFile::exists(*libfile))
514 {
451 {
515 scanFolders();
452 scanFolders();
516 *libfile = _cache->first(Name);
453 *libfile = _cache->first(Name);
517 if(QFile::exists(*libfile))return libfile;
454 if(QFile::exists(*libfile))return libfile;
518 }
455 }
519 else
456 else
520 {
457 {
521 return libfile;
458 return libfile;
522 }
459 }
523 delete libfile;
460 delete libfile;
524 return NULL;
461 return NULL;
525 }
462 }
526
463
527 /*QString findlib(QString name)
464 /*QString findlib(QString name)
528 {
465 {
529
466
530 }*/
467 }*/
531
468
@@ -1,89 +1,87
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) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, 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
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef PLUGINLOADER_H
22 #ifndef PLUGINLOADER_H
23 #define PLUGINLOADER_H
23 #define PLUGINLOADER_H
24
24
25 #include <QString>
25 #include <QString>
26 #include <QLibrary>
26 #include <QLibrary>
27 #include <QObject>
27 #include <QObject>
28 #include <QStringList>
28 #include <QStringList>
29 #include <socexplorerplugininterface.h>
29 #include <socexplorerplugininterface.h>
30 #include <socexplorerplugin.h>
30 #include <socexplorerplugin.h>
31 #include <pluginscache.h>
31 #include <pluginscache.h>
32 /*
32 /*
33 Debug
33 Debug
34 */
34 */
35 #include <stdio.h>
35 #include <stdio.h>
36
36
37 #define loadlib(filename) QLibrary* lib = new QLibrary((fileName));\
37 #define loadlib(filename) QLibrary* lib = new QLibrary((fileName));\
38 lib->load();\
38 lib->load();\
39 if(!lib->isLoaded())\
39 if(!lib->isLoaded())\
40 {\
40 {\
41 return 0;\
41 return 0;\
42 }
42 }
43
43
44
44
45 class pluginloader
45 class pluginloader
46 {
46 {
47
47
48 private:
48 private:
49 static pluginloader* _self;
49 static pluginloader* _self;
50 static PluginsCache* _cache;
50 static PluginsCache* _cache;
51 static QStringList* _folderList;
51 static QStringList* _folderList;
52 ~pluginloader();
52 ~pluginloader();
53 pluginloader();
53 pluginloader();
54 public:
54 public:
55
55
56 static void init();
56 static void init();
57 static pluginloader* self();
57 static pluginloader* self();
58
58
59 static int checklibrary(const QString fileName);
59 static int checklibrary(const QString fileName);
60 static bool isvalid(QString Name);
60 static bool isvalid(QString Name);
61 static socexplorerplugin* newsocexplorerplugin(const QString Name);
61 static socexplorerplugin* newsocexplorerplugin(const QString Name);
62 static QString getlibTypeStr(QString Name);
63 static pluginT getlibType(QString Name);
64 static QString getlibVersion(const QString Name);
62 static QString getlibVersion(const QString Name);
65 static QString getlibPIDstr(const QString Name);
63 static QString getlibPIDstr(const QString Name);
66 static QString getlibVIDstr(const QString Name);
64 static QString getlibVIDstr(const QString Name);
67 static int getlibPID(const QString Name);
65 static int getlibPID(const QString Name);
68 static int getlibVID(const QString Name);
66 static int getlibVID(const QString Name);
69 static int libcanbechild(const QString Name);
67 static int libcanbechild(const QString Name);
70 static int libcanberoot(const QString Name);
68 static int libcanberoot(const QString Name);
71 static QString getlibAuthor(const QString Name);
69 static QString getlibAuthor(const QString Name);
72 static QString getlibName(const QString Name);
70 static QString getlibName(const QString Name);
73 static QString getlibDescription(const QString Name);
71 static QString getlibDescription(const QString Name);
74 static QString getlibDir(const QString Name);
72 static QString getlibDir(const QString Name);
75 static QString findlib(QString name);
73 static QString findlib(QString name);
76 static QList<PluginsCacheItem *> listAvailiables(bool rescan=true);
74 static QList<PluginsCacheItem *> listAvailiables(bool rescan=true);
77 static void scanFolders();
75 static void scanFolders();
78 static void showCache(){_cache->show();}
76 static void showCache(){_cache->show();}
79 private:
77 private:
80 int p_checklibraryQlib(const QString fileName);
78 int p_checklibraryQlib(const QString fileName);
81 int p_checklibraryCustom(const QString fileName);
79 int p_checklibraryCustom(const QString fileName);
82 socexplorerplugin* p_newsocexplorerpluginQlib(const QString Name);
80 socexplorerplugin* p_newsocexplorerpluginQlib(const QString Name);
83 socexplorerplugin* p_newsocexplorerpluginCustom(const QString Name);
81 socexplorerplugin* p_newsocexplorerpluginCustom(const QString Name);
84 static QString* _cacheLookup(const QString Name);
82 static QString* _cacheLookup(const QString Name);
85 static QString _getlibName(const QString fileName);
83 static QString _getlibName(const QString fileName);
86 static int _getlibPID(const QString fileName);
84 static int _getlibPID(const QString fileName);
87 static int _getlibVID(const QString fileName);
85 static int _getlibVID(const QString fileName);
88 };
86 };
89 #endif
87 #endif
@@ -1,74 +1,73
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) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, 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
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef SOCEXPLORERPLUGININTERFACE_H
22 #ifndef SOCEXPLORERPLUGININTERFACE_H
23 #define SOCEXPLORERPLUGININTERFACE_H
23 #define SOCEXPLORERPLUGININTERFACE_H
24
24
25 #include "socexplorerplugininterface_global.h"
25 #include "socexplorerplugininterface_global.h"
26 #include <QString>
26 #include <QString>
27 #include <QtGlobal>
27 #include <QtGlobal>
28 #include <QtPlugin>
28
29
29 #define ComDriverT 1
30 #define PerifDriverT 2
31 typedef int pluginT;
30 typedef int pluginT;
32
31
33 typedef void* (*socexplorerpluginCreateObjectT)();
32 typedef void* (*socexplorerpluginCreateObjectT)();
34 typedef pluginT (*socexplorerpluginTypeT)();
33 typedef pluginT (*socexplorerpluginTypeT)();
35 typedef int (*socexplorerpluginpidT)();
34 typedef int (*socexplorerpluginpidT)();
36 typedef int (*socexplorerpluginvidT)();
35 typedef int (*socexplorerpluginvidT)();
37 typedef int (*socexplorerplugincanberootT)();
36 typedef int (*socexplorerplugincanberootT)();
38 typedef int (*socexplorerplugincanbechildT)();
37 typedef int (*socexplorerplugincanbechildT)();
39 typedef QString (*socexplorerpluginNameT)();
38 typedef QString (*socexplorerpluginNameT)();
40 typedef QString (*socexplorerpluginVersionT)();
39 typedef QString (*socexplorerpluginVersionT)();
41 typedef QString (*socexplorerpluginAuthorT)();
40 typedef QString (*socexplorerpluginAuthorT)();
42 typedef QString (*socexplorerpluginDescriptionT)();
41 typedef QString (*socexplorerpluginDescriptionT)();
43
42
44 extern "C"
43 extern "C"
45 {
44 {
46 #ifndef QT_ENSURE_STACK_ALIGNED_FOR_SSE
45 #ifndef QT_ENSURE_STACK_ALIGNED_FOR_SSE
47 #define QT_ENSURE_STACK_ALIGNED_FOR_SSE
46 #define QT_ENSURE_STACK_ALIGNED_FOR_SSE
48 #endif
47 #endif
49 //! \header This the C interface socexplorer uses to load dynamically any plugin, a C interface is the
48 //! \header This the C interface socexplorer uses to load dynamically any plugin, a C interface is the
50 //! easyest way to manually resolve functions in a dynamic library.
49 //! easyest way to manually resolve functions in a dynamic library.
51
50
52 //! \fn socexplorerpluginCreateObject Plugin constructor.
51 //! \fn socexplorerpluginCreateObject Plugin constructor.
53 LIBSOCEXPLORERPLUGIN_EXPORT void* socexplorerpluginCreateObject()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
52 LIBSOCEXPLORERPLUGIN_EXPORT void* socexplorerpluginCreateObject()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
54 //! \fn socexplorerpluginpid Plugin's PID.
53 //! \fn socexplorerpluginpid Plugin's PID.
55 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerpluginpid()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
54 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerpluginpid()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
56 //! \fn socexplorerpluginvid Plugin's VID.
55 //! \fn socexplorerpluginvid Plugin's VID.
57 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerpluginvid()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
56 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerpluginvid()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
58 //! \fn socexplorerplugincanberoot Tells if the plugin can be a root plugin.
57 //! \fn socexplorerplugincanberoot Tells if the plugin can be a root plugin.
59 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerplugincanberoot()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
58 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerplugincanberoot()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
60 //! \fn socexplorerplugincanberoot Tells if the plugin can be a child plugin.
59 //! \fn socexplorerplugincanberoot Tells if the plugin can be a child plugin.
61 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerplugincanbechild()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
60 LIBSOCEXPLORERPLUGIN_EXPORT int socexplorerplugincanbechild()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
62 //! \fn socexplorerpluginType Gives the plugin's type, not used yet.
61 //! \fn socexplorerpluginType Gives the plugin's type, not used yet.
63 LIBSOCEXPLORERPLUGIN_EXPORT pluginT socexplorerpluginType()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
62 LIBSOCEXPLORERPLUGIN_EXPORT pluginT socexplorerpluginType()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
64 //! \fn socexplorerpluginVersion Gives the plugin's version.
63 //! \fn socexplorerpluginVersion Gives the plugin's version.
65 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginVersion()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
64 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginVersion()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
66 //! \fn socexplorerpluginName Gives the plugin's name.
65 //! \fn socexplorerpluginName Gives the plugin's name.
67 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginName()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
66 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginName()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
68 //! \fn socexplorerpluginAuthor Gives the plugin's author.
67 //! \fn socexplorerpluginAuthor Gives the plugin's author.
69 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginAuthor()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
68 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginAuthor()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
70 //! \fn socexplorerpluginDescription Gives the plugin's description.
69 //! \fn socexplorerpluginDescription Gives the plugin's description.
71 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginDescription()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
70 LIBSOCEXPLORERPLUGIN_EXPORT QString socexplorerpluginDescription()QT_ENSURE_STACK_ALIGNED_FOR_SSE;
72 }
71 }
73
72
74 #endif // SOCEXPLORERPLUGININTERFACE_H
73 #endif // SOCEXPLORERPLUGININTERFACE_H
General Comments 0
You need to be logged in to leave comments. Login now