##// 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
@@ -133,7 +133,9 HEADERS += \
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
@@ -166,7 +168,8 SOURCES += \
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 += \
@@ -217,69 +217,6 socexplorerplugin* pluginloader::newsoce
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();
@@ -59,8 +59,6 public:
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);
@@ -25,9 +25,8
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)();
General Comments 0
You need to be logged in to leave comments. Login now