summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-22 21:04:58 (UTC)
committer benmeyer <benmeyer>2002-10-22 21:04:58 (UTC)
commitc306ba7e1c73ec200b1621d224fc77f45e798e13 (patch) (unidiff)
tree1eb110c64b99c2e6ea2f8ab44c053f1e65f320f3
parent1e1b3e398d6b978a9c2bbd85d8f6b7aafbf72b2f (diff)
downloadopie-c306ba7e1c73ec200b1621d224fc77f45e798e13.zip
opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.tar.gz
opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.tar.bz2
Fix segfault
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO6
-rw-r--r--noncore/net/networksetup/interface.cpp4
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp2
-rw-r--r--noncore/net/networksetup/wlan/wextensions.cpp2
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.cpp2
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp20
-rw-r--r--noncore/settings/networksettings/TODO6
-rw-r--r--noncore/settings/networksettings/interface.cpp4
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp20
12 files changed, 36 insertions, 36 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 7a71142..d61c510 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,11 +1,9 @@
1WLAN needs to be re-written to not use Config 1WLAN needs to be re-written to not use Config
2-remove WLAN Config item 2WHERE Is DHCP info stored???
3-sub class out the wlan info
4-check if an interface supports wireless extensions before config.
5 3
6PPP module needs to be written 4PPP module needs to be written
7 5
8Write a class that parses /proc and not ifconfig 6Write a class that parses /proc and not ifconfig
9 7
10Possible other modules: ipsec, bluetooth 8Possible other modules: ipsec, bluetooth, ipchains
11 9
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index a84b91f..929b3a1 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -1,270 +1,270 @@
1#include "interface.h" 1#include "interface.h"
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7 7
8#define IFCONFIG "/sbin/ifconfig" 8#define IFCONFIG "/sbin/ifconfig"
9#define HDCP_INFO_DIR "/etc/dhcpc" 9#define DHCP_INFO_DIR "/etc/dhcpc"
10 10
11#include <stdio.h> 11#include <stdio.h>
12#include <stdlib.h> 12#include <stdlib.h>
13 13
14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ 14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
15 refresh(); 15 refresh();
16} 16}
17 17
18/** 18/**
19 * Set status 19 * Set status
20 * @param newStatus - the new status 20 * @param newStatus - the new status
21 * emit updateInterface 21 * emit updateInterface
22 */ 22 */
23void Interface::setStatus(bool newStatus){ 23void Interface::setStatus(bool newStatus){
24 if(status != newStatus){ 24 if(status != newStatus){
25 status = newStatus; 25 status = newStatus;
26 refresh(); 26 refresh();
27 } 27 }
28}; 28};
29 29
30/** 30/**
31 * Set if attached or not (802.11 card pulled out for example) 31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached 32 * @param isAttached - if attached
33 * emit updateInterface 33 * emit updateInterface
34 */ 34 */
35void Interface::setAttached(bool isAttached){ 35void Interface::setAttached(bool isAttached){
36 attached = isAttached; 36 attached = isAttached;
37 emit(updateInterface(this)); 37 emit(updateInterface(this));
38}; 38};
39 39
40/** 40/**
41 * Set Hardware name 41 * Set Hardware name
42 * @param name - the new name 42 * @param name - the new name
43 * emit updateInterface 43 * emit updateInterface
44 */ 44 */
45void Interface::setHardwareName(QString name){ 45void Interface::setHardwareName(QString name){
46 hardwareName = name; 46 hardwareName = name;
47 emit(updateInterface(this)); 47 emit(updateInterface(this));
48}; 48};
49 49
50/** 50/**
51 * Set Module owner 51 * Set Module owner
52 * @param owner - the new owner 52 * @param owner - the new owner
53 * emit updateInterface 53 * emit updateInterface
54 */ 54 */
55void Interface::setModuleOwner(Module *owner){ 55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner; 56 moduleOwner = owner;
57 emit(updateInterface(this)); 57 emit(updateInterface(this));
58}; 58};
59 59
60 60
61/** 61/**
62 * Try to start the interface. 62 * Try to start the interface.
63 */ 63 */
64void Interface::start(){ 64void Interface::start(){
65 // check to see if we are already running. 65 // check to see if we are already running.
66 if(true == status) 66 if(true == status)
67 return; 67 return;
68 68
69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); 69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
70 // See if it was successfull... 70 // See if it was successfull...
71 if(ret != 0) 71 if(ret != 0)
72 return; 72 return;
73 73
74 status = true; 74 status = true;
75 refresh(); 75 refresh();
76} 76}
77 77
78/** 78/**
79 * Try to stop the interface. 79 * Try to stop the interface.
80 */ 80 */
81void Interface::stop(){ 81void Interface::stop(){
82 // check to see if we are already stopped. 82 // check to see if we are already stopped.
83 if(false == status) 83 if(false == status)
84 return; 84 return;
85 85
86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); 86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
87 if(ret != 0) 87 if(ret != 0)
88 return; 88 return;
89 89
90 status = true; 90 status = true;
91 refresh(); 91 refresh();
92} 92}
93 93
94/** 94/**
95 * Try to restart the interface. 95 * Try to restart the interface.
96 */ 96 */
97void Interface::restart(){ 97void Interface::restart(){
98 stop(); 98 stop();
99 start(); 99 start();
100} 100}
101 101
102/** 102/**
103 * Try to refresh the information about the interface. 103 * Try to refresh the information about the interface.
104 * First call ifconfig, then check the dhcp-info file 104 * First call ifconfig, then check the dhcp-info file
105 * @return bool true if successfull. 105 * @return bool true if successfull.
106 */ 106 */
107bool Interface::refresh(){ 107bool Interface::refresh(){
108 // See if we are up. 108 // See if we are up.
109 if(status == false){ 109 if(status == false){
110 macAddress = ""; 110 macAddress = "";
111 ip = "0.0.0.0"; 111 ip = "0.0.0.0";
112 subnetMask = "0.0.0.0"; 112 subnetMask = "0.0.0.0";
113 broadcast = ""; 113 broadcast = "";
114 dhcp = false; 114 dhcp = false;
115 dhcpServerIp = ""; 115 dhcpServerIp = "";
116 leaseObtained = ""; 116 leaseObtained = "";
117 leaseExpires = ""; 117 leaseExpires = "";
118 emit(updateInterface(this)); 118 emit(updateInterface(this));
119 return true; 119 return true;
120 } 120 }
121 121
122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); 122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); 123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
124 if(ret != 0){ 124 if(ret != 0){
125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
126 return false; 126 return false;
127 } 127 }
128 128
129 QFile file(fileName); 129 QFile file(fileName);
130 if (!file.open(IO_ReadOnly)){ 130 if (!file.open(IO_ReadOnly)){
131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
132 return false; 132 return false;
133 } 133 }
134 134
135 // Set to the defaults 135 // Set to the defaults
136 macAddress = ""; 136 macAddress = "";
137 ip = "0.0.0.0"; 137 ip = "0.0.0.0";
138 subnetMask = "0.0.0.0"; 138 subnetMask = "0.0.0.0";
139 broadcast = ""; 139 broadcast = "";
140 140
141 QTextStream stream( &file ); 141 QTextStream stream( &file );
142 QString line; 142 QString line;
143 while ( !stream.eof() ) { 143 while ( !stream.eof() ) {
144 line = stream.readLine(); 144 line = stream.readLine();
145 if(line.contains("HWaddr")){ 145 if(line.contains("HWaddr")){
146 int mac = line.find("HWaddr"); 146 int mac = line.find("HWaddr");
147 macAddress = line.mid(mac+7, line.length()); 147 macAddress = line.mid(mac+7, line.length());
148 } 148 }
149 if(line.contains("inet addr")){ 149 if(line.contains("inet addr")){
150 int ipl = line.find("inet addr"); 150 int ipl = line.find("inet addr");
151 int space = line.find(" ", ipl+10); 151 int space = line.find(" ", ipl+10);
152 ip = line.mid(ipl+10, space-ipl-10); 152 ip = line.mid(ipl+10, space-ipl-10);
153 } 153 }
154 if(line.contains("Mask")){ 154 if(line.contains("Mask")){
155 int mask = line.find("Mask"); 155 int mask = line.find("Mask");
156 subnetMask = line.mid(mask+5, line.length()); 156 subnetMask = line.mid(mask+5, line.length());
157 } 157 }
158 if(line.contains("Bcast")){ 158 if(line.contains("Bcast")){
159 int mask = line.find("Bcast"); 159 int mask = line.find("Bcast");
160 int space = line.find(" ", mask+6); 160 int space = line.find(" ", mask+6);
161 broadcast = line.mid(mask+6, space-mask-6); 161 broadcast = line.mid(mask+6, space-mask-6);
162 } 162 }
163 } 163 }
164 file.close(); 164 file.close();
165 QFile::remove(fileName); 165 QFile::remove(fileName);
166 166
167 // DHCP TESTING 167 // DHCP TESTING
168 // reset DHCP info 168 // reset DHCP info
169 dhcpServerIp = ""; 169 dhcpServerIp = "";
170 leaseObtained = ""; 170 leaseObtained = "";
171 leaseExpires = ""; 171 leaseExpires = "";
172 dhcp = false; 172 dhcp = false;
173 173
174 QString dhcpDirectory(HDCP_INFO_DIR); 174 QString dhcpDirectory(DHCP_INFO_DIR);
175 QDir d(dhcpDirectory); 175 QDir d(dhcpDirectory);
176 if(!d.exists(dhcpDirectory)) 176 if(!d.exists(dhcpDirectory))
177 dhcpDirectory = "/var/run"; 177 dhcpDirectory = "/var/run";
178 178
179 // See if we have 179 // See if we have
180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); 180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
181 // If there is no DHCP information then exit now with no errors. 181 // If there is no DHCP information then exit now with no errors.
182 if(!QFile::exists(dhcpFile)){ 182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this)); 183 emit(updateInterface(this));
184 return true; 184 return true;
185 } 185 }
186 186
187 file.setName(dhcpFile); 187 file.setName(dhcpFile);
188 if (!file.open(IO_ReadOnly)){ 188 if (!file.open(IO_ReadOnly)){
189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
190 return false; 190 return false;
191 } 191 }
192 192
193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
194 int leaseTime = 0; 194 int leaseTime = 0;
195 int renewalTime = 0; 195 int renewalTime = 0;
196 196
197 stream.setDevice( &file ); 197 stream.setDevice( &file );
198 while ( !stream.eof() ) { 198 while ( !stream.eof() ) {
199 line = stream.readLine(); 199 line = stream.readLine();
200 if(line.contains("DHCPSIADDR=")) 200 if(line.contains("DHCPSIADDR="))
201 dhcpServerIp = line.mid(11, line.length()); 201 dhcpServerIp = line.mid(11, line.length());
202 if(line.contains("LEASETIME=")) 202 if(line.contains("LEASETIME="))
203 leaseTime = line.mid(10, line.length()).toInt(); 203 leaseTime = line.mid(10, line.length()).toInt();
204 if(line.contains("RENEWALTIME=")) 204 if(line.contains("RENEWALTIME="))
205 renewalTime = line.mid(12, line.length()).toInt(); 205 renewalTime = line.mid(12, line.length()).toInt();
206 } 206 }
207 file.close(); 207 file.close();
208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
210 210
211 // Get the pid of the deamond 211 // Get the pid of the deamond
212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); 212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
213 file.setName(dhcpFile); 213 file.setName(dhcpFile);
214 if (!file.open(IO_ReadOnly)){ 214 if (!file.open(IO_ReadOnly)){
215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
216 return false; 216 return false;
217 } 217 }
218 218
219 int pid = -1; 219 int pid = -1;
220 stream.setDevice( &file ); 220 stream.setDevice( &file );
221 while ( !stream.eof() ) { 221 while ( !stream.eof() ) {
222 line = stream.readLine(); 222 line = stream.readLine();
223 pid = line.toInt(); 223 pid = line.toInt();
224 } 224 }
225 file.close(); 225 file.close();
226 226
227 if( pid == -1){ 227 if( pid == -1){
228 qDebug("Interface: Could not get pid of dhcpc deamon."); 228 qDebug("Interface: Could not get pid of dhcpc deamon.");
229 return false; 229 return false;
230 } 230 }
231 231
232 // Get the start running time of the deamon 232 // Get the start running time of the deamon
233 fileName = (QString("/proc/%1/stat").arg(pid)); 233 fileName = (QString("/proc/%1/stat").arg(pid));
234 file.setName(fileName); 234 file.setName(fileName);
235 stream.setDevice( &file ); 235 stream.setDevice( &file );
236 if (!file.open(IO_ReadOnly)){ 236 if (!file.open(IO_ReadOnly)){
237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
238 return false; 238 return false;
239 } 239 }
240 while ( !stream.eof() ) { 240 while ( !stream.eof() ) {
241 line = stream.readLine(); 241 line = stream.readLine();
242 } 242 }
243 file.close(); 243 file.close();
244 long time = 0; 244 long time = 0;
245 // Grab the start time 245 // Grab the start time
246 // pid com state ppid pgrp session tty_nr tpgid flags 246 // pid com state ppid pgrp session tty_nr tpgid flags
247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
250 // nice 0 itrealvalue starttime 250 // nice 0 itrealvalue starttime
251 "%*d %*d %*d %lu", (long*) &time); 251 "%*d %*d %*d %lu", (long*) &time);
252 time = time/100; 252 time = time/100;
253 253
254 QDateTime datetime(QDateTime::currentDateTime()); 254 QDateTime datetime(QDateTime::currentDateTime());
255 255
256 // Get the uptime of the computer. 256 // Get the uptime of the computer.
257 QFile f("/proc/uptime"); 257 QFile f("/proc/uptime");
258 if ( f.open(IO_ReadOnly) ) { // file opened successfully 258 if ( f.open(IO_ReadOnly) ) { // file opened successfully
259 QTextStream t( &f ); // use a text stream 259 QTextStream t( &f ); // use a text stream
260 int sec = 0; 260 int sec = 0;
261 t >> sec; 261 t >> sec;
262 datetime = datetime.addSecs((-1*sec)); 262 datetime = datetime.addSecs((-1*sec));
263 f.close(); 263 f.close();
264 } 264 }
265 else{ 265 else{
266 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 266 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
267 return false; 267 return false;
268 } 268 }
269 269
270 datetime = datetime.addSecs(time); 270 datetime = datetime.addSecs(time);
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 9d81ab1..c86acdc 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,194 +1,196 @@
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("start Saving mainwindow");
81 // Save profiles. 82 // Save profiles.
82 Config cfg("NetworkSetup"); 83 Config cfg("NetworkSetup");
83 cfg.setGroup("General"); 84 cfg.setGroup("General");
84 cfg.writeEntry("Profiles", profiles.join(" ")); 85 cfg.writeEntry("Profiles", profiles.join(" "));
85 86
86 // Delete all interfaces that don't have owners. 87 // Delete all interfaces that don't have owners.
87 QMap<Interface*, QListViewItem*>::Iterator iIt; 88 QMap<Interface*, QListViewItem*>::Iterator iIt;
88 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 89 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
89 if(iIt.key()->getModuleOwner() == NULL) 90 if(iIt.key()->getModuleOwner() == NULL)
90 delete iIt.key(); 91 delete iIt.key();
91 } 92 }
92 93
93 // Delete Modules and Libraries 94 // Delete Modules and Libraries
94 QMap<Module*, QLibrary*>::Iterator it; 95 QMap<Module*, QLibrary*>::Iterator it;
95 for( it = libraries.begin(); it != libraries.end(); ++it ){ 96 for( it = libraries.begin(); it != libraries.end(); ++it ){
96 delete it.key(); 97 delete it.key();
97 delete it.data(); 98 delete it.data();
98 } 99 }
100 qDebug("done Saving mainwindow");
99} 101}
100 102
101/** 103/**
102 * Load all modules that are found in the path 104 * Load all modules that are found in the path
103 * @param path a directory that is scaned for any plugins that can be loaded 105 * @param path a directory that is scaned for any plugins that can be loaded
104 * and attempts to load them 106 * and attempts to load them
105 */ 107 */
106void MainWindowImp::loadModules(QString path){ 108void MainWindowImp::loadModules(QString path){
107 //qDebug(path.latin1()); 109 //qDebug(path.latin1());
108 QDir d(path); 110 QDir d(path);
109 if(!d.exists()) 111 if(!d.exists())
110 return; 112 return;
111 113
112 // Don't want sym links 114 // Don't want sym links
113 d.setFilter( QDir::Files | QDir::NoSymLinks ); 115 d.setFilter( QDir::Files | QDir::NoSymLinks );
114 const QFileInfoList *list = d.entryInfoList(); 116 const QFileInfoList *list = d.entryInfoList();
115 QFileInfoListIterator it( *list ); 117 QFileInfoListIterator it( *list );
116 QFileInfo *fi; 118 QFileInfo *fi;
117 while ( (fi=it.current()) ) { 119 while ( (fi=it.current()) ) {
118 if(fi->fileName().contains(".so")){ 120 if(fi->fileName().contains(".so")){
119 loadPlugin(path + "/" + fi->fileName()); 121 loadPlugin(path + "/" + fi->fileName());
120 } 122 }
121 ++it; 123 ++it;
122 } 124 }
123} 125}
124 126
125/** 127/**
126 * Attempt to load a function and resolve a function. 128 * Attempt to load a function and resolve a function.
127 * @param pluginFileName - the name of the file in which to attempt to load 129 * @param pluginFileName - the name of the file in which to attempt to load
128 * @param resolveString - function pointer to resolve 130 * @param resolveString - function pointer to resolve
129 * @return pointer to the function with name resolveString or NULL 131 * @return pointer to the function with name resolveString or NULL
130 */ 132 */
131Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 133Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
132 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 134 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
133 QLibrary *lib = new QLibrary(pluginFileName); 135 QLibrary *lib = new QLibrary(pluginFileName);
134 void *functionPointer = lib->resolve(resolveString); 136 void *functionPointer = lib->resolve(resolveString);
135 if( !functionPointer ){ 137 if( !functionPointer ){
136 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 138 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
137 delete lib; 139 delete lib;
138 return NULL; 140 return NULL;
139 } 141 }
140 142
141 // Try to get an object. 143 // Try to get an object.
142 Module *object = ((Module* (*)()) functionPointer)(); 144 Module *object = ((Module* (*)()) functionPointer)();
143 if(object == NULL){ 145 if(object == NULL){
144 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 146 qDebug("MainWindowImp: Couldn't create object, but did load library!");
145 delete lib; 147 delete lib;
146 return NULL; 148 return NULL;
147 } 149 }
148 150
149 // Store for deletion later 151 // Store for deletion later
150 libraries.insert(object, lib); 152 libraries.insert(object, lib);
151 return object; 153 return object;
152} 154}
153 155
154/** 156/**
155 * The Add button was clicked. Bring up the add dialog and if OK is hit 157 * The Add button was clicked. Bring up the add dialog and if OK is hit
156 * load the plugin and append it to the list 158 * load the plugin and append it to the list
157 */ 159 */
158void MainWindowImp::addClicked(){ 160void MainWindowImp::addClicked(){
159 QMap<Module*, QLibrary*>::Iterator it; 161 QMap<Module*, QLibrary*>::Iterator it;
160 QMap<QString, QString> list; 162 QMap<QString, QString> list;
161 QMap<QString, Module*> newInterfaceOwners; 163 QMap<QString, Module*> newInterfaceOwners;
162 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 164 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
163 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 165 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
164 for( it = libraries.begin(); it != libraries.end(); ++it ){ 166 for( it = libraries.begin(); it != libraries.end(); ++it ){
165 if(it.key()){ 167 if(it.key()){
166 (it.key())->possibleNewInterfaces(list); 168 (it.key())->possibleNewInterfaces(list);
167 } 169 }
168 } 170 }
169 // See if the list has anything that we can add. 171 // See if the list has anything that we can add.
170 if(list.count() == 0){ 172 if(list.count() == 0){
171 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 173 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
172 return; 174 return;
173 } 175 }
174 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 176 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
175 addNewConnection.addConnections(list); 177 addNewConnection.addConnections(list);
176 addNewConnection.showMaximized(); 178 addNewConnection.showMaximized();
177 if(QDialog::Accepted == addNewConnection.exec()){ 179 if(QDialog::Accepted == addNewConnection.exec()){
178 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 180 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
179 if(!item) 181 if(!item)
180 return; 182 return;
181 183
182 for( it = libraries.begin(); it != libraries.end(); ++it ){ 184 for( it = libraries.begin(); it != libraries.end(); ++it ){
183 if(it.key()){ 185 if(it.key()){
184 Interface *i = (it.key())->addNewInterface(item->text(0)); 186 Interface *i = (it.key())->addNewInterface(item->text(0));
185 if(i){ 187 if(i){
186 interfaceNames.insert(i->getInterfaceName(), i); 188 interfaceNames.insert(i->getInterfaceName(), i);
187 updateInterface(i); 189 updateInterface(i);
188 } 190 }
189 } 191 }
190 } 192 }
191 } 193 }
192} 194}
193 195
194/** 196/**
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp
index ef4ba8f..e545bd1 100644
--- a/noncore/net/networksetup/wlan/wextensions.cpp
+++ b/noncore/net/networksetup/wlan/wextensions.cpp
@@ -64,112 +64,112 @@ QString WExtensions::essid(){
64 return QString(); 64 return QString();
65 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ 65 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){
66 iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; 66 iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
67 return QString(iwr.u.essid.pointer); 67 return QString(iwr.u.essid.pointer);
68 } 68 }
69 return QString(); 69 return QString();
70} 70}
71 71
72/** 72/**
73 * @return QString the mode of interface 73 * @return QString the mode of interface
74 */ 74 */
75QString WExtensions::mode(){ 75QString WExtensions::mode(){
76 if(!hasWirelessExtensions) 76 if(!hasWirelessExtensions)
77 return QString(); 77 return QString();
78 if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) 78 if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) )
79 return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); 79 return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed");
80 return QString(); 80 return QString();
81} 81}
82 82
83/** 83/**
84 * Get the frequency that the interface is running at. 84 * Get the frequency that the interface is running at.
85 * @return int the frequency that the interfacae is running at. 85 * @return int the frequency that the interfacae is running at.
86 */ 86 */
87double WExtensions::frequency(){ 87double WExtensions::frequency(){
88 if(!hasWirelessExtensions) 88 if(!hasWirelessExtensions)
89 return 0; 89 return 0;
90 if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) 90 if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr ))
91 return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); 91 return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
92 return 0; 92 return 0;
93} 93}
94 94
95/*** 95/***
96 * Get the current rate that the card is transmiting at. 96 * Get the current rate that the card is transmiting at.
97 */ 97 */
98double WExtensions::rate(){ 98double WExtensions::rate(){
99 if(!hasWirelessExtensions) 99 if(!hasWirelessExtensions)
100 return 0; 100 return 0;
101 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ 101 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){
102 return ((double)iwr.u.bitrate.value)/1000000; 102 return ((double)iwr.u.bitrate.value)/1000000;
103 } 103 }
104 return 0; 104 return 0;
105} 105}
106 106
107 107
108/** 108/**
109 * @return QString the AccessPoint that the interface is connected to. 109 * @return QString the AccessPoint that the interface is connected to.
110 */ 110 */
111QString WExtensions::ap(){ 111QString WExtensions::ap(){
112 if(!hasWirelessExtensions) 112 if(!hasWirelessExtensions)
113 return QString(); 113 return QString();
114 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ 114 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){
115 QString ap; 115 QString ap;
116 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 116 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
117 iwr.u.ap_addr.sa_data[0]&0xff, 117 iwr.u.ap_addr.sa_data[0]&0xff,
118 iwr.u.ap_addr.sa_data[1]&0xff, 118 iwr.u.ap_addr.sa_data[1]&0xff,
119 iwr.u.ap_addr.sa_data[2]&0xff, 119 iwr.u.ap_addr.sa_data[2]&0xff,
120 iwr.u.ap_addr.sa_data[3]&0xff, 120 iwr.u.ap_addr.sa_data[3]&0xff,
121 iwr.u.ap_addr.sa_data[4]&0xff, 121 iwr.u.ap_addr.sa_data[4]&0xff,
122 iwr.u.ap_addr.sa_data[5]&0xff ); 122 iwr.u.ap_addr.sa_data[5]&0xff );
123 return ap; 123 return ap;
124 } 124 }
125 else return QString(); 125 else return QString();
126} 126}
127 127
128/** 128/**
129 * Get the stats for interfaces 129 * Get the stats for interfaces
130 * @param signal the signal strength of interface 130 * @param signal the signal strength of interface
131 * @param noise the noise level of the interface 131 * @param noise the noise level of the interface
132 * @param quality the quality level of the interface 132 * @param quality the quality level of the interface
133 * @return bool true if successfull 133 * @return bool true if successfull
134 */ 134 */
135bool WExtensions::stats(int &signal, int &noise, int &quality){ 135bool WExtensions::stats(int &signal, int &noise, int &quality){
136 // gather link quality from /proc/net/wireless 136 // gather link quality from /proc/net/wireless
137 if(!QFile::exists(PROCNETWIRELESS)) 137 if(!QFile::exists(PROCNETWIRELESS))
138 return false; 138 return false;
139 139
140 char c; 140 char c;
141 QString status; 141 QString status;
142 QString name; 142 QString name;
143 143
144 QFile wfile( PROCNETWIRELESS ); 144 QFile wfile( PROCNETWIRELESS );
145 if(!wfile.open( IO_ReadOnly )) 145 if(!wfile.open( IO_ReadOnly ))
146 return false; 146 return false;
147 147
148 QTextStream wstream( &wfile ); 148 QTextStream wstream( &wfile );
149 wstream.readLine(); // skip the first two lines 149 wstream.readLine(); // skip the first two lines
150 wstream.readLine(); // because they only contain headers 150 wstream.readLine(); // because they only contain headers
151 while(!wstream.atEnd()){ 151 while(!wstream.atEnd()){
152 wstream >> name >> status >> quality >> c >> signal >> c >> noise; 152 wstream >> name >> status >> quality >> c >> signal >> c >> noise;
153 if(name == QString("%1:").arg(interface)){ 153 if(name == QString("%1:").arg(interface)){
154 if ( quality > 92 ) 154 if ( quality > 92 )
155 qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); 155 qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality );
156 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) 156 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) )
157 qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); 157 qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal );
158 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) 158 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) )
159 qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); 159 qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise );
160 qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); 160 //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1());
161 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; 161 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER;
162 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; 162 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER;
163 quality = ( quality*100 ) / 92; 163 quality = ( quality*100 ) / 92;
164 return true; 164 return true;
165 } 165 }
166 } 166 }
167 167
168 qDebug("WExtensions::statsCard no longer present."); 168 qDebug("WExtensions::statsCard no longer present.");
169 quality = -1; 169 quality = -1;
170 signal = IW_LOWER; 170 signal = IW_LOWER;
171 noise = IW_LOWER; 171 noise = IW_LOWER;
172 return false; 172 return false;
173} 173}
174 174
175// wextensions.cpp 175// wextensions.cpp
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp
index ea19207..94c7518 100644
--- a/noncore/net/networksetup/wlan/wlanimp.cpp
+++ b/noncore/net/networksetup/wlan/wlanimp.cpp
@@ -1,115 +1,115 @@
1#include "wlanimp.h" 1#include "wlanimp.h"
2 2
3/* Config class */ 3/* Config class */
4#include <qpe/config.h> 4#include <qpe/config.h>
5/* Global namespace */ 5/* Global namespace */
6#include <qpe/global.h> 6#include <qpe/global.h>
7/* system() */ 7/* system() */
8#include <stdlib.h> 8#include <stdlib.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qtextstream.h> 11#include <qtextstream.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13#include <qlineedit.h> 13#include <qlineedit.h>
14#include <qspinbox.h> 14#include <qspinbox.h>
15#include <qradiobutton.h> 15#include <qradiobutton.h>
16#include <qcheckbox.h> 16#include <qcheckbox.h>
17#include <qregexp.h> 17#include <qregexp.h>
18 18
19WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name){ 19WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name, Qt::WDestructiveClose){
20 config = new Config("wireless"); 20 config = new Config("wireless");
21 readConfig(); 21 readConfig();
22} 22}
23 23
24WLANImp::~WLANImp( ){ 24WLANImp::~WLANImp( ){
25 delete config; 25 delete config;
26} 26}
27 27
28void WLANImp::readConfig() 28void WLANImp::readConfig()
29{ 29{
30 qWarning( "WLANImp::readConfig() called." ); 30 qWarning( "WLANImp::readConfig() called." );
31 config->setGroup( "Properties" ); 31 config->setGroup( "Properties" );
32 QString ssid = config->readEntry( "SSID", "any" ); 32 QString ssid = config->readEntry( "SSID", "any" );
33 if( ssid == "any" || ssid == "ANY" ){ 33 if( ssid == "any" || ssid == "ANY" ){
34 essNon->setChecked( true ); 34 essNon->setChecked( true );
35 } else { 35 } else {
36 essSpecific->setChecked( true ); 36 essSpecific->setChecked( true );
37 essSpecificLineEdit->setText( ssid ); 37 essSpecificLineEdit->setText( ssid );
38 } 38 }
39 QString mode = config->readEntry( "Mode", "Managed" ); 39 QString mode = config->readEntry( "Mode", "Managed" );
40 if( mode == "adhoc" ) { 40 if( mode == "adhoc" ) {
41 network802->setChecked( true ); 41 network802->setChecked( true );
42 } else { 42 } else {
43 networkInfrastructure->setChecked( true ); 43 networkInfrastructure->setChecked( true );
44 } 44 }
45 networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); 45 networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) );
46// config->readEntry( "RATE", "auto" ); 46// config->readEntry( "RATE", "auto" );
47 config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); 47 config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false );
48 config->readEntry( "AuthType", "opensystem" ); 48 config->readEntry( "AuthType", "opensystem" );
49 config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); 49 config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true );
50 int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); 50 int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 );
51 switch( defaultkey ){ 51 switch( defaultkey ){
52 case 0: 52 case 0:
53 keyRadio0->setChecked( true ); 53 keyRadio0->setChecked( true );
54 break; 54 break;
55 case 1: 55 case 1:
56 keyRadio1->setChecked( true ); 56 keyRadio1->setChecked( true );
57 break; 57 break;
58 case 2: 58 case 2:
59 keyRadio2->setChecked( true ); 59 keyRadio2->setChecked( true );
60 break; 60 break;
61 case 3: 61 case 3:
62 keyRadio3->setChecked( true ); 62 keyRadio3->setChecked( true );
63 break; 63 break;
64 } 64 }
65 keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); 65 keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" ));
66 keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); 66 keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" ));
67 keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); 67 keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" ));
68 keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); 68 keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" ));
69 return; 69 return;
70} 70}
71 71
72bool WLANImp::writeConfig() 72bool WLANImp::writeConfig()
73{ 73{
74 qWarning( "WLANImp::writeConfig() called." ); 74 qWarning( "WLANImp::writeConfig() called." );
75 config->setGroup( "Properties" ); 75 config->setGroup( "Properties" );
76 if( essNon->isChecked() ) { 76 if( essNon->isChecked() ) {
77 config->writeEntry( "SSID", "any" ); 77 config->writeEntry( "SSID", "any" );
78 } else { 78 } else {
79 config->writeEntry( "SSID", essSpecificLineEdit->text() ); 79 config->writeEntry( "SSID", essSpecificLineEdit->text() );
80 } 80 }
81 if( networkInfrastructure->isChecked() ){ 81 if( networkInfrastructure->isChecked() ){
82 config->writeEntry( "Mode", "Managed" ); 82 config->writeEntry( "Mode", "Managed" );
83 } else if( network802->isChecked() ){ 83 } else if( network802->isChecked() ){
84 config->writeEntry( "Mode", "adhoc" ); 84 config->writeEntry( "Mode", "adhoc" );
85 } 85 }
86 config->writeEntry( "CHANNEL", networkChannel->value() ); 86 config->writeEntry( "CHANNEL", networkChannel->value() );
87// config->readEntry( "RATE", "auto" ); 87// config->readEntry( "RATE", "auto" );
88 wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); 88 wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" );
89 authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); 89 authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" );
90 key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); 90 key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" );
91 if( keyRadio0->isChecked() ){ 91 if( keyRadio0->isChecked() ){
92 config->writeEntry( "dot11WEPDefaultKeyID", 0 ); 92 config->writeEntry( "dot11WEPDefaultKeyID", 0 );
93 } else if( keyRadio1->isChecked() ){ 93 } else if( keyRadio1->isChecked() ){
94 config->writeEntry( "dot11WEPDefaultKeyID", 1 ); 94 config->writeEntry( "dot11WEPDefaultKeyID", 1 );
95 } else if( keyRadio2->isChecked() ){ 95 } else if( keyRadio2->isChecked() ){
96 config->writeEntry( "dot11WEPDefaultKeyID", 2 ); 96 config->writeEntry( "dot11WEPDefaultKeyID", 2 );
97 } else if( keyRadio3->isChecked() ){ 97 } else if( keyRadio3->isChecked() ){
98 config->writeEntry( "dot11WEPDefaultKeyID", 3 ); 98 config->writeEntry( "dot11WEPDefaultKeyID", 3 );
99 } 99 }
100 config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); 100 config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() );
101 config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); 101 config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() );
102 config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); 102 config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() );
103 config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); 103 config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() );
104 return writeWirelessOpts( ); 104 return writeWirelessOpts( );
105} 105}
106 106
107/** 107/**
108 */ 108 */
109void WLANImp::accept() 109void WLANImp::accept()
110{ 110{
111 if ( writeConfig() ) 111 if ( writeConfig() )
112 QDialog::accept(); 112 QDialog::accept();
113} 113}
114 114
115void WLANImp::done ( int r ) 115void WLANImp::done ( int r )
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 73e753c..7507c54 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -1,129 +1,129 @@
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 // get output from iwconfig
14} 13}
15 14
16/** 15/**
17 */ 16 */
18WLANModule::~WLANModule(){ 17WLANModule::~WLANModule(){
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 //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ 49 i->setHardwareName("802.11b");
51 i->setHardwareName("802.11b"); 50 list.append(i);
52 list.append(i); 51 return true;
53 return true;
54 //}
55 //return false;
56} 52}
57 53
58/** 54/**
59 * Create, set tabWiget and return the WLANConfigure Module 55 * Create, set tabWiget and return the WLANConfigure Module
60 * @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.
61 * @return QWidget* pointer to the tab widget in this modules configure. 57 * @return QWidget* pointer to the tab widget in this modules configure.
62 */ 58 */
63QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ 59QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){
64 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); 60 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig");
65 (*tabWidget) = wlanconfig->tabWidget; 61 (*tabWidget) = wlanconfig->tabWidget;
66 return wlanconfig; 62 return wlanconfig;
67} 63}
68 64
69/** 65/**
70 * Create, set tabWiget and return the Information Module 66 * Create, set tabWiget and return the Information Module
71 * @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.
72 * @return QWidget* pointer to the tab widget in this modules info. 68 * @return QWidget* pointer to the tab widget in this modules info.
73 */ 69 */
74QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 70QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
75 WExtensions we(i->getInterfaceName()); 71 WExtensions we(i->getInterfaceName());
76 if(!we.doesHaveWirelessExtensions()) 72 if(!we.doesHaveWirelessExtensions())
77 return NULL; 73 return NULL;
78 74
79 WlanInfo *info = new WlanInfo(0, "wireless info"); 75 WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose);
80 (*tabWidget) = info->tabWidget; 76 (*tabWidget) = info->tabWidget;
81 77
82 info->essidLabel->setText(we.essid()); 78 info->essidLabel->setText(we.essid());
83 info->apLabel->setText(we.ap()); 79 info->apLabel->setText(we.ap());
84 info->stationLabel->setText(we.station()); 80 info->stationLabel->setText(we.station());
85 info->modeLabel->setText(we.mode()); 81 info->modeLabel->setText(we.mode());
86 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); 82 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency()));
87 int signal = 0; 83 int signal = 0;
88 int noise = 0; 84 int noise = 0;
89 int quality = 0; 85 int quality = 0;
90 we.stats(signal, noise, quality); 86 we.stats(signal, noise, quality);
91 info->signalProgressBar->setProgress(signal); 87 info->signalProgressBar->setProgress(signal);
92 info->noiseProgressBar->setProgress(noise); 88 info->noiseProgressBar->setProgress(noise);
93 info->qualityProgressBar->setProgress(quality); 89 info->qualityProgressBar->setProgress(quality);
94 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); 90 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate()));
91 //WlanInfo info (0, "wireless info", true);
92 //info.show();
93 //return NULL;
94
95 return info; 95 return info;
96} 96}
97 97
98/** 98/**
99 * Get all active (up or down) interfaces 99 * Get all active (up or down) interfaces
100 * @return QList<Interface> A list of interfaces that exsist that havn't 100 * @return QList<Interface> A list of interfaces that exsist that havn't
101 * been called by isOwner() 101 * been called by isOwner()
102 */ 102 */
103QList<Interface> WLANModule::getInterfaces(){ 103QList<Interface> WLANModule::getInterfaces(){
104 return list; 104 return list;
105} 105}
106 106
107/** 107/**
108 * Attempt to add a new interface as defined by name 108 * Attempt to add a new interface as defined by name
109 * @param name the name of the type of interface that should be created given 109 * @param name the name of the type of interface that should be created given
110 * by possibleNewInterfaces(); 110 * by possibleNewInterfaces();
111 * @return Interface* NULL if it was unable to be created. 111 * @return Interface* NULL if it was unable to be created.
112 */ 112 */
113Interface *WLANModule::addNewInterface(QString ){ 113Interface *WLANModule::addNewInterface(QString ){
114 // We can't add a 802.11 interface, either the hardware will be there 114 // We can't add a 802.11 interface, either the hardware will be there
115 // or it wont. 115 // or it wont.
116 return NULL; 116 return NULL;
117} 117}
118 118
119/** 119/**
120 * Attempts to remove the interface, doesn't delete i 120 * Attempts to remove the interface, doesn't delete i
121 * @return bool true if successfull, false otherwise. 121 * @return bool true if successfull, false otherwise.
122 */ 122 */
123bool WLANModule::remove(Interface*){ 123bool WLANModule::remove(Interface*){
124 // Can't remove a hardware device, you can stop it though. 124 // Can't remove a hardware device, you can stop it though.
125 return false; 125 return false;
126} 126}
127 127
128// wlanmodule.cpp 128// wlanmodule.cpp
129 129
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 7a71142..d61c510 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,11 +1,9 @@
1WLAN needs to be re-written to not use Config 1WLAN needs to be re-written to not use Config
2-remove WLAN Config item 2WHERE Is DHCP info stored???
3-sub class out the wlan info
4-check if an interface supports wireless extensions before config.
5 3
6PPP module needs to be written 4PPP module needs to be written
7 5
8Write a class that parses /proc and not ifconfig 6Write a class that parses /proc and not ifconfig
9 7
10Possible other modules: ipsec, bluetooth 8Possible other modules: ipsec, bluetooth, ipchains
11 9
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index a84b91f..929b3a1 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -1,270 +1,270 @@
1#include "interface.h" 1#include "interface.h"
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7 7
8#define IFCONFIG "/sbin/ifconfig" 8#define IFCONFIG "/sbin/ifconfig"
9#define HDCP_INFO_DIR "/etc/dhcpc" 9#define DHCP_INFO_DIR "/etc/dhcpc"
10 10
11#include <stdio.h> 11#include <stdio.h>
12#include <stdlib.h> 12#include <stdlib.h>
13 13
14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ 14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
15 refresh(); 15 refresh();
16} 16}
17 17
18/** 18/**
19 * Set status 19 * Set status
20 * @param newStatus - the new status 20 * @param newStatus - the new status
21 * emit updateInterface 21 * emit updateInterface
22 */ 22 */
23void Interface::setStatus(bool newStatus){ 23void Interface::setStatus(bool newStatus){
24 if(status != newStatus){ 24 if(status != newStatus){
25 status = newStatus; 25 status = newStatus;
26 refresh(); 26 refresh();
27 } 27 }
28}; 28};
29 29
30/** 30/**
31 * Set if attached or not (802.11 card pulled out for example) 31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached 32 * @param isAttached - if attached
33 * emit updateInterface 33 * emit updateInterface
34 */ 34 */
35void Interface::setAttached(bool isAttached){ 35void Interface::setAttached(bool isAttached){
36 attached = isAttached; 36 attached = isAttached;
37 emit(updateInterface(this)); 37 emit(updateInterface(this));
38}; 38};
39 39
40/** 40/**
41 * Set Hardware name 41 * Set Hardware name
42 * @param name - the new name 42 * @param name - the new name
43 * emit updateInterface 43 * emit updateInterface
44 */ 44 */
45void Interface::setHardwareName(QString name){ 45void Interface::setHardwareName(QString name){
46 hardwareName = name; 46 hardwareName = name;
47 emit(updateInterface(this)); 47 emit(updateInterface(this));
48}; 48};
49 49
50/** 50/**
51 * Set Module owner 51 * Set Module owner
52 * @param owner - the new owner 52 * @param owner - the new owner
53 * emit updateInterface 53 * emit updateInterface
54 */ 54 */
55void Interface::setModuleOwner(Module *owner){ 55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner; 56 moduleOwner = owner;
57 emit(updateInterface(this)); 57 emit(updateInterface(this));
58}; 58};
59 59
60 60
61/** 61/**
62 * Try to start the interface. 62 * Try to start the interface.
63 */ 63 */
64void Interface::start(){ 64void Interface::start(){
65 // check to see if we are already running. 65 // check to see if we are already running.
66 if(true == status) 66 if(true == status)
67 return; 67 return;
68 68
69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); 69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
70 // See if it was successfull... 70 // See if it was successfull...
71 if(ret != 0) 71 if(ret != 0)
72 return; 72 return;
73 73
74 status = true; 74 status = true;
75 refresh(); 75 refresh();
76} 76}
77 77
78/** 78/**
79 * Try to stop the interface. 79 * Try to stop the interface.
80 */ 80 */
81void Interface::stop(){ 81void Interface::stop(){
82 // check to see if we are already stopped. 82 // check to see if we are already stopped.
83 if(false == status) 83 if(false == status)
84 return; 84 return;
85 85
86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); 86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
87 if(ret != 0) 87 if(ret != 0)
88 return; 88 return;
89 89
90 status = true; 90 status = true;
91 refresh(); 91 refresh();
92} 92}
93 93
94/** 94/**
95 * Try to restart the interface. 95 * Try to restart the interface.
96 */ 96 */
97void Interface::restart(){ 97void Interface::restart(){
98 stop(); 98 stop();
99 start(); 99 start();
100} 100}
101 101
102/** 102/**
103 * Try to refresh the information about the interface. 103 * Try to refresh the information about the interface.
104 * First call ifconfig, then check the dhcp-info file 104 * First call ifconfig, then check the dhcp-info file
105 * @return bool true if successfull. 105 * @return bool true if successfull.
106 */ 106 */
107bool Interface::refresh(){ 107bool Interface::refresh(){
108 // See if we are up. 108 // See if we are up.
109 if(status == false){ 109 if(status == false){
110 macAddress = ""; 110 macAddress = "";
111 ip = "0.0.0.0"; 111 ip = "0.0.0.0";
112 subnetMask = "0.0.0.0"; 112 subnetMask = "0.0.0.0";
113 broadcast = ""; 113 broadcast = "";
114 dhcp = false; 114 dhcp = false;
115 dhcpServerIp = ""; 115 dhcpServerIp = "";
116 leaseObtained = ""; 116 leaseObtained = "";
117 leaseExpires = ""; 117 leaseExpires = "";
118 emit(updateInterface(this)); 118 emit(updateInterface(this));
119 return true; 119 return true;
120 } 120 }
121 121
122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); 122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); 123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
124 if(ret != 0){ 124 if(ret != 0){
125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
126 return false; 126 return false;
127 } 127 }
128 128
129 QFile file(fileName); 129 QFile file(fileName);
130 if (!file.open(IO_ReadOnly)){ 130 if (!file.open(IO_ReadOnly)){
131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
132 return false; 132 return false;
133 } 133 }
134 134
135 // Set to the defaults 135 // Set to the defaults
136 macAddress = ""; 136 macAddress = "";
137 ip = "0.0.0.0"; 137 ip = "0.0.0.0";
138 subnetMask = "0.0.0.0"; 138 subnetMask = "0.0.0.0";
139 broadcast = ""; 139 broadcast = "";
140 140
141 QTextStream stream( &file ); 141 QTextStream stream( &file );
142 QString line; 142 QString line;
143 while ( !stream.eof() ) { 143 while ( !stream.eof() ) {
144 line = stream.readLine(); 144 line = stream.readLine();
145 if(line.contains("HWaddr")){ 145 if(line.contains("HWaddr")){
146 int mac = line.find("HWaddr"); 146 int mac = line.find("HWaddr");
147 macAddress = line.mid(mac+7, line.length()); 147 macAddress = line.mid(mac+7, line.length());
148 } 148 }
149 if(line.contains("inet addr")){ 149 if(line.contains("inet addr")){
150 int ipl = line.find("inet addr"); 150 int ipl = line.find("inet addr");
151 int space = line.find(" ", ipl+10); 151 int space = line.find(" ", ipl+10);
152 ip = line.mid(ipl+10, space-ipl-10); 152 ip = line.mid(ipl+10, space-ipl-10);
153 } 153 }
154 if(line.contains("Mask")){ 154 if(line.contains("Mask")){
155 int mask = line.find("Mask"); 155 int mask = line.find("Mask");
156 subnetMask = line.mid(mask+5, line.length()); 156 subnetMask = line.mid(mask+5, line.length());
157 } 157 }
158 if(line.contains("Bcast")){ 158 if(line.contains("Bcast")){
159 int mask = line.find("Bcast"); 159 int mask = line.find("Bcast");
160 int space = line.find(" ", mask+6); 160 int space = line.find(" ", mask+6);
161 broadcast = line.mid(mask+6, space-mask-6); 161 broadcast = line.mid(mask+6, space-mask-6);
162 } 162 }
163 } 163 }
164 file.close(); 164 file.close();
165 QFile::remove(fileName); 165 QFile::remove(fileName);
166 166
167 // DHCP TESTING 167 // DHCP TESTING
168 // reset DHCP info 168 // reset DHCP info
169 dhcpServerIp = ""; 169 dhcpServerIp = "";
170 leaseObtained = ""; 170 leaseObtained = "";
171 leaseExpires = ""; 171 leaseExpires = "";
172 dhcp = false; 172 dhcp = false;
173 173
174 QString dhcpDirectory(HDCP_INFO_DIR); 174 QString dhcpDirectory(DHCP_INFO_DIR);
175 QDir d(dhcpDirectory); 175 QDir d(dhcpDirectory);
176 if(!d.exists(dhcpDirectory)) 176 if(!d.exists(dhcpDirectory))
177 dhcpDirectory = "/var/run"; 177 dhcpDirectory = "/var/run";
178 178
179 // See if we have 179 // See if we have
180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); 180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
181 // If there is no DHCP information then exit now with no errors. 181 // If there is no DHCP information then exit now with no errors.
182 if(!QFile::exists(dhcpFile)){ 182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this)); 183 emit(updateInterface(this));
184 return true; 184 return true;
185 } 185 }
186 186
187 file.setName(dhcpFile); 187 file.setName(dhcpFile);
188 if (!file.open(IO_ReadOnly)){ 188 if (!file.open(IO_ReadOnly)){
189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
190 return false; 190 return false;
191 } 191 }
192 192
193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
194 int leaseTime = 0; 194 int leaseTime = 0;
195 int renewalTime = 0; 195 int renewalTime = 0;
196 196
197 stream.setDevice( &file ); 197 stream.setDevice( &file );
198 while ( !stream.eof() ) { 198 while ( !stream.eof() ) {
199 line = stream.readLine(); 199 line = stream.readLine();
200 if(line.contains("DHCPSIADDR=")) 200 if(line.contains("DHCPSIADDR="))
201 dhcpServerIp = line.mid(11, line.length()); 201 dhcpServerIp = line.mid(11, line.length());
202 if(line.contains("LEASETIME=")) 202 if(line.contains("LEASETIME="))
203 leaseTime = line.mid(10, line.length()).toInt(); 203 leaseTime = line.mid(10, line.length()).toInt();
204 if(line.contains("RENEWALTIME=")) 204 if(line.contains("RENEWALTIME="))
205 renewalTime = line.mid(12, line.length()).toInt(); 205 renewalTime = line.mid(12, line.length()).toInt();
206 } 206 }
207 file.close(); 207 file.close();
208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
210 210
211 // Get the pid of the deamond 211 // Get the pid of the deamond
212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); 212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
213 file.setName(dhcpFile); 213 file.setName(dhcpFile);
214 if (!file.open(IO_ReadOnly)){ 214 if (!file.open(IO_ReadOnly)){
215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
216 return false; 216 return false;
217 } 217 }
218 218
219 int pid = -1; 219 int pid = -1;
220 stream.setDevice( &file ); 220 stream.setDevice( &file );
221 while ( !stream.eof() ) { 221 while ( !stream.eof() ) {
222 line = stream.readLine(); 222 line = stream.readLine();
223 pid = line.toInt(); 223 pid = line.toInt();
224 } 224 }
225 file.close(); 225 file.close();
226 226
227 if( pid == -1){ 227 if( pid == -1){
228 qDebug("Interface: Could not get pid of dhcpc deamon."); 228 qDebug("Interface: Could not get pid of dhcpc deamon.");
229 return false; 229 return false;
230 } 230 }
231 231
232 // Get the start running time of the deamon 232 // Get the start running time of the deamon
233 fileName = (QString("/proc/%1/stat").arg(pid)); 233 fileName = (QString("/proc/%1/stat").arg(pid));
234 file.setName(fileName); 234 file.setName(fileName);
235 stream.setDevice( &file ); 235 stream.setDevice( &file );
236 if (!file.open(IO_ReadOnly)){ 236 if (!file.open(IO_ReadOnly)){
237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
238 return false; 238 return false;
239 } 239 }
240 while ( !stream.eof() ) { 240 while ( !stream.eof() ) {
241 line = stream.readLine(); 241 line = stream.readLine();
242 } 242 }
243 file.close(); 243 file.close();
244 long time = 0; 244 long time = 0;
245 // Grab the start time 245 // Grab the start time
246 // pid com state ppid pgrp session tty_nr tpgid flags 246 // pid com state ppid pgrp session tty_nr tpgid flags
247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
250 // nice 0 itrealvalue starttime 250 // nice 0 itrealvalue starttime
251 "%*d %*d %*d %lu", (long*) &time); 251 "%*d %*d %*d %lu", (long*) &time);
252 time = time/100; 252 time = time/100;
253 253
254 QDateTime datetime(QDateTime::currentDateTime()); 254 QDateTime datetime(QDateTime::currentDateTime());
255 255
256 // Get the uptime of the computer. 256 // Get the uptime of the computer.
257 QFile f("/proc/uptime"); 257 QFile f("/proc/uptime");
258 if ( f.open(IO_ReadOnly) ) { // file opened successfully 258 if ( f.open(IO_ReadOnly) ) { // file opened successfully
259 QTextStream t( &f ); // use a text stream 259 QTextStream t( &f ); // use a text stream
260 int sec = 0; 260 int sec = 0;
261 t >> sec; 261 t >> sec;
262 datetime = datetime.addSecs((-1*sec)); 262 datetime = datetime.addSecs((-1*sec));
263 f.close(); 263 f.close();
264 } 264 }
265 else{ 265 else{
266 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 266 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
267 return false; 267 return false;
268 } 268 }
269 269
270 datetime = datetime.addSecs(time); 270 datetime = datetime.addSecs(time);
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 9d81ab1..c86acdc 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,194 +1,196 @@
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("start Saving mainwindow");
81 // Save profiles. 82 // Save profiles.
82 Config cfg("NetworkSetup"); 83 Config cfg("NetworkSetup");
83 cfg.setGroup("General"); 84 cfg.setGroup("General");
84 cfg.writeEntry("Profiles", profiles.join(" ")); 85 cfg.writeEntry("Profiles", profiles.join(" "));
85 86
86 // Delete all interfaces that don't have owners. 87 // Delete all interfaces that don't have owners.
87 QMap<Interface*, QListViewItem*>::Iterator iIt; 88 QMap<Interface*, QListViewItem*>::Iterator iIt;
88 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 89 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
89 if(iIt.key()->getModuleOwner() == NULL) 90 if(iIt.key()->getModuleOwner() == NULL)
90 delete iIt.key(); 91 delete iIt.key();
91 } 92 }
92 93
93 // Delete Modules and Libraries 94 // Delete Modules and Libraries
94 QMap<Module*, QLibrary*>::Iterator it; 95 QMap<Module*, QLibrary*>::Iterator it;
95 for( it = libraries.begin(); it != libraries.end(); ++it ){ 96 for( it = libraries.begin(); it != libraries.end(); ++it ){
96 delete it.key(); 97 delete it.key();
97 delete it.data(); 98 delete it.data();
98 } 99 }
100 qDebug("done Saving mainwindow");
99} 101}
100 102
101/** 103/**
102 * Load all modules that are found in the path 104 * Load all modules that are found in the path
103 * @param path a directory that is scaned for any plugins that can be loaded 105 * @param path a directory that is scaned for any plugins that can be loaded
104 * and attempts to load them 106 * and attempts to load them
105 */ 107 */
106void MainWindowImp::loadModules(QString path){ 108void MainWindowImp::loadModules(QString path){
107 //qDebug(path.latin1()); 109 //qDebug(path.latin1());
108 QDir d(path); 110 QDir d(path);
109 if(!d.exists()) 111 if(!d.exists())
110 return; 112 return;
111 113
112 // Don't want sym links 114 // Don't want sym links
113 d.setFilter( QDir::Files | QDir::NoSymLinks ); 115 d.setFilter( QDir::Files | QDir::NoSymLinks );
114 const QFileInfoList *list = d.entryInfoList(); 116 const QFileInfoList *list = d.entryInfoList();
115 QFileInfoListIterator it( *list ); 117 QFileInfoListIterator it( *list );
116 QFileInfo *fi; 118 QFileInfo *fi;
117 while ( (fi=it.current()) ) { 119 while ( (fi=it.current()) ) {
118 if(fi->fileName().contains(".so")){ 120 if(fi->fileName().contains(".so")){
119 loadPlugin(path + "/" + fi->fileName()); 121 loadPlugin(path + "/" + fi->fileName());
120 } 122 }
121 ++it; 123 ++it;
122 } 124 }
123} 125}
124 126
125/** 127/**
126 * Attempt to load a function and resolve a function. 128 * Attempt to load a function and resolve a function.
127 * @param pluginFileName - the name of the file in which to attempt to load 129 * @param pluginFileName - the name of the file in which to attempt to load
128 * @param resolveString - function pointer to resolve 130 * @param resolveString - function pointer to resolve
129 * @return pointer to the function with name resolveString or NULL 131 * @return pointer to the function with name resolveString or NULL
130 */ 132 */
131Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 133Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
132 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 134 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
133 QLibrary *lib = new QLibrary(pluginFileName); 135 QLibrary *lib = new QLibrary(pluginFileName);
134 void *functionPointer = lib->resolve(resolveString); 136 void *functionPointer = lib->resolve(resolveString);
135 if( !functionPointer ){ 137 if( !functionPointer ){
136 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 138 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
137 delete lib; 139 delete lib;
138 return NULL; 140 return NULL;
139 } 141 }
140 142
141 // Try to get an object. 143 // Try to get an object.
142 Module *object = ((Module* (*)()) functionPointer)(); 144 Module *object = ((Module* (*)()) functionPointer)();
143 if(object == NULL){ 145 if(object == NULL){
144 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 146 qDebug("MainWindowImp: Couldn't create object, but did load library!");
145 delete lib; 147 delete lib;
146 return NULL; 148 return NULL;
147 } 149 }
148 150
149 // Store for deletion later 151 // Store for deletion later
150 libraries.insert(object, lib); 152 libraries.insert(object, lib);
151 return object; 153 return object;
152} 154}
153 155
154/** 156/**
155 * The Add button was clicked. Bring up the add dialog and if OK is hit 157 * The Add button was clicked. Bring up the add dialog and if OK is hit
156 * load the plugin and append it to the list 158 * load the plugin and append it to the list
157 */ 159 */
158void MainWindowImp::addClicked(){ 160void MainWindowImp::addClicked(){
159 QMap<Module*, QLibrary*>::Iterator it; 161 QMap<Module*, QLibrary*>::Iterator it;
160 QMap<QString, QString> list; 162 QMap<QString, QString> list;
161 QMap<QString, Module*> newInterfaceOwners; 163 QMap<QString, Module*> newInterfaceOwners;
162 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 164 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
163 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 165 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
164 for( it = libraries.begin(); it != libraries.end(); ++it ){ 166 for( it = libraries.begin(); it != libraries.end(); ++it ){
165 if(it.key()){ 167 if(it.key()){
166 (it.key())->possibleNewInterfaces(list); 168 (it.key())->possibleNewInterfaces(list);
167 } 169 }
168 } 170 }
169 // See if the list has anything that we can add. 171 // See if the list has anything that we can add.
170 if(list.count() == 0){ 172 if(list.count() == 0){
171 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 173 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
172 return; 174 return;
173 } 175 }
174 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 176 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
175 addNewConnection.addConnections(list); 177 addNewConnection.addConnections(list);
176 addNewConnection.showMaximized(); 178 addNewConnection.showMaximized();
177 if(QDialog::Accepted == addNewConnection.exec()){ 179 if(QDialog::Accepted == addNewConnection.exec()){
178 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 180 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
179 if(!item) 181 if(!item)
180 return; 182 return;
181 183
182 for( it = libraries.begin(); it != libraries.end(); ++it ){ 184 for( it = libraries.begin(); it != libraries.end(); ++it ){
183 if(it.key()){ 185 if(it.key()){
184 Interface *i = (it.key())->addNewInterface(item->text(0)); 186 Interface *i = (it.key())->addNewInterface(item->text(0));
185 if(i){ 187 if(i){
186 interfaceNames.insert(i->getInterfaceName(), i); 188 interfaceNames.insert(i->getInterfaceName(), i);
187 updateInterface(i); 189 updateInterface(i);
188 } 190 }
189 } 191 }
190 } 192 }
191 } 193 }
192} 194}
193 195
194/** 196/**
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp
index ef4ba8f..e545bd1 100644
--- a/noncore/settings/networksettings/wlan/wextensions.cpp
+++ b/noncore/settings/networksettings/wlan/wextensions.cpp
@@ -64,112 +64,112 @@ QString WExtensions::essid(){
64 return QString(); 64 return QString();
65 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ 65 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){
66 iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; 66 iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
67 return QString(iwr.u.essid.pointer); 67 return QString(iwr.u.essid.pointer);
68 } 68 }
69 return QString(); 69 return QString();
70} 70}
71 71
72/** 72/**
73 * @return QString the mode of interface 73 * @return QString the mode of interface
74 */ 74 */
75QString WExtensions::mode(){ 75QString WExtensions::mode(){
76 if(!hasWirelessExtensions) 76 if(!hasWirelessExtensions)
77 return QString(); 77 return QString();
78 if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) 78 if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) )
79 return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); 79 return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed");
80 return QString(); 80 return QString();
81} 81}
82 82
83/** 83/**
84 * Get the frequency that the interface is running at. 84 * Get the frequency that the interface is running at.
85 * @return int the frequency that the interfacae is running at. 85 * @return int the frequency that the interfacae is running at.
86 */ 86 */
87double WExtensions::frequency(){ 87double WExtensions::frequency(){
88 if(!hasWirelessExtensions) 88 if(!hasWirelessExtensions)
89 return 0; 89 return 0;
90 if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) 90 if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr ))
91 return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); 91 return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
92 return 0; 92 return 0;
93} 93}
94 94
95/*** 95/***
96 * Get the current rate that the card is transmiting at. 96 * Get the current rate that the card is transmiting at.
97 */ 97 */
98double WExtensions::rate(){ 98double WExtensions::rate(){
99 if(!hasWirelessExtensions) 99 if(!hasWirelessExtensions)
100 return 0; 100 return 0;
101 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ 101 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){
102 return ((double)iwr.u.bitrate.value)/1000000; 102 return ((double)iwr.u.bitrate.value)/1000000;
103 } 103 }
104 return 0; 104 return 0;
105} 105}
106 106
107 107
108/** 108/**
109 * @return QString the AccessPoint that the interface is connected to. 109 * @return QString the AccessPoint that the interface is connected to.
110 */ 110 */
111QString WExtensions::ap(){ 111QString WExtensions::ap(){
112 if(!hasWirelessExtensions) 112 if(!hasWirelessExtensions)
113 return QString(); 113 return QString();
114 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ 114 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){
115 QString ap; 115 QString ap;
116 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 116 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
117 iwr.u.ap_addr.sa_data[0]&0xff, 117 iwr.u.ap_addr.sa_data[0]&0xff,
118 iwr.u.ap_addr.sa_data[1]&0xff, 118 iwr.u.ap_addr.sa_data[1]&0xff,
119 iwr.u.ap_addr.sa_data[2]&0xff, 119 iwr.u.ap_addr.sa_data[2]&0xff,
120 iwr.u.ap_addr.sa_data[3]&0xff, 120 iwr.u.ap_addr.sa_data[3]&0xff,
121 iwr.u.ap_addr.sa_data[4]&0xff, 121 iwr.u.ap_addr.sa_data[4]&0xff,
122 iwr.u.ap_addr.sa_data[5]&0xff ); 122 iwr.u.ap_addr.sa_data[5]&0xff );
123 return ap; 123 return ap;
124 } 124 }
125 else return QString(); 125 else return QString();
126} 126}
127 127
128/** 128/**
129 * Get the stats for interfaces 129 * Get the stats for interfaces
130 * @param signal the signal strength of interface 130 * @param signal the signal strength of interface
131 * @param noise the noise level of the interface 131 * @param noise the noise level of the interface
132 * @param quality the quality level of the interface 132 * @param quality the quality level of the interface
133 * @return bool true if successfull 133 * @return bool true if successfull
134 */ 134 */
135bool WExtensions::stats(int &signal, int &noise, int &quality){ 135bool WExtensions::stats(int &signal, int &noise, int &quality){
136 // gather link quality from /proc/net/wireless 136 // gather link quality from /proc/net/wireless
137 if(!QFile::exists(PROCNETWIRELESS)) 137 if(!QFile::exists(PROCNETWIRELESS))
138 return false; 138 return false;
139 139
140 char c; 140 char c;
141 QString status; 141 QString status;
142 QString name; 142 QString name;
143 143
144 QFile wfile( PROCNETWIRELESS ); 144 QFile wfile( PROCNETWIRELESS );
145 if(!wfile.open( IO_ReadOnly )) 145 if(!wfile.open( IO_ReadOnly ))
146 return false; 146 return false;
147 147
148 QTextStream wstream( &wfile ); 148 QTextStream wstream( &wfile );
149 wstream.readLine(); // skip the first two lines 149 wstream.readLine(); // skip the first two lines
150 wstream.readLine(); // because they only contain headers 150 wstream.readLine(); // because they only contain headers
151 while(!wstream.atEnd()){ 151 while(!wstream.atEnd()){
152 wstream >> name >> status >> quality >> c >> signal >> c >> noise; 152 wstream >> name >> status >> quality >> c >> signal >> c >> noise;
153 if(name == QString("%1:").arg(interface)){ 153 if(name == QString("%1:").arg(interface)){
154 if ( quality > 92 ) 154 if ( quality > 92 )
155 qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); 155 qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality );
156 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) 156 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) )
157 qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); 157 qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal );
158 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) 158 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) )
159 qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); 159 qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise );
160 qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); 160 //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1());
161 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; 161 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER;
162 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; 162 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER;
163 quality = ( quality*100 ) / 92; 163 quality = ( quality*100 ) / 92;
164 return true; 164 return true;
165 } 165 }
166 } 166 }
167 167
168 qDebug("WExtensions::statsCard no longer present."); 168 qDebug("WExtensions::statsCard no longer present.");
169 quality = -1; 169 quality = -1;
170 signal = IW_LOWER; 170 signal = IW_LOWER;
171 noise = IW_LOWER; 171 noise = IW_LOWER;
172 return false; 172 return false;
173} 173}
174 174
175// wextensions.cpp 175// wextensions.cpp
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index ea19207..94c7518 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -1,115 +1,115 @@
1#include "wlanimp.h" 1#include "wlanimp.h"
2 2
3/* Config class */ 3/* Config class */
4#include <qpe/config.h> 4#include <qpe/config.h>
5/* Global namespace */ 5/* Global namespace */
6#include <qpe/global.h> 6#include <qpe/global.h>
7/* system() */ 7/* system() */
8#include <stdlib.h> 8#include <stdlib.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qtextstream.h> 11#include <qtextstream.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13#include <qlineedit.h> 13#include <qlineedit.h>
14#include <qspinbox.h> 14#include <qspinbox.h>
15#include <qradiobutton.h> 15#include <qradiobutton.h>
16#include <qcheckbox.h> 16#include <qcheckbox.h>
17#include <qregexp.h> 17#include <qregexp.h>
18 18
19WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name){ 19WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name, Qt::WDestructiveClose){
20 config = new Config("wireless"); 20 config = new Config("wireless");
21 readConfig(); 21 readConfig();
22} 22}
23 23
24WLANImp::~WLANImp( ){ 24WLANImp::~WLANImp( ){
25 delete config; 25 delete config;
26} 26}
27 27
28void WLANImp::readConfig() 28void WLANImp::readConfig()
29{ 29{
30 qWarning( "WLANImp::readConfig() called." ); 30 qWarning( "WLANImp::readConfig() called." );
31 config->setGroup( "Properties" ); 31 config->setGroup( "Properties" );
32 QString ssid = config->readEntry( "SSID", "any" ); 32 QString ssid = config->readEntry( "SSID", "any" );
33 if( ssid == "any" || ssid == "ANY" ){ 33 if( ssid == "any" || ssid == "ANY" ){
34 essNon->setChecked( true ); 34 essNon->setChecked( true );
35 } else { 35 } else {
36 essSpecific->setChecked( true ); 36 essSpecific->setChecked( true );
37 essSpecificLineEdit->setText( ssid ); 37 essSpecificLineEdit->setText( ssid );
38 } 38 }
39 QString mode = config->readEntry( "Mode", "Managed" ); 39 QString mode = config->readEntry( "Mode", "Managed" );
40 if( mode == "adhoc" ) { 40 if( mode == "adhoc" ) {
41 network802->setChecked( true ); 41 network802->setChecked( true );
42 } else { 42 } else {
43 networkInfrastructure->setChecked( true ); 43 networkInfrastructure->setChecked( true );
44 } 44 }
45 networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); 45 networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) );
46// config->readEntry( "RATE", "auto" ); 46// config->readEntry( "RATE", "auto" );
47 config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); 47 config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false );
48 config->readEntry( "AuthType", "opensystem" ); 48 config->readEntry( "AuthType", "opensystem" );
49 config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); 49 config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true );
50 int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); 50 int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 );
51 switch( defaultkey ){ 51 switch( defaultkey ){
52 case 0: 52 case 0:
53 keyRadio0->setChecked( true ); 53 keyRadio0->setChecked( true );
54 break; 54 break;
55 case 1: 55 case 1:
56 keyRadio1->setChecked( true ); 56 keyRadio1->setChecked( true );
57 break; 57 break;
58 case 2: 58 case 2:
59 keyRadio2->setChecked( true ); 59 keyRadio2->setChecked( true );
60 break; 60 break;
61 case 3: 61 case 3:
62 keyRadio3->setChecked( true ); 62 keyRadio3->setChecked( true );
63 break; 63 break;
64 } 64 }
65 keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); 65 keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" ));
66 keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); 66 keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" ));
67 keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); 67 keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" ));
68 keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); 68 keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" ));
69 return; 69 return;
70} 70}
71 71
72bool WLANImp::writeConfig() 72bool WLANImp::writeConfig()
73{ 73{
74 qWarning( "WLANImp::writeConfig() called." ); 74 qWarning( "WLANImp::writeConfig() called." );
75 config->setGroup( "Properties" ); 75 config->setGroup( "Properties" );
76 if( essNon->isChecked() ) { 76 if( essNon->isChecked() ) {
77 config->writeEntry( "SSID", "any" ); 77 config->writeEntry( "SSID", "any" );
78 } else { 78 } else {
79 config->writeEntry( "SSID", essSpecificLineEdit->text() ); 79 config->writeEntry( "SSID", essSpecificLineEdit->text() );
80 } 80 }
81 if( networkInfrastructure->isChecked() ){ 81 if( networkInfrastructure->isChecked() ){
82 config->writeEntry( "Mode", "Managed" ); 82 config->writeEntry( "Mode", "Managed" );
83 } else if( network802->isChecked() ){ 83 } else if( network802->isChecked() ){
84 config->writeEntry( "Mode", "adhoc" ); 84 config->writeEntry( "Mode", "adhoc" );
85 } 85 }
86 config->writeEntry( "CHANNEL", networkChannel->value() ); 86 config->writeEntry( "CHANNEL", networkChannel->value() );
87// config->readEntry( "RATE", "auto" ); 87// config->readEntry( "RATE", "auto" );
88 wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); 88 wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" );
89 authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); 89 authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" );
90 key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); 90 key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" );
91 if( keyRadio0->isChecked() ){ 91 if( keyRadio0->isChecked() ){
92 config->writeEntry( "dot11WEPDefaultKeyID", 0 ); 92 config->writeEntry( "dot11WEPDefaultKeyID", 0 );
93 } else if( keyRadio1->isChecked() ){ 93 } else if( keyRadio1->isChecked() ){
94 config->writeEntry( "dot11WEPDefaultKeyID", 1 ); 94 config->writeEntry( "dot11WEPDefaultKeyID", 1 );
95 } else if( keyRadio2->isChecked() ){ 95 } else if( keyRadio2->isChecked() ){
96 config->writeEntry( "dot11WEPDefaultKeyID", 2 ); 96 config->writeEntry( "dot11WEPDefaultKeyID", 2 );
97 } else if( keyRadio3->isChecked() ){ 97 } else if( keyRadio3->isChecked() ){
98 config->writeEntry( "dot11WEPDefaultKeyID", 3 ); 98 config->writeEntry( "dot11WEPDefaultKeyID", 3 );
99 } 99 }
100 config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); 100 config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() );
101 config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); 101 config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() );
102 config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); 102 config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() );
103 config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); 103 config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() );
104 return writeWirelessOpts( ); 104 return writeWirelessOpts( );
105} 105}
106 106
107/** 107/**
108 */ 108 */
109void WLANImp::accept() 109void WLANImp::accept()
110{ 110{
111 if ( writeConfig() ) 111 if ( writeConfig() )
112 QDialog::accept(); 112 QDialog::accept();
113} 113}
114 114
115void WLANImp::done ( int r ) 115void WLANImp::done ( int r )
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 73e753c..7507c54 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,129 +1,129 @@
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 // get output from iwconfig
14} 13}
15 14
16/** 15/**
17 */ 16 */
18WLANModule::~WLANModule(){ 17WLANModule::~WLANModule(){
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 //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ 49 i->setHardwareName("802.11b");
51 i->setHardwareName("802.11b"); 50 list.append(i);
52 list.append(i); 51 return true;
53 return true;
54 //}
55 //return false;
56} 52}
57 53
58/** 54/**
59 * Create, set tabWiget and return the WLANConfigure Module 55 * Create, set tabWiget and return the WLANConfigure Module
60 * @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.
61 * @return QWidget* pointer to the tab widget in this modules configure. 57 * @return QWidget* pointer to the tab widget in this modules configure.
62 */ 58 */
63QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ 59QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){
64 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); 60 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig");
65 (*tabWidget) = wlanconfig->tabWidget; 61 (*tabWidget) = wlanconfig->tabWidget;
66 return wlanconfig; 62 return wlanconfig;
67} 63}
68 64
69/** 65/**
70 * Create, set tabWiget and return the Information Module 66 * Create, set tabWiget and return the Information Module
71 * @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.
72 * @return QWidget* pointer to the tab widget in this modules info. 68 * @return QWidget* pointer to the tab widget in this modules info.
73 */ 69 */
74QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 70QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
75 WExtensions we(i->getInterfaceName()); 71 WExtensions we(i->getInterfaceName());
76 if(!we.doesHaveWirelessExtensions()) 72 if(!we.doesHaveWirelessExtensions())
77 return NULL; 73 return NULL;
78 74
79 WlanInfo *info = new WlanInfo(0, "wireless info"); 75 WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose);
80 (*tabWidget) = info->tabWidget; 76 (*tabWidget) = info->tabWidget;
81 77
82 info->essidLabel->setText(we.essid()); 78 info->essidLabel->setText(we.essid());
83 info->apLabel->setText(we.ap()); 79 info->apLabel->setText(we.ap());
84 info->stationLabel->setText(we.station()); 80 info->stationLabel->setText(we.station());
85 info->modeLabel->setText(we.mode()); 81 info->modeLabel->setText(we.mode());
86 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); 82 info->freqLabel->setText(QString("%1 GHz").arg(we.frequency()));
87 int signal = 0; 83 int signal = 0;
88 int noise = 0; 84 int noise = 0;
89 int quality = 0; 85 int quality = 0;
90 we.stats(signal, noise, quality); 86 we.stats(signal, noise, quality);
91 info->signalProgressBar->setProgress(signal); 87 info->signalProgressBar->setProgress(signal);
92 info->noiseProgressBar->setProgress(noise); 88 info->noiseProgressBar->setProgress(noise);
93 info->qualityProgressBar->setProgress(quality); 89 info->qualityProgressBar->setProgress(quality);
94 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); 90 info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate()));
91 //WlanInfo info (0, "wireless info", true);
92 //info.show();
93 //return NULL;
94
95 return info; 95 return info;
96} 96}
97 97
98/** 98/**
99 * Get all active (up or down) interfaces 99 * Get all active (up or down) interfaces
100 * @return QList<Interface> A list of interfaces that exsist that havn't 100 * @return QList<Interface> A list of interfaces that exsist that havn't
101 * been called by isOwner() 101 * been called by isOwner()
102 */ 102 */
103QList<Interface> WLANModule::getInterfaces(){ 103QList<Interface> WLANModule::getInterfaces(){
104 return list; 104 return list;
105} 105}
106 106
107/** 107/**
108 * Attempt to add a new interface as defined by name 108 * Attempt to add a new interface as defined by name
109 * @param name the name of the type of interface that should be created given 109 * @param name the name of the type of interface that should be created given
110 * by possibleNewInterfaces(); 110 * by possibleNewInterfaces();
111 * @return Interface* NULL if it was unable to be created. 111 * @return Interface* NULL if it was unable to be created.
112 */ 112 */
113Interface *WLANModule::addNewInterface(QString ){ 113Interface *WLANModule::addNewInterface(QString ){
114 // We can't add a 802.11 interface, either the hardware will be there 114 // We can't add a 802.11 interface, either the hardware will be there
115 // or it wont. 115 // or it wont.
116 return NULL; 116 return NULL;
117} 117}
118 118
119/** 119/**
120 * Attempts to remove the interface, doesn't delete i 120 * Attempts to remove the interface, doesn't delete i
121 * @return bool true if successfull, false otherwise. 121 * @return bool true if successfull, false otherwise.
122 */ 122 */
123bool WLANModule::remove(Interface*){ 123bool WLANModule::remove(Interface*){
124 // Can't remove a hardware device, you can stop it though. 124 // Can't remove a hardware device, you can stop it though.
125 return false; 125 return false;
126} 126}
127 127
128// wlanmodule.cpp 128// wlanmodule.cpp
129 129