summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
authorbenmeyer <benmeyer>2002-11-08 16:16:11 (UTC)
committer benmeyer <benmeyer>2002-11-08 16:16:11 (UTC)
commite0db2259cc26cab12c6f1131b82dd867c454a3ff (patch) (unidiff)
treee251396e5e96839aed5bf6a930dff37fefe5acc0 /noncore/settings/networksettings/mainwindowimp.cpp
parentd8ac5b68b504536136347547816992b1cf605cd4 (diff)
downloadopie-e0db2259cc26cab12c6f1131b82dd867c454a3ff.zip
opie-e0db2259cc26cab12c6f1131b82dd867c454a3ff.tar.gz
opie-e0db2259cc26cab12c6f1131b82dd867c454a3ff.tar.bz2
Code Optimizations
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 48ef9b3..7b93554 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -9,49 +9,49 @@
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 14
15#include <qmainwindow.h> 15#include <qmainwindow.h>
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17 17
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/qlibrary.h> 19#include <qpe/qlibrary.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22 22
23#include <qlist.h> 23#include <qlist.h>
24#include <qdir.h> 24#include <qdir.h>
25#include <qfile.h> 25#include <qfile.h>
26#include <qtextstream.h> 26#include <qtextstream.h>
27 27
28#include <net/if.h> 28#include <net/if.h>
29#include <sys/ioctl.h> 29#include <sys/ioctl.h>
30 30
31#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 31#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
32 32
33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false), scheme(DEFAULT_SCHEME){
34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
38 38
39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
42 42
43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
44 // Load connections. 44 // Load connections.
45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
46 getAllInterfaces(); 46 getAllInterfaces();
47 47
48 Interfaces i; 48 Interfaces i;
49 QStringList list = i.getInterfaceList(); 49 QStringList list = i.getInterfaceList();
50 QMap<QString, Interface*>::Iterator it; 50 QMap<QString, Interface*>::Iterator it;
51 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 51 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
52 bool found = false; 52 bool found = false;
53 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 53 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
54 if(it.key() == (*ni)) 54 if(it.key() == (*ni))
55 found = true; 55 found = true;
56 } 56 }
57 if(!found){ 57 if(!found){
@@ -168,74 +168,74 @@ void MainWindowImp::getAllInterfaces(){
168 i->setHardwareName("Multicast"); 168 i->setHardwareName("Multicast");
169 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 169 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
170 i->setHardwareName("Loopback"); 170 i->setHardwareName("Loopback");
171 else 171 else
172 i->setHardwareName("Unknown"); 172 i->setHardwareName("Unknown");
173 173
174 interfaceNames.insert(i->getInterfaceName(), i); 174 interfaceNames.insert(i->getInterfaceName(), i);
175 updateInterface(i); 175 updateInterface(i);
176 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 176 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
177 break; 177 break;
178 178
179 default: 179 default:
180 qDebug(ifr->ifr_name); 180 qDebug(ifr->ifr_name);
181 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1()); 181 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1());
182 break; 182 break;
183 } 183 }
184 } 184 }
185} 185}
186 186
187/** 187/**
188 * Load all modules that are found in the path 188 * Load all modules that are found in the path
189 * @param path a directory that is scaned for any plugins that can be loaded 189 * @param path a directory that is scaned for any plugins that can be loaded
190 * and attempts to load them 190 * and attempts to load them
191 */ 191 */
192void MainWindowImp::loadModules(QString path){ 192void MainWindowImp::loadModules(const QString &path){
193 //qDebug(path.latin1()); 193 //qDebug(path.latin1());
194 QDir d(path); 194 QDir d(path);
195 if(!d.exists()) 195 if(!d.exists())
196 return; 196 return;
197 197
198 // Don't want sym links 198 // Don't want sym links
199 d.setFilter( QDir::Files | QDir::NoSymLinks ); 199 d.setFilter( QDir::Files | QDir::NoSymLinks );
200 const QFileInfoList *list = d.entryInfoList(); 200 const QFileInfoList *list = d.entryInfoList();
201 QFileInfoListIterator it( *list ); 201 QFileInfoListIterator it( *list );
202 QFileInfo *fi; 202 QFileInfo *fi;
203 while ( (fi=it.current()) ) { 203 while ( (fi=it.current()) ) {
204 if(fi->fileName().contains(".so")){ 204 if(fi->fileName().contains(".so")){
205 loadPlugin(path + "/" + fi->fileName()); 205 loadPlugin(path + "/" + fi->fileName());
206 } 206 }
207 ++it; 207 ++it;
208 } 208 }
209} 209}
210 210
211/** 211/**
212 * Attempt to load a function and resolve a function. 212 * Attempt to load a function and resolve a function.
213 * @param pluginFileName - the name of the file in which to attempt to load 213 * @param pluginFileName - the name of the file in which to attempt to load
214 * @param resolveString - function pointer to resolve 214 * @param resolveString - function pointer to resolve
215 * @return pointer to the function with name resolveString or NULL 215 * @return pointer to the function with name resolveString or NULL
216 */ 216 */
217Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 217Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
218 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 218 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
219 QLibrary *lib = new QLibrary(pluginFileName); 219 QLibrary *lib = new QLibrary(pluginFileName);
220 void *functionPointer = lib->resolve(resolveString); 220 void *functionPointer = lib->resolve(resolveString);
221 if( !functionPointer ){ 221 if( !functionPointer ){
222 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 222 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
223 delete lib; 223 delete lib;
224 return NULL; 224 return NULL;
225 } 225 }
226 226
227 // Try to get an object. 227 // Try to get an object.
228 Module *object = ((Module* (*)()) functionPointer)(); 228 Module *object = ((Module* (*)()) functionPointer)();
229 if(object == NULL){ 229 if(object == NULL){
230 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 230 qDebug("MainWindowImp: Couldn't create object, but did load library!");
231 delete lib; 231 delete lib;
232 return NULL; 232 return NULL;
233 } 233 }
234 234
235 // Store for deletion later 235 // Store for deletion later
236 libraries.insert(object, lib); 236 libraries.insert(object, lib);
237 return object; 237 return object;
238} 238}
239 239
240/** 240/**
241 * The Add button was clicked. Bring up the add dialog and if OK is hit 241 * The Add button was clicked. Bring up the add dialog and if OK is hit