summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp3
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp1
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp3
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp1
4 files changed, 2 insertions, 6 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 4a088cb..f9ca83b 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,484 +1,483 @@
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 6
7#include "module.h" 7#include "module.h"
8 8
9#include "kprocess.h" 9#include "kprocess.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtabwidget.h> 12#include <qtabwidget.h>
13#include <qlistbox.h> 13#include <qlistbox.h>
14#include <qlineedit.h> 14#include <qlineedit.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qheader.h> 16#include <qheader.h>
17#include <qlabel.h> 17#include <qlabel.h>
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qlibrary.h> 23#include <qpe/qlibrary.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26 26
27#include <qlist.h> 27#include <qlist.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
32#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
33#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
34 34
35#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 35#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
36 36
37MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 37MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
38 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 38 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
39 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 39 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
40 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 40 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
41 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 41 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
42 42
43 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 43 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
44 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 44 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
45 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 45 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
46 46
47 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 47 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
48 // Load connections. 48 // Load connections.
49 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 49 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
50 getInterfaceList(); 50 getInterfaceList();
51 connectionList->header()->hide(); 51 connectionList->header()->hide();
52 52
53 53
54 Config cfg("NetworkSetup"); 54 Config cfg("NetworkSetup");
55 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 55 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
56 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 56 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
57 profilesList->insertItem((*it)); 57 profilesList->insertItem((*it));
58 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 58 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
59 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 59 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
60 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); 60 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
61 61
62 QFile file(scheme); 62 QFile file(scheme);
63 if ( file.open(IO_ReadOnly) ) { // file opened successfully 63 if ( file.open(IO_ReadOnly) ) { // file opened successfully
64 QTextStream stream( &file ); // use a text stream 64 QTextStream stream( &file ); // use a text stream
65 while ( !stream.eof() ) { // until end of file... 65 while ( !stream.eof() ) { // until end of file...
66 QString line = stream.readLine(); // line of text excluding '\n' 66 QString line = stream.readLine(); // line of text excluding '\n'
67 if(line.contains("SCHEME")){ 67 if(line.contains("SCHEME")){
68 line = line.mid(7, line.length()); 68 line = line.mid(7, line.length());
69 currentProfileLabel->setText(line); 69 currentProfileLabel->setText(line);
70 break; 70 break;
71 } 71 }
72 } 72 }
73 file.close(); 73 file.close();
74 } 74 }
75} 75}
76 76
77/** 77/**
78 * Deconstructor. Save profiles. Delete loaded libraries. 78 * Deconstructor. Save profiles. Delete loaded libraries.
79 */ 79 */
80MainWindowImp::~MainWindowImp(){ 80MainWindowImp::~MainWindowImp(){
81 qDebug("Deleting main window");
82 // Save profiles. 81 // Save profiles.
83 Config cfg("NetworkSetup"); 82 Config cfg("NetworkSetup");
84 cfg.setGroup("General"); 83 cfg.setGroup("General");
85 cfg.writeEntry("Profiles", profiles.join(" ")); 84 cfg.writeEntry("Profiles", profiles.join(" "));
86 85
87 // Delete all interfaces that don't have owners. 86 // Delete all interfaces that don't have owners.
88 QMap<Interface*, QListViewItem*>::Iterator iIt; 87 QMap<Interface*, QListViewItem*>::Iterator iIt;
89 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 88 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
90 if(iIt.key()->getModuleOwner() == NULL) 89 if(iIt.key()->getModuleOwner() == NULL)
91 delete iIt.key(); 90 delete iIt.key();
92 } 91 }
93 92
94 // Delete Modules and Libraries 93 // Delete Modules and Libraries
95 QMap<Module*, QLibrary*>::Iterator it; 94 QMap<Module*, QLibrary*>::Iterator it;
96 for( it = libraries.begin(); it != libraries.end(); ++it ){ 95 for( it = libraries.begin(); it != libraries.end(); ++it ){
97 delete it.key(); 96 delete it.key();
97 // I wonder why I can't delete the libraries
98 //delete it.data(); 98 //delete it.data();
99 } 99 }
100 qDebug("Done deleting main window");
101} 100}
102 101
103/** 102/**
104 * Load all modules that are found in the path 103 * Load all modules that are found in the path
105 * @param path a directory that is scaned for any plugins that can be loaded 104 * @param path a directory that is scaned for any plugins that can be loaded
106 * and attempts to load them 105 * and attempts to load them
107 */ 106 */
108void MainWindowImp::loadModules(QString path){ 107void MainWindowImp::loadModules(QString path){
109 //qDebug(path.latin1()); 108 //qDebug(path.latin1());
110 QDir d(path); 109 QDir d(path);
111 if(!d.exists()) 110 if(!d.exists())
112 return; 111 return;
113 112
114 // Don't want sym links 113 // Don't want sym links
115 d.setFilter( QDir::Files | QDir::NoSymLinks ); 114 d.setFilter( QDir::Files | QDir::NoSymLinks );
116 const QFileInfoList *list = d.entryInfoList(); 115 const QFileInfoList *list = d.entryInfoList();
117 QFileInfoListIterator it( *list ); 116 QFileInfoListIterator it( *list );
118 QFileInfo *fi; 117 QFileInfo *fi;
119 while ( (fi=it.current()) ) { 118 while ( (fi=it.current()) ) {
120 if(fi->fileName().contains(".so")){ 119 if(fi->fileName().contains(".so")){
121 loadPlugin(path + "/" + fi->fileName()); 120 loadPlugin(path + "/" + fi->fileName());
122 } 121 }
123 ++it; 122 ++it;
124 } 123 }
125} 124}
126 125
127/** 126/**
128 * Attempt to load a function and resolve a function. 127 * Attempt to load a function and resolve a function.
129 * @param pluginFileName - the name of the file in which to attempt to load 128 * @param pluginFileName - the name of the file in which to attempt to load
130 * @param resolveString - function pointer to resolve 129 * @param resolveString - function pointer to resolve
131 * @return pointer to the function with name resolveString or NULL 130 * @return pointer to the function with name resolveString or NULL
132 */ 131 */
133Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 132Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
134 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 133 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
135 QLibrary *lib = new QLibrary(pluginFileName); 134 QLibrary *lib = new QLibrary(pluginFileName);
136 void *functionPointer = lib->resolve(resolveString); 135 void *functionPointer = lib->resolve(resolveString);
137 if( !functionPointer ){ 136 if( !functionPointer ){
138 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 137 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
139 delete lib; 138 delete lib;
140 return NULL; 139 return NULL;
141 } 140 }
142 141
143 // Try to get an object. 142 // Try to get an object.
144 Module *object = ((Module* (*)()) functionPointer)(); 143 Module *object = ((Module* (*)()) functionPointer)();
145 if(object == NULL){ 144 if(object == NULL){
146 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 145 qDebug("MainWindowImp: Couldn't create object, but did load library!");
147 delete lib; 146 delete lib;
148 return NULL; 147 return NULL;
149 } 148 }
150 149
151 // Store for deletion later 150 // Store for deletion later
152 libraries.insert(object, lib); 151 libraries.insert(object, lib);
153 return object; 152 return object;
154} 153}
155 154
156/** 155/**
157 * The Add button was clicked. Bring up the add dialog and if OK is hit 156 * The Add button was clicked. Bring up the add dialog and if OK is hit
158 * load the plugin and append it to the list 157 * load the plugin and append it to the list
159 */ 158 */
160void MainWindowImp::addClicked(){ 159void MainWindowImp::addClicked(){
161 QMap<Module*, QLibrary*>::Iterator it; 160 QMap<Module*, QLibrary*>::Iterator it;
162 QMap<QString, QString> list; 161 QMap<QString, QString> list;
163 QMap<QString, Module*> newInterfaceOwners; 162 QMap<QString, Module*> newInterfaceOwners;
164 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 163 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
165 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 164 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
166 for( it = libraries.begin(); it != libraries.end(); ++it ){ 165 for( it = libraries.begin(); it != libraries.end(); ++it ){
167 if(it.key()){ 166 if(it.key()){
168 (it.key())->possibleNewInterfaces(list); 167 (it.key())->possibleNewInterfaces(list);
169 } 168 }
170 } 169 }
171 // See if the list has anything that we can add. 170 // See if the list has anything that we can add.
172 if(list.count() == 0){ 171 if(list.count() == 0){
173 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 172 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
174 return; 173 return;
175 } 174 }
176 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 175 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
177 addNewConnection.addConnections(list); 176 addNewConnection.addConnections(list);
178 addNewConnection.showMaximized(); 177 addNewConnection.showMaximized();
179 if(QDialog::Accepted == addNewConnection.exec()){ 178 if(QDialog::Accepted == addNewConnection.exec()){
180 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 179 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
181 if(!item) 180 if(!item)
182 return; 181 return;
183 182
184 for( it = libraries.begin(); it != libraries.end(); ++it ){ 183 for( it = libraries.begin(); it != libraries.end(); ++it ){
185 if(it.key()){ 184 if(it.key()){
186 Interface *i = (it.key())->addNewInterface(item->text(0)); 185 Interface *i = (it.key())->addNewInterface(item->text(0));
187 if(i){ 186 if(i){
188 interfaceNames.insert(i->getInterfaceName(), i); 187 interfaceNames.insert(i->getInterfaceName(), i);
189 updateInterface(i); 188 updateInterface(i);
190 } 189 }
191 } 190 }
192 } 191 }
193 } 192 }
194} 193}
195 194
196/** 195/**
197 * Prompt the user to see if they really want to do this. 196 * Prompt the user to see if they really want to do this.
198 * If they do then remove from the list and unload. 197 * If they do then remove from the list and unload.
199 */ 198 */
200void MainWindowImp::removeClicked(){ 199void MainWindowImp::removeClicked(){
201 QListViewItem *item = connectionList->currentItem(); 200 QListViewItem *item = connectionList->currentItem();
202 if(!item) { 201 if(!item) {
203 QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); 202 QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok");
204 return; 203 return;
205 } 204 }
206 205
207 Interface *i = interfaceItems[item]; 206 Interface *i = interfaceItems[item];
208 if(i->getModuleOwner() == NULL){ 207 if(i->getModuleOwner() == NULL){
209 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 208 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
210 } 209 }
211 else{ 210 else{
212 if(!i->getModuleOwner()->remove(i)) 211 if(!i->getModuleOwner()->remove(i))
213 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 212 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
214 else{ 213 else{
215 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 214 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
216 // TODO memory managment.... 215 // TODO memory managment....
217 // who deletes the interface? 216 // who deletes the interface?
218 } 217 }
219 } 218 }
220} 219}
221 220
222/** 221/**
223 * Pull up the configure about the currently selected interface. 222 * Pull up the configure about the currently selected interface.
224 * Report an error if no interface is selected. 223 * Report an error if no interface is selected.
225 * If the interface has a module owner then request its configure with a empty 224 * If the interface has a module owner then request its configure with a empty
226 * tab. If tab is !NULL then append the interfaces setup widget to it. 225 * tab. If tab is !NULL then append the interfaces setup widget to it.
227 */ 226 */
228void MainWindowImp::configureClicked(){ 227void MainWindowImp::configureClicked(){
229 QListViewItem *item = connectionList->currentItem(); 228 QListViewItem *item = connectionList->currentItem();
230 if(!item){ 229 if(!item){
231 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 230 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
232 return; 231 return;
233 } 232 }
234 233
235 QString currentProfile = currentProfileLabel->text(); 234 QString currentProfile = currentProfileLabel->text();
236 if(profilesList->count() <= 1 || currentProfile == "All"){ 235 if(profilesList->count() <= 1 || currentProfile == "All"){
237 currentProfile = ""; 236 currentProfile = "";
238 } 237 }
239 238
240 Interface *i = interfaceItems[item]; 239 Interface *i = interfaceItems[item];
241 if(i->getModuleOwner()){ 240 if(i->getModuleOwner()){
242 i->getModuleOwner()->setProfile(currentProfile); 241 i->getModuleOwner()->setProfile(currentProfile);
243 QTabWidget *tabWidget = NULL; 242 QTabWidget *tabWidget = NULL;
244 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); 243 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
245 if(moduleConfigure != NULL){ 244 if(moduleConfigure != NULL){
246 if(tabWidget != NULL){ 245 if(tabWidget != NULL){
247 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose); 246 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
248 configure->setProfile(currentProfile); 247 configure->setProfile(currentProfile);
249 tabWidget->insertTab(configure, "TCP/IP"); 248 tabWidget->insertTab(configure, "TCP/IP");
250 } 249 }
251 moduleConfigure->showMaximized(); 250 moduleConfigure->showMaximized();
252 moduleConfigure->show(); 251 moduleConfigure->show();
253 return; 252 return;
254 } 253 }
255 } 254 }
256 255
257 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose); 256 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
258 configure->setProfile(currentProfile); 257 configure->setProfile(currentProfile);
259 configure->showMaximized(); 258 configure->showMaximized();
260 configure->show(); 259 configure->show();
261} 260}
262 261
263/** 262/**
264 * Pull up the information about the currently selected interface. 263 * Pull up the information about the currently selected interface.
265 * Report an error if no interface is selected. 264 * Report an error if no interface is selected.
266 * If the interface has a module owner then request its configure with a empty 265 * If the interface has a module owner then request its configure with a empty
267 * tab. If tab is !NULL then append the interfaces setup widget to it. 266 * tab. If tab is !NULL then append the interfaces setup widget to it.
268 */ 267 */
269void MainWindowImp::informationClicked(){ 268void MainWindowImp::informationClicked(){
270 QListViewItem *item = connectionList->currentItem(); 269 QListViewItem *item = connectionList->currentItem();
271 if(!item){ 270 if(!item){
272 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 271 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
273 return; 272 return;
274 } 273 }
275 274
276 Interface *i = interfaceItems[item]; 275 Interface *i = interfaceItems[item];
277 if(!i->isAttached()){ 276 if(!i->isAttached()){
278 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 277 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
279 return; 278 return;
280 } 279 }
281 280
282 QStringList list; 281 QStringList list;
283 for(uint i = 0; i < profilesList->count(); i++){ 282 for(uint i = 0; i < profilesList->count(); i++){
284 list.append(profilesList->text(i)); 283 list.append(profilesList->text(i));
285 } 284 }
286 285
287 if(i->getModuleOwner()){ 286 if(i->getModuleOwner()){
288 QTabWidget *tabWidget = NULL; 287 QTabWidget *tabWidget = NULL;
289 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); 288 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
290 if(moduleInformation != NULL){ 289 if(moduleInformation != NULL){
291 if(tabWidget != NULL){ 290 if(tabWidget != NULL){
292 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 291 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
293 tabWidget->insertTab(information, "TCP/IP"); 292 tabWidget->insertTab(information, "TCP/IP");
294 } 293 }
295 moduleInformation->showMaximized(); 294 moduleInformation->showMaximized();
296 moduleInformation->show(); 295 moduleInformation->show();
297 return; 296 return;
298 } 297 }
299 } 298 }
300 299
301 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 300 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
302 information->showMaximized(); 301 information->showMaximized();
303 information->show(); 302 information->show();
304} 303}
305 304
306/** 305/**
307 * Aquire the list of active interfaces from ifconfig 306 * Aquire the list of active interfaces from ifconfig
308 * Call ifconfig and ifconfig -a 307 * Call ifconfig and ifconfig -a
309 */ 308 */
310void MainWindowImp::getInterfaceList(){ 309void MainWindowImp::getInterfaceList(){
311 KShellProcess *processAll = new KShellProcess(); 310 KShellProcess *processAll = new KShellProcess();
312 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 311 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
313 connect(processAll, SIGNAL(processExited(KProcess *)), 312 connect(processAll, SIGNAL(processExited(KProcess *)),
314 this, SLOT(jobDone(KProcess *))); 313 this, SLOT(jobDone(KProcess *)));
315 threads.insert(processAll, TEMP_ALL); 314 threads.insert(processAll, TEMP_ALL);
316 315
317 KShellProcess *process = new KShellProcess(); 316 KShellProcess *process = new KShellProcess();
318 *process << "/sbin/ifconfig" << " > " TEMP_UP; 317 *process << "/sbin/ifconfig" << " > " TEMP_UP;
319 connect(process, SIGNAL(processExited(KProcess *)), 318 connect(process, SIGNAL(processExited(KProcess *)),
320 this, SLOT(jobDone(KProcess *))); 319 this, SLOT(jobDone(KProcess *)));
321 threads.insert(process, TEMP_UP); 320 threads.insert(process, TEMP_UP);
322 321
323 processAll->start(KShellProcess::NotifyOnExit); 322 processAll->start(KShellProcess::NotifyOnExit);
324 process->start(KShellProcess::NotifyOnExit); 323 process->start(KShellProcess::NotifyOnExit);
325} 324}
326 325
327void MainWindowImp::jobDone(KProcess *process){ 326void MainWindowImp::jobDone(KProcess *process){
328 QString fileName = threads[process]; 327 QString fileName = threads[process];
329 threads.remove(process); 328 threads.remove(process);
330 delete process; 329 delete process;
331 330
332 QFile file(fileName); 331 QFile file(fileName);
333 if (!file.open(IO_ReadOnly)){ 332 if (!file.open(IO_ReadOnly)){
334 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 333 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
335 return; 334 return;
336 } 335 }
337 336
338 QTextStream stream( &file ); 337 QTextStream stream( &file );
339 QString line; 338 QString line;
340 while ( !stream.eof() ) { 339 while ( !stream.eof() ) {
341 line = stream.readLine(); 340 line = stream.readLine();
342 int space = line.find(" "); 341 int space = line.find(" ");
343 if(space > 1){ 342 if(space > 1){
344 // We have found an interface 343 // We have found an interface
345 QString interfaceName = line.mid(0, space); 344 QString interfaceName = line.mid(0, space);
346 Interface *i; 345 Interface *i;
347 // We have found an interface 346 // We have found an interface
348 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 347 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
349 // See if we already have it 348 // See if we already have it
350 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 349 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
351 if(fileName == TEMP_ALL) 350 if(fileName == TEMP_ALL)
352 i = new Interface(this, interfaceName, false); 351 i = new Interface(this, interfaceName, false);
353 else 352 else
354 i = new Interface(this, interfaceName, true); 353 i = new Interface(this, interfaceName, true);
355 i->setAttached(true); 354 i->setAttached(true);
356 355
357 QString hardName = "Ethernet"; 356 QString hardName = "Ethernet";
358 int hardwareName = line.find("Link encap:"); 357 int hardwareName = line.find("Link encap:");
359 int macAddress = line.find("HWaddr"); 358 int macAddress = line.find("HWaddr");
360 if(macAddress == -1) 359 if(macAddress == -1)
361 macAddress = line.length(); 360 macAddress = line.length();
362 if(hardwareName != -1) 361 if(hardwareName != -1)
363 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); 362 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
364 363
365 interfaceNames.insert(i->getInterfaceName(), i); 364 interfaceNames.insert(i->getInterfaceName(), i);
366 updateInterface(i); 365 updateInterface(i);
367 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 366 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
368 } 367 }
369 // It was an interface we already had. 368 // It was an interface we already had.
370 else{ 369 else{
371 if(fileName != TEMP_ALL) 370 if(fileName != TEMP_ALL)
372 (interfaceNames[interfaceName])->setStatus(true); 371 (interfaceNames[interfaceName])->setStatus(true);
373 } 372 }
374 } 373 }
375 } 374 }
376 file.close(); 375 file.close();
377 QFile::remove(fileName); 376 QFile::remove(fileName);
378 377
379 if(threads.count() == 0){ 378 if(threads.count() == 0){
380 Interfaces i; 379 Interfaces i;
381 QStringList list = i.getInterfaceList(); 380 QStringList list = i.getInterfaceList();
382 QMap<QString, Interface*>::Iterator it; 381 QMap<QString, Interface*>::Iterator it;
383 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 382 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
384 bool found = false; 383 bool found = false;
385 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 384 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
386 if(it.key() == (*ni)) 385 if(it.key() == (*ni))
387 found = true; 386 found = true;
388 } 387 }
389 if(!found){ 388 if(!found){
390 if(!(*ni).contains("_")){ 389 if(!(*ni).contains("_")){
391 Interface *i = new Interface(this, *ni, false); 390 Interface *i = new Interface(this, *ni, false);
392 i->setAttached(false); 391 i->setAttached(false);
393 i->setHardwareName("Disconnected"); 392 i->setHardwareName("Disconnected");
394 interfaceNames.insert(i->getInterfaceName(), i); 393 interfaceNames.insert(i->getInterfaceName(), i);
395 updateInterface(i); 394 updateInterface(i);
396 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 395 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
397 } 396 }
398 } 397 }
399 } 398 }
400 } 399 }
401} 400}
402 401
403/** 402/**
404 * Update this interface. If no QListViewItem exists create one. 403 * Update this interface. If no QListViewItem exists create one.
405 * @param Interface* pointer to the interface that needs to be updated. 404 * @param Interface* pointer to the interface that needs to be updated.
406 */ 405 */
407void MainWindowImp::updateInterface(Interface *i){ 406void MainWindowImp::updateInterface(Interface *i){
408 if(!advancedUserMode){ 407 if(!advancedUserMode){
409 if(i->getInterfaceName() == "lo") 408 if(i->getInterfaceName() == "lo")
410 return; 409 return;
411 } 410 }
412 411
413 QListViewItem *item = NULL; 412 QListViewItem *item = NULL;
414 413
415 // Find the interface, making it if needed. 414 // Find the interface, making it if needed.
416 if(items.find(i) == items.end()){ 415 if(items.find(i) == items.end()){
417 item = new QListViewItem(connectionList, "", "", ""); 416 item = new QListViewItem(connectionList, "", "", "");
418 // See if you can't find a module owner for this interface 417 // See if you can't find a module owner for this interface
419 QMap<Module*, QLibrary*>::Iterator it; 418 QMap<Module*, QLibrary*>::Iterator it;
420 for( it = libraries.begin(); it != libraries.end(); ++it ){ 419 for( it = libraries.begin(); it != libraries.end(); ++it ){
421 if(it.key()->isOwner(i)) 420 if(it.key()->isOwner(i))
422 i->setModuleOwner(it.key()); 421 i->setModuleOwner(it.key());
423 } 422 }
424 items.insert(i, item); 423 items.insert(i, item);
425 interfaceItems.insert(item, i); 424 interfaceItems.insert(item, i);
426 } 425 }
427 else 426 else
428 item = items[i]; 427 item = items[i];
429 428
430 // Update the icons and information 429 // Update the icons and information
431 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 430 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
432 431
433 QString typeName = "lan"; 432 QString typeName = "lan";
434 if(i->getHardwareName().contains("Local Loopback")) 433 if(i->getHardwareName().contains("Local Loopback"))
435 typeName = "lo"; 434 typeName = "lo";
436 if(i->getInterfaceName().contains("irda")) 435 if(i->getInterfaceName().contains("irda"))
437 typeName = "irda"; 436 typeName = "irda";
438 if(i->getInterfaceName().contains("wlan")) 437 if(i->getInterfaceName().contains("wlan"))
439 typeName = "wlan"; 438 typeName = "wlan";
440 if(i->getInterfaceName().contains("usb")) 439 if(i->getInterfaceName().contains("usb"))
441 typeName = "usb"; 440 typeName = "usb";
442 441
443 if(!i->isAttached()) 442 if(!i->isAttached())
444 typeName = "connect_no"; 443 typeName = "connect_no";
445 // Actually try to use the Module 444 // Actually try to use the Module
446 if(i->getModuleOwner() != NULL) 445 if(i->getModuleOwner() != NULL)
447 typeName = i->getModuleOwner()->getPixmapName(i); 446 typeName = i->getModuleOwner()->getPixmapName(i);
448 447
449 item->setPixmap(1, (Resource::loadPixmap(typeName))); 448 item->setPixmap(1, (Resource::loadPixmap(typeName)));
450 item->setText(2, i->getHardwareName()); 449 item->setText(2, i->getHardwareName());
451 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 450 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
452 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 451 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
453} 452}
454 453
455void MainWindowImp::newProfileChanged(const QString& newText){ 454void MainWindowImp::newProfileChanged(const QString& newText){
456 if(newText.length() > 0) 455 if(newText.length() > 0)
457 newProfileButton->setEnabled(true); 456 newProfileButton->setEnabled(true);
458 else 457 else
459 newProfileButton->setEnabled(false); 458 newProfileButton->setEnabled(false);
460} 459}
461 460
462/** 461/**
463 * Adds a new profile to the list of profiles. 462 * Adds a new profile to the list of profiles.
464 * Don't add profiles that already exists. 463 * Don't add profiles that already exists.
465 * Appends to the list and QStringList 464 * Appends to the list and QStringList
466 */ 465 */
467void MainWindowImp::addProfile(){ 466void MainWindowImp::addProfile(){
468 QString newProfileName = newProfile->text(); 467 QString newProfileName = newProfile->text();
469 if(profiles.grep(newProfileName).count() > 0){ 468 if(profiles.grep(newProfileName).count() > 0){
470 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 469 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
471 return; 470 return;
472 } 471 }
473 profiles.append(newProfileName); 472 profiles.append(newProfileName);
474 profilesList->insertItem(newProfileName); 473 profilesList->insertItem(newProfileName);
475} 474}
476 475
477/** 476/**
478 * Removes the currently selected profile in the combo. 477 * Removes the currently selected profile in the combo.
479 * Doesn't delete if there are less then 2 profiles. 478 * Doesn't delete if there are less then 2 profiles.
480 */ 479 */
481void MainWindowImp::removeProfile(){ 480void MainWindowImp::removeProfile(){
482 if(profilesList->count() <= 1){ 481 if(profilesList->count() <= 1){
483 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); 482 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
484 return; 483 return;
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 3363b8a..bf2589e 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -1,126 +1,125 @@
1#include "wlanmodule.h" 1#include "wlanmodule.h"
2#include "wlanimp.h" 2#include "wlanimp.h"
3#include "info.h" 3#include "info.h"
4#include "wextensions.h" 4#include "wextensions.h"
5 5
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qprogressbar.h> 7#include <qprogressbar.h>
8 8
9/** 9/**
10 * Constructor, find all of the possible interfaces 10 * Constructor, find all of the possible interfaces
11 */ 11 */
12WLANModule::WLANModule() : Module() { 12WLANModule::WLANModule() : Module() {
13} 13}
14 14
15/** 15/**
16 */ 16 */
17WLANModule::~WLANModule(){ 17WLANModule::~WLANModule(){
18 qDebug("Deleting module");
19 Interface *i; 18 Interface *i;
20 for ( i=list.first(); i != 0; i=list.next() ) 19 for ( i=list.first(); i != 0; i=list.next() )
21 delete i; 20 delete i;
22} 21}
23 22
24/** 23/**
25 * Change the current profile 24 * Change the current profile
26 */ 25 */
27void WLANModule::setProfile(QString newProfile){ 26void WLANModule::setProfile(QString newProfile){
28 profile = newProfile; 27 profile = newProfile;
29} 28}
30 29
31/** 30/**
32 * get the icon name for this device. 31 * get the icon name for this device.
33 * @param Interface* can be used in determining the icon. 32 * @param Interface* can be used in determining the icon.
34 * @return QString the icon name (minus .png, .gif etc) 33 * @return QString the icon name (minus .png, .gif etc)
35 */ 34 */
36QString WLANModule::getPixmapName(Interface* ){ 35QString WLANModule::getPixmapName(Interface* ){
37 return "wlan"; 36 return "wlan";
38} 37}
39 38
40/** 39/**
41 * Check to see if the interface i is owned by this module. 40 * Check to see if the interface i is owned by this module.
42 * @param Interface* interface to check against 41 * @param Interface* interface to check against
43 * @return bool true if i is owned by this module, false otherwise. 42 * @return bool true if i is owned by this module, false otherwise.
44 */ 43 */
45bool WLANModule::isOwner(Interface *i){ 44bool WLANModule::isOwner(Interface *i){
46 WExtensions we(i->getInterfaceName()); 45 WExtensions we(i->getInterfaceName());
47 if(!we.doesHaveWirelessExtensions()) 46 if(!we.doesHaveWirelessExtensions())
48 return false; 47 return false;
49 48
50 i->setHardwareName("802.11b"); 49 i->setHardwareName("802.11b");
51 list.append(i); 50 list.append(i);
52 return true; 51 return true;
53} 52}
54 53
55/** 54/**
56 * Create, set tabWiget and return the WLANConfigure Module 55 * Create, set tabWiget and return the WLANConfigure Module
57 * @param tabWidget a pointer to the tab widget that this configure has. 56 * @param tabWidget a pointer to the tab widget that this configure has.
58 * @return QWidget* pointer to the tab widget in this modules configure. 57 * @return QWidget* pointer to the tab widget in this modules configure.
59 */ 58 */
60QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ 59QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){
61 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose); 60 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose);
62 (*tabWidget) = wlanconfig->tabWidget; 61 (*tabWidget) = wlanconfig->tabWidget;
63 return wlanconfig; 62 return wlanconfig;
64} 63}
65 64
66/** 65/**
67 * Create, set tabWiget and return the Information Module 66 * Create, set tabWiget and return the Information Module
68 * @param tabWidget a pointer to the tab widget that this information has. 67 * @param tabWidget a pointer to the tab widget that this information has.
69 * @return QWidget* pointer to the tab widget in this modules info. 68 * @return QWidget* pointer to the tab widget in this modules info.
70 */ 69 */
71QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 70QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
72 WExtensions we(i->getInterfaceName()); 71 WExtensions we(i->getInterfaceName());
73 if(!we.doesHaveWirelessExtensions()) 72 if(!we.doesHaveWirelessExtensions())
74 return NULL; 73 return NULL;
75 74
76 WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose); 75 WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose);
77 (*tabWidget) = info->tabWidget; 76 (*tabWidget) = info->tabWidget;
78 77
79 info->essidLabel->setText(we.essid()); 78 info->essidLabel->setText(we.essid());
80 info->apLabel->setText(we.ap()); 79 info->apLabel->setText(we.ap());
81 info->stationLabel->setText(we.station()); 80 info->stationLabel->setText(we.station());
82 info->modeLabel->setText(we.mode()); 81 info->modeLabel->setText(we.mode());
83 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); 82 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency()));
84 int signal = 0; 83 int signal = 0;
85 int noise = 0; 84 int noise = 0;
86 int quality = 0; 85 int quality = 0;
87 we.stats(signal, noise, quality); 86 we.stats(signal, noise, quality);
88 info->signalProgressBar->setProgress(signal); 87 info->signalProgressBar->setProgress(signal);
89 info->noiseProgressBar->setProgress(noise); 88 info->noiseProgressBar->setProgress(noise);
90 info->qualityProgressBar->setProgress(quality); 89 info->qualityProgressBar->setProgress(quality);
91 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); 90 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate()));
92 return info; 91 return info;
93} 92}
94 93
95/** 94/**
96 * Get all active (up or down) interfaces 95 * Get all active (up or down) interfaces
97 * @return QList<Interface> A list of interfaces that exsist that havn't 96 * @return QList<Interface> A list of interfaces that exsist that havn't
98 * been called by isOwner() 97 * been called by isOwner()
99 */ 98 */
100QList<Interface> WLANModule::getInterfaces(){ 99QList<Interface> WLANModule::getInterfaces(){
101 return list; 100 return list;
102} 101}
103 102
104/** 103/**
105 * Attempt to add a new interface as defined by name 104 * Attempt to add a new interface as defined by name
106 * @param name the name of the type of interface that should be created given 105 * @param name the name of the type of interface that should be created given
107 * by possibleNewInterfaces(); 106 * by possibleNewInterfaces();
108 * @return Interface* NULL if it was unable to be created. 107 * @return Interface* NULL if it was unable to be created.
109 */ 108 */
110Interface *WLANModule::addNewInterface(QString ){ 109Interface *WLANModule::addNewInterface(QString ){
111 // We can't add a 802.11 interface, either the hardware will be there 110 // We can't add a 802.11 interface, either the hardware will be there
112 // or it wont. 111 // or it wont.
113 return NULL; 112 return NULL;
114} 113}
115 114
116/** 115/**
117 * Attempts to remove the interface, doesn't delete i 116 * Attempts to remove the interface, doesn't delete i
118 * @return bool true if successfull, false otherwise. 117 * @return bool true if successfull, false otherwise.
119 */ 118 */
120bool WLANModule::remove(Interface*){ 119bool WLANModule::remove(Interface*){
121 // Can't remove a hardware device, you can stop it though. 120 // Can't remove a hardware device, you can stop it though.
122 return false; 121 return false;
123} 122}
124 123
125// wlanmodule.cpp 124// wlanmodule.cpp
126 125
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 4a088cb..f9ca83b 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,484 +1,483 @@
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 6
7#include "module.h" 7#include "module.h"
8 8
9#include "kprocess.h" 9#include "kprocess.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtabwidget.h> 12#include <qtabwidget.h>
13#include <qlistbox.h> 13#include <qlistbox.h>
14#include <qlineedit.h> 14#include <qlineedit.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qheader.h> 16#include <qheader.h>
17#include <qlabel.h> 17#include <qlabel.h>
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qlibrary.h> 23#include <qpe/qlibrary.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26 26
27#include <qlist.h> 27#include <qlist.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
32#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
33#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
34 34
35#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 35#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
36 36
37MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 37MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
38 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 38 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
39 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 39 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
40 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 40 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
41 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 41 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
42 42
43 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 43 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
44 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 44 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
45 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 45 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
46 46
47 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 47 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
48 // Load connections. 48 // Load connections.
49 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 49 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
50 getInterfaceList(); 50 getInterfaceList();
51 connectionList->header()->hide(); 51 connectionList->header()->hide();
52 52
53 53
54 Config cfg("NetworkSetup"); 54 Config cfg("NetworkSetup");
55 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 55 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
56 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 56 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
57 profilesList->insertItem((*it)); 57 profilesList->insertItem((*it));
58 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 58 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
59 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 59 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
60 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); 60 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
61 61
62 QFile file(scheme); 62 QFile file(scheme);
63 if ( file.open(IO_ReadOnly) ) { // file opened successfully 63 if ( file.open(IO_ReadOnly) ) { // file opened successfully
64 QTextStream stream( &file ); // use a text stream 64 QTextStream stream( &file ); // use a text stream
65 while ( !stream.eof() ) { // until end of file... 65 while ( !stream.eof() ) { // until end of file...
66 QString line = stream.readLine(); // line of text excluding '\n' 66 QString line = stream.readLine(); // line of text excluding '\n'
67 if(line.contains("SCHEME")){ 67 if(line.contains("SCHEME")){
68 line = line.mid(7, line.length()); 68 line = line.mid(7, line.length());
69 currentProfileLabel->setText(line); 69 currentProfileLabel->setText(line);
70 break; 70 break;
71 } 71 }
72 } 72 }
73 file.close(); 73 file.close();
74 } 74 }
75} 75}
76 76
77/** 77/**
78 * Deconstructor. Save profiles. Delete loaded libraries. 78 * Deconstructor. Save profiles. Delete loaded libraries.
79 */ 79 */
80MainWindowImp::~MainWindowImp(){ 80MainWindowImp::~MainWindowImp(){
81 qDebug("Deleting main window");
82 // Save profiles. 81 // Save profiles.
83 Config cfg("NetworkSetup"); 82 Config cfg("NetworkSetup");
84 cfg.setGroup("General"); 83 cfg.setGroup("General");
85 cfg.writeEntry("Profiles", profiles.join(" ")); 84 cfg.writeEntry("Profiles", profiles.join(" "));
86 85
87 // Delete all interfaces that don't have owners. 86 // Delete all interfaces that don't have owners.
88 QMap<Interface*, QListViewItem*>::Iterator iIt; 87 QMap<Interface*, QListViewItem*>::Iterator iIt;
89 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 88 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
90 if(iIt.key()->getModuleOwner() == NULL) 89 if(iIt.key()->getModuleOwner() == NULL)
91 delete iIt.key(); 90 delete iIt.key();
92 } 91 }
93 92
94 // Delete Modules and Libraries 93 // Delete Modules and Libraries
95 QMap<Module*, QLibrary*>::Iterator it; 94 QMap<Module*, QLibrary*>::Iterator it;
96 for( it = libraries.begin(); it != libraries.end(); ++it ){ 95 for( it = libraries.begin(); it != libraries.end(); ++it ){
97 delete it.key(); 96 delete it.key();
97 // I wonder why I can't delete the libraries
98 //delete it.data(); 98 //delete it.data();
99 } 99 }
100 qDebug("Done deleting main window");
101} 100}
102 101
103/** 102/**
104 * Load all modules that are found in the path 103 * Load all modules that are found in the path
105 * @param path a directory that is scaned for any plugins that can be loaded 104 * @param path a directory that is scaned for any plugins that can be loaded
106 * and attempts to load them 105 * and attempts to load them
107 */ 106 */
108void MainWindowImp::loadModules(QString path){ 107void MainWindowImp::loadModules(QString path){
109 //qDebug(path.latin1()); 108 //qDebug(path.latin1());
110 QDir d(path); 109 QDir d(path);
111 if(!d.exists()) 110 if(!d.exists())
112 return; 111 return;
113 112
114 // Don't want sym links 113 // Don't want sym links
115 d.setFilter( QDir::Files | QDir::NoSymLinks ); 114 d.setFilter( QDir::Files | QDir::NoSymLinks );
116 const QFileInfoList *list = d.entryInfoList(); 115 const QFileInfoList *list = d.entryInfoList();
117 QFileInfoListIterator it( *list ); 116 QFileInfoListIterator it( *list );
118 QFileInfo *fi; 117 QFileInfo *fi;
119 while ( (fi=it.current()) ) { 118 while ( (fi=it.current()) ) {
120 if(fi->fileName().contains(".so")){ 119 if(fi->fileName().contains(".so")){
121 loadPlugin(path + "/" + fi->fileName()); 120 loadPlugin(path + "/" + fi->fileName());
122 } 121 }
123 ++it; 122 ++it;
124 } 123 }
125} 124}
126 125
127/** 126/**
128 * Attempt to load a function and resolve a function. 127 * Attempt to load a function and resolve a function.
129 * @param pluginFileName - the name of the file in which to attempt to load 128 * @param pluginFileName - the name of the file in which to attempt to load
130 * @param resolveString - function pointer to resolve 129 * @param resolveString - function pointer to resolve
131 * @return pointer to the function with name resolveString or NULL 130 * @return pointer to the function with name resolveString or NULL
132 */ 131 */
133Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 132Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
134 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 133 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
135 QLibrary *lib = new QLibrary(pluginFileName); 134 QLibrary *lib = new QLibrary(pluginFileName);
136 void *functionPointer = lib->resolve(resolveString); 135 void *functionPointer = lib->resolve(resolveString);
137 if( !functionPointer ){ 136 if( !functionPointer ){
138 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 137 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
139 delete lib; 138 delete lib;
140 return NULL; 139 return NULL;
141 } 140 }
142 141
143 // Try to get an object. 142 // Try to get an object.
144 Module *object = ((Module* (*)()) functionPointer)(); 143 Module *object = ((Module* (*)()) functionPointer)();
145 if(object == NULL){ 144 if(object == NULL){
146 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 145 qDebug("MainWindowImp: Couldn't create object, but did load library!");
147 delete lib; 146 delete lib;
148 return NULL; 147 return NULL;
149 } 148 }
150 149
151 // Store for deletion later 150 // Store for deletion later
152 libraries.insert(object, lib); 151 libraries.insert(object, lib);
153 return object; 152 return object;
154} 153}
155 154
156/** 155/**
157 * The Add button was clicked. Bring up the add dialog and if OK is hit 156 * The Add button was clicked. Bring up the add dialog and if OK is hit
158 * load the plugin and append it to the list 157 * load the plugin and append it to the list
159 */ 158 */
160void MainWindowImp::addClicked(){ 159void MainWindowImp::addClicked(){
161 QMap<Module*, QLibrary*>::Iterator it; 160 QMap<Module*, QLibrary*>::Iterator it;
162 QMap<QString, QString> list; 161 QMap<QString, QString> list;
163 QMap<QString, Module*> newInterfaceOwners; 162 QMap<QString, Module*> newInterfaceOwners;
164 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 163 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
165 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 164 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
166 for( it = libraries.begin(); it != libraries.end(); ++it ){ 165 for( it = libraries.begin(); it != libraries.end(); ++it ){
167 if(it.key()){ 166 if(it.key()){
168 (it.key())->possibleNewInterfaces(list); 167 (it.key())->possibleNewInterfaces(list);
169 } 168 }
170 } 169 }
171 // See if the list has anything that we can add. 170 // See if the list has anything that we can add.
172 if(list.count() == 0){ 171 if(list.count() == 0){
173 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 172 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
174 return; 173 return;
175 } 174 }
176 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 175 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
177 addNewConnection.addConnections(list); 176 addNewConnection.addConnections(list);
178 addNewConnection.showMaximized(); 177 addNewConnection.showMaximized();
179 if(QDialog::Accepted == addNewConnection.exec()){ 178 if(QDialog::Accepted == addNewConnection.exec()){
180 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 179 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
181 if(!item) 180 if(!item)
182 return; 181 return;
183 182
184 for( it = libraries.begin(); it != libraries.end(); ++it ){ 183 for( it = libraries.begin(); it != libraries.end(); ++it ){
185 if(it.key()){ 184 if(it.key()){
186 Interface *i = (it.key())->addNewInterface(item->text(0)); 185 Interface *i = (it.key())->addNewInterface(item->text(0));
187 if(i){ 186 if(i){
188 interfaceNames.insert(i->getInterfaceName(), i); 187 interfaceNames.insert(i->getInterfaceName(), i);
189 updateInterface(i); 188 updateInterface(i);
190 } 189 }
191 } 190 }
192 } 191 }
193 } 192 }
194} 193}
195 194
196/** 195/**
197 * Prompt the user to see if they really want to do this. 196 * Prompt the user to see if they really want to do this.
198 * If they do then remove from the list and unload. 197 * If they do then remove from the list and unload.
199 */ 198 */
200void MainWindowImp::removeClicked(){ 199void MainWindowImp::removeClicked(){
201 QListViewItem *item = connectionList->currentItem(); 200 QListViewItem *item = connectionList->currentItem();
202 if(!item) { 201 if(!item) {
203 QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); 202 QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok");
204 return; 203 return;
205 } 204 }
206 205
207 Interface *i = interfaceItems[item]; 206 Interface *i = interfaceItems[item];
208 if(i->getModuleOwner() == NULL){ 207 if(i->getModuleOwner() == NULL){
209 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 208 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
210 } 209 }
211 else{ 210 else{
212 if(!i->getModuleOwner()->remove(i)) 211 if(!i->getModuleOwner()->remove(i))
213 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 212 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
214 else{ 213 else{
215 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 214 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
216 // TODO memory managment.... 215 // TODO memory managment....
217 // who deletes the interface? 216 // who deletes the interface?
218 } 217 }
219 } 218 }
220} 219}
221 220
222/** 221/**
223 * Pull up the configure about the currently selected interface. 222 * Pull up the configure about the currently selected interface.
224 * Report an error if no interface is selected. 223 * Report an error if no interface is selected.
225 * If the interface has a module owner then request its configure with a empty 224 * If the interface has a module owner then request its configure with a empty
226 * tab. If tab is !NULL then append the interfaces setup widget to it. 225 * tab. If tab is !NULL then append the interfaces setup widget to it.
227 */ 226 */
228void MainWindowImp::configureClicked(){ 227void MainWindowImp::configureClicked(){
229 QListViewItem *item = connectionList->currentItem(); 228 QListViewItem *item = connectionList->currentItem();
230 if(!item){ 229 if(!item){
231 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 230 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
232 return; 231 return;
233 } 232 }
234 233
235 QString currentProfile = currentProfileLabel->text(); 234 QString currentProfile = currentProfileLabel->text();
236 if(profilesList->count() <= 1 || currentProfile == "All"){ 235 if(profilesList->count() <= 1 || currentProfile == "All"){
237 currentProfile = ""; 236 currentProfile = "";
238 } 237 }
239 238
240 Interface *i = interfaceItems[item]; 239 Interface *i = interfaceItems[item];
241 if(i->getModuleOwner()){ 240 if(i->getModuleOwner()){
242 i->getModuleOwner()->setProfile(currentProfile); 241 i->getModuleOwner()->setProfile(currentProfile);
243 QTabWidget *tabWidget = NULL; 242 QTabWidget *tabWidget = NULL;
244 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); 243 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
245 if(moduleConfigure != NULL){ 244 if(moduleConfigure != NULL){
246 if(tabWidget != NULL){ 245 if(tabWidget != NULL){
247 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose); 246 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
248 configure->setProfile(currentProfile); 247 configure->setProfile(currentProfile);
249 tabWidget->insertTab(configure, "TCP/IP"); 248 tabWidget->insertTab(configure, "TCP/IP");
250 } 249 }
251 moduleConfigure->showMaximized(); 250 moduleConfigure->showMaximized();
252 moduleConfigure->show(); 251 moduleConfigure->show();
253 return; 252 return;
254 } 253 }
255 } 254 }
256 255
257 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose); 256 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
258 configure->setProfile(currentProfile); 257 configure->setProfile(currentProfile);
259 configure->showMaximized(); 258 configure->showMaximized();
260 configure->show(); 259 configure->show();
261} 260}
262 261
263/** 262/**
264 * Pull up the information about the currently selected interface. 263 * Pull up the information about the currently selected interface.
265 * Report an error if no interface is selected. 264 * Report an error if no interface is selected.
266 * If the interface has a module owner then request its configure with a empty 265 * If the interface has a module owner then request its configure with a empty
267 * tab. If tab is !NULL then append the interfaces setup widget to it. 266 * tab. If tab is !NULL then append the interfaces setup widget to it.
268 */ 267 */
269void MainWindowImp::informationClicked(){ 268void MainWindowImp::informationClicked(){
270 QListViewItem *item = connectionList->currentItem(); 269 QListViewItem *item = connectionList->currentItem();
271 if(!item){ 270 if(!item){
272 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 271 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
273 return; 272 return;
274 } 273 }
275 274
276 Interface *i = interfaceItems[item]; 275 Interface *i = interfaceItems[item];
277 if(!i->isAttached()){ 276 if(!i->isAttached()){
278 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 277 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
279 return; 278 return;
280 } 279 }
281 280
282 QStringList list; 281 QStringList list;
283 for(uint i = 0; i < profilesList->count(); i++){ 282 for(uint i = 0; i < profilesList->count(); i++){
284 list.append(profilesList->text(i)); 283 list.append(profilesList->text(i));
285 } 284 }
286 285
287 if(i->getModuleOwner()){ 286 if(i->getModuleOwner()){
288 QTabWidget *tabWidget = NULL; 287 QTabWidget *tabWidget = NULL;
289 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); 288 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
290 if(moduleInformation != NULL){ 289 if(moduleInformation != NULL){
291 if(tabWidget != NULL){ 290 if(tabWidget != NULL){
292 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 291 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
293 tabWidget->insertTab(information, "TCP/IP"); 292 tabWidget->insertTab(information, "TCP/IP");
294 } 293 }
295 moduleInformation->showMaximized(); 294 moduleInformation->showMaximized();
296 moduleInformation->show(); 295 moduleInformation->show();
297 return; 296 return;
298 } 297 }
299 } 298 }
300 299
301 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 300 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
302 information->showMaximized(); 301 information->showMaximized();
303 information->show(); 302 information->show();
304} 303}
305 304
306/** 305/**
307 * Aquire the list of active interfaces from ifconfig 306 * Aquire the list of active interfaces from ifconfig
308 * Call ifconfig and ifconfig -a 307 * Call ifconfig and ifconfig -a
309 */ 308 */
310void MainWindowImp::getInterfaceList(){ 309void MainWindowImp::getInterfaceList(){
311 KShellProcess *processAll = new KShellProcess(); 310 KShellProcess *processAll = new KShellProcess();
312 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 311 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
313 connect(processAll, SIGNAL(processExited(KProcess *)), 312 connect(processAll, SIGNAL(processExited(KProcess *)),
314 this, SLOT(jobDone(KProcess *))); 313 this, SLOT(jobDone(KProcess *)));
315 threads.insert(processAll, TEMP_ALL); 314 threads.insert(processAll, TEMP_ALL);
316 315
317 KShellProcess *process = new KShellProcess(); 316 KShellProcess *process = new KShellProcess();
318 *process << "/sbin/ifconfig" << " > " TEMP_UP; 317 *process << "/sbin/ifconfig" << " > " TEMP_UP;
319 connect(process, SIGNAL(processExited(KProcess *)), 318 connect(process, SIGNAL(processExited(KProcess *)),
320 this, SLOT(jobDone(KProcess *))); 319 this, SLOT(jobDone(KProcess *)));
321 threads.insert(process, TEMP_UP); 320 threads.insert(process, TEMP_UP);
322 321
323 processAll->start(KShellProcess::NotifyOnExit); 322 processAll->start(KShellProcess::NotifyOnExit);
324 process->start(KShellProcess::NotifyOnExit); 323 process->start(KShellProcess::NotifyOnExit);
325} 324}
326 325
327void MainWindowImp::jobDone(KProcess *process){ 326void MainWindowImp::jobDone(KProcess *process){
328 QString fileName = threads[process]; 327 QString fileName = threads[process];
329 threads.remove(process); 328 threads.remove(process);
330 delete process; 329 delete process;
331 330
332 QFile file(fileName); 331 QFile file(fileName);
333 if (!file.open(IO_ReadOnly)){ 332 if (!file.open(IO_ReadOnly)){
334 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 333 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
335 return; 334 return;
336 } 335 }
337 336
338 QTextStream stream( &file ); 337 QTextStream stream( &file );
339 QString line; 338 QString line;
340 while ( !stream.eof() ) { 339 while ( !stream.eof() ) {
341 line = stream.readLine(); 340 line = stream.readLine();
342 int space = line.find(" "); 341 int space = line.find(" ");
343 if(space > 1){ 342 if(space > 1){
344 // We have found an interface 343 // We have found an interface
345 QString interfaceName = line.mid(0, space); 344 QString interfaceName = line.mid(0, space);
346 Interface *i; 345 Interface *i;
347 // We have found an interface 346 // We have found an interface
348 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 347 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
349 // See if we already have it 348 // See if we already have it
350 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 349 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
351 if(fileName == TEMP_ALL) 350 if(fileName == TEMP_ALL)
352 i = new Interface(this, interfaceName, false); 351 i = new Interface(this, interfaceName, false);
353 else 352 else
354 i = new Interface(this, interfaceName, true); 353 i = new Interface(this, interfaceName, true);
355 i->setAttached(true); 354 i->setAttached(true);
356 355
357 QString hardName = "Ethernet"; 356 QString hardName = "Ethernet";
358 int hardwareName = line.find("Link encap:"); 357 int hardwareName = line.find("Link encap:");
359 int macAddress = line.find("HWaddr"); 358 int macAddress = line.find("HWaddr");
360 if(macAddress == -1) 359 if(macAddress == -1)
361 macAddress = line.length(); 360 macAddress = line.length();
362 if(hardwareName != -1) 361 if(hardwareName != -1)
363 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); 362 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
364 363
365 interfaceNames.insert(i->getInterfaceName(), i); 364 interfaceNames.insert(i->getInterfaceName(), i);
366 updateInterface(i); 365 updateInterface(i);
367 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 366 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
368 } 367 }
369 // It was an interface we already had. 368 // It was an interface we already had.
370 else{ 369 else{
371 if(fileName != TEMP_ALL) 370 if(fileName != TEMP_ALL)
372 (interfaceNames[interfaceName])->setStatus(true); 371 (interfaceNames[interfaceName])->setStatus(true);
373 } 372 }
374 } 373 }
375 } 374 }
376 file.close(); 375 file.close();
377 QFile::remove(fileName); 376 QFile::remove(fileName);
378 377
379 if(threads.count() == 0){ 378 if(threads.count() == 0){
380 Interfaces i; 379 Interfaces i;
381 QStringList list = i.getInterfaceList(); 380 QStringList list = i.getInterfaceList();
382 QMap<QString, Interface*>::Iterator it; 381 QMap<QString, Interface*>::Iterator it;
383 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 382 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
384 bool found = false; 383 bool found = false;
385 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 384 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
386 if(it.key() == (*ni)) 385 if(it.key() == (*ni))
387 found = true; 386 found = true;
388 } 387 }
389 if(!found){ 388 if(!found){
390 if(!(*ni).contains("_")){ 389 if(!(*ni).contains("_")){
391 Interface *i = new Interface(this, *ni, false); 390 Interface *i = new Interface(this, *ni, false);
392 i->setAttached(false); 391 i->setAttached(false);
393 i->setHardwareName("Disconnected"); 392 i->setHardwareName("Disconnected");
394 interfaceNames.insert(i->getInterfaceName(), i); 393 interfaceNames.insert(i->getInterfaceName(), i);
395 updateInterface(i); 394 updateInterface(i);
396 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 395 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
397 } 396 }
398 } 397 }
399 } 398 }
400 } 399 }
401} 400}
402 401
403/** 402/**
404 * Update this interface. If no QListViewItem exists create one. 403 * Update this interface. If no QListViewItem exists create one.
405 * @param Interface* pointer to the interface that needs to be updated. 404 * @param Interface* pointer to the interface that needs to be updated.
406 */ 405 */
407void MainWindowImp::updateInterface(Interface *i){ 406void MainWindowImp::updateInterface(Interface *i){
408 if(!advancedUserMode){ 407 if(!advancedUserMode){
409 if(i->getInterfaceName() == "lo") 408 if(i->getInterfaceName() == "lo")
410 return; 409 return;
411 } 410 }
412 411
413 QListViewItem *item = NULL; 412 QListViewItem *item = NULL;
414 413
415 // Find the interface, making it if needed. 414 // Find the interface, making it if needed.
416 if(items.find(i) == items.end()){ 415 if(items.find(i) == items.end()){
417 item = new QListViewItem(connectionList, "", "", ""); 416 item = new QListViewItem(connectionList, "", "", "");
418 // See if you can't find a module owner for this interface 417 // See if you can't find a module owner for this interface
419 QMap<Module*, QLibrary*>::Iterator it; 418 QMap<Module*, QLibrary*>::Iterator it;
420 for( it = libraries.begin(); it != libraries.end(); ++it ){ 419 for( it = libraries.begin(); it != libraries.end(); ++it ){
421 if(it.key()->isOwner(i)) 420 if(it.key()->isOwner(i))
422 i->setModuleOwner(it.key()); 421 i->setModuleOwner(it.key());
423 } 422 }
424 items.insert(i, item); 423 items.insert(i, item);
425 interfaceItems.insert(item, i); 424 interfaceItems.insert(item, i);
426 } 425 }
427 else 426 else
428 item = items[i]; 427 item = items[i];
429 428
430 // Update the icons and information 429 // Update the icons and information
431 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 430 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
432 431
433 QString typeName = "lan"; 432 QString typeName = "lan";
434 if(i->getHardwareName().contains("Local Loopback")) 433 if(i->getHardwareName().contains("Local Loopback"))
435 typeName = "lo"; 434 typeName = "lo";
436 if(i->getInterfaceName().contains("irda")) 435 if(i->getInterfaceName().contains("irda"))
437 typeName = "irda"; 436 typeName = "irda";
438 if(i->getInterfaceName().contains("wlan")) 437 if(i->getInterfaceName().contains("wlan"))
439 typeName = "wlan"; 438 typeName = "wlan";
440 if(i->getInterfaceName().contains("usb")) 439 if(i->getInterfaceName().contains("usb"))
441 typeName = "usb"; 440 typeName = "usb";
442 441
443 if(!i->isAttached()) 442 if(!i->isAttached())
444 typeName = "connect_no"; 443 typeName = "connect_no";
445 // Actually try to use the Module 444 // Actually try to use the Module
446 if(i->getModuleOwner() != NULL) 445 if(i->getModuleOwner() != NULL)
447 typeName = i->getModuleOwner()->getPixmapName(i); 446 typeName = i->getModuleOwner()->getPixmapName(i);
448 447
449 item->setPixmap(1, (Resource::loadPixmap(typeName))); 448 item->setPixmap(1, (Resource::loadPixmap(typeName)));
450 item->setText(2, i->getHardwareName()); 449 item->setText(2, i->getHardwareName());
451 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 450 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
452 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 451 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
453} 452}
454 453
455void MainWindowImp::newProfileChanged(const QString& newText){ 454void MainWindowImp::newProfileChanged(const QString& newText){
456 if(newText.length() > 0) 455 if(newText.length() > 0)
457 newProfileButton->setEnabled(true); 456 newProfileButton->setEnabled(true);
458 else 457 else
459 newProfileButton->setEnabled(false); 458 newProfileButton->setEnabled(false);
460} 459}
461 460
462/** 461/**
463 * Adds a new profile to the list of profiles. 462 * Adds a new profile to the list of profiles.
464 * Don't add profiles that already exists. 463 * Don't add profiles that already exists.
465 * Appends to the list and QStringList 464 * Appends to the list and QStringList
466 */ 465 */
467void MainWindowImp::addProfile(){ 466void MainWindowImp::addProfile(){
468 QString newProfileName = newProfile->text(); 467 QString newProfileName = newProfile->text();
469 if(profiles.grep(newProfileName).count() > 0){ 468 if(profiles.grep(newProfileName).count() > 0){
470 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 469 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
471 return; 470 return;
472 } 471 }
473 profiles.append(newProfileName); 472 profiles.append(newProfileName);
474 profilesList->insertItem(newProfileName); 473 profilesList->insertItem(newProfileName);
475} 474}
476 475
477/** 476/**
478 * Removes the currently selected profile in the combo. 477 * Removes the currently selected profile in the combo.
479 * Doesn't delete if there are less then 2 profiles. 478 * Doesn't delete if there are less then 2 profiles.
480 */ 479 */
481void MainWindowImp::removeProfile(){ 480void MainWindowImp::removeProfile(){
482 if(profilesList->count() <= 1){ 481 if(profilesList->count() <= 1){
483 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); 482 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
484 return; 483 return;
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 3363b8a..bf2589e 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,126 +1,125 @@
1#include "wlanmodule.h" 1#include "wlanmodule.h"
2#include "wlanimp.h" 2#include "wlanimp.h"
3#include "info.h" 3#include "info.h"
4#include "wextensions.h" 4#include "wextensions.h"
5 5
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qprogressbar.h> 7#include <qprogressbar.h>
8 8
9/** 9/**
10 * Constructor, find all of the possible interfaces 10 * Constructor, find all of the possible interfaces
11 */ 11 */
12WLANModule::WLANModule() : Module() { 12WLANModule::WLANModule() : Module() {
13} 13}
14 14
15/** 15/**
16 */ 16 */
17WLANModule::~WLANModule(){ 17WLANModule::~WLANModule(){
18 qDebug("Deleting module");
19 Interface *i; 18 Interface *i;
20 for ( i=list.first(); i != 0; i=list.next() ) 19 for ( i=list.first(); i != 0; i=list.next() )
21 delete i; 20 delete i;
22} 21}
23 22
24/** 23/**
25 * Change the current profile 24 * Change the current profile
26 */ 25 */
27void WLANModule::setProfile(QString newProfile){ 26void WLANModule::setProfile(QString newProfile){
28 profile = newProfile; 27 profile = newProfile;
29} 28}
30 29
31/** 30/**
32 * get the icon name for this device. 31 * get the icon name for this device.
33 * @param Interface* can be used in determining the icon. 32 * @param Interface* can be used in determining the icon.
34 * @return QString the icon name (minus .png, .gif etc) 33 * @return QString the icon name (minus .png, .gif etc)
35 */ 34 */
36QString WLANModule::getPixmapName(Interface* ){ 35QString WLANModule::getPixmapName(Interface* ){
37 return "wlan"; 36 return "wlan";
38} 37}
39 38
40/** 39/**
41 * Check to see if the interface i is owned by this module. 40 * Check to see if the interface i is owned by this module.
42 * @param Interface* interface to check against 41 * @param Interface* interface to check against
43 * @return bool true if i is owned by this module, false otherwise. 42 * @return bool true if i is owned by this module, false otherwise.
44 */ 43 */
45bool WLANModule::isOwner(Interface *i){ 44bool WLANModule::isOwner(Interface *i){
46 WExtensions we(i->getInterfaceName()); 45 WExtensions we(i->getInterfaceName());
47 if(!we.doesHaveWirelessExtensions()) 46 if(!we.doesHaveWirelessExtensions())
48 return false; 47 return false;
49 48
50 i->setHardwareName("802.11b"); 49 i->setHardwareName("802.11b");
51 list.append(i); 50 list.append(i);
52 return true; 51 return true;
53} 52}
54 53
55/** 54/**
56 * Create, set tabWiget and return the WLANConfigure Module 55 * Create, set tabWiget and return the WLANConfigure Module
57 * @param tabWidget a pointer to the tab widget that this configure has. 56 * @param tabWidget a pointer to the tab widget that this configure has.
58 * @return QWidget* pointer to the tab widget in this modules configure. 57 * @return QWidget* pointer to the tab widget in this modules configure.
59 */ 58 */
60QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ 59QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){
61 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose); 60 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose);
62 (*tabWidget) = wlanconfig->tabWidget; 61 (*tabWidget) = wlanconfig->tabWidget;
63 return wlanconfig; 62 return wlanconfig;
64} 63}
65 64
66/** 65/**
67 * Create, set tabWiget and return the Information Module 66 * Create, set tabWiget and return the Information Module
68 * @param tabWidget a pointer to the tab widget that this information has. 67 * @param tabWidget a pointer to the tab widget that this information has.
69 * @return QWidget* pointer to the tab widget in this modules info. 68 * @return QWidget* pointer to the tab widget in this modules info.
70 */ 69 */
71QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 70QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
72 WExtensions we(i->getInterfaceName()); 71 WExtensions we(i->getInterfaceName());
73 if(!we.doesHaveWirelessExtensions()) 72 if(!we.doesHaveWirelessExtensions())
74 return NULL; 73 return NULL;
75 74
76 WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose); 75 WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose);
77 (*tabWidget) = info->tabWidget; 76 (*tabWidget) = info->tabWidget;
78 77
79 info->essidLabel->setText(we.essid()); 78 info->essidLabel->setText(we.essid());
80 info->apLabel->setText(we.ap()); 79 info->apLabel->setText(we.ap());
81 info->stationLabel->setText(we.station()); 80 info->stationLabel->setText(we.station());
82 info->modeLabel->setText(we.mode()); 81 info->modeLabel->setText(we.mode());
83 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); 82 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency()));
84 int signal = 0; 83 int signal = 0;
85 int noise = 0; 84 int noise = 0;
86 int quality = 0; 85 int quality = 0;
87 we.stats(signal, noise, quality); 86 we.stats(signal, noise, quality);
88 info->signalProgressBar->setProgress(signal); 87 info->signalProgressBar->setProgress(signal);
89 info->noiseProgressBar->setProgress(noise); 88 info->noiseProgressBar->setProgress(noise);
90 info->qualityProgressBar->setProgress(quality); 89 info->qualityProgressBar->setProgress(quality);
91 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); 90 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate()));
92 return info; 91 return info;
93} 92}
94 93
95/** 94/**
96 * Get all active (up or down) interfaces 95 * Get all active (up or down) interfaces
97 * @return QList<Interface> A list of interfaces that exsist that havn't 96 * @return QList<Interface> A list of interfaces that exsist that havn't
98 * been called by isOwner() 97 * been called by isOwner()
99 */ 98 */
100QList<Interface> WLANModule::getInterfaces(){ 99QList<Interface> WLANModule::getInterfaces(){
101 return list; 100 return list;
102} 101}
103 102
104/** 103/**
105 * Attempt to add a new interface as defined by name 104 * Attempt to add a new interface as defined by name
106 * @param name the name of the type of interface that should be created given 105 * @param name the name of the type of interface that should be created given
107 * by possibleNewInterfaces(); 106 * by possibleNewInterfaces();
108 * @return Interface* NULL if it was unable to be created. 107 * @return Interface* NULL if it was unable to be created.
109 */ 108 */
110Interface *WLANModule::addNewInterface(QString ){ 109Interface *WLANModule::addNewInterface(QString ){
111 // We can't add a 802.11 interface, either the hardware will be there 110 // We can't add a 802.11 interface, either the hardware will be there
112 // or it wont. 111 // or it wont.
113 return NULL; 112 return NULL;
114} 113}
115 114
116/** 115/**
117 * Attempts to remove the interface, doesn't delete i 116 * Attempts to remove the interface, doesn't delete i
118 * @return bool true if successfull, false otherwise. 117 * @return bool true if successfull, false otherwise.
119 */ 118 */
120bool WLANModule::remove(Interface*){ 119bool WLANModule::remove(Interface*){
121 // Can't remove a hardware device, you can stop it though. 120 // Can't remove a hardware device, you can stop it though.
122 return false; 121 return false;
123} 122}
124 123
125// wlanmodule.cpp 124// wlanmodule.cpp
126 125