author | schurig <schurig> | 2003-06-17 06:33:33 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-17 06:33:33 (UTC) |
commit | 9d006f21949fc9a25e323e2fd20fab0bfb249b49 (patch) (unidiff) | |
tree | ce5f2946ffc45d1108ac9612d5915db99818aa4f | |
parent | 0462357c9cad9f271b88f04615acaba4898cbf81 (diff) | |
download | opie-9d006f21949fc9a25e323e2fd20fab0bfb249b49.zip opie-9d006f21949fc9a25e323e2fd20fab0bfb249b49.tar.gz opie-9d006f21949fc9a25e323e2fd20fab0bfb249b49.tar.bz2 |
qpeDir() already has the trailing slash
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 544498f..8ea241d 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -1,326 +1,326 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 2 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | #include "interfacesetupimp.h" | 4 | #include "interfacesetupimp.h" |
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | #include "module.h" | 6 | #include "module.h" |
7 | 7 | ||
8 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
9 | #include <qlistbox.h> | 9 | #include <qlistbox.h> |
10 | #include <qlineedit.h> | 10 | #include <qlineedit.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <qheader.h> | 12 | #include <qheader.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qpe/qcopenvelope_qws.h> | 14 | #include <qpe/qcopenvelope_qws.h> |
15 | #include <qtabwidget.h> // in order to disable the profiles tab | 15 | #include <qtabwidget.h> // in order to disable the profiles tab |
16 | 16 | ||
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | 18 | ||
19 | #ifdef QWS | 19 | #ifdef QWS |
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qpe/qlibrary.h> | 21 | #include <qpe/qlibrary.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #else | 24 | #else |
25 | #include <klibloader.h> | 25 | #include <klibloader.h> |
26 | #define QLibrary KLibrary | 26 | #define QLibrary KLibrary |
27 | #include <kconfig.h> | 27 | #include <kconfig.h> |
28 | #define Config KConfig | 28 | #define Config KConfig |
29 | #include <kapplication.h> | 29 | #include <kapplication.h> |
30 | #include <kstandarddirs.h> | 30 | #include <kstandarddirs.h> |
31 | #include <kiconloader.h> | 31 | #include <kiconloader.h> |
32 | #define showMaximized show | 32 | #define showMaximized show |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #if QT_VERSION < 300 | 35 | #if QT_VERSION < 300 |
36 | #include <qlist.h> | 36 | #include <qlist.h> |
37 | #else | 37 | #else |
38 | #include <qptrlist.h> | 38 | #include <qptrlist.h> |
39 | #endif | 39 | #endif |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <net/if.h> | 45 | #include <net/if.h> |
46 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
47 | #include <sys/socket.h> | 47 | #include <sys/socket.h> |
48 | 48 | ||
49 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 49 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
50 | #define _PROCNETDEV "/proc/net/dev" | 50 | #define _PROCNETDEV "/proc/net/dev" |
51 | 51 | ||
52 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ | 52 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ |
53 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 53 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
54 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 54 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
55 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 55 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
56 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 56 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
57 | 57 | ||
58 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 58 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
59 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 59 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
60 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 60 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
61 | 61 | ||
62 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 62 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
63 | 63 | ||
64 | //FIXME: disable profiles for the moment: | 64 | //FIXME: disable profiles for the moment: |
65 | // tabWidget->setTabEnabled( tab, false ); | 65 | // tabWidget->setTabEnabled( tab, false ); |
66 | 66 | ||
67 | // Load connections. | 67 | // Load connections. |
68 | // /usr/local/kde/lib/libinterfaces.la | 68 | // /usr/local/kde/lib/libinterfaces.la |
69 | #ifdef QWS | 69 | #ifdef QWS |
70 | loadModules(QPEApplication::qpeDir() + "/plugins/networksettings"); | 70 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
71 | #else | 71 | #else |
72 | loader = KLibLoader::self(); | 72 | loader = KLibLoader::self(); |
73 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 73 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
74 | #endif | 74 | #endif |
75 | getAllInterfaces(); | 75 | getAllInterfaces(); |
76 | 76 | ||
77 | Interfaces i; | 77 | Interfaces i; |
78 | QStringList list = i.getInterfaceList(); | 78 | QStringList list = i.getInterfaceList(); |
79 | QMap<QString, Interface*>::Iterator it; | 79 | QMap<QString, Interface*>::Iterator it; |
80 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 80 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
81 | bool found = false; | 81 | bool found = false; |
82 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 82 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
83 | if(it.key() == (*ni)) | 83 | if(it.key() == (*ni)) |
84 | found = true; | 84 | found = true; |
85 | } | 85 | } |
86 | if(!found){ | 86 | if(!found){ |
87 | if(!(*ni).contains("_")){ | 87 | if(!(*ni).contains("_")){ |
88 | Interface *i = new Interface(this, *ni, false); | 88 | Interface *i = new Interface(this, *ni, false); |
89 | i->setAttached(false); | 89 | i->setAttached(false); |
90 | i->setHardwareName(tr("Disconnected")); | 90 | i->setHardwareName(tr("Disconnected")); |
91 | interfaceNames.insert(i->getInterfaceName(), i); | 91 | interfaceNames.insert(i->getInterfaceName(), i); |
92 | updateInterface(i); | 92 | updateInterface(i); |
93 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 93 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | //getInterfaceList(); | 98 | //getInterfaceList(); |
99 | connectionList->header()->hide(); | 99 | connectionList->header()->hide(); |
100 | 100 | ||
101 | Config cfg("NetworkSetup"); | 101 | Config cfg("NetworkSetup"); |
102 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 102 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
103 | for ( QStringList::Iterator it = profiles.begin(); | 103 | for ( QStringList::Iterator it = profiles.begin(); |
104 | it != profiles.end(); ++it) | 104 | it != profiles.end(); ++it) |
105 | profilesList->insertItem((*it)); | 105 | profilesList->insertItem((*it)); |
106 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 106 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
107 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 107 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
108 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 108 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
109 | 109 | ||
110 | QFile file(scheme); | 110 | QFile file(scheme); |
111 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 111 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
112 | QTextStream stream( &file ); // use a text stream | 112 | QTextStream stream( &file ); // use a text stream |
113 | while ( !stream.eof() ) { // until end of file... | 113 | while ( !stream.eof() ) { // until end of file... |
114 | QString line = stream.readLine(); // line of text excluding '\n' | 114 | QString line = stream.readLine(); // line of text excluding '\n' |
115 | if(line.contains("SCHEME")){ | 115 | if(line.contains("SCHEME")){ |
116 | line = line.mid(7, line.length()); | 116 | line = line.mid(7, line.length()); |
117 | currentProfileLabel->setText(line); | 117 | currentProfileLabel->setText(line); |
118 | break; | 118 | break; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | file.close(); | 121 | file.close(); |
122 | } | 122 | } |
123 | makeChannel(); | 123 | makeChannel(); |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Deconstructor. Save profiles. Delete loaded libraries. | 127 | * Deconstructor. Save profiles. Delete loaded libraries. |
128 | */ | 128 | */ |
129 | MainWindowImp::~MainWindowImp(){ | 129 | MainWindowImp::~MainWindowImp(){ |
130 | // Save profiles. | 130 | // Save profiles. |
131 | Config cfg("NetworkSetup"); | 131 | Config cfg("NetworkSetup"); |
132 | cfg.setGroup("General"); | 132 | cfg.setGroup("General"); |
133 | cfg.writeEntry("Profiles", profiles.join(" ")); | 133 | cfg.writeEntry("Profiles", profiles.join(" ")); |
134 | 134 | ||
135 | // Delete all interfaces that don't have owners. | 135 | // Delete all interfaces that don't have owners. |
136 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 136 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
137 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 137 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
138 | if(iIt.key()->getModuleOwner() == NULL) | 138 | if(iIt.key()->getModuleOwner() == NULL) |
139 | delete iIt.key(); | 139 | delete iIt.key(); |
140 | } | 140 | } |
141 | 141 | ||
142 | #ifdef QWS | 142 | #ifdef QWS |
143 | // Delete Modules and Libraries | 143 | // Delete Modules and Libraries |
144 | QMap<Module*, QLibrary*>::Iterator it; | 144 | QMap<Module*, QLibrary*>::Iterator it; |
145 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 145 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
146 | delete it.key(); | 146 | delete it.key(); |
147 | // I wonder why I can't delete the libraries | 147 | // I wonder why I can't delete the libraries |
148 | // What fucking shit this is. | 148 | // What fucking shit this is. |
149 | //delete it.data(); | 149 | //delete it.data(); |
150 | } | 150 | } |
151 | #else | 151 | #else |
152 | // klibloader automaticly deletes the libraries for us... | 152 | // klibloader automaticly deletes the libraries for us... |
153 | #endif | 153 | #endif |
154 | } | 154 | } |
155 | 155 | ||
156 | /** | 156 | /** |
157 | * Query the kernel for all of the interfaces. | 157 | * Query the kernel for all of the interfaces. |
158 | */ | 158 | */ |
159 | void MainWindowImp::getAllInterfaces(){ | 159 | void MainWindowImp::getAllInterfaces(){ |
160 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 160 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
161 | if(sockfd == -1) | 161 | if(sockfd == -1) |
162 | return; | 162 | return; |
163 | 163 | ||
164 | struct ifreq ifr; | 164 | struct ifreq ifr; |
165 | QStringList ifaces; | 165 | QStringList ifaces; |
166 | QFile procFile(QString(_PROCNETDEV)); | 166 | QFile procFile(QString(_PROCNETDEV)); |
167 | int result; | 167 | int result; |
168 | Interface *i; | 168 | Interface *i; |
169 | 169 | ||
170 | if (! procFile.exists()) { | 170 | if (! procFile.exists()) { |
171 | struct ifreq ifrs[100]; | 171 | struct ifreq ifrs[100]; |
172 | struct ifconf ifc; | 172 | struct ifconf ifc; |
173 | ifc.ifc_len = sizeof(ifrs); | 173 | ifc.ifc_len = sizeof(ifrs); |
174 | ifc.ifc_req = ifrs; | 174 | ifc.ifc_req = ifrs; |
175 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 175 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
176 | 176 | ||
177 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { | 177 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { |
178 | struct ifreq *pifr = &ifrs[i]; | 178 | struct ifreq *pifr = &ifrs[i]; |
179 | 179 | ||
180 | ifaces += pifr->ifr_name; | 180 | ifaces += pifr->ifr_name; |
181 | } | 181 | } |
182 | } else { | 182 | } else { |
183 | procFile.open(IO_ReadOnly); | 183 | procFile.open(IO_ReadOnly); |
184 | QString line; | 184 | QString line; |
185 | QTextStream procTs(&procFile); | 185 | QTextStream procTs(&procFile); |
186 | int loc = -1; | 186 | int loc = -1; |
187 | 187 | ||
188 | procTs.readLine(); // eat a line | 188 | procTs.readLine(); // eat a line |
189 | procTs.readLine(); // eat a line | 189 | procTs.readLine(); // eat a line |
190 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | 190 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { |
191 | if((loc = line.find(":")) != -1) { | 191 | if((loc = line.find(":")) != -1) { |
192 | ifaces += line.left(loc); | 192 | ifaces += line.left(loc); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { | 197 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { |
198 | int flags = 0; | 198 | int flags = 0; |
199 | // int family; | 199 | // int family; |
200 | i = NULL; | 200 | i = NULL; |
201 | 201 | ||
202 | strcpy(ifr.ifr_name, (*it).latin1()); | 202 | strcpy(ifr.ifr_name, (*it).latin1()); |
203 | 203 | ||
204 | struct ifreq ifcopy; | 204 | struct ifreq ifcopy; |
205 | ifcopy = ifr; | 205 | ifcopy = ifr; |
206 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 206 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
207 | flags = ifcopy.ifr_flags; | 207 | flags = ifcopy.ifr_flags; |
208 | i = new Interface(this, ifr.ifr_name, false); | 208 | i = new Interface(this, ifr.ifr_name, false); |
209 | i->setAttached(true); | 209 | i->setAttached(true); |
210 | if ((flags & IFF_UP) == IFF_UP) | 210 | if ((flags & IFF_UP) == IFF_UP) |
211 | i->setStatus(true); | 211 | i->setStatus(true); |
212 | else | 212 | else |
213 | i->setStatus(false); | 213 | i->setStatus(false); |
214 | 214 | ||
215 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 215 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
216 | i->setHardwareName("Ethernet"); | 216 | i->setHardwareName("Ethernet"); |
217 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 217 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
218 | i->setHardwareName("Point to Point"); | 218 | i->setHardwareName("Point to Point"); |
219 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 219 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
220 | i->setHardwareName("Multicast"); | 220 | i->setHardwareName("Multicast"); |
221 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 221 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
222 | i->setHardwareName("Loopback"); | 222 | i->setHardwareName("Loopback"); |
223 | else | 223 | else |
224 | i->setHardwareName("Unknown"); | 224 | i->setHardwareName("Unknown"); |
225 | 225 | ||
226 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); | 226 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); |
227 | interfaceNames.insert(i->getInterfaceName(), i); | 227 | interfaceNames.insert(i->getInterfaceName(), i); |
228 | updateInterface(i); | 228 | updateInterface(i); |
229 | connect(i, SIGNAL(updateInterface(Interface *)), | 229 | connect(i, SIGNAL(updateInterface(Interface *)), |
230 | this, SLOT(updateInterface(Interface *))); | 230 | this, SLOT(updateInterface(Interface *))); |
231 | } | 231 | } |
232 | // now lets ask the plugins too ;) | 232 | // now lets ask the plugins too ;) |
233 | QMap<Module*, QLibrary*>::Iterator it; | 233 | QMap<Module*, QLibrary*>::Iterator it; |
234 | QList<Interface> ilist; | 234 | QList<Interface> ilist; |
235 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 235 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
236 | if(it.key()){ | 236 | if(it.key()){ |
237 | ilist = it.key()->getInterfaces(); | 237 | ilist = it.key()->getInterfaces(); |
238 | for( i = ilist.first(); i != 0; i = ilist.next() ){ | 238 | for( i = ilist.first(); i != 0; i = ilist.next() ){ |
239 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | 239 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); |
240 | interfaceNames.insert(i->getInterfaceName(), i); | 240 | interfaceNames.insert(i->getInterfaceName(), i); |
241 | updateInterface(i); | 241 | updateInterface(i); |
242 | connect(i, SIGNAL(updateInterface(Interface *)), | 242 | connect(i, SIGNAL(updateInterface(Interface *)), |
243 | this, SLOT(updateInterface(Interface *))); | 243 | this, SLOT(updateInterface(Interface *))); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * Load all modules that are found in the path | 250 | * Load all modules that are found in the path |
251 | * @param path a directory that is scaned for any plugins that can be loaded | 251 | * @param path a directory that is scaned for any plugins that can be loaded |
252 | * and attempts to load them | 252 | * and attempts to load them |
253 | */ | 253 | */ |
254 | void MainWindowImp::loadModules(const QString &path){ | 254 | void MainWindowImp::loadModules(const QString &path){ |
255 | #ifdef DEBUG | 255 | #ifdef DEBUG |
256 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); | 256 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); |
257 | #endif | 257 | #endif |
258 | QDir d(path); | 258 | QDir d(path); |
259 | if(!d.exists()) | 259 | if(!d.exists()) |
260 | return; | 260 | return; |
261 | 261 | ||
262 | // Don't want sym links | 262 | // Don't want sym links |
263 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 263 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
264 | const QFileInfoList *list = d.entryInfoList(); | 264 | const QFileInfoList *list = d.entryInfoList(); |
265 | QFileInfoListIterator it( *list ); | 265 | QFileInfoListIterator it( *list ); |
266 | QFileInfo *fi; | 266 | QFileInfo *fi; |
267 | while ( (fi=it.current()) ) { | 267 | while ( (fi=it.current()) ) { |
268 | #ifdef QWS | 268 | #ifdef QWS |
269 | if(fi->fileName().contains(".so")){ | 269 | if(fi->fileName().contains(".so")){ |
270 | #else | 270 | #else |
271 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ | 271 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ |
272 | #endif | 272 | #endif |
273 | loadPlugin(path + "/" + fi->fileName()); | 273 | loadPlugin(path + "/" + fi->fileName()); |
274 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); | 274 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); |
275 | } | 275 | } |
276 | ++it; | 276 | ++it; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Attempt to load a function and resolve a function. | 281 | * Attempt to load a function and resolve a function. |
282 | * @param pluginFileName - the name of the file in which to attempt to load | 282 | * @param pluginFileName - the name of the file in which to attempt to load |
283 | * @param resolveString - function pointer to resolve | 283 | * @param resolveString - function pointer to resolve |
284 | * @return pointer to the function with name resolveString or NULL | 284 | * @return pointer to the function with name resolveString or NULL |
285 | */ | 285 | */ |
286 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ | 286 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ |
287 | #ifdef DEBUG | 287 | #ifdef DEBUG |
288 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); | 288 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); |
289 | #endif | 289 | #endif |
290 | #ifdef QWS | 290 | #ifdef QWS |
291 | QLibrary *lib = new QLibrary(pluginFileName); | 291 | QLibrary *lib = new QLibrary(pluginFileName); |
292 | void *functionPointer = lib->resolve(resolveString); | 292 | void *functionPointer = lib->resolve(resolveString); |
293 | if( !functionPointer ){ | 293 | if( !functionPointer ){ |
294 | #ifdef DEBUG | 294 | #ifdef DEBUG |
295 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); | 295 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); |
296 | #endif | 296 | #endif |
297 | delete lib; | 297 | delete lib; |
298 | return NULL; | 298 | return NULL; |
299 | } | 299 | } |
300 | // Try to get an object. | 300 | // Try to get an object. |
301 | Module *object = ((Module* (*)()) functionPointer)(); | 301 | Module *object = ((Module* (*)()) functionPointer)(); |
302 | if(object == NULL){ | 302 | if(object == NULL){ |
303 | #ifdef DEBUG | 303 | #ifdef DEBUG |
304 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 304 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
305 | #endif | 305 | #endif |
306 | delete lib; | 306 | delete lib; |
307 | return NULL; | 307 | return NULL; |
308 | } | 308 | } |
309 | 309 | ||
310 | // Store for deletion later | 310 | // Store for deletion later |
311 | libraries.insert(object, lib); | 311 | libraries.insert(object, lib); |
312 | return object; | 312 | return object; |
313 | 313 | ||
314 | #else | 314 | #else |
315 | QLibrary *lib = loader->library(pluginFileName); | 315 | QLibrary *lib = loader->library(pluginFileName); |
316 | if( !lib || !lib->hasSymbol(resolveString) ){ | 316 | if( !lib || !lib->hasSymbol(resolveString) ){ |
317 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 317 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
318 | return NULL; | 318 | return NULL; |
319 | } | 319 | } |
320 | // Try to get an object. | 320 | // Try to get an object. |
321 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); | 321 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); |
322 | if(object == NULL){ | 322 | if(object == NULL){ |
323 | #ifdef DEBUG | 323 | #ifdef DEBUG |
324 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 324 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
325 | #endif | 325 | #endif |
326 | return NULL; | 326 | return NULL; |