##// END OF EJS Templates
Removed _d for debug binaries, moved plugin to default location...
Jeandet Alexis -
r65:7f2fbf718320 default
parent child
Show More
@@ -0,0 +1,3
1 /usr/lib/SocExplorer/plugins
2 /usr/lib64/SocExplorer/plugins
3
@@ -1,86 +1,88
1 1 #-------------------------------------------------
2 2 #
3 3 # Project created by QtCreator 2011-09-19T22:52:10
4 4 #
5 5 #-------------------------------------------------
6 6
7 7 TEMPLATE = subdirs
8 8 CONFIG += ordered release
9 9
10 10 SUBDIRS = \
11 11 src/common \
12 12 src/SocExplorerEngine \
13 13 src \
14 14 src/SocExplorer_TCP_Terminal
15 15
16 16
17 17 socexplorercfg.path = $$[QT_INSTALL_PREFIX]/mkspecs/features
18 18 socexplorercfg.files = \
19 19 src/SocExplorerEngine/plugins/socexplorerplugin.prf
20 20
21 21
22 22 unix{
23 23 SocExplorer.path = /usr/share/applications/
24 24 SocExplorer.files = unixcfg/SocExplorer.desktop
25 PluginConfPath.path = /etc/SocExplorer/plugin.conf.d/
26 PluginConfPath.files = unixcfg/plugins.conf
25 27 icon.path = /usr/share/SocExplorer
26 28 icon.files = ressources/images/Indiana_Jones_cappello.png
27 29 Wizard.path = /usr/share/qtcreator/templates/wizards/SocExplorerPlugin
28 30 Wizard.files = Qt_Creator_Wizard/SocExplorerPlugin/logo-lpp-cutted.png \
29 31 Qt_Creator_Wizard/SocExplorerPlugin/plugin.cpp \
30 32 Qt_Creator_Wizard/SocExplorerPlugin/plugin.h \
31 33 Qt_Creator_Wizard/SocExplorerPlugin/project.pro \
32 34 Qt_Creator_Wizard/SocExplorerPlugin/wizard.xml
33 INSTALLS+=Wizard SocExplorer icon
35 INSTALLS+=Wizard SocExplorer icon PluginConfPath
34 36 }
35 37 INSTALLS+=socexplorercfg
36 38
37 39
38 40
39 41
40 42
41 43
42 44
43 45
44 46
45 47
46 48
47 49
48 50
49 51
50 52
51 53
52 54
53 55
54 56
55 57
56 58
57 59
58 60
59 61
60 62
61 63
62 64
63 65
64 66
65 67
66 68
67 69
68 70
69 71
70 72
71 73
72 74
73 75
74 76
75 77
76 78
77 79
78 80
79 81
80 82
81 83
82 84
83 85
84 86
85 87
86 88
@@ -1,27 +1,22
1 1
2 2 QT += core gui xml svg network
3 3 contains(QT_MAJOR_VERSION, 5) {
4 4 QT += widgets
5 5 QT += printsupport
6 6 }
7 CONFIG(debug, debug|release) {
8 DEBUG_EXT = _d
9 } else {
10 DEBUG_EXT =
11 }
12 7
13 8 SOCEXPLORER_SDK_BUILD="SOCEXPLORER_SDK_BUILD"
14 9 DEFINES += SOCEXPLORER_SDK_BUILD
15 10
16 11 MOC_DIR = moc
17 12 RCC_DIR = resources
18 13 OBJECTS_DIR = obj
19 14
20 15 win32:DESTDIR = $${SOCEXPLORER_ROOT}/bin/win32/
21 16 unix:DESTDIR = $${SOCEXPLORER_ROOT}/bin/linux/
22 17
23 18
24 19 metrics_cccc.target = metrics_cccc
25 20 metrics_cccc.commands = cccc $(SOURCES) $(HEADERS)
26 21
27 22 QMAKE_EXTRA_TARGETS += metrics_cccc
@@ -1,251 +1,285
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "socexplorerengine.h"
23 23 #include <proxy/socexplorerproxy.h>
24 24
25 25 SocExplorerEngine* SocExplorerEngine::_self = NULL;
26 26 socExplorerXmlModel* SocExplorerEngine::p_xmlmodel=NULL;
27 27 QMainWindow* SocExplorerEngine::mainWindow=NULL;
28 28 QList<SOCModel*>* SocExplorerEngine::SOCs=NULL;
29 29 int SocExplorerEngine::loglvl=1;
30 30
31 31 SocExplorerEngine::SocExplorerEngine(QObject *parent) :
32 32 QObject(parent)
33 33 {
34 34 if(SOCs==NULL)
35 35 {
36 36 SOCs = new QList<SOCModel*>;
37 37 }
38 38
39 39 }
40 40
41 41
42 42 void SocExplorerEngine::init()
43 43 {
44 44 QDir dir;
45 45 if(!_self)
46 46 {
47 47 _self= new SocExplorerEngine;
48 48 }
49 49 if(!dir.exists(configFolder()))
50 50 dir.mkdir(configFolder());
51 51 p_xmlmodel = new socExplorerXmlModel(_self);
52 52 p_xmlmodel->updateSOClist();
53 53 }
54 54
55 55 QString SocExplorerEngine::configFolder()
56 56 {
57 57 return QString(SOCEXPLORER_CONFIG_PATH);
58 58 }
59 59
60 QStringList SocExplorerEngine::pluginFolders()
61 {
62 if(!_self)
63 init();
64 QStringList folders;
65 QDir pluginFolders(QString(SOCEXPLORER_CONFIG_PATH)+"/plugin.conf.d");
66 if(pluginFolders.exists())
67 {
68 pluginFolders.setFilter(QDir::Files | QDir::NoSymLinks);
69 QFileInfoList list = pluginFolders.entryInfoList();
70 for (int i = 0; i < list.size(); ++i)
71 {
72 QFileInfo fileInfo = list.at(i);
73 if(fileInfo.suffix()=="conf")
74 {
75 QFile confFile(fileInfo.absoluteFilePath());
76 if(confFile.open(QIODevice::ReadOnly))
77 {
78 while (!confFile.atEnd())
79 {
80 QString line = confFile.readLine();
81 QDir plugDir(line.remove("\n"));
82 if(plugDir.exists() && !folders.contains(plugDir.absolutePath()))
83 {
84 folders.append(plugDir.absolutePath());
85 }
86 }
87 }
88 }
89 }
90 }
91 return folders;
92 }
93
60 94 SOCModel *SocExplorerEngine::plugin2Soc(socexplorerplugin *plugin)
61 95 {
62 96 if(!_self)
63 97 init();
64 98 if(plugin)
65 99 {
66 100 while (plugin->parent!=NULL) {
67 101 plugin = plugin->parent;
68 102 }
69 103 for(int i=0;i<SOCs->count();i++)
70 104 {
71 105 if(SOCs->at(i)->isRootDev(plugin))
72 106 return SOCs->at(i);
73 107 }
74 108 //no soc found so create a new one
75 109 SOCModel* soc=new SOCModel(plugin);
76 110 SOCs->append(soc);
77 111 return soc;
78 112 }
79 113 return NULL;
80 114 }
81 115
82 116
83 117 int SocExplorerEngine::addEnumDevice(socexplorerplugin* rootPlugin,int VID, int PID, qint32 baseAddress, const QString &name)
84 118 {
85 119 if(!_self)
86 120 init();
87 121 SOCModel* soc = plugin2Soc(rootPlugin);
88 122 if(soc && !soc->enumDeviceExists(baseAddress))
89 123 {
90 124 emit _self->enumDeviceAdded(soc->addEnumDevice(VID,PID,baseAddress,name));
91 125 return 1;
92 126 }
93 127 return 0;
94 128 }
95 129
96 130 QList<SOCModel *> *SocExplorerEngine::getSOCs()
97 131 {
98 132 if(!_self)
99 133 init();
100 134 return SOCs;
101 135 }
102 136
103 137 qint32 SocExplorerEngine::getEnumDeviceBaseAddress(const QString& rootPlugin,int VID, int PID, int count)
104 138 {
105 139 socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin);
106 140 if(plugin==NULL)return -1;
107 141 SOCModel* soc = plugin2Soc(plugin);
108 142 if(soc==NULL)
109 143 return -1;
110 144 return soc->getEnumDeviceBaseAddress(VID,PID,count);
111 145 }
112 146
113 147 qint32 SocExplorerEngine::getEnumDeviceBaseAddress(socexplorerplugin *plugin, int VID, int PID, int count)
114 148 {
115 149 if(plugin==NULL)return -1;
116 150 SOCModel* soc = plugin2Soc(plugin);
117 151 if(soc==NULL)
118 152 return -1;
119 153 return soc->getEnumDeviceBaseAddress(VID,PID,count);
120 154 }
121 155
122 156 qint32 SocExplorerEngine::getEnumDeviceCount(socexplorerplugin *plugin, int VID, int PID)
123 157 {
124 158 if(plugin==NULL)return 0;
125 159 SOCModel* soc = plugin2Soc(plugin);
126 160 if(soc==NULL)
127 161 return 0;
128 162 return soc->getEnumDeviceCount(VID,PID);
129 163 }
130 164
131 165 qint32 SocExplorerEngine::getEnumDeviceCount(const QString &rootPlugin, int VID, int PID)
132 166 {
133 167 socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin);
134 168 if(plugin==NULL)return 0;
135 169 SOCModel* soc = plugin2Soc(plugin);
136 170 if(soc==NULL)
137 171 return 0;
138 172 return soc->getEnumDeviceCount(VID,PID);
139 173 }
140 174
141 175 int SocExplorerEngine::addEnumDevice(const QString &rootPlugin, int VID, int PID, qint32 baseAddress, const QString &name)
142 176 {
143 177 socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin);
144 178 if(plugin==NULL)return -1;
145 179 SOCModel* soc = plugin2Soc(plugin);
146 180 if(soc==NULL)
147 181 return -1;
148 182 soc->addEnumDevice(VID,PID,baseAddress,name);
149 183 return 1;
150 184 }
151 185
152 186
153 187 QString SocExplorerEngine::getDevName(int VID, int PID)
154 188 {
155 189 QList<QDomNodeList> list=p_xmlmodel->getAllNodes("peripheral");
156 190 for(int i=0;i<list.count();i++)
157 191 {
158 192 QDomNodeList nodes=list.at(i);
159 193 for(int l=0;l<nodes.count();l++)
160 194 {
161 195 QDomElement node=nodes.at(l).toElement();
162 196 int nodeVID=node.attribute("vid","0").toInt();
163 197 int nodePID=node.attribute("pid","0").toInt();
164 198 if((nodeVID==VID)&&(nodePID==PID))
165 199 {
166 200 return node.attribute("name","Unknow device");
167 201 }
168 202 }
169 203 }
170 204 return QString("Unknow device");
171 205 }
172 206
173 207 QString SocExplorerEngine::SocExplorerVersion(){return QString(SOCEXPLORER_VERSION);}
174 208
175 209 QString SocExplorerEngine::SocExplorerChangeset(){return QString(SOCEXPLORER_CHAGESET).split(" ").at(0);}
176 210
177 211 QString SocExplorerEngine::SocExplorerBranch(){return QString(SOCEXPLORER_BRANCH);}
178 212
179 213 socExplorerXmlModel *SocExplorerEngine::xmlModel()
180 214 {
181 215 if(!_self)
182 216 init();
183 217 return p_xmlmodel;
184 218 }
185 219
186 220 void SocExplorerEngine::setMainWindow(QMainWindow *Mainwindow)
187 221 {
188 222 if(!_self)
189 223 init();
190 224 mainWindow=Mainwindow;
191 225 }
192 226
193 227 QProgressBar *SocExplorerEngine::getProgressBar(const QString& format, int max)
194 228 {
195 229 if(!_self)
196 230 init();
197 231 QProgressBar* progressBar;
198 232 if(mainWindow!=NULL)
199 233 {
200 234 progressBar = new QProgressBar(mainWindow);
201 235 mainWindow->statusBar()->addWidget(progressBar);
202 236 }
203 237 else
204 238 {
205 239 progressBar = new QProgressBar();
206 240 }
207 241 progressBar->setMaximum(max);
208 242 progressBar->setFormat(format);
209 243 return progressBar;
210 244 }
211 245
212 246 void SocExplorerEngine::deleteProgressBar(QProgressBar *progressBar)
213 247 {
214 248 if(mainWindow!=NULL)
215 249 {
216 250 mainWindow->statusBar()->removeWidget(progressBar);
217 251 }
218 252 delete progressBar;
219 253 }
220 254
221 255 void SocExplorerEngine::addSOC(socexplorerplugin *rootPlugin)
222 256 {
223 257 plugin2Soc(rootPlugin);
224 258 }
225 259
226 260 void SocExplorerEngine::removeSOC(socexplorerplugin *rootPlugin)
227 261 {
228 262 SOCModel* soc=plugin2Soc(rootPlugin);
229 263 SOCs->removeAll(soc);
230 264 delete soc;
231 265 }
232 266
233 267 void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel)
234 268 {
235 269 // TODO add multi output message manager IE also log in files
236 270 if(!_self)
237 271 init();
238 272 if(loglvl>=debugLevel)
239 273 qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName()+":"+message;
240 274 }
241 275
242 276 void SocExplorerEngine::setLogLevel(int level)
243 277 {
244 278 if(!_self)
245 279 init();
246 280 printf("Set log level to %d\n",level);
247 281 loglvl = level;
248 282 }
249 283
250 284
251 285
@@ -1,136 +1,137
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef SOCEXPLORERENGINE_H
23 23 #define SOCEXPLORERENGINE_H
24 24
25 25 #include <stdint.h>
26 26 #include <QObject>
27 27 #include <QtWidgets>
28 28 #include <QStringList>
29 29 #include <QDomDocument>
30 30 #include <QDomElement>
31 31 #include <QDomNodeList>
32 32 #include <QFile>
33 33 #include <QTextStream>
34 34 #include <QDir>
35 35 #include <QApplication>
36 36 #include <QtCore/qglobal.h>
37 37 #include <QFileDialog>
38 38 #include <socexplorerxmlfile.h>
39 39 #include <socexplorerenumdevice.h>
40 40 #include <XMLmodel.h>
41 41 #include <peripheralwidget.h>
42 42 #include <registerwidget.h>
43 43 #include <socmodel.h>
44 44
45 45 #if defined(SOCEXPLORER_SDK_BUILD)
46 46 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
47 47 #else
48 48 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
49 49 #endif
50 50
51 51
52 52 class SOCEXPLORER_SDK_EXPORT SocExplorerAutoProgressBar
53 53 {
54 54 public:
55 55 SocExplorerAutoProgressBar(QProgressBar* progressBar=NULL)
56 56 {
57 57 this->p_progressbar=progressBar;
58 58 }
59 59 ~SocExplorerAutoProgressBar()
60 60 {
61 61 if(p_progressbar)
62 62 {
63 63 delete p_progressbar;
64 64 }
65 65 }
66 66 void setProgressBar(QProgressBar* progressBar)
67 67 {
68 68 this->p_progressbar=progressBar;
69 69 }
70 70 void setValue(int value)
71 71 {
72 72 p_progressbar->setValue(value);
73 73 }
74 74 private:
75 75 QProgressBar* p_progressbar;
76 76 };
77 77
78 78 //! SocExplorerEngine is a pure static class which aims to provide services for both SocExplorer software and plugins.
79 79
80 80 class SOCEXPLORER_SDK_EXPORT SocExplorerEngine : public QObject
81 81 {
82 82 Q_OBJECT
83 83 private:
84 84 static SocExplorerEngine* _self;
85 85 SocExplorerEngine(QObject *parent = 0);
86 86 static void init();
87 87
88 88 public:
89 89 static SocExplorerEngine* self(){ if(!_self){_self= new SocExplorerEngine;}return _self;}
90 90 //! Return the configuration folder path, OS dependant.
91 91 SOCEXPLORER_SDK_EXPORT static QString configFolder();
92 92 //! Return the default plugin folder path, OS dependant.
93 static QString pluginFolder(){return QString(SOCEXPLORER_PLUGINS_INSTALL_PATH);}
94
93 //static QString pluginFolder(){return QString(SOCEXPLORER_PLUGINS_INSTALL_PATH);}
94 static QStringList pluginFolders();
95 static QString configPath(){return QString(SOCEXPLORER_CONFIG_PATH);}
95 96 static int addEnumDevice(socexplorerplugin* rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name);
96 97 static QList<SOCModel*>* getSOCs();
97 98 static QString getDevName(int VID, int PID);
98 99 static QString SocExplorerVersion();
99 100 static QString SocExplorerChangeset();
100 101 static QString SocExplorerBranch();
101 102 static socExplorerXmlModel* xmlModel();
102 103 static void setMainWindow(QMainWindow* Mainwindow);
103 104 static QProgressBar* getProgressBar(const QString &format, int max);
104 105 static void deleteProgressBar(QProgressBar* progressBar);
105 106 static void addSOC(socexplorerplugin* rootPlugin);
106 107 static void removeSOC(socexplorerplugin* rootPlugin);
107 108 static void message(socexplorerplugin* sender,const QString& message,int debugLevel=0);
108 109 static void setLogLevel(int level);
109 110 signals:
110 111 void enumDeviceAdded(socExplorerEnumDevice* device);
111 112 public slots:
112 113 QString getSocExplorerVersion(){return SocExplorerEngine::SocExplorerVersion();}
113 114 QString getSocExplorerChangeset(){return SocExplorerEngine::SocExplorerChangeset();}
114 115 QString getSocExplorerBranch(){return SocExplorerEngine::SocExplorerBranch();}
115 116 qint32 getEnumDeviceBaseAddress(const QString& rootPlugin,int VID,int PID,int count=0);
116 117 qint32 getEnumDeviceBaseAddress(socexplorerplugin* plugin,int VID,int PID,int count=0);
117 118 qint32 getEnumDeviceCount(socexplorerplugin* plugin,int VID,int PID);
118 119 qint32 getEnumDeviceCount(const QString& rootPlugin,int VID,int PID);
119 120 int addEnumDevice(const QString& rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name);
120 121
121 122 private:
122 123 static SOCModel* plugin2Soc(socexplorerplugin* plugin);
123 124 static socExplorerXmlModel* p_xmlmodel;
124 125 static QMainWindow* mainWindow;
125 126 static QList<SOCModel*>* SOCs;
126 127 static int loglvl;
127 128 };
128 129
129 130 #endif // SOCEXPLORERENGINE_H
130 131
131 132
132 133
133 134
134 135
135 136
136 137
@@ -1,142 +1,143
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "pluginmanagerWDGT.h"
23 23 #include "pluginloader.h"
24 24 #include <QFileDialog>
25 25 #include <unistd.h>
26 26 #include <qsvgicon.h>
27 27 #include <socexplorerengine.h>
28 28
29 29 #define mkbutton(button,text,image)button = new QPushButton();\
30 30 button->setIcon(QSvgIcon(image));\
31 31 button->setIconSize(QSize(16,16));\
32 32 button->setToolTip(text)
33 33
34 34
35 35
36 36 pluginmanagerWDGT::pluginmanagerWDGT(QWidget *parent) :
37 37 QSplitter(parent)
38 38 {
39 39 this->setWindowTitle("Plugin Manager");
40 40 this->setOrientation(Qt::Vertical);
41 41 this->pluginListWidgetContainer = new QWidget();
42 42 this->mainlayoutSpliter = new QSplitter;
43 43 this->pluginListLayout = new QVBoxLayout();
44 44 this->mainlayoutSpliter->setOrientation(Qt::Vertical);
45 45 this->treeview = new plugintree();
46 46 this->pluginTable = new PluginList;
47 47 this->ButtonsLayout = new QHBoxLayout();
48 48 this->ButtonsLayout->addStretch();
49 49 this->pluginListLayout->addLayout(this->ButtonsLayout);
50 50 this->addWidget(this->treeview);
51 51 this->pluginListWidgetContainer->setLayout(this->pluginListLayout);
52 52 this->addWidget(this->pluginListWidgetContainer);
53 53 this->pluginListLayout->addWidget(this->pluginTable);
54 54 this->pluginInfos = new pluginInfosWdgt;
55 55
56 56 mkbutton(this->addPluginBt,tr("add plugin"),":/images/open.svg");
57 57 mkbutton(this->removePluginBt,tr("remove plugin(s)"),":/images/trash.svg");
58 58 mkbutton(this->refreshPluginListBt,tr("Refresh Plugin(s) list"),":/images/refresh.svg");
59 59
60 60 this->ButtonsLayout->addWidget(this->addPluginBt);
61 61 this->ButtonsLayout->addWidget(this->refreshPluginListBt);
62 62 this->ButtonsLayout->addWidget(this->removePluginBt);
63 63
64 64 this->addWidget(this->pluginInfos);
65 65
66 66 connect(this->treeview,SIGNAL(geteplugintree()),this,SIGNAL(geteplugintree()));
67 67 connect(this,SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->treeview,SLOT(treeChanged(QList<socexplorerplugin*>)));
68 68 connect(this->pluginTable,SIGNAL(currentRowChanged(int)),this,SLOT(libselected(int)));
69 69 connect(this->pluginTable,SIGNAL(itemSelectionChanged(QStringList)),this->pluginInfos,SLOT(updateInfos(QStringList)));
70 70 connect(this->addPluginBt,SIGNAL(clicked()),this,SLOT(addPlugin()));
71 71 connect(this->removePluginBt,SIGNAL(clicked()),this,SLOT(removePlugin()));
72 72 connect(this->pluginTable,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(loadplugin(QListWidgetItem*)));
73 73 connect(this->refreshPluginListBt,SIGNAL(clicked()),this->pluginTable,SLOT(refreshPluginList()));
74 74 connect(this->treeview,SIGNAL(loadSysDriver(QString)),this,SIGNAL(loadSysDrviver(QString)));
75 75 connect(this->treeview,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString)));
76 76 connect(this->treeview,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString)));
77 77 connect(this->treeview,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString)));
78 78 connect(this->treeview,SIGNAL(pluginselected(QString)),this,SIGNAL(pluginselected(QString)));
79 79 this->rootLoadable = false;
80 80 this->childLoadable = false;
81 81 this->pluginTable->refreshPluginList();
82 82 this->pluginTable->refreshPluginList();
83 83 }
84 84
85 85
86 86 void pluginmanagerWDGT::setRootLoadable(bool flag)
87 87 {
88 88 this->rootLoadable = flag;
89 89 }
90 90
91 91
92 92 void pluginmanagerWDGT::setChildLoadable(bool flag)
93 93 {
94 94 this->childLoadable = flag;
95 95 }
96 96
97 97
98 98
99 99
100 100 void pluginmanagerWDGT::addPlugin()
101 101 {
102 QString fileName = QFileDialog::getOpenFileName(this,tr("Open Plugin"), QDir::homePath(), tr("Plugin Files Files (*.dll *.so *.so.*)"));
103 if(pluginloader::checklibrary(fileName))
104 {
105 QFile::copy(fileName,QString(SocExplorerEngine::pluginFolder())+"/"+ fileName.section('/',-1));
106 }
107 this->pluginTable->refreshPluginList();
102 // /!\ TODO update it remove maximum operation from widget
103 // QString fileName = QFileDialog::getOpenFileName(this,tr("Open Plugin"), QDir::homePath(), tr("Plugin Files Files (*.dll *.so *.so.*)"));
104 // if(pluginloader::checklibrary(fileName))
105 // {
106 // QFile::copy(fileName,QString(SocExplorerEngine::pluginFolder())+"/"+ fileName.section('/',-1));
107 // }
108 // this->pluginTable->refreshPluginList();
108 109 }
109 110
110 111
111 112 void pluginmanagerWDGT::removePlugin()
112 113 {
113 for(int i=0;i<this->pluginTable->selectedItems().count();i++)
114 {
115 QListWidgetItem* item = this->pluginTable->selectedItems().at(i);
116 if(item!=NULL)
117 {
118 QFile::remove(QString(SocExplorerEngine::pluginFolder())+"/"+item->text());
119 }
120 }
121 this->pluginTable->refreshPluginList();
114 // for(int i=0;i<this->pluginTable->selectedItems().count();i++)
115 // {
116 // QListWidgetItem* item = this->pluginTable->selectedItems().at(i);
117 // if(item!=NULL)
118 // {
119 // QFile::remove(QString(SocExplorerEngine::pluginFolder())+"/"+item->text());
120 // }
121 // }
122 // this->pluginTable->refreshPluginList();
122 123 }
123 124
124 125
125 126
126 127 void pluginmanagerWDGT::loadplugin()
127 128 {
128 for(int i=0;i<this->pluginTable->selectedItems().count();i++)
129 {
130 QListWidgetItem* item = this->pluginTable->selectedItems().at(i);
131 if(item!=NULL)
132 {
133 QString plugin = QString(SocExplorerEngine::pluginFolder())+"/"+item->text();
134 emit this->loadSysDrviver(plugin);
135 }
136 }
137 this->pluginTable->refreshPluginList();
129 // for(int i=0;i<this->pluginTable->selectedItems().count();i++)
130 // {
131 // QListWidgetItem* item = this->pluginTable->selectedItems().at(i);
132 // if(item!=NULL)
133 // {
134 // QString plugin = QString(SocExplorerEngine::pluginFolder())+"/"+item->text();
135 // emit this->loadSysDrviver(plugin);
136 // }
137 // }
138 // this->pluginTable->refreshPluginList();
138 139 }
139 140
140 141
141 142
142 143
@@ -1,572 +1,560
1 1 #include "pluginloader.h"
2 2 #include <QDir>
3 3 #include <QFile>
4 4 #include <QFileInfoList>
5 5 #include <QFileInfo>
6 6 #include <QString>
7 7 #include <QStringList>
8 8 #include <QLabel>
9 9 #include <QSettings>
10 10 #include <QApplication>
11 11 #include <QCoreApplication>
12 12 #include <socexplorerengine.h>
13 13 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
14 14 #include "unix/unixpluginloader.h"
15 15 #endif
16 16
17 17 pluginloader* pluginloader::_self = NULL;
18 18 PluginsCache* pluginloader::_cache = NULL;
19 19 QStringList* pluginloader::_folderList = NULL;
20 20
21 21
22 22 pluginloader::pluginloader()
23 23 {
24 24 _cache = new PluginsCache();
25 25 _folderList = new QStringList();
26 QDir pluginPath(QString(SocExplorerEngine::pluginFolder()));
27 if(!pluginPath.exists())
28 {
29 pluginPath.mkpath(QString(SocExplorerEngine::pluginFolder()));
30 }
31 QFile pluginsFolders(QString(SocExplorerEngine::pluginFolder())+"/plugins.conf");
32 *_folderList << QString(SocExplorerEngine::pluginFolder()); //default place
33 if(!pluginsFolders.exists())
34 {
35 pluginsFolders.open(QIODevice::WriteOnly); //if file doesn't exist create it
36 pluginsFolders.close();
37 }
38 *_folderList<< readFoldersList(QStringList()<< QString(SocExplorerEngine::pluginFolder())+"/plugins.conf");
26 _folderList->append(SocExplorerEngine::pluginFolders());
39 27 scanFolders();
40 28 }
41 29
42 30
43 31 QStringList pluginloader::readFoldersList(const QStringList confFiles)
44 32 {
45 33 QDir testDir;
46 34 QStringList folders;
47 35 QFile confFile;
48 36 for(int i=0;i<confFiles.count();i++)
49 37 {
50 38 confFile.setFileName(confFiles.at(i));
51 39 if(confFile.exists())
52 40 {
53 41 if (confFile.open(QIODevice::ReadOnly | QIODevice::Text))
54 42 {
55 43 QTextStream in(&confFile);
56 44 QString line = in.readLine();
57 45 while (!line.isNull())
58 46 {
59 47 testDir.setPath(line);
60 48 if(testDir.exists())
61 49 {
62 50 if(!folders.contains(line))
63 51 folders << line;
64 52 }
65 53 line = in.readLine();
66 54 }
67 55 }
68 56 }
69 57 }
70 58 return folders;
71 59 }
72 60
73 61
74 62 void pluginloader::scanFolders()
75 63 {
76 64 QDir dir;
77 65 QStringList filters;
78 66 filters <<"*.so"<< "*.dll";
79 67 _cache->flush();
80 68 for(int d=0;d<_folderList->count();d++)
81 69 {
82 70 dir.setPath(_folderList->at(d));
83 71 dir.setFilter(QDir::Files);
84 72 dir.setNameFilters(filters);
85 73 QFileInfoList list = dir.entryInfoList();
86 74 for (int i = 0; i < list.size(); ++i)
87 75 {
88 76 QFileInfo fileInfo = list.at(i);
89 77 if(checklibrary(fileInfo.filePath())!=0)
90 78 {
91 79 _cache->append(fileInfo.fileName(),fileInfo.path(),_getlibName(fileInfo.filePath()),_getlibPID(fileInfo.filePath()),_getlibPID(fileInfo.filePath()));
92 80 }
93 81 }
94 82 }
95 83 }
96 84
97 85 int pluginloader::p_checklibraryQlib(const QString fileName)
98 86 {
99 87 QLibrary* lib = new QLibrary;
100 88 lib->setFileName(fileName);
101 89 lib->setLoadHints(QLibrary::PreventUnloadHint);
102 90 lib->load();
103 91 if(!lib->isLoaded())
104 92 {
105 93 qDebug()<<lib->errorString();
106 94 lib->~QLibrary();
107 95 lib = new QLibrary(fileName);
108 96 lib->load();
109 97 }
110 98 delete lib;
111 99 if(QLibrary::resolve(fileName,"socexplorerpluginCreateObject"))
112 100 {
113 101 if(QLibrary::resolve(fileName,"socexplorerpluginpid"))
114 102 {
115 103 if(QLibrary::resolve(fileName,"socexplorerpluginvid"))
116 104 {
117 105 if(QLibrary::resolve(fileName,"socexplorerpluginVersion"))
118 106 {
119 107 if(QLibrary::resolve(fileName,"socexplorerpluginAuthor"))
120 108 {
121 109 if(QLibrary::resolve(fileName,"socexplorerpluginDescription"))
122 110 {
123 111 return 1;
124 112 }
125 113 }
126 114 }
127 115 }
128 116 }
129 117 }
130 118 return 0;
131 119 }
132 120
133 121 int pluginloader::p_checklibraryCustom(const QString fileName)
134 122 {
135 123 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
136 124 unixPluginLoader lib(fileName);
137 125 if(NULL!=lib.resolve("socexplorerpluginCreateObject"))
138 126 {
139 127 if(NULL!=lib.resolve("socexplorerpluginpid"))
140 128 {
141 129 if(NULL!=lib.resolve("socexplorerpluginvid"))
142 130 {
143 131 if(NULL!=lib.resolve("socexplorerpluginVersion"))
144 132 {
145 133 if(NULL!=lib.resolve("socexplorerpluginAuthor"))
146 134 {
147 135 if(NULL!=lib.resolve("socexplorerpluginDescription"))
148 136 {
149 137 return 1;
150 138 }
151 139 }
152 140 }
153 141 }
154 142 }
155 143 }
156 144 #endif
157 145 return 0;
158 146 }
159 147
160 148 socexplorerplugin *pluginloader::p_newsocexplorerpluginQlib(const QString Name)
161 149 {
162 150 QString* libfile= _cacheLookup(Name);
163 151 if(libfile==NULL)return NULL;
164 152 QLibrary* lib = new QLibrary(*libfile);
165 153 delete libfile;
166 154 socexplorerpluginCreateObjectT newDrvr = NULL;
167 155 newDrvr=(socexplorerpluginCreateObjectT)lib->resolve("socexplorerpluginCreateObject");
168 156 if(newDrvr==NULL)
169 157 {
170 158 return NULL;
171 159 }
172 160 return (socexplorerplugin*) newDrvr();
173 161 }
174 162
175 163 socexplorerplugin *pluginloader::p_newsocexplorerpluginCustom(const QString Name)
176 164 {
177 165 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
178 166 QString* libfile= _cacheLookup(Name);
179 167 if(libfile==NULL)return NULL;
180 168 unixPluginLoader lib(*libfile);
181 169 delete libfile;
182 170 socexplorerpluginCreateObjectT newDrvr = NULL;
183 171 newDrvr=(socexplorerpluginCreateObjectT)lib.resolve("socexplorerpluginCreateObject");
184 172 if(newDrvr==NULL)
185 173 {
186 174 return NULL;
187 175 }
188 176 return (socexplorerplugin*) newDrvr();
189 177 #endif
190 178 }
191 179
192 180 QList<PluginsCacheItem*> pluginloader::listAvailiables(bool rescan)
193 181 {
194 182 if(_self==NULL)
195 183 {
196 184 init();
197 185 return _cache->listDrivers();
198 186 }
199 187 if(rescan)
200 188 {
201 189 scanFolders();
202 190 }
203 191
204 192 return _cache->listDrivers();
205 193 }
206 194
207 195
208 196 void pluginloader::init()
209 197 {
210 198 if(_self==NULL)
211 199 {
212 200 _self=new pluginloader();
213 201 }
214 202 }
215 203
216 204
217 205 pluginloader* pluginloader::self()
218 206 {
219 207 if(_self==NULL)
220 208 {
221 209 init();
222 210 }
223 211 return _self;
224 212 }
225 213
226 214 bool pluginloader::isvalid(QString Name)
227 215 {
228 216 if(_self==NULL)init();
229 217 QString* libfile= _cacheLookup(Name);
230 218 if(libfile==NULL)return false;
231 219 else
232 220 {
233 221 delete libfile;
234 222 return true;
235 223 }
236 224
237 225 }
238 226
239 227 int pluginloader::checklibrary(const QString fileName)
240 228 {
241 229 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
242 230 return _self->p_checklibraryCustom(fileName);
243 231 #else
244 232 return _self->p_checklibraryQlib(fileName);
245 233 #endif
246 234 }
247 235
248 236
249 237
250 238
251 239
252 240 socexplorerplugin* pluginloader::newsocexplorerplugin(const QString Name)
253 241 {
254 242 #ifdef SOCEXPLORER_CUSTOM_PLUGIN_LOADER
255 243 return _self->p_newsocexplorerpluginCustom(Name);
256 244 #else
257 245 return _self->p_newsocexplorerpluginQlib(Name);
258 246 #endif
259 247 }
260 248
261 249
262 250 QString pluginloader::getlibTypeStr(QString Name)
263 251 {
264 252 if(_self==NULL)init();
265 253 QString* libfile= _cacheLookup(Name);
266 254 if(libfile==NULL)return NULL;
267 255 QLibrary* lib = new QLibrary(*libfile);
268 256 delete libfile;
269 257 lib->load();
270 258 if(lib->isLoaded())
271 259 {
272 260 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
273 261 if(plugintype!=NULL)
274 262 {
275 263 pluginT type = plugintype();
276 264 switch(type)
277 265 {
278 266 case ComDriverT:
279 267 ////lib->unload();
280 268 lib->~QLibrary();
281 269 return QObject::tr("Comunaication Driver Plugin.");
282 270 break;
283 271 case PerifDriverT:
284 272 ////lib->unload();
285 273 lib->~QLibrary();
286 274 return QObject::tr("Periferial Driver Plugin.");
287 275 break;
288 276 default:
289 277 ////lib->unload();
290 278 lib->~QLibrary();
291 279 return QObject::tr("Unknow Plugin.");
292 280 break;
293 281 }
294 282 }
295 283 }
296 284 lib->~QLibrary();
297 285 return QObject::tr("Can't load Plugin.");
298 286 }
299 287
300 288
301 289
302 290
303 291 pluginT pluginloader::getlibType(QString Name)
304 292 {
305 293 if(_self==NULL)init();
306 294 QString* libfile= _cacheLookup(Name);
307 295 if(libfile==NULL)return (pluginT)NULL;
308 296 QLibrary* lib = new QLibrary(*libfile);
309 297 delete libfile;
310 298 lib->load();
311 299 if(lib->isLoaded())
312 300 {
313 301 socexplorerpluginTypeT plugintype = (socexplorerpluginTypeT)lib->resolve("socexplorerpluginType");
314 302 if(plugintype!=NULL)
315 303 {
316 304 return plugintype();
317 305 }
318 306 }
319 307 lib->~QLibrary();
320 308 return -1;
321 309 }
322 310
323 311
324 312 QString pluginloader::getlibVersion(const QString Name)
325 313 {
326 314 if(_self==NULL)init();
327 315 QString* libfile= _cacheLookup(Name);
328 316 if(libfile==NULL)return NULL;
329 317 QLibrary* lib = new QLibrary(*libfile);
330 318 delete libfile;
331 319 lib->load();
332 320 if(lib->isLoaded())
333 321 {
334 322 socexplorerpluginVersionT pluginversion = (socexplorerpluginVersionT)lib->resolve("socexplorerpluginVersion");
335 323 if(pluginversion!=NULL)
336 324 {
337 325 QString version = pluginversion();
338 326 ////lib->unload();
339 327 lib->~QLibrary();
340 328 return version;
341 329 }
342 330 }
343 331 lib->~QLibrary();
344 332 return QObject::tr("Can't load Plugin.");
345 333 }
346 334
347 335
348 336
349 337 QString pluginloader::getlibPIDstr(const QString Name)
350 338 {
351 339 return QString("0x" + QString::number(pluginloader::getlibPID(Name) , 16));
352 340 }
353 341
354 342 QString pluginloader::getlibVIDstr(const QString Name)
355 343 {
356 344 return QString("0x" + QString::number(pluginloader::getlibVID(Name) , 16));
357 345 }
358 346
359 347
360 348
361 349 int pluginloader::libcanbechild(const QString Name)
362 350 {
363 351 if(_self==NULL)init();
364 352 QString* libfile= _cacheLookup(Name);
365 353 if(libfile==NULL)return (int)NULL;
366 354 QLibrary* lib = new QLibrary(*libfile);
367 355 delete libfile;
368 356 lib->load();
369 357 if(lib->isLoaded())
370 358 {
371 359 socexplorerplugincanbechildT canbechild = (socexplorerplugincanbechildT)lib->resolve("socexplorerplugincanbechild");
372 360 if(canbechild!=NULL)
373 361 {
374 362 int value = canbechild();
375 363 ////lib->unload();
376 364 //lib->~QLibrary();
377 365 return value;
378 366 }
379 367 }
380 368 //lib->~QLibrary();
381 369 return 0;
382 370 }
383 371
384 372
385 373
386 374
387 375 int pluginloader::libcanberoot(const QString Name)
388 376 {
389 377 if(_self==NULL)init();
390 378 QString* libfile= _cacheLookup(Name);
391 379 if(libfile==NULL)return (int)NULL;
392 380 QLibrary* lib = new QLibrary(*libfile);
393 381 delete libfile;
394 382 lib->load();
395 383 if(lib->isLoaded())
396 384 {
397 385 socexplorerplugincanberootT canberoot = (socexplorerplugincanberootT)lib->resolve("socexplorerplugincanberoot");
398 386 if(canberoot!=NULL)
399 387 {
400 388 int value = canberoot();
401 389 ////lib->unload();
402 390 //lib->~QLibrary();
403 391 return value;
404 392 }
405 393 }
406 394 delete lib;
407 395 //lib->~QLibrary();
408 396 return 0;
409 397 }
410 398
411 399 int pluginloader::getlibVID(const QString Name)
412 400 {
413 401 if(_self==NULL)init();
414 402 QString* libfile= _cacheLookup(Name);
415 403 if(libfile==NULL)return 0;
416 404 QString file(*libfile);
417 405 delete libfile;
418 406 return _getlibVID(file);
419 407 }
420 408
421 409
422 410 int pluginloader::getlibPID(const QString Name)
423 411 {
424 412 if(_self==NULL)init();
425 413 QString* libfile= _cacheLookup(Name);
426 414 if(libfile==NULL)return 0;
427 415 QString file(*libfile);
428 416 delete libfile;
429 417 return _getlibPID(file);
430 418 }
431 419
432 420 QString pluginloader::getlibAuthor(const QString Name)
433 421 {
434 422 if(_self==NULL)init();
435 423 QString* libfile= _cacheLookup(Name);
436 424 if(libfile==NULL)return NULL;
437 425 QLibrary* lib = new QLibrary(*libfile);
438 426 delete libfile;
439 427 lib->load();
440 428 if(lib->isLoaded())
441 429 {
442 430 socexplorerpluginAuthorT pluginauthor = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginAuthor");
443 431 if(pluginauthor!=NULL)
444 432 {
445 433 QString author = pluginauthor();
446 434 ////lib->unload();
447 435 lib->~QLibrary();
448 436 return author;
449 437 }
450 438 }
451 439 lib->~QLibrary();
452 440 return QObject::tr("Can't load Plugin.");
453 441 }
454 442
455 443 QString pluginloader::getlibName(const QString Name)
456 444 {
457 445 if(_self==NULL)init();
458 446 QString* libfile= _cacheLookup(Name);
459 447 if(libfile==NULL)return QString("");
460 448 QString file(*libfile);
461 449 delete libfile;
462 450 return _getlibName(file);
463 451 }
464 452
465 453 QString pluginloader::getlibDescription(const QString Name)
466 454 {
467 455 if(_self==NULL)init();
468 456 QString* libfile= _cacheLookup(Name);
469 457 if(libfile==NULL)return NULL;
470 458 QLibrary* lib = new QLibrary(*libfile);
471 459 delete libfile;
472 460 lib->load();
473 461 if(lib->isLoaded())
474 462 {
475 463 socexplorerpluginDescriptionT plugindescription = (socexplorerpluginDescriptionT)lib->resolve("socexplorerpluginDescription");
476 464 if(plugindescription!=NULL)
477 465 {
478 466 QString description = plugindescription();
479 467 ////lib->unload();
480 468 lib->~QLibrary();
481 469 return description;
482 470 }
483 471 }
484 472 lib->~QLibrary();
485 473 return QObject::tr("Can't load Plugin.");
486 474 }
487 475
488 476 QString pluginloader::getlibDir(const QString Name)
489 477 {
490 478 if(_self==NULL)init();
491 479 return *_cacheLookup(Name);
492 480 }
493 481
494 482 QString pluginloader::_getlibName(const QString fileName)
495 483 {
496 484 QLibrary* lib = new QLibrary(fileName);
497 485 lib->load();
498 486 if(lib->isLoaded())
499 487 {
500 488 socexplorerpluginNameT pluginName = (socexplorerpluginAuthorT)lib->resolve("socexplorerpluginName");
501 489 if(pluginName!=NULL)
502 490 {
503 491 QString name = pluginName();
504 492 //lib->unload();
505 493 lib->~QLibrary();
506 494 return name;
507 495 }
508 496 }
509 497 lib->~QLibrary();
510 498 return QObject::tr("Can't load Plugin.");
511 499 }
512 500
513 501 int pluginloader::_getlibPID(const QString fileName)
514 502 {
515 503 QLibrary* lib = new QLibrary(fileName);
516 504 lib->load();
517 505 if(lib->isLoaded())
518 506 {
519 507 socexplorerpluginpidT pluginpid = (socexplorerpluginpidT)lib->resolve("socexplorerpluginpid");
520 508 if(pluginpid!=NULL)
521 509 {
522 510 int pid = pluginpid();
523 511 //lib->unload();
524 512 lib->~QLibrary();
525 513 return pid;
526 514 }
527 515 }
528 516 lib->~QLibrary();
529 517 return 0;
530 518 }
531 519
532 520 int pluginloader::_getlibVID(const QString fileName)
533 521 {
534 522 QLibrary* lib = new QLibrary(fileName);
535 523 lib->load();
536 524 if(lib->isLoaded())
537 525 {
538 526 socexplorerpluginvidT pluginvid = (socexplorerpluginvidT)lib->resolve("socexplorerpluginvid");
539 527 if(pluginvid!=NULL)
540 528 {
541 529 int vid = pluginvid();
542 530 //lib->unload();
543 531 lib->~QLibrary();
544 532 return vid;
545 533 }
546 534 }
547 535 lib->~QLibrary();
548 536 return 0;
549 537 }
550 538
551 539 QString* pluginloader::_cacheLookup(const QString Name)
552 540 {
553 541 QString* libfile= new QString(_cache->first(Name));
554 542 if(!QFile::exists(*libfile))
555 543 {
556 544 scanFolders();
557 545 *libfile = _cache->first(Name);
558 546 if(QFile::exists(*libfile))return libfile;
559 547 }
560 548 else
561 549 {
562 550 return libfile;
563 551 }
564 552 delete libfile;
565 553 return NULL;
566 554 }
567 555
568 556 /*QString findlib(QString name)
569 557 {
570 558
571 559 }*/
572 560
@@ -1,70 +1,71
1 1
2 2
3 3 win32 {
4 4 DEFINES += WIN32
5 5 DEFINES += WINTRANSLATIONPATH
6 6 DEFINES += SOCEXPLORER_TRANSLATION_PATH="\"\\\"./translations"\\\"\"
7 7 SOCEXPLORER_TRANSLATION_INSTALL_PATH = translations
8 8 SOCEXPLORER_INSTALL_PATH =
9 9 SOCEXPLORER_PLUGINS_INSTALL_PATH = $$SOCEXPLORER_PLUGIN_PATH
10 10 }
11 11
12 12 unix {
13 13 DEFINES += UNIX
14 14 DEFINES += UNIXTRANSLATIONPATH
15 15 DEFINES += SOCEXPLORER_TRANSLATION_PATH="\"\\\"/etc/SocExplorer/translations"\\\"\"
16 16 SOCEXPLORER_TRANSLATION_INSTALL_PATH = /etc/SocExplorer/translations
17 17 SOCEXPLORER_INSTALL_PATH = /usr/local/SocExplorer
18 SOCEXPLORER_ROOT_PLUGINS_INSTALL_PATH = $$system(echo $HOME)
19 SOCEXPLORER_PLUGINS_INSTALL_PATH = $${SOCEXPLORER_ROOT_PLUGINS_INSTALL_PATH}"/.SocExplorer/plugins"
18 SOCEXPLORER_PLUGINS_INSTALL_PATH = $$[QT_INSTALL_LIBS]"/SocExplorer/plugins"
19 DEFINES += SOCEXPLORER_CONFIG_PATH="\"\\\"/etc/SocExplorer"\\\"\"
20 SOCEXPLORER_CONFIG_PATH=/etc/SocExplorer
20 21 }
21 22
22 23 isEmpty( SOCEXPLORER_SDK_BUILD ){
23 24 message( "building a plugin" )
24 25 QT += core gui xml
25 26 contains(QT_MAJOR_VERSION, 5) {
26 27 QT += widgets
27 28 }
28 29 CONFIG += pythonqt
29 30 TEMPLATE = lib
30 31 win32:CONFIG += dll
31 32 win32:CONFIG -= static
32 33 OBJECTS_DIR = obj
33 34 MOC_DIR = moc
34 35 DESTDIR = bin
35 CONFIG(debug, debug|release) {
36 DEBUG_EXT = _d
37 } else {
38 DEBUG_EXT =
39 }
36 # CONFIG(debug, debug|release) {
37 # DEBUG_EXT = _d
38 # } else {
39 # DEBUG_EXT =
40 # }
40 41 unix{
41 42 target.path = $${SOCEXPLORER_PLUGINS_INSTALL_PATH}
42 43 INSTALLS += target
43 44 LIBS+= -lsocexplorerengine$${DEBUG_EXT} -lsocexplorercommon$${DEBUG_EXT}
44 45 }
45 46 win32{
46 47 INCLUDEPATH += $$[QT_INSTALL_HEADERS]/SocExplorer/common/libelf
47 48 LIBS+=$$[QT_INSTALL_LIBS]/socexplorerengine$${DEBUG_EXT}.dll $$[QT_INSTALL_LIBS]/socexplorercommon$${DEBUG_EXT}.dll
48 49 }
49 50 DEFINES += SOCEXPLORER_LIBRARY
50 51
51 52 SOURCES += \
52 53 $$[QT_INSTALL_HEADERS]/SocExplorer/pluginsInterface/socexplorerplugininterface.cpp
53 54
54 55 HEADERS += \
55 56 $$[QT_INSTALL_HEADERS]/SocExplorer/genericPySysdriver.h \
56 57 $$[QT_INSTALL_HEADERS]/SocExplorer/socexplorerplugin.h
57 58
58 59 INCLUDEPATH += $$[QT_INSTALL_HEADERS]/SocExplorer/common \
59 60 $$[QT_INSTALL_HEADERS]/SocExplorer \
60 61 $$[QT_INSTALL_HEADERS]/SocExplorer/pluginsInterface
61 62
62 63
63 64 }else{
64 65 message( "building SocExplorer" )
65 66 HEADERS += \
66 67 $$[QT_INSTALL_HEADERS]/SocExplorer/genericPySysdriver.h \
67 68 $$[QT_INSTALL_HEADERS]/SocExplorer/socexplorerplugin.h
68 69 }
69 70
70 71
@@ -1,57 +1,57
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef SOCEXPLORER_H
23 23 #define SOCEXPLORER_H
24 24
25 25 #ifdef WIN32
26 26 #ifdef SOCEXPLORER_EXPORTS
27 27 #define SOCEXPLORER_EXPORT __declspec(dllexport)
28 28 #else
29 29 #define SOCEXPLORER_EXPORT __declspec(dllimport)
30 30 #endif
31 31 #else
32 32 #define SOCEXPLORER_EXPORT
33 33 #endif
34 34
35 35 #ifdef WIN32
36 36 #include <stdlib.h>
37 37 #define socexplorerBswap32(X) _byteswap_ulong(X)
38 38 #else
39 39 #ifdef UNIX
40 40 #include <byteswap.h>
41 41 #define socexplorerBswap32(X) bswap_32(X)
42 42 #endif
43 43 #endif
44 44
45 45
46 46 #ifdef WIN32
47 47 #define SOCEXPLORER_PLUGINS_INSTALL_PATH qApp->applicationDirPath()+"/plugins"
48 48 #define SOCEXPLORER_CONFIG_PATH qApp->applicationDirPath()+"/config"
49 49 #define PYMODULES qApp->applicationDirPath()+"/python"
50 50 #else
51 51 #ifdef UNIX
52 52 #define SOCEXPLORER_PLUGINS_INSTALL_PATH QDir::homePath()+"/.SocExplorer/plugins"
53 #define SOCEXPLORER_CONFIG_PATH QDir::homePath()+"/.SocExplorer/config"
53 //#define SOCEXPLORER_CONFIG_PATH QDir::homePath()+"/.SocExplorer/config"
54 54 #define PYMODULES "/etc/SocExplorer/python"
55 55 #endif
56 56 #endif
57 57 #endif // SOCEXPLORER_H
General Comments 0
You need to be logged in to leave comments. Login now