summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-11-13 16:25:04 (UTC)
committer benmeyer <benmeyer>2002-11-13 16:25:04 (UTC)
commitd3301ad9a74fdf693551bd70bc3cf34b311eaa49 (patch) (unidiff)
treefdc7ee3650af3e7225e1a8966e12bc2c1007b986
parent2bc05c54b2ff1a9b2af7d6bd4d55428cfe0d8db3 (diff)
downloadopie-d3301ad9a74fdf693551bd70bc3cf34b311eaa49.zip
opie-d3301ad9a74fdf693551bd70bc3cf34b311eaa49.tar.gz
opie-d3301ad9a74fdf693551bd70bc3cf34b311eaa49.tar.bz2
code cleanup const's placed in code
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO6
-rw-r--r--noncore/net/networksetup/interfaces/interface.cpp2
-rw-r--r--noncore/net/networksetup/interfaces/interface.h41
-rw-r--r--noncore/net/networksetup/interfaces/interfaces.cpp6
-rw-r--r--noncore/net/networksetup/interfaces/interfaces.h8
-rw-r--r--noncore/net/networksetup/interfaces/interfaces.pro2
-rw-r--r--noncore/net/networksetup/ppp/pppmodule.cpp23
-rw-r--r--noncore/net/networksetup/wlan/infoimp.cpp3
-rw-r--r--noncore/settings/networksettings/TODO6
-rw-r--r--noncore/settings/networksettings/interfaces/interface.cpp2
-rw-r--r--noncore/settings/networksettings/interfaces/interface.h41
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp6
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.h8
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.pro2
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp23
-rw-r--r--noncore/settings/networksettings/wlan/infoimp.cpp3
16 files changed, 94 insertions, 88 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 04b3a7c..020339f 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,16 +1,14 @@
1AndyQ - Fixed a bug in wlanimp.cpp : accept method - put braces round key 1test WEP
2 field if so that settings get saved if WEP is enabled 2WEP key in file wireless.conf is not encrypted !, therefore it is very easy to get the key out of the zaurus..
3
4CLEAN UP
5 3
6udchcp needs to output the dhcp information so interfaces can read it 4udchcp needs to output the dhcp information so interfaces can read it
7 5
8interfacesetupimp really doesn't need a interface* pointer 6interfacesetupimp really doesn't need a interface* pointer
9 7
10Possible other modules to write: ppp, ipsec, bluetooth, ipchains 8Possible other modules to write: ppp, ipsec, bluetooth, ipchains
11 9
12PPP module needs to scan pppd.tdb to see what is currently active 10PPP module needs to scan pppd.tdb to see what is currently active
13 11
14WLAN - add possiblity to input text or hex without knowing "s:" 12WLAN - add possiblity to input text or hex without knowing "s:"
15 13
16Interface setupimp needs to use kernel calls. 14Interface setupimp needs to use kernel calls.
diff --git a/noncore/net/networksetup/interfaces/interface.cpp b/noncore/net/networksetup/interfaces/interface.cpp
index 4129b3d..7ffa76f 100644
--- a/noncore/net/networksetup/interfaces/interface.cpp
+++ b/noncore/net/networksetup/interfaces/interface.cpp
@@ -1,297 +1,297 @@
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 DHCP_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), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){
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(const QString &name){ 45void Interface::setHardwareName(const 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 emit (updateMessage("Unable to start interface,\n already started")); 67 emit (updateMessage("Unable to start interface,\n already started"));
68 return; 68 return;
69 } 69 }
70 70
71 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); 71 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
72 // See if it was successfull... 72 // See if it was successfull...
73 if(ret != 0){ 73 if(ret != 0){
74 emit (updateMessage("Starting interface failed.")); 74 emit (updateMessage("Starting interface failed."));
75 return; 75 return;
76 } 76 }
77 77
78 status = true; 78 status = true;
79 refresh(); 79 refresh();
80 emit (updateMessage("Start successfull")); 80 emit (updateMessage("Start successfull"));
81} 81}
82 82
83/** 83/**
84 * Try to stop the interface. 84 * Try to stop the interface.
85 */ 85 */
86void Interface::stop(){ 86void Interface::stop(){
87 // check to see if we are already stopped. 87 // check to see if we are already stopped.
88 if(false == status){ 88 if(false == status){
89 emit (updateMessage("Unable to stop interface,\n already stopped")); 89 emit (updateMessage("Unable to stop interface,\n already stopped"));
90 return; 90 return;
91 } 91 }
92 92
93 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); 93 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
94 if(ret != 0){ 94 if(ret != 0){
95 emit (updateMessage("Stopping interface failed.")); 95 emit (updateMessage("Stopping interface failed."));
96 return; 96 return;
97 } 97 }
98 98
99 status = false; 99 status = false;
100 refresh(); 100 refresh();
101 emit (updateMessage("Stop successfull")); 101 emit (updateMessage("Stop successfull"));
102} 102}
103 103
104/** 104/**
105 * Try to restart the interface. 105 * Try to restart the interface.
106 */ 106 */
107void Interface::restart(){ 107void Interface::restart(){
108 stop(); 108 stop();
109 start(); 109 start();
110} 110}
111 111
112/** 112/**
113 * Try to refresh the information about the interface. 113 * Try to refresh the information about the interface.
114 * First call ifconfig, then check the dhcp-info file 114 * First call ifconfig, then check the dhcp-info file
115 * @return bool true if successfull. 115 * @return bool true if successfull.
116 */ 116 */
117bool Interface::refresh(){ 117bool Interface::refresh(){
118 // See if we are up. 118 // See if we are up.
119 if(status == false){ 119 if(status == false){
120 macAddress = ""; 120 macAddress = "";
121 ip = "0.0.0.0"; 121 ip = "0.0.0.0";
122 subnetMask = "0.0.0.0"; 122 subnetMask = "0.0.0.0";
123 broadcast = ""; 123 broadcast = "";
124 dhcp = false; 124 dhcp = false;
125 dhcpServerIp = ""; 125 dhcpServerIp = "";
126 leaseObtained = ""; 126 leaseObtained = "";
127 leaseExpires = ""; 127 leaseExpires = "";
128 emit(updateInterface(this)); 128 emit(updateInterface(this));
129 return true; 129 return true;
130 } 130 }
131 131
132 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); 132 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
133 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); 133 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
134 if(ret != 0){ 134 if(ret != 0){
135 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 135 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
136 return false; 136 return false;
137 } 137 }
138 138
139 QFile file(fileName); 139 QFile file(fileName);
140 if (!file.open(IO_ReadOnly)){ 140 if (!file.open(IO_ReadOnly)){
141 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 141 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
142 return false; 142 return false;
143 } 143 }
144 144
145 // Set to the defaults 145 // Set to the defaults
146 macAddress = ""; 146 macAddress = "";
147 ip = "0.0.0.0"; 147 ip = "0.0.0.0";
148 subnetMask = "0.0.0.0"; 148 subnetMask = "0.0.0.0";
149 broadcast = ""; 149 broadcast = "";
150 150
151 QTextStream stream( &file ); 151 QTextStream stream( &file );
152 QString line; 152 QString line;
153 while ( !stream.eof() ) { 153 while ( !stream.eof() ) {
154 line = stream.readLine(); 154 line = stream.readLine();
155 if(line.contains("HWaddr")){ 155 if(line.contains("HWaddr")){
156 int mac = line.find("HWaddr"); 156 int mac = line.find("HWaddr");
157 macAddress = line.mid(mac+7, line.length()); 157 macAddress = line.mid(mac+7, line.length());
158 } 158 }
159 if(line.contains("inet addr")){ 159 if(line.contains("inet addr")){
160 int ipl = line.find("inet addr"); 160 int ipl = line.find("inet addr");
161 int space = line.find(" ", ipl+10); 161 int space = line.find(" ", ipl+10);
162 ip = line.mid(ipl+10, space-ipl-10); 162 ip = line.mid(ipl+10, space-ipl-10);
163 } 163 }
164 if(line.contains("Mask")){ 164 if(line.contains("Mask")){
165 int mask = line.find("Mask"); 165 int mask = line.find("Mask");
166 subnetMask = line.mid(mask+5, line.length()); 166 subnetMask = line.mid(mask+5, line.length());
167 } 167 }
168 if(line.contains("Bcast")){ 168 if(line.contains("Bcast")){
169 int mask = line.find("Bcast"); 169 int mask = line.find("Bcast");
170 int space = line.find(" ", mask+6); 170 int space = line.find(" ", mask+6);
171 broadcast = line.mid(mask+6, space-mask-6); 171 broadcast = line.mid(mask+6, space-mask-6);
172 } 172 }
173 } 173 }
174 file.close(); 174 file.close();
175 QFile::remove(fileName); 175 QFile::remove(fileName);
176 176
177 // DHCP TESTING 177 // DHCP TESTING
178 // reset DHCP info 178 // reset DHCP info
179 dhcpServerIp = ""; 179 dhcpServerIp = "";
180 leaseObtained = ""; 180 leaseObtained = "";
181 leaseExpires = ""; 181 leaseExpires = "";
182 dhcp = false; 182 dhcp = false;
183 183
184 QString dhcpDirectory(DHCP_INFO_DIR); 184 QString dhcpDirectory(DHCP_INFO_DIR);
185 QDir d(dhcpDirectory); 185 QDir d(dhcpDirectory);
186 if(!d.exists(dhcpDirectory)) 186 if(!d.exists(dhcpDirectory))
187 dhcpDirectory = "/var/run"; 187 dhcpDirectory = "/var/run";
188 188
189 // See if we have 189 // See if we have
190 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); 190 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
191 // If there is no DHCP information then exit now with no errors. 191 // If there is no DHCP information then exit now with no errors.
192 if(!QFile::exists(dhcpFile)){ 192 if(!QFile::exists(dhcpFile)){
193 emit(updateInterface(this)); 193 emit(updateInterface(this));
194 return true; 194 return true;
195 } 195 }
196 196
197 file.setName(dhcpFile); 197 file.setName(dhcpFile);
198 if (!file.open(IO_ReadOnly)){ 198 if (!file.open(IO_ReadOnly)){
199 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 199 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
200 return false; 200 return false;
201 } 201 }
202 202
203 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 203 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
204 int leaseTime = 0; 204 int leaseTime = 0;
205 int renewalTime = 0; 205 int renewalTime = 0;
206 206
207 stream.setDevice( &file ); 207 stream.setDevice( &file );
208 while ( !stream.eof() ) { 208 while ( !stream.eof() ) {
209 line = stream.readLine(); 209 line = stream.readLine();
210 if(line.contains("DHCPSIADDR=")) 210 if(line.contains("DHCPSIADDR="))
211 dhcpServerIp = line.mid(11, line.length()); 211 dhcpServerIp = line.mid(11, line.length());
212 if(line.contains("LEASETIME=")) 212 if(line.contains("LEASETIME="))
213 leaseTime = line.mid(10, line.length()).toInt(); 213 leaseTime = line.mid(10, line.length()).toInt();
214 if(line.contains("RENEWALTIME=")) 214 if(line.contains("RENEWALTIME="))
215 renewalTime = line.mid(12, line.length()).toInt(); 215 renewalTime = line.mid(12, line.length()).toInt();
216 } 216 }
217 file.close(); 217 file.close();
218 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 218 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
219 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 219 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
220 220
221 // Get the pid of the deamond 221 // Get the pid of the deamond
222 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); 222 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
223 file.setName(dhcpFile); 223 file.setName(dhcpFile);
224 if (!file.open(IO_ReadOnly)){ 224 if (!file.open(IO_ReadOnly)){
225 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 225 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
226 return false; 226 return false;
227 } 227 }
228 228
229 int pid = -1; 229 int pid = -1;
230 stream.setDevice( &file ); 230 stream.setDevice( &file );
231 while ( !stream.eof() ) { 231 while ( !stream.eof() ) {
232 line = stream.readLine(); 232 line = stream.readLine();
233 pid = line.toInt(); 233 pid = line.toInt();
234 } 234 }
235 file.close(); 235 file.close();
236 236
237 if( pid == -1){ 237 if( pid == -1){
238 qDebug("Interface: Could not get pid of dhcpc deamon."); 238 qDebug("Interface: Could not get pid of dhcpc deamon.");
239 return false; 239 return false;
240 } 240 }
241 241
242 // Get the start running time of the deamon 242 // Get the start running time of the deamon
243 fileName = (QString("/proc/%1/stat").arg(pid)); 243 fileName = (QString("/proc/%1/stat").arg(pid));
244 file.setName(fileName); 244 file.setName(fileName);
245 stream.setDevice( &file ); 245 stream.setDevice( &file );
246 if (!file.open(IO_ReadOnly)){ 246 if (!file.open(IO_ReadOnly)){
247 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 247 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
248 return false; 248 return false;
249 } 249 }
250 while ( !stream.eof() ) { 250 while ( !stream.eof() ) {
251 line = stream.readLine(); 251 line = stream.readLine();
252 } 252 }
253 file.close(); 253 file.close();
254 long time = 0; 254 long time = 0;
255 // Grab the start time 255 // Grab the start time
256 // pid com state ppid pgrp session tty_nr tpgid flags 256 // pid com state ppid pgrp session tty_nr tpgid flags
257 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 257 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
258 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 258 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
259 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 259 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
260 // nice 0 itrealvalue starttime 260 // nice 0 itrealvalue starttime
261 "%*d %*d %*d %lu", (long*) &time); 261 "%*d %*d %*d %lu", (long*) &time);
262 time = time/100; 262 time = time/100;
263 263
264 QDateTime datetime(QDateTime::currentDateTime()); 264 QDateTime datetime(QDateTime::currentDateTime());
265 265
266 // Get the uptime of the computer. 266 // Get the uptime of the computer.
267 QFile f("/proc/uptime"); 267 QFile f("/proc/uptime");
268 if ( f.open(IO_ReadOnly) ) { // file opened successfully 268 if ( f.open(IO_ReadOnly) ) { // file opened successfully
269 QTextStream t( &f ); // use a text stream 269 QTextStream t( &f ); // use a text stream
270 int sec = 0; 270 int sec = 0;
271 t >> sec; 271 t >> sec;
272 datetime = datetime.addSecs((-1*sec)); 272 datetime = datetime.addSecs((-1*sec));
273 f.close(); 273 f.close();
274 } 274 }
275 else{ 275 else{
276 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 276 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
277 return false; 277 return false;
278 } 278 }
279 279
280 datetime = datetime.addSecs(time); 280 datetime = datetime.addSecs(time);
281 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); 281 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
282 282
283 // Calculate the start and renew times 283 // Calculate the start and renew times
284 leaseObtained= datetime.toString(); 284 leaseObtained= datetime.toString();
285 285
286 // Calculate the start and renew times 286 // Calculate the start and renew times
287 datetime = datetime.addSecs(leaseTime); 287 datetime = datetime.addSecs(leaseTime);
288 leaseExpires = datetime.toString(); 288 leaseExpires = datetime.toString();
289 289
290 dhcp = true; 290 dhcp = true;
291 291
292 emit(updateInterface(this)); 292 emit(updateInterface(this));
293 return true; 293 return true;
294} 294}
295 295
296// interface.cpp 296// interface.cpp
297 297
diff --git a/noncore/net/networksetup/interfaces/interface.h b/noncore/net/networksetup/interfaces/interface.h
index 989d6d8..d37834a 100644
--- a/noncore/net/networksetup/interfaces/interface.h
+++ b/noncore/net/networksetup/interfaces/interface.h
@@ -1,71 +1,72 @@
1#ifndef INTERFACE_H 1#ifndef INTERFACE_H
2#define INTERFACE_H 2#define INTERFACE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7class Module; 7class Module;
8 8
9class Interface : public QObject{ 9class Interface : public QObject{
10 Q_OBJECT 10 Q_OBJECT
11 11
12signals: 12signals:
13 void updateInterface(Interface *i); 13 void updateInterface(Interface *i);
14 void updateMessage(const QString &message); 14 void updateMessage(const QString &message);
15 15
16public: 16public:
17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false); 17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
18 18
19 QString getInterfaceName(){ QString n(this->name()); return n; }; 19 QString getInterfaceName() const { QString n(this->name()); return n; };
20 20
21 bool getStatus(){ return status; }; 21 bool getStatus() const { return status; };
22 void setStatus(bool newStatus); 22 void setStatus(bool newStatus);
23 23
24 bool isAttached(){ return attached; }; 24 bool isAttached() const { return attached; };
25 void setAttached(bool isAttached=false); 25 void setAttached(bool isAttached=false);
26 26
27 QString getHardwareName(){ return hardwareName; }; 27 QString getHardwareName() const { return hardwareName; };
28 void setHardwareName(const QString &name="Unknown"); 28 void setHardwareName(const QString &name="Unknown");
29 29
30 Module* getModuleOwner(){ return moduleOwner; }; 30 Module* getModuleOwner() const { return moduleOwner; };
31 void setModuleOwner(Module *owner=NULL); 31 void setModuleOwner(Module *owner=NULL);
32 32
33 // inet information. 33 // inet information.
34 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress() const { return macAddress; };
35 QString getIp(){ return ip; }; 35 QString getIp() const { return ip; };
36 QString getSubnetMask(){ return subnetMask; }; 36 QString getSubnetMask() const { return subnetMask; };
37 QString getBroadcast(){ return broadcast; }; 37 QString getBroadcast() const { return broadcast; };
38 bool isDhcp(){ return dhcp; }; 38 bool isDhcp() const { return dhcp; };
39 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp() const { return dhcpServerIp; };
40 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained() const { return leaseObtained; };
41 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires() const { return leaseExpires; };
42 42
43public slots: 43public slots:
44 bool refresh(); 44 bool refresh();
45 void start(); 45 void start();
46 void stop(); 46 void stop();
47 void restart(); 47 void restart();
48 48
49private: 49private:
50 // Interface information 50 // Interface information
51 bool status;
52 bool attached;
53 QString hardwareName; 51 QString hardwareName;
54 Module *moduleOwner; 52 Module *moduleOwner;
55 53 bool status;
54 bool attached;
55
56 // Network information 56 // Network information
57 QString macAddress;
58 QString ip;
59 QString broadcast;
60 QString subnetMask;
61 bool dhcp; 57 bool dhcp;
62 QString dhcpServerIp; 58 QString dhcpServerIp;
63 QString leaseObtained; 59 QString leaseObtained;
64 QString leaseExpires; 60 QString leaseExpires;
65 61
62 QString macAddress;
63 QString ip;
64 QString broadcast;
65 QString subnetMask;
66
66}; 67};
67 68
68#endif 69#endif
69 70
70// interface.h 71// interface.h
71 72
diff --git a/noncore/net/networksetup/interfaces/interfaces.cpp b/noncore/net/networksetup/interfaces/interfaces.cpp
index e49998e..8f685fe 100644
--- a/noncore/net/networksetup/interfaces/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces/interfaces.cpp
@@ -1,527 +1,527 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qregexp.h> 5#include <qregexp.h>
6 6
7// The three stanza's 7// The three stanza's
8#define AUTO "auto" 8#define AUTO "auto"
9#define IFACE "iface" 9#define IFACE "iface"
10#define MAPPING "mapping" 10#define MAPPING "mapping"
11 11
12/** 12/**
13 * Constructor. Reads in the interfaces file and then split the file up by 13 * Constructor. Reads in the interfaces file and then split the file up by
14 * the \n for interfaces variable. 14 * the \n for interfaces variable.
15 * @param useInterfacesFile if an interface file other then the default is 15 * @param useInterfacesFile if an interface file other then the default is
16 * desired to be used it should be passed in. 16 * desired to be used it should be passed in.
17 */ 17 */
18Interfaces::Interfaces(QString useInterfacesFile){ 18Interfaces::Interfaces(QString useInterfacesFile){
19 acceptedFamily.append(INTERFACES_FAMILY_INET); 19 acceptedFamily.append(INTERFACES_FAMILY_INET);
20 acceptedFamily.append(INTERFACES_FAMILY_IPX); 20 acceptedFamily.append(INTERFACES_FAMILY_IPX);
21 acceptedFamily.append(INTERFACES_FAMILY_INET6); 21 acceptedFamily.append(INTERFACES_FAMILY_INET6);
22 22
23 interfacesFile = useInterfacesFile; 23 interfacesFile = useInterfacesFile;
24 QFile file(interfacesFile); 24 QFile file(interfacesFile);
25 if (!file.open(IO_ReadOnly)){ 25 if (!file.open(IO_ReadOnly)){
26 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); 26 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
27 currentIface = interfaces.end(); 27 currentIface = interfaces.end();
28 currentMapping = interfaces.end(); 28 currentMapping = interfaces.end();
29 return; 29 return;
30 } 30 }
31 QTextStream stream( &file ); 31 QTextStream stream( &file );
32 QString line; 32 QString line;
33 while ( !stream.eof() ) { 33 while ( !stream.eof() ) {
34 line += stream.readLine(); 34 line += stream.readLine();
35 line += "\n"; 35 line += "\n";
36 } 36 }
37 file.close(); 37 file.close();
38 interfaces = QStringList::split("\n", line, true); 38 interfaces = QStringList::split("\n", line, true);
39 39
40 currentIface = interfaces.end(); 40 currentIface = interfaces.end();
41 currentMapping = interfaces.end(); 41 currentMapping = interfaces.end();
42} 42}
43 43
44 44
45/** 45/**
46 * Get a list of all interfaces in the interface file. Usefull for 46 * Get a list of all interfaces in the interface file. Usefull for
47 * hardware that is not currently connected such as an 802.11b card 47 * hardware that is not currently connected such as an 802.11b card
48 * not plugged in, but configured for when it is plugged in. 48 * not plugged in, but configured for when it is plugged in.
49 * @return Return string list of interfaces. 49 * @return Return string list of interfaces.
50 **/ 50 **/
51QStringList Interfaces::getInterfaceList(){ 51QStringList Interfaces::getInterfaceList(){
52 QStringList list; 52 QStringList list;
53 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 53 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
54 QString line = (*it).simplifyWhiteSpace(); 54 QString line = (*it).simplifyWhiteSpace();
55 if(line.contains(IFACE) && line.at(0) != '#'){ 55 if(line.contains(IFACE) && line.at(0) != '#'){
56 line = line.mid(QString(IFACE).length() +1, line.length()); 56 line = line.mid(QString(IFACE).length() +1, line.length());
57 line = line.simplifyWhiteSpace(); 57 line = line.simplifyWhiteSpace();
58 int findSpace = line.find(" "); 58 int findSpace = line.find(" ");
59 if( findSpace >= 0){ 59 if( findSpace >= 0){
60 line = line.mid(0, findSpace); 60 line = line.mid(0, findSpace);
61 list.append(line); 61 list.append(line);
62 } 62 }
63 } 63 }
64 } 64 }
65 return list; 65 return list;
66} 66}
67 67
68/** 68/**
69 * Find out if interface is in an "auto" group or not. 69 * Find out if interface is in an "auto" group or not.
70 * Report any duplicates such as eth0 being in two differnt auto's 70 * Report any duplicates such as eth0 being in two differnt auto's
71 * @param interface interface to check to see if it is on or not. 71 * @param interface interface to check to see if it is on or not.
72 * @return true is interface is in auto 72 * @return true is interface is in auto
73 */ 73 */
74bool Interfaces::isAuto(const QString &interface){ 74bool Interfaces::isAuto(const QString &interface) const {
75 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 75 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
76 QStringList awi = autoLines.grep(QRegExp(interface)); 76 QStringList awi = autoLines.grep(QRegExp(interface));
77 if(awi.count() > 1) 77 if(awi.count() > 1)
78 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 78 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
79 if(awi.count() < 1) 79 if(awi.count() < 1)
80 return false; 80 return false;
81 return true; 81 return true;
82} 82}
83 83
84/** 84/**
85 * Attempt to set the auto option for interface to setAuto. 85 * Attempt to set the auto option for interface to setAuto.
86 * @param interface the interface to set 86 * @param interface the interface to set
87 * @param setAuto the value to set interface to. 87 * @param setAuto the value to set interface to.
88 * @return false if already set to setAuto. 88 * @return false if already set to setAuto.
89 * */ 89 * */
90bool Interfaces::setAuto(const QString &interface, bool setAuto){ 90bool Interfaces::setAuto(const QString &interface, bool setAuto){
91 // Don't need to set it if it is already set. 91 // Don't need to set it if it is already set.
92 if(isAuto(interface) == setAuto) 92 if(isAuto(interface) == setAuto)
93 return false; 93 return false;
94 94
95 bool changed = false; 95 bool changed = false;
96 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 96 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
97 if((*it).contains(AUTO)){ 97 if((*it).contains(AUTO)){
98 //We know that they are not in any group so let add to this auto. 98 //We know that they are not in any group so let add to this auto.
99 if(setAuto){ 99 if(setAuto){
100 (*it) = (*it) += " " + interface; 100 (*it) = (*it) += " " + interface;
101 // Don't care to have such thins as: auto eth0 lo usb0 101 // Don't care to have such thins as: auto eth0 lo usb0
102 (*it) = (*it).simplifyWhiteSpace(); 102 (*it) = (*it).simplifyWhiteSpace();
103 changed = true; 103 changed = true;
104 break; 104 break;
105 } 105 }
106 // else see if we need to remove from this one 106 // else see if we need to remove from this one
107 else{ 107 else{
108 if((*it).contains(interface)){ 108 if((*it).contains(interface)){
109 (*it) = (*it).replace(QRegExp(interface), ""); 109 (*it) = (*it).replace(QRegExp(interface), "");
110 // if AUTO is the only thing left clear the line 110 // if AUTO is the only thing left clear the line
111 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) 111 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO)
112 (*it) = ""; 112 (*it) = "";
113 changed = true; 113 changed = true;
114 // Don't break because we want to make sure we remove all cases. 114 // Don't break because we want to make sure we remove all cases.
115 } 115 }
116 } 116 }
117 } 117 }
118 } 118 }
119 // In the case where there is no AUTO field add one. 119 // In the case where there is no AUTO field add one.
120 if(!changed && setAuto) 120 if(!changed && setAuto)
121 interfaces.append(QString(AUTO" %1").arg(interface)); 121 interfaces.append(QString(AUTO" %1").arg(interface));
122 return true; 122 return true;
123} 123}
124 124
125/** 125/**
126 * Set the current interface to interface. This needs to be done before you 126 * Set the current interface to interface. This needs to be done before you
127 * can call getFamily(), getMethod, and get/setOption(). 127 * can call getFamily(), getMethod, and get/setOption().
128 * @param interface the name of the interface to set. All whitespace is 128 * @param interface the name of the interface to set. All whitespace is
129 * removed from the interface name. 129 * removed from the interface name.
130 * @return bool true if it is successfull. 130 * @return bool true if it is successfull.
131 */ 131 */
132bool Interfaces::setInterface(QString interface){ 132bool Interfaces::setInterface(QString interface){
133 interface = interface.simplifyWhiteSpace(); 133 interface = interface.simplifyWhiteSpace();
134 interface = interface.replace(QRegExp(" "), ""); 134 interface = interface.replace(QRegExp(" "), "");
135 return setStanza(IFACE, interface, currentIface); 135 return setStanza(IFACE, interface, currentIface);
136} 136}
137 137
138/** 138/**
139 * A quick helper funtion to see if the current interface is set. 139 * A quick helper funtion to see if the current interface is set.
140 * @return bool true if set, false otherwise. 140 * @return bool true if set, false otherwise.
141 */ 141 */
142bool Interfaces::isInterfaceSet(){ 142bool Interfaces::isInterfaceSet() const {
143 return (currentIface != interfaces.end()); 143 return (interfaces.end() != currentIface);
144} 144}
145 145
146/** 146/**
147 * Add a new interface of with the settings - family and method 147 * Add a new interface of with the settings - family and method
148 * @param interface the name of the interface to set. All whitespace is 148 * @param interface the name of the interface to set. All whitespace is
149 * removed from the interface name. 149 * removed from the interface name.
150 * @param family the family of this interface inet or inet, ipx or inet6 150 * @param family the family of this interface inet or inet, ipx or inet6
151 * Must of one of the families defined in interfaces.h 151 * Must of one of the families defined in interfaces.h
152 * @param method for the family. see interfaces man page for family methods. 152 * @param method for the family. see interfaces man page for family methods.
153 * @return true if successfull. 153 * @return true if successfull.
154 */ 154 */
155bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ 155bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
156 if(0 == acceptedFamily.contains(family)) 156 if(0 == acceptedFamily.contains(family))
157 return false; 157 return false;
158 QString newInterface = interface.simplifyWhiteSpace(); 158 QString newInterface = interface.simplifyWhiteSpace();
159 newInterface = newInterface.replace(QRegExp(" "), ""); 159 newInterface = newInterface.replace(QRegExp(" "), "");
160 interfaces.append(""); 160 interfaces.append("");
161 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); 161 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
162 return true; 162 return true;
163} 163}
164 164
165/** 165/**
166 * Copies interface with name interface to name newInterface 166 * Copies interface with name interface to name newInterface
167 * @param newInterface name of the new interface. 167 * @param newInterface name of the new interface.
168 * @return bool true if successfull 168 * @return bool true if successfull
169 */ 169 */
170bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ 170bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
171 if(!setInterface(interface)) 171 if(!setInterface(interface))
172 return false; 172 return false;
173 173
174 // Store the old interface and bump past the stanza line. 174 // Store the old interface and bump past the stanza line.
175 QStringList::Iterator it = currentIface; 175 QStringList::Iterator it = currentIface;
176 it++; 176 it++;
177 177
178 // Add the new interface 178 // Add the new interface
179 bool error; 179 bool error;
180 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 180 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
181 if(!setInterface(newInterface)) 181 if(!setInterface(newInterface))
182 return false; 182 return false;
183 183
184 QStringList::Iterator newIface = currentIface; 184 QStringList::Iterator newIface = currentIface;
185 newIface++; 185 newIface++;
186 186
187 // Copy all of the lines 187 // Copy all of the lines
188 for ( ; it != interfaces.end(); ++it ){ 188 for ( ; it != interfaces.end(); ++it ){
189 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 189 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
190 break; 190 break;
191 newIface = interfaces.insert(newIface, *it); 191 newIface = interfaces.insert(newIface, *it);
192 } 192 }
193 193
194 return true; 194 return true;
195} 195}
196 196
197/** 197/**
198 * Remove the currently selected interface and all of its options. 198 * Remove the currently selected interface and all of its options.
199 * @return bool if successfull or not. 199 * @return bool if successfull or not.
200 */ 200 */
201bool Interfaces::removeInterface(){ 201bool Interfaces::removeInterface(){
202 return removeStanza(currentIface); 202 return removeStanza(currentIface);
203} 203}
204 204
205/** 205/**
206 * Gets the hardware name of the interface that is currently selected. 206 * Gets the hardware name of the interface that is currently selected.
207 * @return QString name of the hardware interface (eth0, usb2, wlan1...). 207 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
208 * @param error set to true if any error occurs, false otherwise. 208 * @param error set to true if any error occurs, false otherwise.
209 */ 209 */
210QString Interfaces::getInterfaceName(bool &error){ 210QString Interfaces::getInterfaceName(bool &error){
211 if(currentIface == interfaces.end()){ 211 if(currentIface == interfaces.end()){
212 error = true; 212 error = true;
213 return QString(); 213 return QString();
214 } 214 }
215 QString line = (*currentIface); 215 QString line = (*currentIface);
216 line = line.mid(QString(IFACE).length() +1, line.length()); 216 line = line.mid(QString(IFACE).length() +1, line.length());
217 line = line.simplifyWhiteSpace(); 217 line = line.simplifyWhiteSpace();
218 int findSpace = line.find(" "); 218 int findSpace = line.find(" ");
219 if( findSpace < 0){ 219 if( findSpace < 0){
220 error = true; 220 error = true;
221 return QString(); 221 return QString();
222 } 222 }
223 error = false; 223 error = false;
224 return line.mid(0, findSpace); 224 return line.mid(0, findSpace);
225} 225}
226 226
227/** 227/**
228 * Gets the family name of the interface that is currently selected. 228 * Gets the family name of the interface that is currently selected.
229 * @return QString name of the family (inet, inet6, ipx). 229 * @return QString name of the family (inet, inet6, ipx).
230 * @param error set to true if any error occurs, false otherwise. 230 * @param error set to true if any error occurs, false otherwise.
231 */ 231 */
232QString Interfaces::getInterfaceFamily(bool &error){ 232QString Interfaces::getInterfaceFamily(bool &error){
233 QString name = getInterfaceName(error); 233 QString name = getInterfaceName(error);
234 if(error) 234 if(error)
235 return QString(); 235 return QString();
236 QString line = (*currentIface); 236 QString line = (*currentIface);
237 line = line.mid(QString(IFACE).length() +1, line.length()); 237 line = line.mid(QString(IFACE).length() +1, line.length());
238 line = line.mid(name.length()+1, line.length()); 238 line = line.mid(name.length()+1, line.length());
239 line = line.simplifyWhiteSpace(); 239 line = line.simplifyWhiteSpace();
240 int findSpace = line.find(" "); 240 int findSpace = line.find(" ");
241 if( findSpace < 0){ 241 if( findSpace < 0){
242 error = true; 242 error = true;
243 return QString(); 243 return QString();
244 } 244 }
245 error = false; 245 error = false;
246 return line.mid(0, findSpace); 246 return line.mid(0, findSpace);
247} 247}
248 248
249/** 249/**
250 * Gets the method of the interface that is currently selected. 250 * Gets the method of the interface that is currently selected.
251 * @return QString name of the method such as staic or dhcp. 251 * @return QString name of the method such as staic or dhcp.
252 * See the man page of interfaces for possible methods depending on the family. 252 * See the man page of interfaces for possible methods depending on the family.
253 * @param error set to true if any error occurs, false otherwise. 253 * @param error set to true if any error occurs, false otherwise.
254 */ 254 */
255QString Interfaces::getInterfaceMethod(bool &error){ 255QString Interfaces::getInterfaceMethod(bool &error){
256 QString name = getInterfaceName(error); 256 QString name = getInterfaceName(error);
257 if(error) 257 if(error)
258 return QString(); 258 return QString();
259 QString family = getInterfaceFamily(error); 259 QString family = getInterfaceFamily(error);
260 if(error) 260 if(error)
261 return QString(); 261 return QString();
262 QString line = (*currentIface); 262 QString line = (*currentIface);
263 line = line.mid(QString(IFACE).length()+1, line.length()); 263 line = line.mid(QString(IFACE).length()+1, line.length());
264 line = line.mid(name.length()+1, line.length()); 264 line = line.mid(name.length()+1, line.length());
265 line = line.mid(family.length()+1, line.length()); 265 line = line.mid(family.length()+1, line.length());
266 line = line.simplifyWhiteSpace(); 266 line = line.simplifyWhiteSpace();
267 error = false; 267 error = false;
268 return line; 268 return line;
269} 269}
270 270
271/** 271/**
272 * Sets the interface name to newName. 272 * Sets the interface name to newName.
273 * @param newName the new name of the interface. All whitespace is removed. 273 * @param newName the new name of the interface. All whitespace is removed.
274 * @return bool true if successfull. 274 * @return bool true if successfull.
275 */ 275 */
276bool Interfaces::setInterfaceName(const QString &newName){ 276bool Interfaces::setInterfaceName(const QString &newName){
277 if(currentIface == interfaces.end()) 277 if(currentIface == interfaces.end())
278 return false; 278 return false;
279 QString name = newName.simplifyWhiteSpace(); 279 QString name = newName.simplifyWhiteSpace();
280 name = name.replace(QRegExp(" "), ""); 280 name = name.replace(QRegExp(" "), "");
281 bool returnValue = false; 281 bool returnValue = false;
282 (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 282 (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
283 return !returnValue; 283 return !returnValue;
284} 284}
285 285
286/** 286/**
287 * Sets the interface family to newName. 287 * Sets the interface family to newName.
288 * @param newName the new name of the interface. Must be one of the families 288 * @param newName the new name of the interface. Must be one of the families
289 * defined in the interfaces.h file. 289 * defined in the interfaces.h file.
290 * @return bool true if successfull. 290 * @return bool true if successfull.
291 */ 291 */
292bool Interfaces::setInterfaceFamily(const QString &newName){ 292bool Interfaces::setInterfaceFamily(const QString &newName){
293 if(currentIface == interfaces.end()) 293 if(currentIface == interfaces.end())
294 return false; 294 return false;
295 if(acceptedFamily.contains(newName)==0) 295 if(acceptedFamily.contains(newName)==0)
296 return false; 296 return false;
297 bool returnValue = false; 297 bool returnValue = false;
298 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 298 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
299 return !returnValue; 299 return !returnValue;
300} 300}
301 301
302/** 302/**
303 * Sets the interface method to newName 303 * Sets the interface method to newName
304 * @param newName the new name of the interface 304 * @param newName the new name of the interface
305 * @return bool true if successfull. 305 * @return bool true if successfull.
306 */ 306 */
307bool Interfaces::setInterfaceMethod(const QString &newName){ 307bool Interfaces::setInterfaceMethod(const QString &newName){
308 if(currentIface == interfaces.end()) 308 if(currentIface == interfaces.end())
309 return false; 309 return false;
310 bool returnValue = false; 310 bool returnValue = false;
311 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 311 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
312 return !returnValue; 312 return !returnValue;
313} 313}
314 314
315/** 315/**
316 * Get a value for an option in the currently selected interface. For example 316 * Get a value for an option in the currently selected interface. For example
317 * calling getInterfaceOption("address") on the following stanza would 317 * calling getInterfaceOption("address") on the following stanza would
318 * return 192.168.1.1. 318 * return 192.168.1.1.
319 * iface eth0 static 319 * iface eth0 static
320 * address 192.168.1.1 320 * address 192.168.1.1
321 * @param option the options to get the value. 321 * @param option the options to get the value.
322 * @param error set to true if any error occurs, false otherwise. 322 * @param error set to true if any error occurs, false otherwise.
323 * @return QString the options value. QString::null if error == true 323 * @return QString the options value. QString::null if error == true
324 */ 324 */
325QString Interfaces::getInterfaceOption(const QString &option, bool &error){ 325QString Interfaces::getInterfaceOption(const QString &option, bool &error){
326 return getOption(currentIface, option, error); 326 return getOption(currentIface, option, error);
327} 327}
328 328
329/** 329/**
330 * Set a value for an option in the currently selected interface. If option 330 * Set a value for an option in the currently selected interface. If option
331 * doesn't exist then it is added along with the value. 331 * doesn't exist then it is added along with the value.
332 * @param option the options to set the value. 332 * @param option the options to set the value.
333 * @param value the value that option should be set to. 333 * @param value the value that option should be set to.
334 * @param error set to true if any error occurs, false otherwise. 334 * @param error set to true if any error occurs, false otherwise.
335 * @return QString the options value. QString::null if error == true 335 * @return QString the options value. QString::null if error == true
336 */ 336 */
337bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ 337bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
338 return setOption(currentIface, option, value); 338 return setOption(currentIface, option, value);
339} 339}
340 340
341/** 341/**
342 * Removes a value for an option in the currently selected interface. 342 * Removes a value for an option in the currently selected interface.
343 * @param option the options to set the value. 343 * @param option the options to set the value.
344 * @param value the value that option should be set to. 344 * @param value the value that option should be set to.
345 * @param error set to true if any error occurs, false otherwise. 345 * @param error set to true if any error occurs, false otherwise.
346 * @return QString the options value. QString::null if error == true 346 * @return QString the options value. QString::null if error == true
347 */ 347 */
348bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ 348bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
349 return removeOption(currentIface, option, value); 349 return removeOption(currentIface, option, value);
350} 350}
351 351
352/** 352/**
353 * Removes all of the options from the currently selected interface. 353 * Removes all of the options from the currently selected interface.
354 * @return bool error if if successfull 354 * @return bool error if if successfull
355 */ 355 */
356bool Interfaces::removeAllInterfaceOptions(){ 356bool Interfaces::removeAllInterfaceOptions(){
357 return removeAllOptions(currentIface); 357 return removeAllOptions(currentIface);
358} 358}
359 359
360/** 360/**
361 * Set the current map to interface's map. This needs to be done before you 361 * Set the current map to interface's map. This needs to be done before you
362 * can call addMapping(), set/getMap(), and get/setScript(). 362 * can call addMapping(), set/getMap(), and get/setScript().
363 * @param interface the name of the interface to set. All whitespace is 363 * @param interface the name of the interface to set. All whitespace is
364 * removed from the interface name. 364 * removed from the interface name.
365 * @return bool true if it is successfull. 365 * @return bool true if it is successfull.
366 */ 366 */
367bool Interfaces::setMapping(const QString &interface){ 367bool Interfaces::setMapping(const QString &interface){
368 QString interfaceName = interface.simplifyWhiteSpace(); 368 QString interfaceName = interface.simplifyWhiteSpace();
369 interfaceName = interfaceName.replace(QRegExp(" "), ""); 369 interfaceName = interfaceName.replace(QRegExp(" "), "");
370 return setStanza(MAPPING, interfaceName, currentMapping); 370 return setStanza(MAPPING, interfaceName, currentMapping);
371} 371}
372 372
373/** 373/**
374 * Adds a new Mapping to the interfaces file with interfaces. 374 * Adds a new Mapping to the interfaces file with interfaces.
375 * @param interface the name(s) of the interfaces to set to this mapping 375 * @param interface the name(s) of the interfaces to set to this mapping
376 */ 376 */
377void Interfaces::addMapping(const QString &option){ 377void Interfaces::addMapping(const QString &option){
378 interfaces.append(""); 378 interfaces.append("");
379 interfaces.append(QString(MAPPING " %1").arg(option)); 379 interfaces.append(QString(MAPPING " %1").arg(option));
380} 380}
381 381
382/** 382/**
383 * Remove the currently selected map and all of its options. 383 * Remove the currently selected map and all of its options.
384 * @return bool if successfull or not. 384 * @return bool if successfull or not.
385 */ 385 */
386bool Interfaces::removeMapping(){ 386bool Interfaces::removeMapping(){
387 return removeStanza(currentMapping); 387 return removeStanza(currentMapping);
388} 388}
389 389
390/** 390/**
391 * Set a map option within a mapping. 391 * Set a map option within a mapping.
392 * @param map map to use 392 * @param map map to use
393 * @param value value to go with map 393 * @param value value to go with map
394 * @return bool true if it is successfull. 394 * @return bool true if it is successfull.
395 */ 395 */
396bool Interfaces::setMap(const QString &map, const QString &value){ 396bool Interfaces::setMap(const QString &map, const QString &value){
397 return setOption(currentMapping, map, value); 397 return setOption(currentMapping, map, value);
398} 398}
399 399
400/** 400/**
401 * Removes a map option within a mapping. 401 * Removes a map option within a mapping.
402 * @param map map to use 402 * @param map map to use
403 * @param value value to go with map 403 * @param value value to go with map
404 * @return bool true if it is successfull. 404 * @return bool true if it is successfull.
405 */ 405 */
406bool Interfaces::removeMap(const QString &map, const QString &value){ 406bool Interfaces::removeMap(const QString &map, const QString &value){
407 return removeOption(currentMapping, map, value); 407 return removeOption(currentMapping, map, value);
408} 408}
409 409
410/** 410/**
411 * Get a map value within a mapping. 411 * Get a map value within a mapping.
412 * @param map map to get value of 412 * @param map map to get value of
413 * @param bool true if it is successfull. 413 * @param bool true if it is successfull.
414 * @return value that goes to the map 414 * @return value that goes to the map
415 */ 415 */
416QString Interfaces::getMap(const QString &map, bool &error){ 416QString Interfaces::getMap(const QString &map, bool &error){
417 return getOption(currentMapping, map, error); 417 return getOption(currentMapping, map, error);
418} 418}
419 419
420/** 420/**
421 * Sets a script value of the current mapping to argument. 421 * Sets a script value of the current mapping to argument.
422 * @param argument the script name. 422 * @param argument the script name.
423 * @return true if successfull. 423 * @return true if successfull.
424 */ 424 */
425bool Interfaces::setScript(const QString &argument){ 425bool Interfaces::setScript(const QString &argument){
426 return setOption(currentMapping, "script", argument); 426 return setOption(currentMapping, "script", argument);
427} 427}
428 428
429/** 429/**
430 * @param error true if could not retrieve the current script argument. 430 * @param error true if could not retrieve the current script argument.
431 * @return QString the argument of the script for the current mapping. 431 * @return QString the argument of the script for the current mapping.
432 */ 432 */
433QString Interfaces::getScript(bool &error){ 433QString Interfaces::getScript(bool &error){
434 return getOption(currentMapping, "script", error); 434 return getOption(currentMapping, "script", error);
435} 435}
436 436
437 437
438 438
439/** 439/**
440 * Helper function used to parse through the QStringList and put pointers in 440 * Helper function used to parse through the QStringList and put pointers in
441 * the correct place. 441 * the correct place.
442 * @param stanza The stanza (auto, iface, mapping) to look for. 442 * @param stanza The stanza (auto, iface, mapping) to look for.
443 * @param option string that must be in the stanza's main line. 443 * @param option string that must be in the stanza's main line.
444 * @param interator interator to place at location of stanza if successfull. 444 * @param interator interator to place at location of stanza if successfull.
445 * @return bool true if the stanza is found. 445 * @return bool true if the stanza is found.
446 */ 446 */
447bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ 447bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
448 bool found = false; 448 bool found = false;
449 iterator = interfaces.end(); 449 iterator = interfaces.end();
450 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 450 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
451 QString line = (*it).simplifyWhiteSpace(); 451 QString line = (*it).simplifyWhiteSpace();
452 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ 452 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
453 uint point = line.find(option); 453 uint point = line.find(option);
454 bool valid = true; 454 bool valid = true;
455 if(point > 0){ 455 if(point > 0){
456 // There are more chars in the line. check +1 456 // There are more chars in the line. check +1
457 if(line.at(point-1) != ' ') 457 if(line.at(point-1) != ' ')
458 valid = false; 458 valid = false;
459 } 459 }
460 point += option.length(); 460 point += option.length();
461 if(point < line.length()-1){ 461 if(point < line.length()-1){
462 // There are more chars in the line. check -1 462 // There are more chars in the line. check -1
463 if(line.at(point) != ' ') 463 if(line.at(point) != ' ')
464 valid = false; 464 valid = false;
465 } 465 }
466 if(valid){ 466 if(valid){
467 if(found == true){ 467 if(found == true){
468 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 468 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
469 } 469 }
470 found = true; 470 found = true;
471 iterator = it; 471 iterator = it;
472 } 472 }
473 } 473 }
474 } 474 }
475 return found; 475 return found;
476} 476}
477 477
478/** 478/**
479 * Sets a value of an option in a stanza 479 * Sets a value of an option in a stanza
480 * @param start the start of the stanza 480 * @param start the start of the stanza
481 * @param option the option to use when setting value. 481 * @param option the option to use when setting value.
482 * @return bool true if successfull, false otherwise. 482 * @return bool true if successfull, false otherwise.
483 */ 483 */
484bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 484bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
485 if(start == interfaces.end()) 485 if(start == interfaces.end())
486 return false; 486 return false;
487 487
488 bool found = false; 488 bool found = false;
489 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 489 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
490 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 490 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
491 if(!found && value != ""){ 491 if(!found && value != ""){
492 // Got to the end of the stanza without finding it, so append it. 492 // Got to the end of the stanza without finding it, so append it.
493 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 493 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
494 } 494 }
495 found = true; 495 found = true;
496 break; 496 break;
497 } 497 }
498 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 498 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
499 // Found it in stanza so replace it. 499 // Found it in stanza so replace it.
500 if(found) 500 if(found)
501 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 501 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
502 found = true; 502 found = true;
503 (*it) = QString("\t%1 %2").arg(option).arg(value); 503 (*it) = QString("\t%1 %2").arg(option).arg(value);
504 } 504 }
505 } 505 }
506 if(!found){ 506 if(!found){
507 QStringList::Iterator p = start; 507 QStringList::Iterator p = start;
508 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 508 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
509 found = true; 509 found = true;
510 } 510 }
511 return found; 511 return found;
512} 512}
513 513
514/** 514/**
515 * Removes a stanza and all of its options 515 * Removes a stanza and all of its options
516 * @param stanza the stanza to remove 516 * @param stanza the stanza to remove
517 * @return bool true if successfull. 517 * @return bool true if successfull.
518 */ 518 */
519bool Interfaces::removeStanza(QStringList::Iterator &stanza){ 519bool Interfaces::removeStanza(QStringList::Iterator &stanza){
520 if(stanza == interfaces.end()) 520 if(stanza == interfaces.end())
521 return false; 521 return false;
522 (*stanza) = ""; 522 (*stanza) = "";
523 return removeAllOptions(stanza); 523 return removeAllOptions(stanza);
524} 524}
525 525
526/** 526/**
527 * Removes a option in a stanza 527 * Removes a option in a stanza
diff --git a/noncore/net/networksetup/interfaces/interfaces.h b/noncore/net/networksetup/interfaces/interfaces.h
index d662919..bac2a7e 100644
--- a/noncore/net/networksetup/interfaces/interfaces.h
+++ b/noncore/net/networksetup/interfaces/interfaces.h
@@ -1,77 +1,77 @@
1#ifndef INTERFACES_H 1#ifndef INTERFACES_H
2#define INTERFACES_H 2#define INTERFACES_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6 6
7#define INTERFACES_LOOPBACK "loopback" 7#define INTERFACES_LOOPBACK "loopback"
8 8
9#define INTERFACES_FAMILY_INET "inet" 9#define INTERFACES_FAMILY_INET "inet"
10#define INTERFACES_FAMILY_IPX "ipx" 10#define INTERFACES_FAMILY_IPX "ipx"
11#define INTERFACES_FAMILY_INET6 "inet6" 11#define INTERFACES_FAMILY_INET6 "inet6"
12 12
13#define INTERFACES_METHOD_DHCP "dhcp" 13#define INTERFACES_METHOD_DHCP "dhcp"
14#define INTERFACES_METHOD_STATIC "static" 14#define INTERFACES_METHOD_STATIC "static"
15#define INTERFACES_METHOD_PPP "ppp" 15#define INTERFACES_METHOD_PPP "ppp"
16 16
17/** 17/**
18 * This class provides a clean frontend for parsing the network interfaces file. 18 * This class provides a clean frontend for parsing the network interfaces file.
19 * It provides helper functions to minipulate the options within the file. 19 * It provides helper functions to minipulate the options within the file.
20 * See the interfaces man page for the syntax rules. 20 * See the interfaces man page for the syntax rules.
21 */ 21 */
22class Interfaces { 22class Interfaces {
23 23
24public: 24public:
25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); 25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
26 QStringList getInterfaceList(); 26 QStringList getInterfaceList();
27 27
28 bool isAuto(const QString &interface); 28 bool isAuto(const QString &interface) const ;
29 bool setAuto(const QString &interface, bool setAuto); 29 bool setAuto(const QString &interface, bool setAuto);
30 30
31 bool removeInterface(); 31 bool removeInterface();
32 bool addInterface(const QString &interface, const QString &family, const QString &method); 32 bool addInterface(const QString &interface, const QString &family, const QString &method);
33 bool copyInterface(const QString &oldInterface, const QString &newInterface); 33 bool copyInterface(const QString &oldInterface, const QString &newInterface);
34 bool setInterface(QString interface); 34 bool setInterface(QString interface);
35 bool isInterfaceSet(); 35 bool isInterfaceSet() const ;
36 QString getInterfaceName(bool &error); 36 QString getInterfaceName(bool &error);
37 bool setInterfaceName(const QString &newName); 37 bool setInterfaceName(const QString &newName);
38 QString getInterfaceFamily(bool &error); 38 QString getInterfaceFamily(bool &error);
39 bool setInterfaceFamily(const QString &newName); 39 bool setInterfaceFamily(const QString &newName);
40 QString getInterfaceMethod(bool &error); 40 QString getInterfaceMethod(bool &error);
41 bool setInterfaceMethod(const QString &newName); 41 bool setInterfaceMethod(const QString &newName);
42 QString getInterfaceOption(const QString &option, bool &error); 42 QString getInterfaceOption(const QString &option, bool &error);
43 bool setInterfaceOption(const QString &option, const QString &value); 43 bool setInterfaceOption(const QString &option, const QString &value);
44 bool removeInterfaceOption(const QString &option, const QString &value); 44 bool removeInterfaceOption(const QString &option, const QString &value);
45 bool removeAllInterfaceOptions(); 45 bool removeAllInterfaceOptions();
46 46
47 bool setMapping(const QString &interface); 47 bool setMapping(const QString &interface);
48 bool removeMapping(); 48 bool removeMapping();
49 void addMapping(const QString &options); 49 void addMapping(const QString &options);
50 bool setMap(const QString &map, const QString &value); 50 bool setMap(const QString &map, const QString &value);
51 bool removeMap(const QString &map, const QString &value); 51 bool removeMap(const QString &map, const QString &value);
52 QString getMap(const QString &map, bool &error); 52 QString getMap(const QString &map, bool &error);
53 bool setScript(const QString &argument); 53 bool setScript(const QString &argument);
54 QString getScript(bool &error); 54 QString getScript(bool &error);
55 55
56 bool write(); 56 bool write();
57 57
58private: 58private:
59 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator); 59 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
60 bool removeStanza(QStringList::Iterator &stanza);
60 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value); 61 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
62 bool removeAllOptions(const QStringList::Iterator &start);
61 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value); 63 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
62 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error); 64 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
63 bool removeStanza(QStringList::Iterator &stanza);
64 bool removeAllOptions(const QStringList::Iterator &start);
65 65
66 QString interfacesFile; 66 QString interfacesFile;
67 QStringList interfaces; 67 QStringList interfaces;
68 QStringList::Iterator currentIface; 68 QStringList::Iterator currentIface;
69 QStringList::Iterator currentMapping; 69 QStringList::Iterator currentMapping;
70 70
71 QStringList acceptedFamily; 71 QStringList acceptedFamily;
72}; 72};
73 73
74#endif 74#endif
75 75
76// interfaces 76// interfaces
77 77
diff --git a/noncore/net/networksetup/interfaces/interfaces.pro b/noncore/net/networksetup/interfaces/interfaces.pro
index 9a024f6..d6b43fb 100644
--- a/noncore/net/networksetup/interfaces/interfaces.pro
+++ b/noncore/net/networksetup/interfaces/interfaces.pro
@@ -1,12 +1,12 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3 #CONFIG += qt warn_on debug 3 #CONFIG += qt warn_on debug
4 DESTDIR = $(QTDIR)/lib$(PROJMAK) 4 #DESTDIR = $(QTDIR)/lib$(PROJMAK)
5 HEADERS = interface.h interfaceinformationimp.h interfaces.h interfacesetupimp.h 5 HEADERS = interface.h interfaceinformationimp.h interfaces.h interfacesetupimp.h
6 SOURCES = interface.cpp interfaces.cpp interfaceinformationimp.cpp interfacesetupimp.cpp 6 SOURCES = interface.cpp interfaces.cpp interfaceinformationimp.cpp interfacesetupimp.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include ../ 7 INCLUDEPATH+= $(OPIEDIR)/include ../
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10 INTERFACES= interfaceadvanced.ui interfaceinformation.ui interfacesetup.ui 10 INTERFACES= interfaceadvanced.ui interfaceinformation.ui interfacesetup.ui
11 TARGET = interfaces 11 TARGET = interfaces
12 VERSION = 1.0.0 12 VERSION = 1.0.0
diff --git a/noncore/net/networksetup/ppp/pppmodule.cpp b/noncore/net/networksetup/ppp/pppmodule.cpp
index 68bb0a0..72cd45e 100644
--- a/noncore/net/networksetup/ppp/pppmodule.cpp
+++ b/noncore/net/networksetup/ppp/pppmodule.cpp
@@ -1,104 +1,107 @@
1#include "pppmodule.h" 1#include "pppmodule.h"
2#include "pppimp.h"
2#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
3 4
4/** 5/**
5 * Constructor, find all of the possible interfaces 6 * Constructor, find all of the possible interfaces
6 */ 7 */
7PPPModule::PPPModule() : Module() { 8PPPModule::PPPModule() : Module() {
8} 9}
9 10
10/** 11/**
11 * Delete any interfaces that we own. 12 * Delete any interfaces that we own.
12 */ 13 */
13PPPModule::~PPPModule(){ 14PPPModule::~PPPModule(){
14 Interface *i; 15 Interface *i;
15 for ( i=list.first(); i != 0; i=list.next() ) 16 for ( i=list.first(); i != 0; i=list.next() )
16 delete i; 17 delete i;
17} 18}
18 19
19/** 20/**
20 * Change the current profile 21 * Change the current profile
21 */ 22 */
22void PPPModule::setProfile(const QString &newProfile){ 23void PPPModule::setProfile(const QString &newProfile){
23 profile = newProfile; 24 profile = newProfile;
24} 25}
25 26
26/** 27/**
27 * get the icon name for this device. 28 * get the icon name for this device.
28 * @param Interface* can be used in determining the icon. 29 * @param Interface* can be used in determining the icon.
29 * @return QString the icon name (minus .png, .gif etc) 30 * @return QString the icon name (minus .png, .gif etc)
30 */ 31 */
31QString PPPModule::getPixmapName(Interface* ){ 32QString PPPModule::getPixmapName(Interface* ){
32 return "ppp"; 33 return "ppp";
33} 34}
34 35
35/** 36/**
36 * Check to see if the interface i is owned by this module. 37 * Check to see if the interface i is owned by this module.
37 * @param Interface* interface to check against 38 * @param Interface* interface to check against
38 * @return bool true if i is owned by this module, false otherwise. 39 * @return bool true if i is owned by this module, false otherwise.
39 */ 40 */
40bool PPPModule::isOwner(Interface *i){ 41bool PPPModule::isOwner(Interface *i){
41 // Scan the ppp database 42 if(!i->getInterfaceName().upper().contains("PPP"))
42 return false; 43 return false;
43 44
44 i->setHardwareName("PPP"); 45 i->setHardwareName("PPP");
45 list.append(i); 46 list.append(i);
46 return true; 47 return true;
47} 48}
48 49
49/** 50/**
50 * Create, and return the WLANConfigure Module 51 * Create, and return the WLANConfigure Module
51 * @return QWidget* pointer to this modules configure. 52 * @return QWidget* pointer to this modules configure.
52 */ 53 */
53QWidget *PPPModule::configure(Interface *i){ 54QWidget *PPPModule::configure(Interface *i){
54 return NULL; 55 return NULL;
55 //PPPConfigureImp *pppconfig = new PPPConfigureImp(0, "PPPConfig", i, false, Qt::WDestructiveClose); 56 //PPPConfigureImp *pppconfig = new PPPConfigureImp(0, "PPPConfig", i, false, Qt::WDestructiveClose);
56 //pppconfig->setProfile(profile); 57 //pppconfig->setProfile(profile);
57 //return wlanconfig; 58 //return wlanconfig;
58} 59}
59 60
60/** 61/**
61 * Create, and return the Information Module 62 * Create, and return the Information Module
62 * @return QWidget* pointer to this modules info. 63 * @return QWidget* pointer to this modules info.
63 */ 64 */
64QWidget *PPPModule::information(Interface *i){ 65QWidget *PPPModule::information(Interface *i){
65 return NULL; 66 // We don't have any advanced pppd information widget yet :-D
66 67 // TODO ^
67 //WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 68 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i);
68 //InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); 69 return information;
69 //info->tabWidget->insertTab(information, "TCP/IP");
70 //return info;
71} 70}
72 71
73/** 72/**
74 * Get all active (up or down) interfaces 73 * Get all active (up or down) interfaces
75 * @return QList<Interface> A list of interfaces that exsist that havn't 74 * @return QList<Interface> A list of interfaces that exsist that havn't
76 * been called by isOwner() 75 * been called by isOwner()
77 */ 76 */
78QList<Interface> PPPModule::getInterfaces(){ 77QList<Interface> PPPModule::getInterfaces(){
78 // List all of the files in the peer directory
79 return list; 79 return list;
80} 80}
81 81
82/** 82/**
83 * Attempt to add a new interface as defined by name 83 * Attempt to add a new interface as defined by name
84 * @param name the name of the type of interface that should be created given 84 * @param name the name of the type of interface that should be created given
85 * by possibleNewInterfaces(); 85 * by possibleNewInterfaces();
86 * @return Interface* NULL if it was unable to be created. 86 * @return Interface* NULL if it was unable to be created.
87 */ 87 */
88Interface *PPPModule::addNewInterface(const QString &newInterface){ 88Interface *PPPModule::addNewInterface(const QString &newInterface){
89 // We can't add a 802.11 interface, either the hardware will be there 89 // If the
90 // or it wont. 90 PPPConfigureImp imp(0, "PPPConfigImp");
91 if(imp.exec() == QDialog::Accepted ){
92
93 }
91 return NULL; 94 return NULL;
92} 95}
93 96
94/** 97/**
95 * Attempts to remove the interface, doesn't delete i 98 * Attempts to remove the interface, doesn't delete i
96 * @return bool true if successfull, false otherwise. 99 * @return bool true if successfull, false otherwise.
97 */ 100 */
98bool PPPModule::remove(Interface*){ 101bool PPPModule::remove(Interface*){
99 // Can't remove a hardware device, you can stop it though. 102 // Can't remove a hardware device, you can stop it though.
100 return false; 103 return false;
101} 104}
102 105
103// pppmodule.cpp 106// pppmodule.cpp
104 107
diff --git a/noncore/net/networksetup/wlan/infoimp.cpp b/noncore/net/networksetup/wlan/infoimp.cpp
index e1eef81..6d3e167 100644
--- a/noncore/net/networksetup/wlan/infoimp.cpp
+++ b/noncore/net/networksetup/wlan/infoimp.cpp
@@ -1,55 +1,56 @@
1#include "infoimp.h" 1#include "infoimp.h"
2#include "wextensions.h" 2#include "wextensions.h"
3
3#include <qtimer.h> 4#include <qtimer.h>
4#include <qprogressbar.h> 5#include <qprogressbar.h>
5#include <qlabel.h> 6#include <qlabel.h>
6 7
7/** 8/**
8 * Constructor. If wireless extensions are enabled on device name then 9 * Constructor. If wireless extensions are enabled on device name then
9 * start a timer that every second will update the information. 10 * start a timer that every second will update the information.
10 */ 11 */
11WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){ 12WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){
12 WExtensions *wExtensions = new WExtensions(name); 13 WExtensions *wExtensions = new WExtensions(name);
13 if(!wExtensions->doesHaveWirelessExtensions()){ 14 if(!wExtensions->doesHaveWirelessExtensions()){
14 delete wExtensions; 15 delete wExtensions;
15 qDebug("No extension"); 16 qDebug("WlanInfoImp::No wireless extension");
16 return; 17 return;
17 } 18 }
18 delete wExtensions; 19 delete wExtensions;
19 timer = new QTimer( this ); 20 timer = new QTimer( this );
20 connect( timer, SIGNAL(timeout()), this, SLOT(update())); 21 connect( timer, SIGNAL(timeout()), this, SLOT(update()));
21 timer->start( 1000, false ); 22 timer->start( 1000, false );
22} 23}
23 24
24/** 25/**
25 * Updates the information about the wireless device. 26 * Updates the information about the wireless device.
26 */ 27 */
27void WlanInfoImp::update(){ 28void WlanInfoImp::update(){
28 WExtensions *wExtensions = new WExtensions(this->name()); 29 WExtensions *wExtensions = new WExtensions(this->name());
29 if(!wExtensions->doesHaveWirelessExtensions()){ 30 if(!wExtensions->doesHaveWirelessExtensions()){
30 qDebug("No extension"); 31 qDebug("No extension");
31 delete wExtensions; 32 delete wExtensions;
32 timer->stop(); 33 timer->stop();
33 return; 34 return;
34 } 35 }
35 essidLabel->setText(wExtensions->essid()); 36 essidLabel->setText(wExtensions->essid());
36 apLabel->setText(wExtensions->ap()); 37 apLabel->setText(wExtensions->ap());
37 stationLabel->setText(wExtensions->station()); 38 stationLabel->setText(wExtensions->station());
38 modeLabel->setText(wExtensions->mode()); 39 modeLabel->setText(wExtensions->mode());
39 freqLabel->setText(QString("%1 GHz").arg(wExtensions->frequency())); 40 freqLabel->setText(QString("%1 GHz").arg(wExtensions->frequency()));
40 int signal = 0; 41 int signal = 0;
41 int noise = 0; 42 int noise = 0;
42 int quality = 0; 43 int quality = 0;
43 wExtensions->stats(signal, noise, quality); 44 wExtensions->stats(signal, noise, quality);
44 if(signalProgressBar->progress() != signal) 45 if(signalProgressBar->progress() != signal)
45 signalProgressBar->setProgress(signal); 46 signalProgressBar->setProgress(signal);
46 if(noiseProgressBar->progress() != noise) 47 if(noiseProgressBar->progress() != noise)
47 noiseProgressBar->setProgress(noise); 48 noiseProgressBar->setProgress(noise);
48 if(qualityProgressBar->progress() != quality) 49 if(qualityProgressBar->progress() != quality)
49 qualityProgressBar->setProgress(quality); 50 qualityProgressBar->setProgress(quality);
50 rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate())); 51 rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate()));
51 delete wExtensions; 52 delete wExtensions;
52} 53}
53 54
54// infoimp.cpp 55// infoimp.cpp
55 56
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 04b3a7c..020339f 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,16 +1,14 @@
1AndyQ - Fixed a bug in wlanimp.cpp : accept method - put braces round key 1test WEP
2 field if so that settings get saved if WEP is enabled 2WEP key in file wireless.conf is not encrypted !, therefore it is very easy to get the key out of the zaurus..
3
4CLEAN UP
5 3
6udchcp needs to output the dhcp information so interfaces can read it 4udchcp needs to output the dhcp information so interfaces can read it
7 5
8interfacesetupimp really doesn't need a interface* pointer 6interfacesetupimp really doesn't need a interface* pointer
9 7
10Possible other modules to write: ppp, ipsec, bluetooth, ipchains 8Possible other modules to write: ppp, ipsec, bluetooth, ipchains
11 9
12PPP module needs to scan pppd.tdb to see what is currently active 10PPP module needs to scan pppd.tdb to see what is currently active
13 11
14WLAN - add possiblity to input text or hex without knowing "s:" 12WLAN - add possiblity to input text or hex without knowing "s:"
15 13
16Interface setupimp needs to use kernel calls. 14Interface setupimp needs to use kernel calls.
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp
index 4129b3d..7ffa76f 100644
--- a/noncore/settings/networksettings/interfaces/interface.cpp
+++ b/noncore/settings/networksettings/interfaces/interface.cpp
@@ -1,297 +1,297 @@
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 DHCP_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), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){
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(const QString &name){ 45void Interface::setHardwareName(const 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 emit (updateMessage("Unable to start interface,\n already started")); 67 emit (updateMessage("Unable to start interface,\n already started"));
68 return; 68 return;
69 } 69 }
70 70
71 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); 71 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
72 // See if it was successfull... 72 // See if it was successfull...
73 if(ret != 0){ 73 if(ret != 0){
74 emit (updateMessage("Starting interface failed.")); 74 emit (updateMessage("Starting interface failed."));
75 return; 75 return;
76 } 76 }
77 77
78 status = true; 78 status = true;
79 refresh(); 79 refresh();
80 emit (updateMessage("Start successfull")); 80 emit (updateMessage("Start successfull"));
81} 81}
82 82
83/** 83/**
84 * Try to stop the interface. 84 * Try to stop the interface.
85 */ 85 */
86void Interface::stop(){ 86void Interface::stop(){
87 // check to see if we are already stopped. 87 // check to see if we are already stopped.
88 if(false == status){ 88 if(false == status){
89 emit (updateMessage("Unable to stop interface,\n already stopped")); 89 emit (updateMessage("Unable to stop interface,\n already stopped"));
90 return; 90 return;
91 } 91 }
92 92
93 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); 93 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
94 if(ret != 0){ 94 if(ret != 0){
95 emit (updateMessage("Stopping interface failed.")); 95 emit (updateMessage("Stopping interface failed."));
96 return; 96 return;
97 } 97 }
98 98
99 status = false; 99 status = false;
100 refresh(); 100 refresh();
101 emit (updateMessage("Stop successfull")); 101 emit (updateMessage("Stop successfull"));
102} 102}
103 103
104/** 104/**
105 * Try to restart the interface. 105 * Try to restart the interface.
106 */ 106 */
107void Interface::restart(){ 107void Interface::restart(){
108 stop(); 108 stop();
109 start(); 109 start();
110} 110}
111 111
112/** 112/**
113 * Try to refresh the information about the interface. 113 * Try to refresh the information about the interface.
114 * First call ifconfig, then check the dhcp-info file 114 * First call ifconfig, then check the dhcp-info file
115 * @return bool true if successfull. 115 * @return bool true if successfull.
116 */ 116 */
117bool Interface::refresh(){ 117bool Interface::refresh(){
118 // See if we are up. 118 // See if we are up.
119 if(status == false){ 119 if(status == false){
120 macAddress = ""; 120 macAddress = "";
121 ip = "0.0.0.0"; 121 ip = "0.0.0.0";
122 subnetMask = "0.0.0.0"; 122 subnetMask = "0.0.0.0";
123 broadcast = ""; 123 broadcast = "";
124 dhcp = false; 124 dhcp = false;
125 dhcpServerIp = ""; 125 dhcpServerIp = "";
126 leaseObtained = ""; 126 leaseObtained = "";
127 leaseExpires = ""; 127 leaseExpires = "";
128 emit(updateInterface(this)); 128 emit(updateInterface(this));
129 return true; 129 return true;
130 } 130 }
131 131
132 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); 132 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
133 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); 133 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
134 if(ret != 0){ 134 if(ret != 0){
135 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 135 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
136 return false; 136 return false;
137 } 137 }
138 138
139 QFile file(fileName); 139 QFile file(fileName);
140 if (!file.open(IO_ReadOnly)){ 140 if (!file.open(IO_ReadOnly)){
141 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 141 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
142 return false; 142 return false;
143 } 143 }
144 144
145 // Set to the defaults 145 // Set to the defaults
146 macAddress = ""; 146 macAddress = "";
147 ip = "0.0.0.0"; 147 ip = "0.0.0.0";
148 subnetMask = "0.0.0.0"; 148 subnetMask = "0.0.0.0";
149 broadcast = ""; 149 broadcast = "";
150 150
151 QTextStream stream( &file ); 151 QTextStream stream( &file );
152 QString line; 152 QString line;
153 while ( !stream.eof() ) { 153 while ( !stream.eof() ) {
154 line = stream.readLine(); 154 line = stream.readLine();
155 if(line.contains("HWaddr")){ 155 if(line.contains("HWaddr")){
156 int mac = line.find("HWaddr"); 156 int mac = line.find("HWaddr");
157 macAddress = line.mid(mac+7, line.length()); 157 macAddress = line.mid(mac+7, line.length());
158 } 158 }
159 if(line.contains("inet addr")){ 159 if(line.contains("inet addr")){
160 int ipl = line.find("inet addr"); 160 int ipl = line.find("inet addr");
161 int space = line.find(" ", ipl+10); 161 int space = line.find(" ", ipl+10);
162 ip = line.mid(ipl+10, space-ipl-10); 162 ip = line.mid(ipl+10, space-ipl-10);
163 } 163 }
164 if(line.contains("Mask")){ 164 if(line.contains("Mask")){
165 int mask = line.find("Mask"); 165 int mask = line.find("Mask");
166 subnetMask = line.mid(mask+5, line.length()); 166 subnetMask = line.mid(mask+5, line.length());
167 } 167 }
168 if(line.contains("Bcast")){ 168 if(line.contains("Bcast")){
169 int mask = line.find("Bcast"); 169 int mask = line.find("Bcast");
170 int space = line.find(" ", mask+6); 170 int space = line.find(" ", mask+6);
171 broadcast = line.mid(mask+6, space-mask-6); 171 broadcast = line.mid(mask+6, space-mask-6);
172 } 172 }
173 } 173 }
174 file.close(); 174 file.close();
175 QFile::remove(fileName); 175 QFile::remove(fileName);
176 176
177 // DHCP TESTING 177 // DHCP TESTING
178 // reset DHCP info 178 // reset DHCP info
179 dhcpServerIp = ""; 179 dhcpServerIp = "";
180 leaseObtained = ""; 180 leaseObtained = "";
181 leaseExpires = ""; 181 leaseExpires = "";
182 dhcp = false; 182 dhcp = false;
183 183
184 QString dhcpDirectory(DHCP_INFO_DIR); 184 QString dhcpDirectory(DHCP_INFO_DIR);
185 QDir d(dhcpDirectory); 185 QDir d(dhcpDirectory);
186 if(!d.exists(dhcpDirectory)) 186 if(!d.exists(dhcpDirectory))
187 dhcpDirectory = "/var/run"; 187 dhcpDirectory = "/var/run";
188 188
189 // See if we have 189 // See if we have
190 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); 190 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
191 // If there is no DHCP information then exit now with no errors. 191 // If there is no DHCP information then exit now with no errors.
192 if(!QFile::exists(dhcpFile)){ 192 if(!QFile::exists(dhcpFile)){
193 emit(updateInterface(this)); 193 emit(updateInterface(this));
194 return true; 194 return true;
195 } 195 }
196 196
197 file.setName(dhcpFile); 197 file.setName(dhcpFile);
198 if (!file.open(IO_ReadOnly)){ 198 if (!file.open(IO_ReadOnly)){
199 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 199 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
200 return false; 200 return false;
201 } 201 }
202 202
203 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 203 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
204 int leaseTime = 0; 204 int leaseTime = 0;
205 int renewalTime = 0; 205 int renewalTime = 0;
206 206
207 stream.setDevice( &file ); 207 stream.setDevice( &file );
208 while ( !stream.eof() ) { 208 while ( !stream.eof() ) {
209 line = stream.readLine(); 209 line = stream.readLine();
210 if(line.contains("DHCPSIADDR=")) 210 if(line.contains("DHCPSIADDR="))
211 dhcpServerIp = line.mid(11, line.length()); 211 dhcpServerIp = line.mid(11, line.length());
212 if(line.contains("LEASETIME=")) 212 if(line.contains("LEASETIME="))
213 leaseTime = line.mid(10, line.length()).toInt(); 213 leaseTime = line.mid(10, line.length()).toInt();
214 if(line.contains("RENEWALTIME=")) 214 if(line.contains("RENEWALTIME="))
215 renewalTime = line.mid(12, line.length()).toInt(); 215 renewalTime = line.mid(12, line.length()).toInt();
216 } 216 }
217 file.close(); 217 file.close();
218 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 218 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
219 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 219 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
220 220
221 // Get the pid of the deamond 221 // Get the pid of the deamond
222 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); 222 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
223 file.setName(dhcpFile); 223 file.setName(dhcpFile);
224 if (!file.open(IO_ReadOnly)){ 224 if (!file.open(IO_ReadOnly)){
225 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 225 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
226 return false; 226 return false;
227 } 227 }
228 228
229 int pid = -1; 229 int pid = -1;
230 stream.setDevice( &file ); 230 stream.setDevice( &file );
231 while ( !stream.eof() ) { 231 while ( !stream.eof() ) {
232 line = stream.readLine(); 232 line = stream.readLine();
233 pid = line.toInt(); 233 pid = line.toInt();
234 } 234 }
235 file.close(); 235 file.close();
236 236
237 if( pid == -1){ 237 if( pid == -1){
238 qDebug("Interface: Could not get pid of dhcpc deamon."); 238 qDebug("Interface: Could not get pid of dhcpc deamon.");
239 return false; 239 return false;
240 } 240 }
241 241
242 // Get the start running time of the deamon 242 // Get the start running time of the deamon
243 fileName = (QString("/proc/%1/stat").arg(pid)); 243 fileName = (QString("/proc/%1/stat").arg(pid));
244 file.setName(fileName); 244 file.setName(fileName);
245 stream.setDevice( &file ); 245 stream.setDevice( &file );
246 if (!file.open(IO_ReadOnly)){ 246 if (!file.open(IO_ReadOnly)){
247 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 247 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
248 return false; 248 return false;
249 } 249 }
250 while ( !stream.eof() ) { 250 while ( !stream.eof() ) {
251 line = stream.readLine(); 251 line = stream.readLine();
252 } 252 }
253 file.close(); 253 file.close();
254 long time = 0; 254 long time = 0;
255 // Grab the start time 255 // Grab the start time
256 // pid com state ppid pgrp session tty_nr tpgid flags 256 // pid com state ppid pgrp session tty_nr tpgid flags
257 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 257 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
258 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 258 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
259 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 259 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
260 // nice 0 itrealvalue starttime 260 // nice 0 itrealvalue starttime
261 "%*d %*d %*d %lu", (long*) &time); 261 "%*d %*d %*d %lu", (long*) &time);
262 time = time/100; 262 time = time/100;
263 263
264 QDateTime datetime(QDateTime::currentDateTime()); 264 QDateTime datetime(QDateTime::currentDateTime());
265 265
266 // Get the uptime of the computer. 266 // Get the uptime of the computer.
267 QFile f("/proc/uptime"); 267 QFile f("/proc/uptime");
268 if ( f.open(IO_ReadOnly) ) { // file opened successfully 268 if ( f.open(IO_ReadOnly) ) { // file opened successfully
269 QTextStream t( &f ); // use a text stream 269 QTextStream t( &f ); // use a text stream
270 int sec = 0; 270 int sec = 0;
271 t >> sec; 271 t >> sec;
272 datetime = datetime.addSecs((-1*sec)); 272 datetime = datetime.addSecs((-1*sec));
273 f.close(); 273 f.close();
274 } 274 }
275 else{ 275 else{
276 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 276 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
277 return false; 277 return false;
278 } 278 }
279 279
280 datetime = datetime.addSecs(time); 280 datetime = datetime.addSecs(time);
281 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); 281 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
282 282
283 // Calculate the start and renew times 283 // Calculate the start and renew times
284 leaseObtained= datetime.toString(); 284 leaseObtained= datetime.toString();
285 285
286 // Calculate the start and renew times 286 // Calculate the start and renew times
287 datetime = datetime.addSecs(leaseTime); 287 datetime = datetime.addSecs(leaseTime);
288 leaseExpires = datetime.toString(); 288 leaseExpires = datetime.toString();
289 289
290 dhcp = true; 290 dhcp = true;
291 291
292 emit(updateInterface(this)); 292 emit(updateInterface(this));
293 return true; 293 return true;
294} 294}
295 295
296// interface.cpp 296// interface.cpp
297 297
diff --git a/noncore/settings/networksettings/interfaces/interface.h b/noncore/settings/networksettings/interfaces/interface.h
index 989d6d8..d37834a 100644
--- a/noncore/settings/networksettings/interfaces/interface.h
+++ b/noncore/settings/networksettings/interfaces/interface.h
@@ -1,71 +1,72 @@
1#ifndef INTERFACE_H 1#ifndef INTERFACE_H
2#define INTERFACE_H 2#define INTERFACE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7class Module; 7class Module;
8 8
9class Interface : public QObject{ 9class Interface : public QObject{
10 Q_OBJECT 10 Q_OBJECT
11 11
12signals: 12signals:
13 void updateInterface(Interface *i); 13 void updateInterface(Interface *i);
14 void updateMessage(const QString &message); 14 void updateMessage(const QString &message);
15 15
16public: 16public:
17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false); 17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
18 18
19 QString getInterfaceName(){ QString n(this->name()); return n; }; 19 QString getInterfaceName() const { QString n(this->name()); return n; };
20 20
21 bool getStatus(){ return status; }; 21 bool getStatus() const { return status; };
22 void setStatus(bool newStatus); 22 void setStatus(bool newStatus);
23 23
24 bool isAttached(){ return attached; }; 24 bool isAttached() const { return attached; };
25 void setAttached(bool isAttached=false); 25 void setAttached(bool isAttached=false);
26 26
27 QString getHardwareName(){ return hardwareName; }; 27 QString getHardwareName() const { return hardwareName; };
28 void setHardwareName(const QString &name="Unknown"); 28 void setHardwareName(const QString &name="Unknown");
29 29
30 Module* getModuleOwner(){ return moduleOwner; }; 30 Module* getModuleOwner() const { return moduleOwner; };
31 void setModuleOwner(Module *owner=NULL); 31 void setModuleOwner(Module *owner=NULL);
32 32
33 // inet information. 33 // inet information.
34 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress() const { return macAddress; };
35 QString getIp(){ return ip; }; 35 QString getIp() const { return ip; };
36 QString getSubnetMask(){ return subnetMask; }; 36 QString getSubnetMask() const { return subnetMask; };
37 QString getBroadcast(){ return broadcast; }; 37 QString getBroadcast() const { return broadcast; };
38 bool isDhcp(){ return dhcp; }; 38 bool isDhcp() const { return dhcp; };
39 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp() const { return dhcpServerIp; };
40 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained() const { return leaseObtained; };
41 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires() const { return leaseExpires; };
42 42
43public slots: 43public slots:
44 bool refresh(); 44 bool refresh();
45 void start(); 45 void start();
46 void stop(); 46 void stop();
47 void restart(); 47 void restart();
48 48
49private: 49private:
50 // Interface information 50 // Interface information
51 bool status;
52 bool attached;
53 QString hardwareName; 51 QString hardwareName;
54 Module *moduleOwner; 52 Module *moduleOwner;
55 53 bool status;
54 bool attached;
55
56 // Network information 56 // Network information
57 QString macAddress;
58 QString ip;
59 QString broadcast;
60 QString subnetMask;
61 bool dhcp; 57 bool dhcp;
62 QString dhcpServerIp; 58 QString dhcpServerIp;
63 QString leaseObtained; 59 QString leaseObtained;
64 QString leaseExpires; 60 QString leaseExpires;
65 61
62 QString macAddress;
63 QString ip;
64 QString broadcast;
65 QString subnetMask;
66
66}; 67};
67 68
68#endif 69#endif
69 70
70// interface.h 71// interface.h
71 72
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index e49998e..8f685fe 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -1,527 +1,527 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qregexp.h> 5#include <qregexp.h>
6 6
7// The three stanza's 7// The three stanza's
8#define AUTO "auto" 8#define AUTO "auto"
9#define IFACE "iface" 9#define IFACE "iface"
10#define MAPPING "mapping" 10#define MAPPING "mapping"
11 11
12/** 12/**
13 * Constructor. Reads in the interfaces file and then split the file up by 13 * Constructor. Reads in the interfaces file and then split the file up by
14 * the \n for interfaces variable. 14 * the \n for interfaces variable.
15 * @param useInterfacesFile if an interface file other then the default is 15 * @param useInterfacesFile if an interface file other then the default is
16 * desired to be used it should be passed in. 16 * desired to be used it should be passed in.
17 */ 17 */
18Interfaces::Interfaces(QString useInterfacesFile){ 18Interfaces::Interfaces(QString useInterfacesFile){
19 acceptedFamily.append(INTERFACES_FAMILY_INET); 19 acceptedFamily.append(INTERFACES_FAMILY_INET);
20 acceptedFamily.append(INTERFACES_FAMILY_IPX); 20 acceptedFamily.append(INTERFACES_FAMILY_IPX);
21 acceptedFamily.append(INTERFACES_FAMILY_INET6); 21 acceptedFamily.append(INTERFACES_FAMILY_INET6);
22 22
23 interfacesFile = useInterfacesFile; 23 interfacesFile = useInterfacesFile;
24 QFile file(interfacesFile); 24 QFile file(interfacesFile);
25 if (!file.open(IO_ReadOnly)){ 25 if (!file.open(IO_ReadOnly)){
26 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); 26 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
27 currentIface = interfaces.end(); 27 currentIface = interfaces.end();
28 currentMapping = interfaces.end(); 28 currentMapping = interfaces.end();
29 return; 29 return;
30 } 30 }
31 QTextStream stream( &file ); 31 QTextStream stream( &file );
32 QString line; 32 QString line;
33 while ( !stream.eof() ) { 33 while ( !stream.eof() ) {
34 line += stream.readLine(); 34 line += stream.readLine();
35 line += "\n"; 35 line += "\n";
36 } 36 }
37 file.close(); 37 file.close();
38 interfaces = QStringList::split("\n", line, true); 38 interfaces = QStringList::split("\n", line, true);
39 39
40 currentIface = interfaces.end(); 40 currentIface = interfaces.end();
41 currentMapping = interfaces.end(); 41 currentMapping = interfaces.end();
42} 42}
43 43
44 44
45/** 45/**
46 * Get a list of all interfaces in the interface file. Usefull for 46 * Get a list of all interfaces in the interface file. Usefull for
47 * hardware that is not currently connected such as an 802.11b card 47 * hardware that is not currently connected such as an 802.11b card
48 * not plugged in, but configured for when it is plugged in. 48 * not plugged in, but configured for when it is plugged in.
49 * @return Return string list of interfaces. 49 * @return Return string list of interfaces.
50 **/ 50 **/
51QStringList Interfaces::getInterfaceList(){ 51QStringList Interfaces::getInterfaceList(){
52 QStringList list; 52 QStringList list;
53 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 53 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
54 QString line = (*it).simplifyWhiteSpace(); 54 QString line = (*it).simplifyWhiteSpace();
55 if(line.contains(IFACE) && line.at(0) != '#'){ 55 if(line.contains(IFACE) && line.at(0) != '#'){
56 line = line.mid(QString(IFACE).length() +1, line.length()); 56 line = line.mid(QString(IFACE).length() +1, line.length());
57 line = line.simplifyWhiteSpace(); 57 line = line.simplifyWhiteSpace();
58 int findSpace = line.find(" "); 58 int findSpace = line.find(" ");
59 if( findSpace >= 0){ 59 if( findSpace >= 0){
60 line = line.mid(0, findSpace); 60 line = line.mid(0, findSpace);
61 list.append(line); 61 list.append(line);
62 } 62 }
63 } 63 }
64 } 64 }
65 return list; 65 return list;
66} 66}
67 67
68/** 68/**
69 * Find out if interface is in an "auto" group or not. 69 * Find out if interface is in an "auto" group or not.
70 * Report any duplicates such as eth0 being in two differnt auto's 70 * Report any duplicates such as eth0 being in two differnt auto's
71 * @param interface interface to check to see if it is on or not. 71 * @param interface interface to check to see if it is on or not.
72 * @return true is interface is in auto 72 * @return true is interface is in auto
73 */ 73 */
74bool Interfaces::isAuto(const QString &interface){ 74bool Interfaces::isAuto(const QString &interface) const {
75 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 75 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
76 QStringList awi = autoLines.grep(QRegExp(interface)); 76 QStringList awi = autoLines.grep(QRegExp(interface));
77 if(awi.count() > 1) 77 if(awi.count() > 1)
78 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 78 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
79 if(awi.count() < 1) 79 if(awi.count() < 1)
80 return false; 80 return false;
81 return true; 81 return true;
82} 82}
83 83
84/** 84/**
85 * Attempt to set the auto option for interface to setAuto. 85 * Attempt to set the auto option for interface to setAuto.
86 * @param interface the interface to set 86 * @param interface the interface to set
87 * @param setAuto the value to set interface to. 87 * @param setAuto the value to set interface to.
88 * @return false if already set to setAuto. 88 * @return false if already set to setAuto.
89 * */ 89 * */
90bool Interfaces::setAuto(const QString &interface, bool setAuto){ 90bool Interfaces::setAuto(const QString &interface, bool setAuto){
91 // Don't need to set it if it is already set. 91 // Don't need to set it if it is already set.
92 if(isAuto(interface) == setAuto) 92 if(isAuto(interface) == setAuto)
93 return false; 93 return false;
94 94
95 bool changed = false; 95 bool changed = false;
96 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 96 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
97 if((*it).contains(AUTO)){ 97 if((*it).contains(AUTO)){
98 //We know that they are not in any group so let add to this auto. 98 //We know that they are not in any group so let add to this auto.
99 if(setAuto){ 99 if(setAuto){
100 (*it) = (*it) += " " + interface; 100 (*it) = (*it) += " " + interface;
101 // Don't care to have such thins as: auto eth0 lo usb0 101 // Don't care to have such thins as: auto eth0 lo usb0
102 (*it) = (*it).simplifyWhiteSpace(); 102 (*it) = (*it).simplifyWhiteSpace();
103 changed = true; 103 changed = true;
104 break; 104 break;
105 } 105 }
106 // else see if we need to remove from this one 106 // else see if we need to remove from this one
107 else{ 107 else{
108 if((*it).contains(interface)){ 108 if((*it).contains(interface)){
109 (*it) = (*it).replace(QRegExp(interface), ""); 109 (*it) = (*it).replace(QRegExp(interface), "");
110 // if AUTO is the only thing left clear the line 110 // if AUTO is the only thing left clear the line
111 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) 111 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO)
112 (*it) = ""; 112 (*it) = "";
113 changed = true; 113 changed = true;
114 // Don't break because we want to make sure we remove all cases. 114 // Don't break because we want to make sure we remove all cases.
115 } 115 }
116 } 116 }
117 } 117 }
118 } 118 }
119 // In the case where there is no AUTO field add one. 119 // In the case where there is no AUTO field add one.
120 if(!changed && setAuto) 120 if(!changed && setAuto)
121 interfaces.append(QString(AUTO" %1").arg(interface)); 121 interfaces.append(QString(AUTO" %1").arg(interface));
122 return true; 122 return true;
123} 123}
124 124
125/** 125/**
126 * Set the current interface to interface. This needs to be done before you 126 * Set the current interface to interface. This needs to be done before you
127 * can call getFamily(), getMethod, and get/setOption(). 127 * can call getFamily(), getMethod, and get/setOption().
128 * @param interface the name of the interface to set. All whitespace is 128 * @param interface the name of the interface to set. All whitespace is
129 * removed from the interface name. 129 * removed from the interface name.
130 * @return bool true if it is successfull. 130 * @return bool true if it is successfull.
131 */ 131 */
132bool Interfaces::setInterface(QString interface){ 132bool Interfaces::setInterface(QString interface){
133 interface = interface.simplifyWhiteSpace(); 133 interface = interface.simplifyWhiteSpace();
134 interface = interface.replace(QRegExp(" "), ""); 134 interface = interface.replace(QRegExp(" "), "");
135 return setStanza(IFACE, interface, currentIface); 135 return setStanza(IFACE, interface, currentIface);
136} 136}
137 137
138/** 138/**
139 * A quick helper funtion to see if the current interface is set. 139 * A quick helper funtion to see if the current interface is set.
140 * @return bool true if set, false otherwise. 140 * @return bool true if set, false otherwise.
141 */ 141 */
142bool Interfaces::isInterfaceSet(){ 142bool Interfaces::isInterfaceSet() const {
143 return (currentIface != interfaces.end()); 143 return (interfaces.end() != currentIface);
144} 144}
145 145
146/** 146/**
147 * Add a new interface of with the settings - family and method 147 * Add a new interface of with the settings - family and method
148 * @param interface the name of the interface to set. All whitespace is 148 * @param interface the name of the interface to set. All whitespace is
149 * removed from the interface name. 149 * removed from the interface name.
150 * @param family the family of this interface inet or inet, ipx or inet6 150 * @param family the family of this interface inet or inet, ipx or inet6
151 * Must of one of the families defined in interfaces.h 151 * Must of one of the families defined in interfaces.h
152 * @param method for the family. see interfaces man page for family methods. 152 * @param method for the family. see interfaces man page for family methods.
153 * @return true if successfull. 153 * @return true if successfull.
154 */ 154 */
155bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ 155bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
156 if(0 == acceptedFamily.contains(family)) 156 if(0 == acceptedFamily.contains(family))
157 return false; 157 return false;
158 QString newInterface = interface.simplifyWhiteSpace(); 158 QString newInterface = interface.simplifyWhiteSpace();
159 newInterface = newInterface.replace(QRegExp(" "), ""); 159 newInterface = newInterface.replace(QRegExp(" "), "");
160 interfaces.append(""); 160 interfaces.append("");
161 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); 161 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
162 return true; 162 return true;
163} 163}
164 164
165/** 165/**
166 * Copies interface with name interface to name newInterface 166 * Copies interface with name interface to name newInterface
167 * @param newInterface name of the new interface. 167 * @param newInterface name of the new interface.
168 * @return bool true if successfull 168 * @return bool true if successfull
169 */ 169 */
170bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ 170bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
171 if(!setInterface(interface)) 171 if(!setInterface(interface))
172 return false; 172 return false;
173 173
174 // Store the old interface and bump past the stanza line. 174 // Store the old interface and bump past the stanza line.
175 QStringList::Iterator it = currentIface; 175 QStringList::Iterator it = currentIface;
176 it++; 176 it++;
177 177
178 // Add the new interface 178 // Add the new interface
179 bool error; 179 bool error;
180 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 180 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
181 if(!setInterface(newInterface)) 181 if(!setInterface(newInterface))
182 return false; 182 return false;
183 183
184 QStringList::Iterator newIface = currentIface; 184 QStringList::Iterator newIface = currentIface;
185 newIface++; 185 newIface++;
186 186
187 // Copy all of the lines 187 // Copy all of the lines
188 for ( ; it != interfaces.end(); ++it ){ 188 for ( ; it != interfaces.end(); ++it ){
189 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 189 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
190 break; 190 break;
191 newIface = interfaces.insert(newIface, *it); 191 newIface = interfaces.insert(newIface, *it);
192 } 192 }
193 193
194 return true; 194 return true;
195} 195}
196 196
197/** 197/**
198 * Remove the currently selected interface and all of its options. 198 * Remove the currently selected interface and all of its options.
199 * @return bool if successfull or not. 199 * @return bool if successfull or not.
200 */ 200 */
201bool Interfaces::removeInterface(){ 201bool Interfaces::removeInterface(){
202 return removeStanza(currentIface); 202 return removeStanza(currentIface);
203} 203}
204 204
205/** 205/**
206 * Gets the hardware name of the interface that is currently selected. 206 * Gets the hardware name of the interface that is currently selected.
207 * @return QString name of the hardware interface (eth0, usb2, wlan1...). 207 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
208 * @param error set to true if any error occurs, false otherwise. 208 * @param error set to true if any error occurs, false otherwise.
209 */ 209 */
210QString Interfaces::getInterfaceName(bool &error){ 210QString Interfaces::getInterfaceName(bool &error){
211 if(currentIface == interfaces.end()){ 211 if(currentIface == interfaces.end()){
212 error = true; 212 error = true;
213 return QString(); 213 return QString();
214 } 214 }
215 QString line = (*currentIface); 215 QString line = (*currentIface);
216 line = line.mid(QString(IFACE).length() +1, line.length()); 216 line = line.mid(QString(IFACE).length() +1, line.length());
217 line = line.simplifyWhiteSpace(); 217 line = line.simplifyWhiteSpace();
218 int findSpace = line.find(" "); 218 int findSpace = line.find(" ");
219 if( findSpace < 0){ 219 if( findSpace < 0){
220 error = true; 220 error = true;
221 return QString(); 221 return QString();
222 } 222 }
223 error = false; 223 error = false;
224 return line.mid(0, findSpace); 224 return line.mid(0, findSpace);
225} 225}
226 226
227/** 227/**
228 * Gets the family name of the interface that is currently selected. 228 * Gets the family name of the interface that is currently selected.
229 * @return QString name of the family (inet, inet6, ipx). 229 * @return QString name of the family (inet, inet6, ipx).
230 * @param error set to true if any error occurs, false otherwise. 230 * @param error set to true if any error occurs, false otherwise.
231 */ 231 */
232QString Interfaces::getInterfaceFamily(bool &error){ 232QString Interfaces::getInterfaceFamily(bool &error){
233 QString name = getInterfaceName(error); 233 QString name = getInterfaceName(error);
234 if(error) 234 if(error)
235 return QString(); 235 return QString();
236 QString line = (*currentIface); 236 QString line = (*currentIface);
237 line = line.mid(QString(IFACE).length() +1, line.length()); 237 line = line.mid(QString(IFACE).length() +1, line.length());
238 line = line.mid(name.length()+1, line.length()); 238 line = line.mid(name.length()+1, line.length());
239 line = line.simplifyWhiteSpace(); 239 line = line.simplifyWhiteSpace();
240 int findSpace = line.find(" "); 240 int findSpace = line.find(" ");
241 if( findSpace < 0){ 241 if( findSpace < 0){
242 error = true; 242 error = true;
243 return QString(); 243 return QString();
244 } 244 }
245 error = false; 245 error = false;
246 return line.mid(0, findSpace); 246 return line.mid(0, findSpace);
247} 247}
248 248
249/** 249/**
250 * Gets the method of the interface that is currently selected. 250 * Gets the method of the interface that is currently selected.
251 * @return QString name of the method such as staic or dhcp. 251 * @return QString name of the method such as staic or dhcp.
252 * See the man page of interfaces for possible methods depending on the family. 252 * See the man page of interfaces for possible methods depending on the family.
253 * @param error set to true if any error occurs, false otherwise. 253 * @param error set to true if any error occurs, false otherwise.
254 */ 254 */
255QString Interfaces::getInterfaceMethod(bool &error){ 255QString Interfaces::getInterfaceMethod(bool &error){
256 QString name = getInterfaceName(error); 256 QString name = getInterfaceName(error);
257 if(error) 257 if(error)
258 return QString(); 258 return QString();
259 QString family = getInterfaceFamily(error); 259 QString family = getInterfaceFamily(error);
260 if(error) 260 if(error)
261 return QString(); 261 return QString();
262 QString line = (*currentIface); 262 QString line = (*currentIface);
263 line = line.mid(QString(IFACE).length()+1, line.length()); 263 line = line.mid(QString(IFACE).length()+1, line.length());
264 line = line.mid(name.length()+1, line.length()); 264 line = line.mid(name.length()+1, line.length());
265 line = line.mid(family.length()+1, line.length()); 265 line = line.mid(family.length()+1, line.length());
266 line = line.simplifyWhiteSpace(); 266 line = line.simplifyWhiteSpace();
267 error = false; 267 error = false;
268 return line; 268 return line;
269} 269}
270 270
271/** 271/**
272 * Sets the interface name to newName. 272 * Sets the interface name to newName.
273 * @param newName the new name of the interface. All whitespace is removed. 273 * @param newName the new name of the interface. All whitespace is removed.
274 * @return bool true if successfull. 274 * @return bool true if successfull.
275 */ 275 */
276bool Interfaces::setInterfaceName(const QString &newName){ 276bool Interfaces::setInterfaceName(const QString &newName){
277 if(currentIface == interfaces.end()) 277 if(currentIface == interfaces.end())
278 return false; 278 return false;
279 QString name = newName.simplifyWhiteSpace(); 279 QString name = newName.simplifyWhiteSpace();
280 name = name.replace(QRegExp(" "), ""); 280 name = name.replace(QRegExp(" "), "");
281 bool returnValue = false; 281 bool returnValue = false;
282 (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 282 (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
283 return !returnValue; 283 return !returnValue;
284} 284}
285 285
286/** 286/**
287 * Sets the interface family to newName. 287 * Sets the interface family to newName.
288 * @param newName the new name of the interface. Must be one of the families 288 * @param newName the new name of the interface. Must be one of the families
289 * defined in the interfaces.h file. 289 * defined in the interfaces.h file.
290 * @return bool true if successfull. 290 * @return bool true if successfull.
291 */ 291 */
292bool Interfaces::setInterfaceFamily(const QString &newName){ 292bool Interfaces::setInterfaceFamily(const QString &newName){
293 if(currentIface == interfaces.end()) 293 if(currentIface == interfaces.end())
294 return false; 294 return false;
295 if(acceptedFamily.contains(newName)==0) 295 if(acceptedFamily.contains(newName)==0)
296 return false; 296 return false;
297 bool returnValue = false; 297 bool returnValue = false;
298 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 298 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
299 return !returnValue; 299 return !returnValue;
300} 300}
301 301
302/** 302/**
303 * Sets the interface method to newName 303 * Sets the interface method to newName
304 * @param newName the new name of the interface 304 * @param newName the new name of the interface
305 * @return bool true if successfull. 305 * @return bool true if successfull.
306 */ 306 */
307bool Interfaces::setInterfaceMethod(const QString &newName){ 307bool Interfaces::setInterfaceMethod(const QString &newName){
308 if(currentIface == interfaces.end()) 308 if(currentIface == interfaces.end())
309 return false; 309 return false;
310 bool returnValue = false; 310 bool returnValue = false;
311 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 311 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
312 return !returnValue; 312 return !returnValue;
313} 313}
314 314
315/** 315/**
316 * Get a value for an option in the currently selected interface. For example 316 * Get a value for an option in the currently selected interface. For example
317 * calling getInterfaceOption("address") on the following stanza would 317 * calling getInterfaceOption("address") on the following stanza would
318 * return 192.168.1.1. 318 * return 192.168.1.1.
319 * iface eth0 static 319 * iface eth0 static
320 * address 192.168.1.1 320 * address 192.168.1.1
321 * @param option the options to get the value. 321 * @param option the options to get the value.
322 * @param error set to true if any error occurs, false otherwise. 322 * @param error set to true if any error occurs, false otherwise.
323 * @return QString the options value. QString::null if error == true 323 * @return QString the options value. QString::null if error == true
324 */ 324 */
325QString Interfaces::getInterfaceOption(const QString &option, bool &error){ 325QString Interfaces::getInterfaceOption(const QString &option, bool &error){
326 return getOption(currentIface, option, error); 326 return getOption(currentIface, option, error);
327} 327}
328 328
329/** 329/**
330 * Set a value for an option in the currently selected interface. If option 330 * Set a value for an option in the currently selected interface. If option
331 * doesn't exist then it is added along with the value. 331 * doesn't exist then it is added along with the value.
332 * @param option the options to set the value. 332 * @param option the options to set the value.
333 * @param value the value that option should be set to. 333 * @param value the value that option should be set to.
334 * @param error set to true if any error occurs, false otherwise. 334 * @param error set to true if any error occurs, false otherwise.
335 * @return QString the options value. QString::null if error == true 335 * @return QString the options value. QString::null if error == true
336 */ 336 */
337bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ 337bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
338 return setOption(currentIface, option, value); 338 return setOption(currentIface, option, value);
339} 339}
340 340
341/** 341/**
342 * Removes a value for an option in the currently selected interface. 342 * Removes a value for an option in the currently selected interface.
343 * @param option the options to set the value. 343 * @param option the options to set the value.
344 * @param value the value that option should be set to. 344 * @param value the value that option should be set to.
345 * @param error set to true if any error occurs, false otherwise. 345 * @param error set to true if any error occurs, false otherwise.
346 * @return QString the options value. QString::null if error == true 346 * @return QString the options value. QString::null if error == true
347 */ 347 */
348bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ 348bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
349 return removeOption(currentIface, option, value); 349 return removeOption(currentIface, option, value);
350} 350}
351 351
352/** 352/**
353 * Removes all of the options from the currently selected interface. 353 * Removes all of the options from the currently selected interface.
354 * @return bool error if if successfull 354 * @return bool error if if successfull
355 */ 355 */
356bool Interfaces::removeAllInterfaceOptions(){ 356bool Interfaces::removeAllInterfaceOptions(){
357 return removeAllOptions(currentIface); 357 return removeAllOptions(currentIface);
358} 358}
359 359
360/** 360/**
361 * Set the current map to interface's map. This needs to be done before you 361 * Set the current map to interface's map. This needs to be done before you
362 * can call addMapping(), set/getMap(), and get/setScript(). 362 * can call addMapping(), set/getMap(), and get/setScript().
363 * @param interface the name of the interface to set. All whitespace is 363 * @param interface the name of the interface to set. All whitespace is
364 * removed from the interface name. 364 * removed from the interface name.
365 * @return bool true if it is successfull. 365 * @return bool true if it is successfull.
366 */ 366 */
367bool Interfaces::setMapping(const QString &interface){ 367bool Interfaces::setMapping(const QString &interface){
368 QString interfaceName = interface.simplifyWhiteSpace(); 368 QString interfaceName = interface.simplifyWhiteSpace();
369 interfaceName = interfaceName.replace(QRegExp(" "), ""); 369 interfaceName = interfaceName.replace(QRegExp(" "), "");
370 return setStanza(MAPPING, interfaceName, currentMapping); 370 return setStanza(MAPPING, interfaceName, currentMapping);
371} 371}
372 372
373/** 373/**
374 * Adds a new Mapping to the interfaces file with interfaces. 374 * Adds a new Mapping to the interfaces file with interfaces.
375 * @param interface the name(s) of the interfaces to set to this mapping 375 * @param interface the name(s) of the interfaces to set to this mapping
376 */ 376 */
377void Interfaces::addMapping(const QString &option){ 377void Interfaces::addMapping(const QString &option){
378 interfaces.append(""); 378 interfaces.append("");
379 interfaces.append(QString(MAPPING " %1").arg(option)); 379 interfaces.append(QString(MAPPING " %1").arg(option));
380} 380}
381 381
382/** 382/**
383 * Remove the currently selected map and all of its options. 383 * Remove the currently selected map and all of its options.
384 * @return bool if successfull or not. 384 * @return bool if successfull or not.
385 */ 385 */
386bool Interfaces::removeMapping(){ 386bool Interfaces::removeMapping(){
387 return removeStanza(currentMapping); 387 return removeStanza(currentMapping);
388} 388}
389 389
390/** 390/**
391 * Set a map option within a mapping. 391 * Set a map option within a mapping.
392 * @param map map to use 392 * @param map map to use
393 * @param value value to go with map 393 * @param value value to go with map
394 * @return bool true if it is successfull. 394 * @return bool true if it is successfull.
395 */ 395 */
396bool Interfaces::setMap(const QString &map, const QString &value){ 396bool Interfaces::setMap(const QString &map, const QString &value){
397 return setOption(currentMapping, map, value); 397 return setOption(currentMapping, map, value);
398} 398}
399 399
400/** 400/**
401 * Removes a map option within a mapping. 401 * Removes a map option within a mapping.
402 * @param map map to use 402 * @param map map to use
403 * @param value value to go with map 403 * @param value value to go with map
404 * @return bool true if it is successfull. 404 * @return bool true if it is successfull.
405 */ 405 */
406bool Interfaces::removeMap(const QString &map, const QString &value){ 406bool Interfaces::removeMap(const QString &map, const QString &value){
407 return removeOption(currentMapping, map, value); 407 return removeOption(currentMapping, map, value);
408} 408}
409 409
410/** 410/**
411 * Get a map value within a mapping. 411 * Get a map value within a mapping.
412 * @param map map to get value of 412 * @param map map to get value of
413 * @param bool true if it is successfull. 413 * @param bool true if it is successfull.
414 * @return value that goes to the map 414 * @return value that goes to the map
415 */ 415 */
416QString Interfaces::getMap(const QString &map, bool &error){ 416QString Interfaces::getMap(const QString &map, bool &error){
417 return getOption(currentMapping, map, error); 417 return getOption(currentMapping, map, error);
418} 418}
419 419
420/** 420/**
421 * Sets a script value of the current mapping to argument. 421 * Sets a script value of the current mapping to argument.
422 * @param argument the script name. 422 * @param argument the script name.
423 * @return true if successfull. 423 * @return true if successfull.
424 */ 424 */
425bool Interfaces::setScript(const QString &argument){ 425bool Interfaces::setScript(const QString &argument){
426 return setOption(currentMapping, "script", argument); 426 return setOption(currentMapping, "script", argument);
427} 427}
428 428
429/** 429/**
430 * @param error true if could not retrieve the current script argument. 430 * @param error true if could not retrieve the current script argument.
431 * @return QString the argument of the script for the current mapping. 431 * @return QString the argument of the script for the current mapping.
432 */ 432 */
433QString Interfaces::getScript(bool &error){ 433QString Interfaces::getScript(bool &error){
434 return getOption(currentMapping, "script", error); 434 return getOption(currentMapping, "script", error);
435} 435}
436 436
437 437
438 438
439/** 439/**
440 * Helper function used to parse through the QStringList and put pointers in 440 * Helper function used to parse through the QStringList and put pointers in
441 * the correct place. 441 * the correct place.
442 * @param stanza The stanza (auto, iface, mapping) to look for. 442 * @param stanza The stanza (auto, iface, mapping) to look for.
443 * @param option string that must be in the stanza's main line. 443 * @param option string that must be in the stanza's main line.
444 * @param interator interator to place at location of stanza if successfull. 444 * @param interator interator to place at location of stanza if successfull.
445 * @return bool true if the stanza is found. 445 * @return bool true if the stanza is found.
446 */ 446 */
447bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ 447bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
448 bool found = false; 448 bool found = false;
449 iterator = interfaces.end(); 449 iterator = interfaces.end();
450 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 450 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
451 QString line = (*it).simplifyWhiteSpace(); 451 QString line = (*it).simplifyWhiteSpace();
452 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ 452 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
453 uint point = line.find(option); 453 uint point = line.find(option);
454 bool valid = true; 454 bool valid = true;
455 if(point > 0){ 455 if(point > 0){
456 // There are more chars in the line. check +1 456 // There are more chars in the line. check +1
457 if(line.at(point-1) != ' ') 457 if(line.at(point-1) != ' ')
458 valid = false; 458 valid = false;
459 } 459 }
460 point += option.length(); 460 point += option.length();
461 if(point < line.length()-1){ 461 if(point < line.length()-1){
462 // There are more chars in the line. check -1 462 // There are more chars in the line. check -1
463 if(line.at(point) != ' ') 463 if(line.at(point) != ' ')
464 valid = false; 464 valid = false;
465 } 465 }
466 if(valid){ 466 if(valid){
467 if(found == true){ 467 if(found == true){
468 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 468 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
469 } 469 }
470 found = true; 470 found = true;
471 iterator = it; 471 iterator = it;
472 } 472 }
473 } 473 }
474 } 474 }
475 return found; 475 return found;
476} 476}
477 477
478/** 478/**
479 * Sets a value of an option in a stanza 479 * Sets a value of an option in a stanza
480 * @param start the start of the stanza 480 * @param start the start of the stanza
481 * @param option the option to use when setting value. 481 * @param option the option to use when setting value.
482 * @return bool true if successfull, false otherwise. 482 * @return bool true if successfull, false otherwise.
483 */ 483 */
484bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 484bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
485 if(start == interfaces.end()) 485 if(start == interfaces.end())
486 return false; 486 return false;
487 487
488 bool found = false; 488 bool found = false;
489 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 489 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
490 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 490 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
491 if(!found && value != ""){ 491 if(!found && value != ""){
492 // Got to the end of the stanza without finding it, so append it. 492 // Got to the end of the stanza without finding it, so append it.
493 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 493 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
494 } 494 }
495 found = true; 495 found = true;
496 break; 496 break;
497 } 497 }
498 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 498 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
499 // Found it in stanza so replace it. 499 // Found it in stanza so replace it.
500 if(found) 500 if(found)
501 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 501 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
502 found = true; 502 found = true;
503 (*it) = QString("\t%1 %2").arg(option).arg(value); 503 (*it) = QString("\t%1 %2").arg(option).arg(value);
504 } 504 }
505 } 505 }
506 if(!found){ 506 if(!found){
507 QStringList::Iterator p = start; 507 QStringList::Iterator p = start;
508 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 508 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
509 found = true; 509 found = true;
510 } 510 }
511 return found; 511 return found;
512} 512}
513 513
514/** 514/**
515 * Removes a stanza and all of its options 515 * Removes a stanza and all of its options
516 * @param stanza the stanza to remove 516 * @param stanza the stanza to remove
517 * @return bool true if successfull. 517 * @return bool true if successfull.
518 */ 518 */
519bool Interfaces::removeStanza(QStringList::Iterator &stanza){ 519bool Interfaces::removeStanza(QStringList::Iterator &stanza){
520 if(stanza == interfaces.end()) 520 if(stanza == interfaces.end())
521 return false; 521 return false;
522 (*stanza) = ""; 522 (*stanza) = "";
523 return removeAllOptions(stanza); 523 return removeAllOptions(stanza);
524} 524}
525 525
526/** 526/**
527 * Removes a option in a stanza 527 * Removes a option in a stanza
diff --git a/noncore/settings/networksettings/interfaces/interfaces.h b/noncore/settings/networksettings/interfaces/interfaces.h
index d662919..bac2a7e 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.h
+++ b/noncore/settings/networksettings/interfaces/interfaces.h
@@ -1,77 +1,77 @@
1#ifndef INTERFACES_H 1#ifndef INTERFACES_H
2#define INTERFACES_H 2#define INTERFACES_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6 6
7#define INTERFACES_LOOPBACK "loopback" 7#define INTERFACES_LOOPBACK "loopback"
8 8
9#define INTERFACES_FAMILY_INET "inet" 9#define INTERFACES_FAMILY_INET "inet"
10#define INTERFACES_FAMILY_IPX "ipx" 10#define INTERFACES_FAMILY_IPX "ipx"
11#define INTERFACES_FAMILY_INET6 "inet6" 11#define INTERFACES_FAMILY_INET6 "inet6"
12 12
13#define INTERFACES_METHOD_DHCP "dhcp" 13#define INTERFACES_METHOD_DHCP "dhcp"
14#define INTERFACES_METHOD_STATIC "static" 14#define INTERFACES_METHOD_STATIC "static"
15#define INTERFACES_METHOD_PPP "ppp" 15#define INTERFACES_METHOD_PPP "ppp"
16 16
17/** 17/**
18 * This class provides a clean frontend for parsing the network interfaces file. 18 * This class provides a clean frontend for parsing the network interfaces file.
19 * It provides helper functions to minipulate the options within the file. 19 * It provides helper functions to minipulate the options within the file.
20 * See the interfaces man page for the syntax rules. 20 * See the interfaces man page for the syntax rules.
21 */ 21 */
22class Interfaces { 22class Interfaces {
23 23
24public: 24public:
25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); 25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
26 QStringList getInterfaceList(); 26 QStringList getInterfaceList();
27 27
28 bool isAuto(const QString &interface); 28 bool isAuto(const QString &interface) const ;
29 bool setAuto(const QString &interface, bool setAuto); 29 bool setAuto(const QString &interface, bool setAuto);
30 30
31 bool removeInterface(); 31 bool removeInterface();
32 bool addInterface(const QString &interface, const QString &family, const QString &method); 32 bool addInterface(const QString &interface, const QString &family, const QString &method);
33 bool copyInterface(const QString &oldInterface, const QString &newInterface); 33 bool copyInterface(const QString &oldInterface, const QString &newInterface);
34 bool setInterface(QString interface); 34 bool setInterface(QString interface);
35 bool isInterfaceSet(); 35 bool isInterfaceSet() const ;
36 QString getInterfaceName(bool &error); 36 QString getInterfaceName(bool &error);
37 bool setInterfaceName(const QString &newName); 37 bool setInterfaceName(const QString &newName);
38 QString getInterfaceFamily(bool &error); 38 QString getInterfaceFamily(bool &error);
39 bool setInterfaceFamily(const QString &newName); 39 bool setInterfaceFamily(const QString &newName);
40 QString getInterfaceMethod(bool &error); 40 QString getInterfaceMethod(bool &error);
41 bool setInterfaceMethod(const QString &newName); 41 bool setInterfaceMethod(const QString &newName);
42 QString getInterfaceOption(const QString &option, bool &error); 42 QString getInterfaceOption(const QString &option, bool &error);
43 bool setInterfaceOption(const QString &option, const QString &value); 43 bool setInterfaceOption(const QString &option, const QString &value);
44 bool removeInterfaceOption(const QString &option, const QString &value); 44 bool removeInterfaceOption(const QString &option, const QString &value);
45 bool removeAllInterfaceOptions(); 45 bool removeAllInterfaceOptions();
46 46
47 bool setMapping(const QString &interface); 47 bool setMapping(const QString &interface);
48 bool removeMapping(); 48 bool removeMapping();
49 void addMapping(const QString &options); 49 void addMapping(const QString &options);
50 bool setMap(const QString &map, const QString &value); 50 bool setMap(const QString &map, const QString &value);
51 bool removeMap(const QString &map, const QString &value); 51 bool removeMap(const QString &map, const QString &value);
52 QString getMap(const QString &map, bool &error); 52 QString getMap(const QString &map, bool &error);
53 bool setScript(const QString &argument); 53 bool setScript(const QString &argument);
54 QString getScript(bool &error); 54 QString getScript(bool &error);
55 55
56 bool write(); 56 bool write();
57 57
58private: 58private:
59 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator); 59 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
60 bool removeStanza(QStringList::Iterator &stanza);
60 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value); 61 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
62 bool removeAllOptions(const QStringList::Iterator &start);
61 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value); 63 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
62 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error); 64 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
63 bool removeStanza(QStringList::Iterator &stanza);
64 bool removeAllOptions(const QStringList::Iterator &start);
65 65
66 QString interfacesFile; 66 QString interfacesFile;
67 QStringList interfaces; 67 QStringList interfaces;
68 QStringList::Iterator currentIface; 68 QStringList::Iterator currentIface;
69 QStringList::Iterator currentMapping; 69 QStringList::Iterator currentMapping;
70 70
71 QStringList acceptedFamily; 71 QStringList acceptedFamily;
72}; 72};
73 73
74#endif 74#endif
75 75
76// interfaces 76// interfaces
77 77
diff --git a/noncore/settings/networksettings/interfaces/interfaces.pro b/noncore/settings/networksettings/interfaces/interfaces.pro
index 9a024f6..d6b43fb 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.pro
+++ b/noncore/settings/networksettings/interfaces/interfaces.pro
@@ -1,12 +1,12 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3 #CONFIG += qt warn_on debug 3 #CONFIG += qt warn_on debug
4 DESTDIR = $(QTDIR)/lib$(PROJMAK) 4 #DESTDIR = $(QTDIR)/lib$(PROJMAK)
5 HEADERS = interface.h interfaceinformationimp.h interfaces.h interfacesetupimp.h 5 HEADERS = interface.h interfaceinformationimp.h interfaces.h interfacesetupimp.h
6 SOURCES = interface.cpp interfaces.cpp interfaceinformationimp.cpp interfacesetupimp.cpp 6 SOURCES = interface.cpp interfaces.cpp interfaceinformationimp.cpp interfacesetupimp.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include ../ 7 INCLUDEPATH+= $(OPIEDIR)/include ../
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10 INTERFACES= interfaceadvanced.ui interfaceinformation.ui interfacesetup.ui 10 INTERFACES= interfaceadvanced.ui interfaceinformation.ui interfacesetup.ui
11 TARGET = interfaces 11 TARGET = interfaces
12 VERSION = 1.0.0 12 VERSION = 1.0.0
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 68bb0a0..72cd45e 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,104 +1,107 @@
1#include "pppmodule.h" 1#include "pppmodule.h"
2#include "pppimp.h"
2#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
3 4
4/** 5/**
5 * Constructor, find all of the possible interfaces 6 * Constructor, find all of the possible interfaces
6 */ 7 */
7PPPModule::PPPModule() : Module() { 8PPPModule::PPPModule() : Module() {
8} 9}
9 10
10/** 11/**
11 * Delete any interfaces that we own. 12 * Delete any interfaces that we own.
12 */ 13 */
13PPPModule::~PPPModule(){ 14PPPModule::~PPPModule(){
14 Interface *i; 15 Interface *i;
15 for ( i=list.first(); i != 0; i=list.next() ) 16 for ( i=list.first(); i != 0; i=list.next() )
16 delete i; 17 delete i;
17} 18}
18 19
19/** 20/**
20 * Change the current profile 21 * Change the current profile
21 */ 22 */
22void PPPModule::setProfile(const QString &newProfile){ 23void PPPModule::setProfile(const QString &newProfile){
23 profile = newProfile; 24 profile = newProfile;
24} 25}
25 26
26/** 27/**
27 * get the icon name for this device. 28 * get the icon name for this device.
28 * @param Interface* can be used in determining the icon. 29 * @param Interface* can be used in determining the icon.
29 * @return QString the icon name (minus .png, .gif etc) 30 * @return QString the icon name (minus .png, .gif etc)
30 */ 31 */
31QString PPPModule::getPixmapName(Interface* ){ 32QString PPPModule::getPixmapName(Interface* ){
32 return "ppp"; 33 return "ppp";
33} 34}
34 35
35/** 36/**
36 * Check to see if the interface i is owned by this module. 37 * Check to see if the interface i is owned by this module.
37 * @param Interface* interface to check against 38 * @param Interface* interface to check against
38 * @return bool true if i is owned by this module, false otherwise. 39 * @return bool true if i is owned by this module, false otherwise.
39 */ 40 */
40bool PPPModule::isOwner(Interface *i){ 41bool PPPModule::isOwner(Interface *i){
41 // Scan the ppp database 42 if(!i->getInterfaceName().upper().contains("PPP"))
42 return false; 43 return false;
43 44
44 i->setHardwareName("PPP"); 45 i->setHardwareName("PPP");
45 list.append(i); 46 list.append(i);
46 return true; 47 return true;
47} 48}
48 49
49/** 50/**
50 * Create, and return the WLANConfigure Module 51 * Create, and return the WLANConfigure Module
51 * @return QWidget* pointer to this modules configure. 52 * @return QWidget* pointer to this modules configure.
52 */ 53 */
53QWidget *PPPModule::configure(Interface *i){ 54QWidget *PPPModule::configure(Interface *i){
54 return NULL; 55 return NULL;
55 //PPPConfigureImp *pppconfig = new PPPConfigureImp(0, "PPPConfig", i, false, Qt::WDestructiveClose); 56 //PPPConfigureImp *pppconfig = new PPPConfigureImp(0, "PPPConfig", i, false, Qt::WDestructiveClose);
56 //pppconfig->setProfile(profile); 57 //pppconfig->setProfile(profile);
57 //return wlanconfig; 58 //return wlanconfig;
58} 59}
59 60
60/** 61/**
61 * Create, and return the Information Module 62 * Create, and return the Information Module
62 * @return QWidget* pointer to this modules info. 63 * @return QWidget* pointer to this modules info.
63 */ 64 */
64QWidget *PPPModule::information(Interface *i){ 65QWidget *PPPModule::information(Interface *i){
65 return NULL; 66 // We don't have any advanced pppd information widget yet :-D
66 67 // TODO ^
67 //WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 68 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i);
68 //InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); 69 return information;
69 //info->tabWidget->insertTab(information, "TCP/IP");
70 //return info;
71} 70}
72 71
73/** 72/**
74 * Get all active (up or down) interfaces 73 * Get all active (up or down) interfaces
75 * @return QList<Interface> A list of interfaces that exsist that havn't 74 * @return QList<Interface> A list of interfaces that exsist that havn't
76 * been called by isOwner() 75 * been called by isOwner()
77 */ 76 */
78QList<Interface> PPPModule::getInterfaces(){ 77QList<Interface> PPPModule::getInterfaces(){
78 // List all of the files in the peer directory
79 return list; 79 return list;
80} 80}
81 81
82/** 82/**
83 * Attempt to add a new interface as defined by name 83 * Attempt to add a new interface as defined by name
84 * @param name the name of the type of interface that should be created given 84 * @param name the name of the type of interface that should be created given
85 * by possibleNewInterfaces(); 85 * by possibleNewInterfaces();
86 * @return Interface* NULL if it was unable to be created. 86 * @return Interface* NULL if it was unable to be created.
87 */ 87 */
88Interface *PPPModule::addNewInterface(const QString &newInterface){ 88Interface *PPPModule::addNewInterface(const QString &newInterface){
89 // We can't add a 802.11 interface, either the hardware will be there 89 // If the
90 // or it wont. 90 PPPConfigureImp imp(0, "PPPConfigImp");
91 if(imp.exec() == QDialog::Accepted ){
92
93 }
91 return NULL; 94 return NULL;
92} 95}
93 96
94/** 97/**
95 * Attempts to remove the interface, doesn't delete i 98 * Attempts to remove the interface, doesn't delete i
96 * @return bool true if successfull, false otherwise. 99 * @return bool true if successfull, false otherwise.
97 */ 100 */
98bool PPPModule::remove(Interface*){ 101bool PPPModule::remove(Interface*){
99 // Can't remove a hardware device, you can stop it though. 102 // Can't remove a hardware device, you can stop it though.
100 return false; 103 return false;
101} 104}
102 105
103// pppmodule.cpp 106// pppmodule.cpp
104 107
diff --git a/noncore/settings/networksettings/wlan/infoimp.cpp b/noncore/settings/networksettings/wlan/infoimp.cpp
index e1eef81..6d3e167 100644
--- a/noncore/settings/networksettings/wlan/infoimp.cpp
+++ b/noncore/settings/networksettings/wlan/infoimp.cpp
@@ -1,55 +1,56 @@
1#include "infoimp.h" 1#include "infoimp.h"
2#include "wextensions.h" 2#include "wextensions.h"
3
3#include <qtimer.h> 4#include <qtimer.h>
4#include <qprogressbar.h> 5#include <qprogressbar.h>
5#include <qlabel.h> 6#include <qlabel.h>
6 7
7/** 8/**
8 * Constructor. If wireless extensions are enabled on device name then 9 * Constructor. If wireless extensions are enabled on device name then
9 * start a timer that every second will update the information. 10 * start a timer that every second will update the information.
10 */ 11 */
11WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){ 12WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){
12 WExtensions *wExtensions = new WExtensions(name); 13 WExtensions *wExtensions = new WExtensions(name);
13 if(!wExtensions->doesHaveWirelessExtensions()){ 14 if(!wExtensions->doesHaveWirelessExtensions()){
14 delete wExtensions; 15 delete wExtensions;
15 qDebug("No extension"); 16 qDebug("WlanInfoImp::No wireless extension");
16 return; 17 return;
17 } 18 }
18 delete wExtensions; 19 delete wExtensions;
19 timer = new QTimer( this ); 20 timer = new QTimer( this );
20 connect( timer, SIGNAL(timeout()), this, SLOT(update())); 21 connect( timer, SIGNAL(timeout()), this, SLOT(update()));
21 timer->start( 1000, false ); 22 timer->start( 1000, false );
22} 23}
23 24
24/** 25/**
25 * Updates the information about the wireless device. 26 * Updates the information about the wireless device.
26 */ 27 */
27void WlanInfoImp::update(){ 28void WlanInfoImp::update(){
28 WExtensions *wExtensions = new WExtensions(this->name()); 29 WExtensions *wExtensions = new WExtensions(this->name());
29 if(!wExtensions->doesHaveWirelessExtensions()){ 30 if(!wExtensions->doesHaveWirelessExtensions()){
30 qDebug("No extension"); 31 qDebug("No extension");
31 delete wExtensions; 32 delete wExtensions;
32 timer->stop(); 33 timer->stop();
33 return; 34 return;
34 } 35 }
35 essidLabel->setText(wExtensions->essid()); 36 essidLabel->setText(wExtensions->essid());
36 apLabel->setText(wExtensions->ap()); 37 apLabel->setText(wExtensions->ap());
37 stationLabel->setText(wExtensions->station()); 38 stationLabel->setText(wExtensions->station());
38 modeLabel->setText(wExtensions->mode()); 39 modeLabel->setText(wExtensions->mode());
39 freqLabel->setText(QString("%1 GHz").arg(wExtensions->frequency())); 40 freqLabel->setText(QString("%1 GHz").arg(wExtensions->frequency()));
40 int signal = 0; 41 int signal = 0;
41 int noise = 0; 42 int noise = 0;
42 int quality = 0; 43 int quality = 0;
43 wExtensions->stats(signal, noise, quality); 44 wExtensions->stats(signal, noise, quality);
44 if(signalProgressBar->progress() != signal) 45 if(signalProgressBar->progress() != signal)
45 signalProgressBar->setProgress(signal); 46 signalProgressBar->setProgress(signal);
46 if(noiseProgressBar->progress() != noise) 47 if(noiseProgressBar->progress() != noise)
47 noiseProgressBar->setProgress(noise); 48 noiseProgressBar->setProgress(noise);
48 if(qualityProgressBar->progress() != quality) 49 if(qualityProgressBar->progress() != quality)
49 qualityProgressBar->setProgress(quality); 50 qualityProgressBar->setProgress(quality);
50 rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate())); 51 rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate()));
51 delete wExtensions; 52 delete wExtensions;
52} 53}
53 54
54// infoimp.cpp 55// infoimp.cpp
55 56