summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-17 16:30:44 (UTC)
committer benmeyer <benmeyer>2002-10-17 16:30:44 (UTC)
commit18cc7321db186865629a5c4702074211e42b92fd (patch) (unidiff)
treebeb15112009c1cc966115904a322b32d465e47e6
parent75f078ec92376db2c90a327bbc50d9bb5c1fb57a (diff)
downloadopie-18cc7321db186865629a5c4702074211e42b92fd.zip
opie-18cc7321db186865629a5c4702074211e42b92fd.tar.gz
opie-18cc7321db186865629a5c4702074211e42b92fd.tar.bz2
interface is now a qobject
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO2
-rw-r--r--noncore/net/networksetup/interface.cpp77
-rw-r--r--noncore/net/networksetup/interface.h31
-rw-r--r--noncore/net/networksetup/interfaceadvanced.ui11
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.cpp51
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.h6
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp43
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp4
-rw-r--r--noncore/settings/networksettings/TODO2
-rw-r--r--noncore/settings/networksettings/interface.cpp77
-rw-r--r--noncore/settings/networksettings/interface.h31
-rw-r--r--noncore/settings/networksettings/interfaceadvanced.ui11
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.cpp51
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.h6
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp43
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp4
16 files changed, 258 insertions, 192 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 7386646..c8e2989 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,8 +1,10 @@
1Write a class that parses /proc and not ifconfig
2
1[ ] Wlanmodule needs to check if an interface supports wireless 3[ ] Wlanmodule needs to check if an interface supports wireless
2 extensions. 4 extensions.
3[x] When you set options in wlanmodule, hit OK, it exits all of 5[x] When you set options in wlanmodule, hit OK, it exits all of
4 networksetup, doesnt bring you back to the main screen. 6 networksetup, doesnt bring you back to the main screen.
5[x] Wlanmodule isnt writing out wireless.opts 7[x] Wlanmodule isnt writing out wireless.opts
6[ ] Need a means of bringing an interface up and down (calling 8[ ] Need a means of bringing an interface up and down (calling
7 out ifup/ifdown) from the gui. 9 out ifup/ifdown) from the gui.
8 -Ben- Click information, then click up or down... :-D 10 -Ben- Click information, then click up or down... :-D
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index 1f32093..1e01da4 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -1,242 +1,287 @@
1#include "interface.h" 1#include "interface.h"
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7 7
8#define IFCONFIG "/sbin/ifconfig" 8#define IFCONFIG "/sbin/ifconfig"
9#define HDCP_INFO_DIR "/etc/dhcpc" 9#define HDCP_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(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ 14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
15 refresh(); 15 refresh();
16} 16}
17 17
18/** 18/**
19 * Set status
20 * @param newStatus - the new status
21 * emit updateInterface
22 */
23void Interface::setStatus(bool newStatus){
24 if(status != newStatus){
25 status = newStatus;
26 refresh();
27 }
28};
29
30/**
31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached
33 * emit updateInterface
34 */
35void Interface::setAttached(bool isAttached){
36 attached = isAttached;
37 emit(updateInterface(this));
38};
39
40/**
41 * Set Hardware name
42 * @param name - the new name
43 * emit updateInterface
44 */
45void Interface::setHardwareName(QString name){
46 hardareName = name;
47 emit(updateInterface(this));
48};
49
50/**
51 * Set Module owner
52 * @param owner - the new owner
53 * emit updateInterface
54 */
55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner;
57 emit(updateInterface(this));
58};
59
60
61/**
19 * Try to start the interface. 62 * Try to start the interface.
20 * @return bool true if successfull.
21 */ 63 */
22bool Interface::start(){ 64void Interface::start(){
23 // check to see if we are already running. 65 // check to see if we are already running.
24 if(status) 66 if(true == status)
25 return false; 67 return;
26 68
27 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1()); 69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
70 // See if it was successfull...
28 if(ret != 0) 71 if(ret != 0)
29 return false; 72 return;
30 73
31 status = true; 74 status = true;
32 refresh(); 75 refresh();
33 return true;
34} 76}
35 77
36/** 78/**
37 * Try to stop the interface. 79 * Try to stop the interface.
38 * @return bool true if successfull.
39 */ 80 */
40bool Interface::stop(){ 81void Interface::stop(){
41 // check to see if we are already stopped. 82 // check to see if we are already stopped.
42 if(status == false) 83 if(false == status)
43 return false; 84 return;
44 85
45 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1()); 86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
46 if(ret != 0) 87 if(ret != 0)
47 return false; 88 return;
48 89
49 status = true; 90 status = true;
50 refresh(); 91 refresh();
51 return true;
52} 92}
93
53/** 94/**
54 * Try to restart the interface. 95 * Try to restart the interface.
55 * @return bool true if successfull.
56 */ 96 */
57bool Interface::restart(){ 97void Interface::restart(){
58 return (stop() && start()); 98 stop();
99 start();
59} 100}
60 101
61/** 102/**
62 * Try to refresh the information about the interface. 103 * Try to refresh the information about the interface.
63 * First call ifconfig, then check the dhcp-info file 104 * First call ifconfig, then check the dhcp-info file
64 * @return bool true if successfull. 105 * @return bool true if successfull.
65 */ 106 */
66bool Interface::refresh(){ 107bool Interface::refresh(){
67 // See if we are up. 108 // See if we are up.
68 if(status == false){ 109 if(status == false){
69 macAddress = ""; 110 macAddress = "";
70 ip = "0.0.0.0"; 111 ip = "0.0.0.0";
71 subnetMask = "0.0.0.0"; 112 subnetMask = "0.0.0.0";
72 broadcast = ""; 113 broadcast = "";
73 dhcp = false; 114 dhcp = false;
74 dhcpServerIp = ""; 115 dhcpServerIp = "";
75 leaseObtained = ""; 116 leaseObtained = "";
76 leaseExpires = ""; 117 leaseExpires = "";
118 emit(updateInterface(this));
77 return true; 119 return true;
78 } 120 }
79 121
80 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); 122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName);
81 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1()); 123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1());
82 if(ret != 0){ 124 if(ret != 0){
83 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
84 return false; 126 return false;
85 } 127 }
86 128
87 QFile file(fileName); 129 QFile file(fileName);
88 if (!file.open(IO_ReadOnly)){ 130 if (!file.open(IO_ReadOnly)){
89 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
90 return false; 132 return false;
91 } 133 }
92 134
93 // Set to the defaults 135 // Set to the defaults
94 macAddress = ""; 136 macAddress = "";
95 ip = "0.0.0.0"; 137 ip = "0.0.0.0";
96 subnetMask = "0.0.0.0"; 138 subnetMask = "0.0.0.0";
97 broadcast = ""; 139 broadcast = "";
98 140
99 QTextStream stream( &file ); 141 QTextStream stream( &file );
100 QString line; 142 QString line;
101 while ( !stream.eof() ) { 143 while ( !stream.eof() ) {
102 line = stream.readLine(); 144 line = stream.readLine();
103 if(line.contains("HWaddr")){ 145 if(line.contains("HWaddr")){
104 int mac = line.find("HWaddr"); 146 int mac = line.find("HWaddr");
105 macAddress = line.mid(mac+7, line.length()); 147 macAddress = line.mid(mac+7, line.length());
106 } 148 }
107 if(line.contains("inet addr")){ 149 if(line.contains("inet addr")){
108 int ipl = line.find("inet addr"); 150 int ipl = line.find("inet addr");
109 int space = line.find(" ", ipl+10); 151 int space = line.find(" ", ipl+10);
110 ip = line.mid(ipl+10, space-ipl-10); 152 ip = line.mid(ipl+10, space-ipl-10);
111 } 153 }
112 if(line.contains("Mask")){ 154 if(line.contains("Mask")){
113 int mask = line.find("Mask"); 155 int mask = line.find("Mask");
114 subnetMask = line.mid(mask+5, line.length()); 156 subnetMask = line.mid(mask+5, line.length());
115 } 157 }
116 if(line.contains("Bcast")){ 158 if(line.contains("Bcast")){
117 int mask = line.find("Bcast"); 159 int mask = line.find("Bcast");
118 int space = line.find(" ", mask+6); 160 int space = line.find(" ", mask+6);
119 broadcast = line.mid(mask+6, space-mask-6); 161 broadcast = line.mid(mask+6, space-mask-6);
120 } 162 }
121 } 163 }
122 file.close(); 164 file.close();
123 QFile::remove(fileName); 165 QFile::remove(fileName);
124 166
125 // DHCP TESTING 167 // DHCP TESTING
126 // reset DHCP info 168 // reset DHCP info
127 dhcpServerIp = ""; 169 dhcpServerIp = "";
128 leaseObtained = ""; 170 leaseObtained = "";
129 leaseExpires = ""; 171 leaseExpires = "";
130 dhcp = false; 172 dhcp = false;
131 173
132 QString dhcpDirectory(HDCP_INFO_DIR); 174 QString dhcpDirectory(HDCP_INFO_DIR);
133 QDir d(dhcpDirectory); 175 QDir d(dhcpDirectory);
134 if(!d.exists(dhcpDirectory)) 176 if(!d.exists(dhcpDirectory))
135 dhcpDirectory = "/var/run"; 177 dhcpDirectory = "/var/run";
136 178
137 // See if we have 179 // See if we have
138 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); 180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
139 // If there is no DHCP information then exit now with no errors. 181 // If there is no DHCP information then exit now with no errors.
140 if(!QFile::exists(dhcpFile)){ 182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this));
141 return true; 184 return true;
142 } 185 }
143 186
144 file.setName(dhcpFile); 187 file.setName(dhcpFile);
145 if (!file.open(IO_ReadOnly)){ 188 if (!file.open(IO_ReadOnly)){
146 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
147 return false; 190 return false;
148 } 191 }
149 192
150 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
151 int leaseTime = 0; 194 int leaseTime = 0;
152 int renewalTime = 0; 195 int renewalTime = 0;
153 196
154 stream.setDevice( &file ); 197 stream.setDevice( &file );
155 while ( !stream.eof() ) { 198 while ( !stream.eof() ) {
156 line = stream.readLine(); 199 line = stream.readLine();
157 if(line.contains("DHCPSIADDR=")) 200 if(line.contains("DHCPSIADDR="))
158 dhcpServerIp = line.mid(11, line.length()); 201 dhcpServerIp = line.mid(11, line.length());
159 if(line.contains("LEASETIME=")) 202 if(line.contains("LEASETIME="))
160 leaseTime = line.mid(10, line.length()).toInt(); 203 leaseTime = line.mid(10, line.length()).toInt();
161 if(line.contains("RENEWALTIME=")) 204 if(line.contains("RENEWALTIME="))
162 renewalTime = line.mid(12, line.length()).toInt(); 205 renewalTime = line.mid(12, line.length()).toInt();
163 } 206 }
164 file.close(); 207 file.close();
165 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
166 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
167 210
168 // Get the pid of the deamond 211 // Get the pid of the deamond
169 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); 212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName));
170 file.setName(dhcpFile); 213 file.setName(dhcpFile);
171 if (!file.open(IO_ReadOnly)){ 214 if (!file.open(IO_ReadOnly)){
172 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
173 return false; 216 return false;
174 } 217 }
175 218
176 int pid = -1; 219 int pid = -1;
177 stream.setDevice( &file ); 220 stream.setDevice( &file );
178 while ( !stream.eof() ) { 221 while ( !stream.eof() ) {
179 line = stream.readLine(); 222 line = stream.readLine();
180 pid = line.toInt(); 223 pid = line.toInt();
181 } 224 }
182 file.close(); 225 file.close();
183 226
184 if( pid == -1){ 227 if( pid == -1){
185 qDebug("Interface: Could not get pid of dhcpc deamon."); 228 qDebug("Interface: Could not get pid of dhcpc deamon.");
186 return false; 229 return false;
187 } 230 }
188 231
189 // Get the start running time of the deamon 232 // Get the start running time of the deamon
190 fileName = (QString("/proc/%1/stat").arg(pid)); 233 fileName = (QString("/proc/%1/stat").arg(pid));
191 file.setName(fileName); 234 file.setName(fileName);
192 stream.setDevice( &file ); 235 stream.setDevice( &file );
193 if (!file.open(IO_ReadOnly)){ 236 if (!file.open(IO_ReadOnly)){
194 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
195 return false; 238 return false;
196 } 239 }
197 while ( !stream.eof() ) { 240 while ( !stream.eof() ) {
198 line = stream.readLine(); 241 line = stream.readLine();
199 } 242 }
200 file.close(); 243 file.close();
201 long time = 0; 244 long time = 0;
202 // Grab the start time 245 // Grab the start time
203 // pid com state ppid pgrp session tty_nr tpgid flags 246 // pid com state ppid pgrp session tty_nr tpgid flags
204 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
205 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
206 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
207 // nice 0 itrealvalue starttime 250 // nice 0 itrealvalue starttime
208 "%*d %*d %*d %lu", (long*) &time); 251 "%*d %*d %*d %lu", (long*) &time);
209 time = time/100; 252 time = time/100;
210 253
211 QDateTime datetime(QDateTime::currentDateTime()); 254 QDateTime datetime(QDateTime::currentDateTime());
212 255
213 // Get the uptime of the computer. 256 // Get the uptime of the computer.
214 QFile f("/proc/uptime"); 257 QFile f("/proc/uptime");
215 if ( f.open(IO_ReadOnly) ) { // file opened successfully 258 if ( f.open(IO_ReadOnly) ) { // file opened successfully
216 QTextStream t( &f ); // use a text stream 259 QTextStream t( &f ); // use a text stream
217 int sec = 0; 260 int sec = 0;
218 t >> sec; 261 t >> sec;
219 datetime = datetime.addSecs((-1*sec)); 262 datetime = datetime.addSecs((-1*sec));
220 f.close(); 263 f.close();
221 } 264 }
222 else{ 265 else{
223 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 266 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
224 return false; 267 return false;
225 } 268 }
226 269
227 datetime = datetime.addSecs(time); 270 datetime = datetime.addSecs(time);
228 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); 271 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
229 272
230 // Calculate the start and renew times 273 // Calculate the start and renew times
231 leaseObtained= datetime.toString(); 274 leaseObtained= datetime.toString();
232 275
233 // Calculate the start and renew times 276 // Calculate the start and renew times
234 datetime = datetime.addSecs(leaseTime); 277 datetime = datetime.addSecs(leaseTime);
235 leaseExpires = datetime.toString(); 278 leaseExpires = datetime.toString();
236 279
237 dhcp = true; 280 dhcp = true;
281
282 emit(updateInterface(this));
238 return true; 283 return true;
239} 284}
240 285
241// interface.cpp 286// interface.cpp
242 287
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h
index 1406e99..980171a 100644
--- a/noncore/net/networksetup/interface.h
+++ b/noncore/net/networksetup/interface.h
@@ -1,67 +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 6
6class Module; 7class Module;
7 8
8class Interface { 9class Interface : public QObject{
10 Q_OBJECT
9 11
12signals:
13 void updateInterface(Interface *i);
14
10public: 15public:
11 Interface(QString name = "unknown", bool status = false); 16 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
12 virtual ~Interface(){}; 17 virtual ~Interface(){};
13 18
19 virtual QString getInterfaceName(){ QString n(this->name()); return n; };
20
14 virtual bool getStatus(){ return status; }; 21 virtual bool getStatus(){ return status; };
15 virtual void setStatus(bool newSatus){ status = newSatus; refresh(); }; 22 virtual void setStatus(bool newStatus);
16 23
17 virtual bool isAttached(){ return attached; }; 24 virtual bool isAttached(){ return attached; };
18 virtual void setAttached(bool isAttached=false){ attached = isAttached; }; 25 virtual void setAttached(bool isAttached=false);
19
20 virtual QString getInterfaceName(){ return interfaceName; };
21 virtual void setInterfaceName(QString name="unknown"){ interfaceName = name; };
22 26
23 virtual QString getHardwareName(){ return hardareName; }; 27 virtual QString getHardwareName(){ return hardareName; };
24 virtual void setHardwareName(QString name="Unknown"){ hardareName = name; }; 28 virtual void setHardwareName(QString name="Unknown");
25 29
26 virtual Module* getModuleOwner(){ return moduleOwner; }; 30 virtual Module* getModuleOwner(){ return moduleOwner; };
27 virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; }; 31 virtual void setModuleOwner(Module *owner=NULL);
28 32
29 // inet information. 33 // inet information.
30 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress(){ return macAddress; };
31 QString getIp(){ return ip; }; 35 QString getIp(){ return ip; };
32 QString getSubnetMask(){ return subnetMask; }; 36 QString getSubnetMask(){ return subnetMask; };
33 QString getBroadcast(){ return broadcast; }; 37 QString getBroadcast(){ return broadcast; };
34 bool isDhcp(){ return dhcp; }; 38 bool isDhcp(){ return dhcp; };
35 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp(){ return dhcpServerIp; };
36 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained(){ return leaseObtained; };
37 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires(){ return leaseExpires; };
38 42
43public slots:
39 bool refresh(); 44 bool refresh();
40 bool start(); 45 void start();
41 bool stop(); 46 void stop();
42 bool restart(); 47 void restart();
43 48
44private: 49private:
45 // Interface information 50 // Interface information
46 bool status; 51 bool status;
47 bool attached; 52 bool attached;
48 QString interfaceName; 53 QString interfaceName;
49 QString hardareName; 54 QString hardareName;
50 Module *moduleOwner; 55 Module *moduleOwner;
51 56
52 // Network information 57 // Network information
53 QString macAddress; 58 QString macAddress;
54 QString ip; 59 QString ip;
55 QString broadcast; 60 QString broadcast;
56 QString subnetMask; 61 QString subnetMask;
57 bool dhcp; 62 bool dhcp;
58 QString dhcpServerIp; 63 QString dhcpServerIp;
59 QString leaseObtained; 64 QString leaseObtained;
60 QString leaseExpires; 65 QString leaseExpires;
61 66
62}; 67};
63 68
64#endif 69#endif
65 70
66// interface.h 71// interface.h
67 72
diff --git a/noncore/net/networksetup/interfaceadvanced.ui b/noncore/net/networksetup/interfaceadvanced.ui
index 7520abe..efe67b0 100644
--- a/noncore/net/networksetup/interfaceadvanced.ui
+++ b/noncore/net/networksetup/interfaceadvanced.ui
@@ -1,337 +1,344 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>InterfaceAdvanced</class> 2<class>InterfaceAdvanced</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>InterfaceAdvanced</cstring> 7 <cstring>InterfaceAdvanced</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>188</width> 14 <width>214</width>
15 <height>277</height> 15 <height>286</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>320</width>
22 <height>32767</height>
23 </size>
24 </property>
25 <property stdset="1">
19 <name>caption</name> 26 <name>caption</name>
20 <string>Advanced Interface Information</string> 27 <string>Advanced Interface Information</string>
21 </property> 28 </property>
22 <grid> 29 <grid>
23 <property stdset="1"> 30 <property stdset="1">
24 <name>margin</name> 31 <name>margin</name>
25 <number>11</number> 32 <number>11</number>
26 </property> 33 </property>
27 <property stdset="1"> 34 <property stdset="1">
28 <name>spacing</name> 35 <name>spacing</name>
29 <number>6</number> 36 <number>6</number>
30 </property> 37 </property>
31 <widget row="1" column="0" > 38 <widget row="1" column="0" >
32 <class>QLabel</class> 39 <class>QLabel</class>
33 <property stdset="1"> 40 <property stdset="1">
34 <name>name</name> 41 <name>name</name>
35 <cstring>TextLabel1</cstring> 42 <cstring>TextLabel1</cstring>
36 </property> 43 </property>
37 <property stdset="1"> 44 <property stdset="1">
38 <name>text</name> 45 <name>text</name>
39 <string>MAC Address</string> 46 <string>MAC Address</string>
40 </property> 47 </property>
41 </widget> 48 </widget>
42 <widget row="0" column="1" > 49 <widget row="0" column="1" >
43 <class>QLabel</class> 50 <class>QLabel</class>
44 <property stdset="1"> 51 <property stdset="1">
45 <name>name</name> 52 <name>name</name>
46 <cstring>interfaceName</cstring> 53 <cstring>interfaceName</cstring>
47 </property> 54 </property>
48 <property stdset="1"> 55 <property stdset="1">
49 <name>frameShape</name> 56 <name>frameShape</name>
50 <enum>Panel</enum> 57 <enum>Panel</enum>
51 </property> 58 </property>
52 <property stdset="1"> 59 <property stdset="1">
53 <name>frameShadow</name> 60 <name>frameShadow</name>
54 <enum>Sunken</enum> 61 <enum>Sunken</enum>
55 </property> 62 </property>
56 <property stdset="1"> 63 <property stdset="1">
57 <name>text</name> 64 <name>text</name>
58 <string>eth0</string> 65 <string>eth0</string>
59 </property> 66 </property>
60 </widget> 67 </widget>
61 <widget row="2" column="0" > 68 <widget row="2" column="0" >
62 <class>QLabel</class> 69 <class>QLabel</class>
63 <property stdset="1"> 70 <property stdset="1">
64 <name>name</name> 71 <name>name</name>
65 <cstring>TextLabel3</cstring> 72 <cstring>TextLabel3</cstring>
66 </property> 73 </property>
67 <property stdset="1"> 74 <property stdset="1">
68 <name>text</name> 75 <name>text</name>
69 <string>IP Address</string> 76 <string>IP Address</string>
70 </property> 77 </property>
71 </widget> 78 </widget>
72 <widget row="1" column="1" > 79 <widget row="1" column="1" >
73 <class>QLabel</class> 80 <class>QLabel</class>
74 <property stdset="1"> 81 <property stdset="1">
75 <name>name</name> 82 <name>name</name>
76 <cstring>macAddressLabel</cstring> 83 <cstring>macAddressLabel</cstring>
77 </property> 84 </property>
78 <property stdset="1"> 85 <property stdset="1">
79 <name>frameShape</name> 86 <name>frameShape</name>
80 <enum>Panel</enum> 87 <enum>Panel</enum>
81 </property> 88 </property>
82 <property stdset="1"> 89 <property stdset="1">
83 <name>frameShadow</name> 90 <name>frameShadow</name>
84 <enum>Sunken</enum> 91 <enum>Sunken</enum>
85 </property> 92 </property>
86 <property stdset="1"> 93 <property stdset="1">
87 <name>text</name> 94 <name>text</name>
88 <string>00:00:00:00:00:00</string> 95 <string>00:00:00:00:00:00</string>
89 </property> 96 </property>
90 </widget> 97 </widget>
91 <widget row="0" column="0" > 98 <widget row="0" column="0" >
92 <class>QLabel</class> 99 <class>QLabel</class>
93 <property stdset="1"> 100 <property stdset="1">
94 <name>name</name> 101 <name>name</name>
95 <cstring>TextLabel7</cstring> 102 <cstring>TextLabel7</cstring>
96 </property> 103 </property>
97 <property stdset="1"> 104 <property stdset="1">
98 <name>text</name> 105 <name>text</name>
99 <string>Interface</string> 106 <string>Interface</string>
100 </property> 107 </property>
101 </widget> 108 </widget>
102 <widget row="4" column="0" > 109 <widget row="4" column="0" >
103 <class>QLabel</class> 110 <class>QLabel</class>
104 <property stdset="1"> 111 <property stdset="1">
105 <name>name</name> 112 <name>name</name>
106 <cstring>TextLabel4</cstring> 113 <cstring>TextLabel4</cstring>
107 </property> 114 </property>
108 <property stdset="1"> 115 <property stdset="1">
109 <name>enabled</name> 116 <name>enabled</name>
110 <bool>true</bool> 117 <bool>true</bool>
111 </property> 118 </property>
112 <property stdset="1"> 119 <property stdset="1">
113 <name>text</name> 120 <name>text</name>
114 <string>Subnet Mask</string> 121 <string>Subnet Mask</string>
115 </property> 122 </property>
116 </widget> 123 </widget>
117 <widget row="2" column="1" > 124 <widget row="2" column="1" >
118 <class>QLabel</class> 125 <class>QLabel</class>
119 <property stdset="1"> 126 <property stdset="1">
120 <name>name</name> 127 <name>name</name>
121 <cstring>ipAddressLabel</cstring> 128 <cstring>ipAddressLabel</cstring>
122 </property> 129 </property>
123 <property stdset="1"> 130 <property stdset="1">
124 <name>frameShape</name> 131 <name>frameShape</name>
125 <enum>Panel</enum> 132 <enum>Panel</enum>
126 </property> 133 </property>
127 <property stdset="1"> 134 <property stdset="1">
128 <name>frameShadow</name> 135 <name>frameShadow</name>
129 <enum>Sunken</enum> 136 <enum>Sunken</enum>
130 </property> 137 </property>
131 <property stdset="1"> 138 <property stdset="1">
132 <name>text</name> 139 <name>text</name>
133 <string>0.0.0.0</string> 140 <string>0.0.0.0</string>
134 </property> 141 </property>
135 </widget> 142 </widget>
136 <widget row="4" column="1" > 143 <widget row="4" column="1" >
137 <class>QLabel</class> 144 <class>QLabel</class>
138 <property stdset="1"> 145 <property stdset="1">
139 <name>name</name> 146 <name>name</name>
140 <cstring>subnetMaskLabel</cstring> 147 <cstring>subnetMaskLabel</cstring>
141 </property> 148 </property>
142 <property stdset="1"> 149 <property stdset="1">
143 <name>frameShape</name> 150 <name>frameShape</name>
144 <enum>Panel</enum> 151 <enum>Panel</enum>
145 </property> 152 </property>
146 <property stdset="1"> 153 <property stdset="1">
147 <name>frameShadow</name> 154 <name>frameShadow</name>
148 <enum>Sunken</enum> 155 <enum>Sunken</enum>
149 </property> 156 </property>
150 <property stdset="1"> 157 <property stdset="1">
151 <name>text</name> 158 <name>text</name>
152 <string>0.0.0.0</string> 159 <string>0.0.0.0</string>
153 </property> 160 </property>
154 </widget> 161 </widget>
155 <widget row="3" column="0" > 162 <widget row="3" column="0" >
156 <class>QLabel</class> 163 <class>QLabel</class>
157 <property stdset="1"> 164 <property stdset="1">
158 <name>name</name> 165 <name>name</name>
159 <cstring>TextLabel2</cstring> 166 <cstring>TextLabel2</cstring>
160 </property> 167 </property>
161 <property stdset="1"> 168 <property stdset="1">
162 <name>text</name> 169 <name>text</name>
163 <string>Broadcast</string> 170 <string>Broadcast</string>
164 </property> 171 </property>
165 </widget> 172 </widget>
166 <widget row="3" column="1" > 173 <widget row="3" column="1" >
167 <class>QLabel</class> 174 <class>QLabel</class>
168 <property stdset="1"> 175 <property stdset="1">
169 <name>name</name> 176 <name>name</name>
170 <cstring>broadcastLabel</cstring> 177 <cstring>broadcastLabel</cstring>
171 </property> 178 </property>
172 <property stdset="1"> 179 <property stdset="1">
173 <name>frameShape</name> 180 <name>frameShape</name>
174 <enum>Panel</enum> 181 <enum>Panel</enum>
175 </property> 182 </property>
176 <property stdset="1"> 183 <property stdset="1">
177 <name>frameShadow</name> 184 <name>frameShadow</name>
178 <enum>Sunken</enum> 185 <enum>Sunken</enum>
179 </property> 186 </property>
180 </widget> 187 </widget>
181 <widget row="5" column="0" rowspan="1" colspan="2" > 188 <widget row="5" column="0" rowspan="1" colspan="2" >
182 <class>QGroupBox</class> 189 <class>QGroupBox</class>
183 <property stdset="1"> 190 <property stdset="1">
184 <name>name</name> 191 <name>name</name>
185 <cstring>GroupBox2</cstring> 192 <cstring>GroupBox2</cstring>
186 </property> 193 </property>
187 <property stdset="1"> 194 <property stdset="1">
188 <name>title</name> 195 <name>title</name>
189 <string>DHCP Information</string> 196 <string>DHCP Information</string>
190 </property> 197 </property>
191 <grid> 198 <grid>
192 <property stdset="1"> 199 <property stdset="1">
193 <name>margin</name> 200 <name>margin</name>
194 <number>11</number> 201 <number>11</number>
195 </property> 202 </property>
196 <property stdset="1"> 203 <property stdset="1">
197 <name>spacing</name> 204 <name>spacing</name>
198 <number>6</number> 205 <number>6</number>
199 </property> 206 </property>
200 <widget row="0" column="0" > 207 <widget row="0" column="0" >
201 <class>QLabel</class> 208 <class>QLabel</class>
202 <property stdset="1"> 209 <property stdset="1">
203 <name>name</name> 210 <name>name</name>
204 <cstring>TextLabel6</cstring> 211 <cstring>TextLabel6</cstring>
205 </property> 212 </property>
206 <property stdset="1"> 213 <property stdset="1">
207 <name>text</name> 214 <name>text</name>
208 <string>DHCP Server</string> 215 <string>DHCP Server</string>
209 </property> 216 </property>
210 </widget> 217 </widget>
211 <widget row="2" column="1" > 218 <widget row="2" column="1" >
212 <class>QLabel</class> 219 <class>QLabel</class>
213 <property stdset="1"> 220 <property stdset="1">
214 <name>name</name> 221 <name>name</name>
215 <cstring>leaseExpiresLabel</cstring> 222 <cstring>leaseExpiresLabel</cstring>
216 </property> 223 </property>
217 <property stdset="1"> 224 <property stdset="1">
218 <name>frameShape</name> 225 <name>frameShape</name>
219 <enum>Panel</enum> 226 <enum>Panel</enum>
220 </property> 227 </property>
221 <property stdset="1"> 228 <property stdset="1">
222 <name>frameShadow</name> 229 <name>frameShadow</name>
223 <enum>Sunken</enum> 230 <enum>Sunken</enum>
224 </property> 231 </property>
225 <property stdset="1"> 232 <property stdset="1">
226 <name>text</name> 233 <name>text</name>
227 <string></string> 234 <string></string>
228 </property> 235 </property>
229 </widget> 236 </widget>
230 <widget row="1" column="1" > 237 <widget row="1" column="1" >
231 <class>QLabel</class> 238 <class>QLabel</class>
232 <property stdset="1"> 239 <property stdset="1">
233 <name>name</name> 240 <name>name</name>
234 <cstring>leaseObtainedLabel</cstring> 241 <cstring>leaseObtainedLabel</cstring>
235 </property> 242 </property>
236 <property stdset="1"> 243 <property stdset="1">
237 <name>frameShape</name> 244 <name>frameShape</name>
238 <enum>Panel</enum> 245 <enum>Panel</enum>
239 </property> 246 </property>
240 <property stdset="1"> 247 <property stdset="1">
241 <name>frameShadow</name> 248 <name>frameShadow</name>
242 <enum>Sunken</enum> 249 <enum>Sunken</enum>
243 </property> 250 </property>
244 <property stdset="1"> 251 <property stdset="1">
245 <name>text</name> 252 <name>text</name>
246 <string></string> 253 <string></string>
247 </property> 254 </property>
248 </widget> 255 </widget>
249 <widget row="2" column="0" > 256 <widget row="2" column="0" >
250 <class>QLabel</class> 257 <class>QLabel</class>
251 <property stdset="1"> 258 <property stdset="1">
252 <name>name</name> 259 <name>name</name>
253 <cstring>TextLabel9</cstring> 260 <cstring>TextLabel9</cstring>
254 </property> 261 </property>
255 <property stdset="1"> 262 <property stdset="1">
256 <name>text</name> 263 <name>text</name>
257 <string>Lease Expires</string> 264 <string>Lease Expires</string>
258 </property> 265 </property>
259 </widget> 266 </widget>
260 <widget row="1" column="0" > 267 <widget row="1" column="0" >
261 <class>QLabel</class> 268 <class>QLabel</class>
262 <property stdset="1"> 269 <property stdset="1">
263 <name>name</name> 270 <name>name</name>
264 <cstring>TextLabel8</cstring> 271 <cstring>TextLabel8</cstring>
265 </property> 272 </property>
266 <property stdset="1"> 273 <property stdset="1">
267 <name>text</name> 274 <name>text</name>
268 <string>Lease Obtained</string> 275 <string>Lease Obtained</string>
269 </property> 276 </property>
270 </widget> 277 </widget>
271 <widget row="0" column="1" > 278 <widget row="0" column="1" >
272 <class>QLabel</class> 279 <class>QLabel</class>
273 <property stdset="1"> 280 <property stdset="1">
274 <name>name</name> 281 <name>name</name>
275 <cstring>dhcpServerLabel</cstring> 282 <cstring>dhcpServerLabel</cstring>
276 </property> 283 </property>
277 <property stdset="1"> 284 <property stdset="1">
278 <name>frameShape</name> 285 <name>frameShape</name>
279 <enum>Panel</enum> 286 <enum>Panel</enum>
280 </property> 287 </property>
281 <property stdset="1"> 288 <property stdset="1">
282 <name>frameShadow</name> 289 <name>frameShadow</name>
283 <enum>Sunken</enum> 290 <enum>Sunken</enum>
284 </property> 291 </property>
285 <property stdset="1"> 292 <property stdset="1">
286 <name>text</name> 293 <name>text</name>
287 <string></string> 294 <string></string>
288 </property> 295 </property>
289 </widget> 296 </widget>
290 </grid> 297 </grid>
291 </widget> 298 </widget>
292 <spacer row="6" column="1" > 299 <spacer row="6" column="1" >
293 <property> 300 <property>
294 <name>name</name> 301 <name>name</name>
295 <cstring>Spacer2</cstring> 302 <cstring>Spacer2</cstring>
296 </property> 303 </property>
297 <property stdset="1"> 304 <property stdset="1">
298 <name>orientation</name> 305 <name>orientation</name>
299 <enum>Vertical</enum> 306 <enum>Vertical</enum>
300 </property> 307 </property>
301 <property stdset="1"> 308 <property stdset="1">
302 <name>sizeType</name> 309 <name>sizeType</name>
303 <enum>Expanding</enum> 310 <enum>Expanding</enum>
304 </property> 311 </property>
305 <property> 312 <property>
306 <name>sizeHint</name> 313 <name>sizeHint</name>
307 <size> 314 <size>
308 <width>20</width> 315 <width>20</width>
309 <height>20</height> 316 <height>20</height>
310 </size> 317 </size>
311 </property> 318 </property>
312 </spacer> 319 </spacer>
313 </grid> 320 </grid>
314</widget> 321</widget>
315<customwidgets> 322<customwidgets>
316 <customwidget> 323 <customwidget>
317 <class>QWidget</class> 324 <class>QWidget</class>
318 <header location="local">qwidget.h</header> 325 <header location="local">qwidget.h</header>
319 <sizehint> 326 <sizehint>
320 <width>100</width> 327 <width>100</width>
321 <height>100</height> 328 <height>100</height>
322 </sizehint> 329 </sizehint>
323 <container>0</container> 330 <container>0</container>
324 <sizepolicy> 331 <sizepolicy>
325 <hordata>7</hordata> 332 <hordata>7</hordata>
326 <verdata>7</verdata> 333 <verdata>7</verdata>
327 </sizepolicy> 334 </sizepolicy>
328 <pixmap>image0</pixmap> 335 <pixmap>image0</pixmap>
329 </customwidget> 336 </customwidget>
330</customwidgets> 337</customwidgets>
331<images> 338<images>
332 <image> 339 <image>
333 <name>image0</name> 340 <name>image0</name>
334 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> 341 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
335 </image> 342 </image>
336</images> 343</images>
337</UI> 344</UI>
diff --git a/noncore/net/networksetup/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaceinformationimp.cpp
index e37e0f8..59a6400 100644
--- a/noncore/net/networksetup/interfaceinformationimp.cpp
+++ b/noncore/net/networksetup/interfaceinformationimp.cpp
@@ -1,94 +1,67 @@
1#include "interfaceinformationimp.h" 1#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h" 2#include "interfaceadvanced.h"
3 3
4#include <qpushbutton.h> 4#include <qpushbutton.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <assert.h> 6#include <assert.h>
7 7
8/** 8/**
9 * Constructor for the InterfaceInformationImp class. This class pretty much 9 * Constructor for the InterfaceInformationImp class. This class pretty much
10 * just display's information about the interface that is passed to it. 10 * just display's information about the interface that is passed to it.
11 */ 11 */
12InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ 12InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){
13 assert(i); 13 assert(i);
14 14
15 interface = i; 15 interface = i;
16 updateInterface(); 16 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
17 connect(startButton, SIGNAL(clicked()), this, SLOT(start())); 17 updateInterface(interface);
18 connect(stopButton, SIGNAL(clicked()), this, SLOT(stop())); 18 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
19 connect(restartButton, SIGNAL(clicked()), this, SLOT(restart())); 19 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
20 connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); 20 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
21 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
21 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); 22 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
22 23
23} 24}
24 25
25void InterfaceInformationImp::updateInterface(){ 26/**
27 * Update the interface information and buttons.
28 * @param Intarface *i the interface to update (should be the one we already
29 * know about).
30 */
31void InterfaceInformationImp::updateInterface(Interface *i){
26 if(interface->getStatus()){ 32 if(interface->getStatus()){
27 startButton->setEnabled(false); 33 startButton->setEnabled(false);
28 stopButton->setEnabled(true); 34 stopButton->setEnabled(true);
29 restartButton->setEnabled(true); 35 restartButton->setEnabled(true);
30 } 36 }
31 else{ 37 else{
32 startButton->setEnabled(true); 38 startButton->setEnabled(true);
33 stopButton->setEnabled(false); 39 stopButton->setEnabled(false);
34 restartButton->setEnabled(false); 40 restartButton->setEnabled(false);
35 } 41 }
36 macAddressLabel->setText(interface->getMacAddress()); 42 macAddressLabel->setText(interface->getMacAddress());
37 ipAddressLabel->setText(interface->getIp()); 43 ipAddressLabel->setText(interface->getIp());
38 subnetMaskLabel->setText(interface->getSubnetMask()); 44 subnetMaskLabel->setText(interface->getSubnetMask());
39 broadcastLabel->setText(interface->getBroadcast()); 45 broadcastLabel->setText(interface->getBroadcast());
40} 46}
41 47
42/** 48/**
43 * Start the interface. Update the information if successfull
44 */
45void InterfaceInformationImp::start(){
46 if(interface->start()){
47 updateInterface();
48 }
49}
50
51/**
52 * Stop the interface.
53 */
54void InterfaceInformationImp::stop(){
55 if(interface->stop()){
56 updateInterface();
57 }
58}
59
60/***
61 * Tell the interface to refresh its information.
62 **/
63void InterfaceInformationImp::refresh(){
64 if(interface->refresh())
65 updateInterface();
66}
67
68void InterfaceInformationImp::restart(){
69 if(interface->restart()){
70 updateInterface();
71 }
72}
73
74
75/**
76 * Create the advanced widget. Fill it with the current interface's information. 49 * Create the advanced widget. Fill it with the current interface's information.
77 * Display it. 50 * Display it.
78 */ 51 */
79void InterfaceInformationImp::advanced(){ 52void InterfaceInformationImp::advanced(){
80 InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); 53 InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced");
81 a->interfaceName->setText(interface->getInterfaceName()); 54 a->interfaceName->setText(interface->getInterfaceName());
82 a->macAddressLabel->setText(interface->getMacAddress()); 55 a->macAddressLabel->setText(interface->getMacAddress());
83 a->ipAddressLabel->setText(interface->getIp()); 56 a->ipAddressLabel->setText(interface->getIp());
84 a->subnetMaskLabel->setText(interface->getSubnetMask()); 57 a->subnetMaskLabel->setText(interface->getSubnetMask());
85 a->broadcastLabel->setText(interface->getBroadcast()); 58 a->broadcastLabel->setText(interface->getBroadcast());
86 a->dhcpServerLabel->setText(interface->getDhcpServerIp()); 59 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
87 a->leaseObtainedLabel->setText(interface->getLeaseObtained()); 60 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
88 a->leaseExpiresLabel->setText(interface->getLeaseExpires()); 61 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
89 a->showMaximized(); 62 a->showMaximized();
90 a->show(); 63 a->show();
91} 64}
92 65
93// infoimp.cpp 66// infoimp.cpp
94 67
diff --git a/noncore/net/networksetup/interfaceinformationimp.h b/noncore/net/networksetup/interfaceinformationimp.h
index c8a478e..42213cc 100644
--- a/noncore/net/networksetup/interfaceinformationimp.h
+++ b/noncore/net/networksetup/interfaceinformationimp.h
@@ -1,31 +1,27 @@
1#ifndef INTERFACEINFORMATIONIMP_H 1#ifndef INTERFACEINFORMATIONIMP_H
2#define INTERFACEINFORMATIONIMP_H 2#define INTERFACEINFORMATIONIMP_H
3 3
4#include "interfaceinformation.h" 4#include "interfaceinformation.h"
5#include "interface.h" 5#include "interface.h"
6 6
7class InterfaceInformationImp : public InterfaceInformation { 7class InterfaceInformationImp : public InterfaceInformation {
8 8
9Q_OBJECT 9Q_OBJECT
10 10
11public: 11public:
12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); 12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
13 ~InterfaceInformationImp(){}; 13 ~InterfaceInformationImp(){};
14 14
15private slots: 15private slots:
16 void start();
17 void stop();
18 void refresh();
19 void restart();
20 void advanced(); 16 void advanced();
17 void updateInterface(Interface *i);
21 18
22private: 19private:
23 Interface *interface; 20 Interface *interface;
24 void updateInterface();
25 21
26}; 22};
27 23
28#endif 24#endif
29 25
30// addserviceimp.h 26// addserviceimp.h
31 27
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index b46362f..117bac1 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,460 +1,463 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h" 5#include "interfaces.h"
6 6
7#include "module.h" 7#include "module.h"
8 8
9#include "kprocess.h" 9#include "kprocess.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtabwidget.h> 12#include <qtabwidget.h>
13#include <qlistbox.h> 13#include <qlistbox.h>
14#include <qlineedit.h> 14#include <qlineedit.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qheader.h> 16#include <qheader.h>
17#include <qlabel.h> 17#include <qlabel.h>
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qlibrary.h> 23#include <qpe/qlibrary.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26 26
27#include <qlist.h> 27#include <qlist.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
32#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
33#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
34 34
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
40 40
41 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 41 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
42 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 42 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
43 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 43 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
44 44
45 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 45 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
46 // Load connections. 46 // Load connections.
47 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 47 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
48 getInterfaceList(); 48 getInterfaceList();
49 connectionList->header()->hide(); 49 connectionList->header()->hide();
50 50
51 51
52 Config cfg("NetworkSetup"); 52 Config cfg("NetworkSetup");
53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
55 profilesList->insertItem((*it)); 55 profilesList->insertItem((*it));
56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
57} 57}
58 58
59/** 59/**
60 * Deconstructor. Save profiles. Delete loaded libraries. 60 * Deconstructor. Save profiles. Delete loaded libraries.
61 */ 61 */
62MainWindowImp::~MainWindowImp(){ 62MainWindowImp::~MainWindowImp(){
63 // Save profiles. 63 // Save profiles.
64 if(profiles.count() > 1){ 64 if(profiles.count() > 1){
65 Config cfg("NetworkSetup"); 65 Config cfg("NetworkSetup");
66 cfg.setGroup("General"); 66 cfg.setGroup("General");
67 cfg.writeEntry("Profiles", profiles.join(" ")); 67 cfg.writeEntry("Profiles", profiles.join(" "));
68 } 68 }
69 // Delete Modules and Libraries 69 // Delete Modules and Libraries
70 QMap<Module*, QLibrary*>::Iterator it; 70 QMap<Module*, QLibrary*>::Iterator it;
71 for( it = libraries.begin(); it != libraries.end(); ++it ){ 71 for( it = libraries.begin(); it != libraries.end(); ++it ){
72 delete it.key(); 72 delete it.key();
73 delete it.data(); 73 delete it.data();
74 } 74 }
75} 75}
76 76
77/** 77/**
78 * Load all modules that are found in the path 78 * Load all modules that are found in the path
79 * @param path a directory that is scaned for any plugins that can be loaded 79 * @param path a directory that is scaned for any plugins that can be loaded
80 * and attempts to load them 80 * and attempts to load them
81 */ 81 */
82void MainWindowImp::loadModules(QString path){ 82void MainWindowImp::loadModules(QString path){
83 qDebug(path.latin1()); 83 qDebug(path.latin1());
84 QDir d(path); 84 QDir d(path);
85 if(!d.exists()) 85 if(!d.exists())
86 return; 86 return;
87 87
88 // Don't want sym links 88 // Don't want sym links
89 d.setFilter( QDir::Files | QDir::NoSymLinks ); 89 d.setFilter( QDir::Files | QDir::NoSymLinks );
90 const QFileInfoList *list = d.entryInfoList(); 90 const QFileInfoList *list = d.entryInfoList();
91 QFileInfoListIterator it( *list ); 91 QFileInfoListIterator it( *list );
92 QFileInfo *fi; 92 QFileInfo *fi;
93 while ( (fi=it.current()) ) { 93 while ( (fi=it.current()) ) {
94 if(fi->fileName().contains(".so")){ 94 if(fi->fileName().contains(".so")){
95 loadPlugin(path + "/" + fi->fileName()); 95 loadPlugin(path + "/" + fi->fileName());
96 } 96 }
97 ++it; 97 ++it;
98 } 98 }
99} 99}
100 100
101/** 101/**
102 * Attempt to load a function and resolve a function. 102 * Attempt to load a function and resolve a function.
103 * @param pluginFileName - the name of the file in which to attempt to load 103 * @param pluginFileName - the name of the file in which to attempt to load
104 * @param resolveString - function pointer to resolve 104 * @param resolveString - function pointer to resolve
105 * @return pointer to the function with name resolveString or NULL 105 * @return pointer to the function with name resolveString or NULL
106 */ 106 */
107Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 107Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
108 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 108 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
109 QLibrary *lib = new QLibrary(pluginFileName); 109 QLibrary *lib = new QLibrary(pluginFileName);
110 void *functionPointer = lib->resolve(resolveString); 110 void *functionPointer = lib->resolve(resolveString);
111 if( !functionPointer ){ 111 if( !functionPointer ){
112 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 112 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
113 delete lib; 113 delete lib;
114 return NULL; 114 return NULL;
115 } 115 }
116 116
117 // Try to get an object. 117 // Try to get an object.
118 Module *object = ((Module* (*)()) functionPointer)(); 118 Module *object = ((Module* (*)()) functionPointer)();
119 if(object == NULL){ 119 if(object == NULL){
120 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 120 qDebug("MainWindowImp: Couldn't create object, but did load library!");
121 delete lib; 121 delete lib;
122 return NULL; 122 return NULL;
123 } 123 }
124 124
125 // Store for deletion later 125 // Store for deletion later
126 libraries.insert(object, lib); 126 libraries.insert(object, lib);
127 return object; 127 return object;
128} 128}
129 129
130/** 130/**
131 * The Add button was clicked. Bring up the add dialog and if OK is hit 131 * The Add button was clicked. Bring up the add dialog and if OK is hit
132 * load the plugin and append it to the list 132 * load the plugin and append it to the list
133 */ 133 */
134void MainWindowImp::addClicked(){ 134void MainWindowImp::addClicked(){
135 QMap<Module*, QLibrary*>::Iterator it; 135 QMap<Module*, QLibrary*>::Iterator it;
136 QMap<QString, QString> list; 136 QMap<QString, QString> list;
137 QMap<QString, Module*> newInterfaceOwners; 137 QMap<QString, Module*> newInterfaceOwners;
138 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 138 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
139 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 139 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
140 for( it = libraries.begin(); it != libraries.end(); ++it ){ 140 for( it = libraries.begin(); it != libraries.end(); ++it ){
141 if(it.key()){ 141 if(it.key()){
142 (it.key())->possibleNewInterfaces(list); 142 (it.key())->possibleNewInterfaces(list);
143 } 143 }
144 } 144 }
145 // See if the list has anything that we can add. 145 // See if the list has anything that we can add.
146 if(list.count() == 0){ 146 if(list.count() == 0){
147 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 147 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
148 return; 148 return;
149 } 149 }
150 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 150 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
151 addNewConnection.addConnections(list); 151 addNewConnection.addConnections(list);
152 addNewConnection.showMaximized(); 152 addNewConnection.showMaximized();
153 if(QDialog::Accepted == addNewConnection.exec()){ 153 if(QDialog::Accepted == addNewConnection.exec()){
154 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 154 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
155 if(!item) 155 if(!item)
156 return; 156 return;
157 157
158 for( it = libraries.begin(); it != libraries.end(); ++it ){ 158 for( it = libraries.begin(); it != libraries.end(); ++it ){
159 if(it.key()){ 159 if(it.key()){
160 Interface *i = (it.key())->addNewInterface(item->text(0)); 160 Interface *i = (it.key())->addNewInterface(item->text(0));
161 if(i){ 161 if(i){
162 interfaceNames.insert(i->getInterfaceName(), i); 162 interfaceNames.insert(i->getInterfaceName(), i);
163 updateInterface(i); 163 updateInterface(i);
164 } 164 }
165 } 165 }
166 } 166 }
167 } 167 }
168} 168}
169 169
170/** 170/**
171 * Prompt the user to see if they really want to do this. 171 * Prompt the user to see if they really want to do this.
172 * If they do then remove from the list and unload. 172 * If they do then remove from the list and unload.
173 */ 173 */
174void MainWindowImp::removeClicked(){ 174void MainWindowImp::removeClicked(){
175 QListViewItem *item = connectionList->currentItem(); 175 QListViewItem *item = connectionList->currentItem();
176 if(!item) { 176 if(!item) {
177 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 177 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
178 return; 178 return;
179 } 179 }
180 180
181 Interface *i = interfaceItems[item]; 181 Interface *i = interfaceItems[item];
182 if(i->getModuleOwner() == NULL){ 182 if(i->getModuleOwner() == NULL){
183 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 183 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
184 } 184 }
185 else{ 185 else{
186 if(!i->getModuleOwner()->remove(i)) 186 if(!i->getModuleOwner()->remove(i))
187 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 187 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
188 else{ 188 else{
189 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 189 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
190 // TODO memory managment.... 190 // TODO memory managment....
191 // who deletes the interface? 191 // who deletes the interface?
192 } 192 }
193 } 193 }
194} 194}
195 195
196/** 196/**
197 * Pull up the configure about the currently selected interface. 197 * Pull up the configure about the currently selected interface.
198 * Report an error if no interface is selected. 198 * Report an error if no interface is selected.
199 * If the interface has a module owner then request its configure with a empty 199 * If the interface has a module owner then request its configure with a empty
200 * tab. If tab is !NULL then append the interfaces setup widget to it. 200 * tab. If tab is !NULL then append the interfaces setup widget to it.
201 */ 201 */
202void MainWindowImp::configureClicked(){ 202void MainWindowImp::configureClicked(){
203 QListViewItem *item = connectionList->currentItem(); 203 QListViewItem *item = connectionList->currentItem();
204 if(!item){ 204 if(!item){
205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
206 return; 206 return;
207 } 207 }
208 208
209 Interface *i = interfaceItems[item]; 209 Interface *i = interfaceItems[item];
210 if(i->getModuleOwner()){ 210 if(i->getModuleOwner()){
211 QTabWidget *tabWidget = NULL; 211 QTabWidget *tabWidget = NULL;
212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
213 if(moduleConfigure != NULL){ 213 if(moduleConfigure != NULL){
214 if(tabWidget != NULL){ 214 if(tabWidget != NULL){
215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
216 tabWidget->insertTab(configure, "TCP/IP"); 216 tabWidget->insertTab(configure, "TCP/IP");
217 } 217 }
218 moduleConfigure->showMaximized(); 218 moduleConfigure->showMaximized();
219 moduleConfigure->show(); 219 moduleConfigure->show();
220 return; 220 return;
221 } 221 }
222 } 222 }
223 223
224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
225 configure->showMaximized(); 225 configure->showMaximized();
226 configure->show(); 226 configure->show();
227} 227}
228 228
229/** 229/**
230 * Pull up the information about the currently selected interface. 230 * Pull up the information about the currently selected interface.
231 * Report an error if no interface is selected. 231 * Report an error if no interface is selected.
232 * If the interface has a module owner then request its configure with a empty 232 * If the interface has a module owner then request its configure with a empty
233 * tab. If tab is !NULL then append the interfaces setup widget to it. 233 * tab. If tab is !NULL then append the interfaces setup widget to it.
234 */ 234 */
235void MainWindowImp::informationClicked(){ 235void MainWindowImp::informationClicked(){
236 QListViewItem *item = connectionList->currentItem(); 236 QListViewItem *item = connectionList->currentItem();
237 if(!item){ 237 if(!item){
238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
239 return; 239 return;
240 } 240 }
241 241
242 Interface *i = interfaceItems[item]; 242 Interface *i = interfaceItems[item];
243 if(!i->isAttached()){ 243 if(!i->isAttached()){
244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); 244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
245 return; 245 return;
246 } 246 }
247 if(i->getModuleOwner()){ 247 if(i->getModuleOwner()){
248 QTabWidget *tabWidget = NULL; 248 QTabWidget *tabWidget = NULL;
249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
250 if(moduleInformation != NULL){ 250 if(moduleInformation != NULL){
251 if(tabWidget != NULL){ 251 if(tabWidget != NULL){
252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
253 tabWidget->insertTab(information, "TCP/IP"); 253 tabWidget->insertTab(information, "TCP/IP");
254 } 254 }
255 moduleInformation->showMaximized(); 255 moduleInformation->showMaximized();
256 moduleInformation->show(); 256 moduleInformation->show();
257 return; 257 return;
258 } 258 }
259 } 259 }
260 260
261 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 261 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
262 information->showMaximized(); 262 information->showMaximized();
263 information->show(); 263 information->show();
264} 264}
265 265
266/** 266/**
267 * Aquire the list of active interfaces from ifconfig 267 * Aquire the list of active interfaces from ifconfig
268 * Call ifconfig and ifconfig -a 268 * Call ifconfig and ifconfig -a
269 */ 269 */
270void MainWindowImp::getInterfaceList(){ 270void MainWindowImp::getInterfaceList(){
271 KShellProcess *processAll = new KShellProcess(); 271 KShellProcess *processAll = new KShellProcess();
272 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 272 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
273 connect(processAll, SIGNAL(processExited(KProcess *)), 273 connect(processAll, SIGNAL(processExited(KProcess *)),
274 this, SLOT(jobDone(KProcess *))); 274 this, SLOT(jobDone(KProcess *)));
275 threads.insert(processAll, TEMP_ALL); 275 threads.insert(processAll, TEMP_ALL);
276 276
277 KShellProcess *process = new KShellProcess(); 277 KShellProcess *process = new KShellProcess();
278 *process << "/sbin/ifconfig" << " > " TEMP_UP; 278 *process << "/sbin/ifconfig" << " > " TEMP_UP;
279 connect(process, SIGNAL(processExited(KProcess *)), 279 connect(process, SIGNAL(processExited(KProcess *)),
280 this, SLOT(jobDone(KProcess *))); 280 this, SLOT(jobDone(KProcess *)));
281 threads.insert(process, TEMP_UP); 281 threads.insert(process, TEMP_UP);
282 282
283 processAll->start(KShellProcess::NotifyOnExit); 283 processAll->start(KShellProcess::NotifyOnExit);
284 process->start(KShellProcess::NotifyOnExit); 284 process->start(KShellProcess::NotifyOnExit);
285} 285}
286 286
287void MainWindowImp::jobDone(KProcess *process){ 287void MainWindowImp::jobDone(KProcess *process){
288 QString fileName = threads[process]; 288 QString fileName = threads[process];
289 threads.remove(process); 289 threads.remove(process);
290 delete process; 290 delete process;
291 291
292 QFile file(fileName); 292 QFile file(fileName);
293 if (!file.open(IO_ReadOnly)){ 293 if (!file.open(IO_ReadOnly)){
294 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 294 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
295 return; 295 return;
296 } 296 }
297 297
298 QTextStream stream( &file ); 298 QTextStream stream( &file );
299 QString line; 299 QString line;
300 while ( !stream.eof() ) { 300 while ( !stream.eof() ) {
301 line = stream.readLine(); 301 line = stream.readLine();
302 int space = line.find(" "); 302 int space = line.find(" ");
303 if(space > 1){ 303 if(space > 1){
304 // We have found an interface 304 // We have found an interface
305 QString interfaceName = line.mid(0, space); 305 QString interfaceName = line.mid(0, space);
306 Interface *i; 306 Interface *i;
307 // We have found an interface
308 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
307 // See if we already have it 309 // See if we already have it
308 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 310 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
309 if(fileName == TEMP_ALL) 311 if(fileName == TEMP_ALL)
310 i = new Interface(interfaceName, false); 312 i = new Interface(this, interfaceName, false);
311 else 313 else
312 i = new Interface(interfaceName, true); 314 i = new Interface(this, interfaceName, true);
315 i->setAttached(true);
316
317 QString hardName = "Ethernet";
318 int hardwareName = line.find("Link encap:");
319 int macAddress = line.find("HWaddr");
320 if(macAddress == -1)
321 macAddress = line.length();
322 if(hardwareName != -1)
323 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
324
325 interfaceNames.insert(i->getInterfaceName(), i);
326 updateInterface(i);
327 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
313 } 328 }
329 // It was an interface we already had.
314 else{ 330 else{
315 i = interfaceNames[interfaceName]; 331 i = interfaceNames[interfaceName];
316 if(fileName != TEMP_ALL) 332 if(fileName != TEMP_ALL)
317 i->setStatus(true); 333 i->setStatus(true);
318 } 334 }
319
320 i->setAttached(true);
321 i->setInterfaceName(interfaceName);
322
323 QString hardName = "Ethernet";
324 int hardwareName = line.find("Link encap:");
325 int macAddress = line.find("HWaddr");
326 if(macAddress == -1)
327 macAddress = line.length();
328 if(hardwareName != -1)
329 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
330 // We have found an interface
331 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
332 interfaceNames.insert(i->getInterfaceName(), i);
333 updateInterface(i);
334 } 335 }
335 } 336 }
336 file.close(); 337 file.close();
337 QFile::remove(fileName); 338 QFile::remove(fileName);
338 339
339 if(threads.count() == 0){ 340 if(threads.count() == 0){
340 Interfaces i; 341 Interfaces i;
341 QStringList list = i.getInterfaceList(); 342 QStringList list = i.getInterfaceList();
342 QMap<QString, Interface*>::Iterator it; 343 QMap<QString, Interface*>::Iterator it;
343 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 344 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
344 bool found = false; 345 bool found = false;
345 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 346 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
346 if(it.key() == (*ni)) 347 if(it.key() == (*ni))
347 found = true; 348 found = true;
348 } 349 }
349 if(!found){ 350 if(!found){
350 Interface *i = new Interface(*ni, false); 351 Interface *i = new Interface(this, *ni, false);
351 i->setAttached(false); 352 i->setAttached(false);
352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 353 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
353 i->setInterfaceName(*ni);
354 interfaceNames.insert(i->getInterfaceName(), i); 354 interfaceNames.insert(i->getInterfaceName(), i);
355 updateInterface(i); 355 updateInterface(i);
356 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
356 } 357 }
357 } 358 }
358 } 359 }
359} 360}
360 361
361/** 362/**
362 * Update this interface. If no QListViewItem exists create one. 363 * Update this interface. If no QListViewItem exists create one.
363 * @param Interface* pointer to the interface that needs to be updated. 364 * @param Interface* pointer to the interface that needs to be updated.
364 */ 365 */
365void MainWindowImp::updateInterface(Interface *i){ 366void MainWindowImp::updateInterface(Interface *i){
366 if(!advancedUserMode){ 367 if(!advancedUserMode){
367 if(i->getInterfaceName() == "lo") 368 if(i->getInterfaceName() == "lo")
368 return; 369 return;
369 } 370 }
370 371
371 QListViewItem *item = NULL; 372 QListViewItem *item = NULL;
372 373
373 // Find the interface, making it if needed. 374 // Find the interface, making it if needed.
374 if(items.find(i) == items.end()){ 375 if(items.find(i) == items.end()){
375 item = new QListViewItem(connectionList, "", "", ""); 376 item = new QListViewItem(connectionList, "", "", "");
376 // See if you can't find a module owner for this interface 377 // See if you can't find a module owner for this interface
377 QMap<Module*, QLibrary*>::Iterator it; 378 QMap<Module*, QLibrary*>::Iterator it;
378 for( it = libraries.begin(); it != libraries.end(); ++it ){ 379 for( it = libraries.begin(); it != libraries.end(); ++it ){
379 if(it.key()->isOwner(i)) 380 if(it.key()->isOwner(i))
380 i->setModuleOwner(it.key()); 381 i->setModuleOwner(it.key());
381 } 382 }
382 items.insert(i, item); 383 items.insert(i, item);
383 interfaceItems.insert(item, i); 384 interfaceItems.insert(item, i);
384 } 385 }
385 else 386 else
386 item = items[i]; 387 item = items[i];
387 388
388 // Update the icons and information 389 // Update the icons and information
389 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 390 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
390 391
391 QString typeName = "lan"; 392 QString typeName = "lan";
392 if(i->getHardwareName().contains("Local Loopback")) 393 if(i->getHardwareName().contains("Local Loopback"))
393 typeName = "lo"; 394 typeName = "lo";
394 if(i->getInterfaceName().contains("irda")) 395 if(i->getInterfaceName().contains("irda"))
395 typeName = "irda"; 396 typeName = "irda";
396 if(i->getInterfaceName().contains("wlan")) 397 if(i->getInterfaceName().contains("wlan"))
397 typeName = "wlan"; 398 typeName = "wlan";
398 399 if(i->getInterfaceName().contains("usb"))
400 typeName = "usb";
401
399 if(!i->isAttached()) 402 if(!i->isAttached())
400 typeName = "connect_no"; 403 typeName = "connect_no";
401 // Actually try to use the Module 404 // Actually try to use the Module
402 if(i->getModuleOwner() != NULL) 405 if(i->getModuleOwner() != NULL)
403 typeName = i->getModuleOwner()->getPixmapName(i); 406 typeName = i->getModuleOwner()->getPixmapName(i);
404 407
405 item->setPixmap(1, (Resource::loadPixmap(typeName))); 408 item->setPixmap(1, (Resource::loadPixmap(typeName)));
406 item->setText(2, i->getHardwareName()); 409 item->setText(2, i->getHardwareName());
407 item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); 410 item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
408} 411}
409 412
410void MainWindowImp::newProfileChanged(const QString& newText){ 413void MainWindowImp::newProfileChanged(const QString& newText){
411 if(newText.length() > 0) 414 if(newText.length() > 0)
412 newProfileButton->setEnabled(true); 415 newProfileButton->setEnabled(true);
413 else 416 else
414 newProfileButton->setEnabled(false); 417 newProfileButton->setEnabled(false);
415} 418}
416 419
417/** 420/**
418 * Adds a new profile to the list of profiles. 421 * Adds a new profile to the list of profiles.
419 * Don't add profiles that already exists. 422 * Don't add profiles that already exists.
420 * Appends to the list and QStringList 423 * Appends to the list and QStringList
421 */ 424 */
422void MainWindowImp::addProfile(){ 425void MainWindowImp::addProfile(){
423 QString newProfileName = newProfile->text(); 426 QString newProfileName = newProfile->text();
424 if(profiles.grep(newProfileName).count() > 0){ 427 if(profiles.grep(newProfileName).count() > 0){
425 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 428 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
426 return; 429 return;
427 } 430 }
428 profiles.append(newProfileName); 431 profiles.append(newProfileName);
429 profilesList->insertItem(newProfileName); 432 profilesList->insertItem(newProfileName);
430} 433}
431 434
432/** 435/**
433 * Removes the currently selected profile in the combo. 436 * Removes the currently selected profile in the combo.
434 * Doesn't delete if there are less then 2 profiles. 437 * Doesn't delete if there are less then 2 profiles.
435 */ 438 */
436void MainWindowImp::removeProfile(){ 439void MainWindowImp::removeProfile(){
437 if(profilesList->count() <= 1){ 440 if(profilesList->count() <= 1){
438 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok"); 441 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
439 return; 442 return;
440 } 443 }
441 QString profileToRemove = profilesList->currentText(); 444 QString profileToRemove = profilesList->currentText();
442 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 445 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
443 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 446 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
444 profilesList->clear(); 447 profilesList->clear();
445 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 448 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
446 profilesList->insertItem((*it)); 449 profilesList->insertItem((*it));
447 } 450 }
448 451
449} 452}
450 453
451/** 454/**
452 * A new profile has been selected, change. 455 * A new profile has been selected, change.
453 * @param newProfile the new profile. 456 * @param newProfile the new profile.
454 */ 457 */
455void MainWindowImp::changeProfile(){ 458void MainWindowImp::changeProfile(){
456 currentProfileLabel->setText(profilesList->text(profilesList->currentItem())); 459 currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
457} 460}
458 461
459// mainwindowimp.cpp 462// mainwindowimp.cpp
460 463
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 98d2eb6..f0394b4 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -1,84 +1,86 @@
1#include "wlanmodule.h" 1#include "wlanmodule.h"
2#include <qpe/config.h> 2#include <qpe/config.h>
3#include "wlanimp.h" 3#include "wlanimp.h"
4 4
5/** 5/**
6 * Constructor, find all of the possible interfaces 6 * Constructor, find all of the possible interfaces
7 */ 7 */
8WLANModule::WLANModule() : Module() { 8WLANModule::WLANModule() : Module() {
9 // get output from iwconfig 9 // get output from iwconfig
10} 10}
11 11
12/** 12/**
13 * get the icon name for this device. 13 * get the icon name for this device.
14 * @param Interface* can be used in determining the icon. 14 * @param Interface* can be used in determining the icon.
15 * @return QString the icon name (minus .png, .gif etc) 15 * @return QString the icon name (minus .png, .gif etc)
16 */ 16 */
17QString WLANModule::getPixmapName(Interface* ){ 17QString WLANModule::getPixmapName(Interface* ){
18 return "wlan"; 18 return "wlan";
19} 19}
20 20
21/** 21/**
22 * Check to see if the interface i is owned by this module. 22 * Check to see if the interface i is owned by this module.
23 * @param Interface* interface to check against 23 * @param Interface* interface to check against
24 * @return bool true if i is owned by this module, false otherwise. 24 * @return bool true if i is owned by this module, false otherwise.
25 */ 25 */
26bool WLANModule::isOwner(Interface *i){ 26bool WLANModule::isOwner(Interface *i){
27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0") 27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
28 i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName()));
28 return true; 29 return true;
30 }
29 return false; 31 return false;
30} 32}
31 33
32/** 34/**
33 * Create, set tabWiget and return the WLANConfigure Module 35 * Create, set tabWiget and return the WLANConfigure Module
34 * @param tabWidget a pointer to the tab widget that this configure has. 36 * @param tabWidget a pointer to the tab widget that this configure has.
35 * @return QWidget* pointer to the tab widget in this modules configure. 37 * @return QWidget* pointer to the tab widget in this modules configure.
36 */ 38 */
37QWidget *WLANModule::configure(QTabWidget **tabWidget){ 39QWidget *WLANModule::configure(QTabWidget **tabWidget){
38 Config *cfg = new Config("wireless"); 40 Config *cfg = new Config("wireless");
39 WLANImp *wlanconfig = new WLANImp(*cfg); 41 WLANImp *wlanconfig = new WLANImp(*cfg);
40 (*tabWidget) = wlanconfig->tabWidget; 42 (*tabWidget) = wlanconfig->tabWidget;
41 return wlanconfig; 43 return wlanconfig;
42} 44}
43 45
44/** 46/**
45 * Create, set tabWiget and return the Information Module 47 * Create, set tabWiget and return the Information Module
46 * @param tabWidget a pointer to the tab widget that this information has. 48 * @param tabWidget a pointer to the tab widget that this information has.
47 * @return QWidget* pointer to the tab widget in this modules info. 49 * @return QWidget* pointer to the tab widget in this modules info.
48 */ 50 */
49QWidget *WLANModule::information(QTabWidget **tabWidget){ 51QWidget *WLANModule::information(QTabWidget **tabWidget){
50 return NULL; 52 return NULL;
51} 53}
52 54
53/** 55/**
54 * Get all active (up or down) interfaces 56 * Get all active (up or down) interfaces
55 * @return QList<Interface> A list of interfaces that exsist that havn't 57 * @return QList<Interface> A list of interfaces that exsist that havn't
56 * been called by isOwner() 58 * been called by isOwner()
57 */ 59 */
58QList<Interface> WLANModule::getInterfaces(){ 60QList<Interface> WLANModule::getInterfaces(){
59 return list; 61 return list;
60} 62}
61 63
62/** 64/**
63 * Attempt to add a new interface as defined by name 65 * Attempt to add a new interface as defined by name
64 * @param name the name of the type of interface that should be created given 66 * @param name the name of the type of interface that should be created given
65 * by possibleNewInterfaces(); 67 * by possibleNewInterfaces();
66 * @return Interface* NULL if it was unable to be created. 68 * @return Interface* NULL if it was unable to be created.
67 */ 69 */
68Interface *WLANModule::addNewInterface(QString ){ 70Interface *WLANModule::addNewInterface(QString ){
69 // We can't add a 802.11 interface, either the hardware will be there 71 // We can't add a 802.11 interface, either the hardware will be there
70 // or it wont. 72 // or it wont.
71 return NULL; 73 return NULL;
72} 74}
73 75
74/** 76/**
75 * Attempts to remove the interface, doesn't delete i 77 * Attempts to remove the interface, doesn't delete i
76 * @return bool true if successfull, false otherwise. 78 * @return bool true if successfull, false otherwise.
77 */ 79 */
78bool WLANModule::remove(Interface*){ 80bool WLANModule::remove(Interface*){
79 // Can't remove a hardware device, you can stop it though. 81 // Can't remove a hardware device, you can stop it though.
80 return false; 82 return false;
81} 83}
82 84
83// wlanmodule.cpp 85// wlanmodule.cpp
84 86
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 7386646..c8e2989 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,8 +1,10 @@
1Write a class that parses /proc and not ifconfig
2
1[ ] Wlanmodule needs to check if an interface supports wireless 3[ ] Wlanmodule needs to check if an interface supports wireless
2 extensions. 4 extensions.
3[x] When you set options in wlanmodule, hit OK, it exits all of 5[x] When you set options in wlanmodule, hit OK, it exits all of
4 networksetup, doesnt bring you back to the main screen. 6 networksetup, doesnt bring you back to the main screen.
5[x] Wlanmodule isnt writing out wireless.opts 7[x] Wlanmodule isnt writing out wireless.opts
6[ ] Need a means of bringing an interface up and down (calling 8[ ] Need a means of bringing an interface up and down (calling
7 out ifup/ifdown) from the gui. 9 out ifup/ifdown) from the gui.
8 -Ben- Click information, then click up or down... :-D 10 -Ben- Click information, then click up or down... :-D
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index 1f32093..1e01da4 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -1,242 +1,287 @@
1#include "interface.h" 1#include "interface.h"
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7 7
8#define IFCONFIG "/sbin/ifconfig" 8#define IFCONFIG "/sbin/ifconfig"
9#define HDCP_INFO_DIR "/etc/dhcpc" 9#define HDCP_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(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ 14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
15 refresh(); 15 refresh();
16} 16}
17 17
18/** 18/**
19 * Set status
20 * @param newStatus - the new status
21 * emit updateInterface
22 */
23void Interface::setStatus(bool newStatus){
24 if(status != newStatus){
25 status = newStatus;
26 refresh();
27 }
28};
29
30/**
31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached
33 * emit updateInterface
34 */
35void Interface::setAttached(bool isAttached){
36 attached = isAttached;
37 emit(updateInterface(this));
38};
39
40/**
41 * Set Hardware name
42 * @param name - the new name
43 * emit updateInterface
44 */
45void Interface::setHardwareName(QString name){
46 hardareName = name;
47 emit(updateInterface(this));
48};
49
50/**
51 * Set Module owner
52 * @param owner - the new owner
53 * emit updateInterface
54 */
55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner;
57 emit(updateInterface(this));
58};
59
60
61/**
19 * Try to start the interface. 62 * Try to start the interface.
20 * @return bool true if successfull.
21 */ 63 */
22bool Interface::start(){ 64void Interface::start(){
23 // check to see if we are already running. 65 // check to see if we are already running.
24 if(status) 66 if(true == status)
25 return false; 67 return;
26 68
27 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1()); 69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
70 // See if it was successfull...
28 if(ret != 0) 71 if(ret != 0)
29 return false; 72 return;
30 73
31 status = true; 74 status = true;
32 refresh(); 75 refresh();
33 return true;
34} 76}
35 77
36/** 78/**
37 * Try to stop the interface. 79 * Try to stop the interface.
38 * @return bool true if successfull.
39 */ 80 */
40bool Interface::stop(){ 81void Interface::stop(){
41 // check to see if we are already stopped. 82 // check to see if we are already stopped.
42 if(status == false) 83 if(false == status)
43 return false; 84 return;
44 85
45 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1()); 86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
46 if(ret != 0) 87 if(ret != 0)
47 return false; 88 return;
48 89
49 status = true; 90 status = true;
50 refresh(); 91 refresh();
51 return true;
52} 92}
93
53/** 94/**
54 * Try to restart the interface. 95 * Try to restart the interface.
55 * @return bool true if successfull.
56 */ 96 */
57bool Interface::restart(){ 97void Interface::restart(){
58 return (stop() && start()); 98 stop();
99 start();
59} 100}
60 101
61/** 102/**
62 * Try to refresh the information about the interface. 103 * Try to refresh the information about the interface.
63 * First call ifconfig, then check the dhcp-info file 104 * First call ifconfig, then check the dhcp-info file
64 * @return bool true if successfull. 105 * @return bool true if successfull.
65 */ 106 */
66bool Interface::refresh(){ 107bool Interface::refresh(){
67 // See if we are up. 108 // See if we are up.
68 if(status == false){ 109 if(status == false){
69 macAddress = ""; 110 macAddress = "";
70 ip = "0.0.0.0"; 111 ip = "0.0.0.0";
71 subnetMask = "0.0.0.0"; 112 subnetMask = "0.0.0.0";
72 broadcast = ""; 113 broadcast = "";
73 dhcp = false; 114 dhcp = false;
74 dhcpServerIp = ""; 115 dhcpServerIp = "";
75 leaseObtained = ""; 116 leaseObtained = "";
76 leaseExpires = ""; 117 leaseExpires = "";
118 emit(updateInterface(this));
77 return true; 119 return true;
78 } 120 }
79 121
80 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); 122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName);
81 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1()); 123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1());
82 if(ret != 0){ 124 if(ret != 0){
83 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
84 return false; 126 return false;
85 } 127 }
86 128
87 QFile file(fileName); 129 QFile file(fileName);
88 if (!file.open(IO_ReadOnly)){ 130 if (!file.open(IO_ReadOnly)){
89 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
90 return false; 132 return false;
91 } 133 }
92 134
93 // Set to the defaults 135 // Set to the defaults
94 macAddress = ""; 136 macAddress = "";
95 ip = "0.0.0.0"; 137 ip = "0.0.0.0";
96 subnetMask = "0.0.0.0"; 138 subnetMask = "0.0.0.0";
97 broadcast = ""; 139 broadcast = "";
98 140
99 QTextStream stream( &file ); 141 QTextStream stream( &file );
100 QString line; 142 QString line;
101 while ( !stream.eof() ) { 143 while ( !stream.eof() ) {
102 line = stream.readLine(); 144 line = stream.readLine();
103 if(line.contains("HWaddr")){ 145 if(line.contains("HWaddr")){
104 int mac = line.find("HWaddr"); 146 int mac = line.find("HWaddr");
105 macAddress = line.mid(mac+7, line.length()); 147 macAddress = line.mid(mac+7, line.length());
106 } 148 }
107 if(line.contains("inet addr")){ 149 if(line.contains("inet addr")){
108 int ipl = line.find("inet addr"); 150 int ipl = line.find("inet addr");
109 int space = line.find(" ", ipl+10); 151 int space = line.find(" ", ipl+10);
110 ip = line.mid(ipl+10, space-ipl-10); 152 ip = line.mid(ipl+10, space-ipl-10);
111 } 153 }
112 if(line.contains("Mask")){ 154 if(line.contains("Mask")){
113 int mask = line.find("Mask"); 155 int mask = line.find("Mask");
114 subnetMask = line.mid(mask+5, line.length()); 156 subnetMask = line.mid(mask+5, line.length());
115 } 157 }
116 if(line.contains("Bcast")){ 158 if(line.contains("Bcast")){
117 int mask = line.find("Bcast"); 159 int mask = line.find("Bcast");
118 int space = line.find(" ", mask+6); 160 int space = line.find(" ", mask+6);
119 broadcast = line.mid(mask+6, space-mask-6); 161 broadcast = line.mid(mask+6, space-mask-6);
120 } 162 }
121 } 163 }
122 file.close(); 164 file.close();
123 QFile::remove(fileName); 165 QFile::remove(fileName);
124 166
125 // DHCP TESTING 167 // DHCP TESTING
126 // reset DHCP info 168 // reset DHCP info
127 dhcpServerIp = ""; 169 dhcpServerIp = "";
128 leaseObtained = ""; 170 leaseObtained = "";
129 leaseExpires = ""; 171 leaseExpires = "";
130 dhcp = false; 172 dhcp = false;
131 173
132 QString dhcpDirectory(HDCP_INFO_DIR); 174 QString dhcpDirectory(HDCP_INFO_DIR);
133 QDir d(dhcpDirectory); 175 QDir d(dhcpDirectory);
134 if(!d.exists(dhcpDirectory)) 176 if(!d.exists(dhcpDirectory))
135 dhcpDirectory = "/var/run"; 177 dhcpDirectory = "/var/run";
136 178
137 // See if we have 179 // See if we have
138 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); 180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
139 // If there is no DHCP information then exit now with no errors. 181 // If there is no DHCP information then exit now with no errors.
140 if(!QFile::exists(dhcpFile)){ 182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this));
141 return true; 184 return true;
142 } 185 }
143 186
144 file.setName(dhcpFile); 187 file.setName(dhcpFile);
145 if (!file.open(IO_ReadOnly)){ 188 if (!file.open(IO_ReadOnly)){
146 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
147 return false; 190 return false;
148 } 191 }
149 192
150 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
151 int leaseTime = 0; 194 int leaseTime = 0;
152 int renewalTime = 0; 195 int renewalTime = 0;
153 196
154 stream.setDevice( &file ); 197 stream.setDevice( &file );
155 while ( !stream.eof() ) { 198 while ( !stream.eof() ) {
156 line = stream.readLine(); 199 line = stream.readLine();
157 if(line.contains("DHCPSIADDR=")) 200 if(line.contains("DHCPSIADDR="))
158 dhcpServerIp = line.mid(11, line.length()); 201 dhcpServerIp = line.mid(11, line.length());
159 if(line.contains("LEASETIME=")) 202 if(line.contains("LEASETIME="))
160 leaseTime = line.mid(10, line.length()).toInt(); 203 leaseTime = line.mid(10, line.length()).toInt();
161 if(line.contains("RENEWALTIME=")) 204 if(line.contains("RENEWALTIME="))
162 renewalTime = line.mid(12, line.length()).toInt(); 205 renewalTime = line.mid(12, line.length()).toInt();
163 } 206 }
164 file.close(); 207 file.close();
165 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
166 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
167 210
168 // Get the pid of the deamond 211 // Get the pid of the deamond
169 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); 212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName));
170 file.setName(dhcpFile); 213 file.setName(dhcpFile);
171 if (!file.open(IO_ReadOnly)){ 214 if (!file.open(IO_ReadOnly)){
172 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
173 return false; 216 return false;
174 } 217 }
175 218
176 int pid = -1; 219 int pid = -1;
177 stream.setDevice( &file ); 220 stream.setDevice( &file );
178 while ( !stream.eof() ) { 221 while ( !stream.eof() ) {
179 line = stream.readLine(); 222 line = stream.readLine();
180 pid = line.toInt(); 223 pid = line.toInt();
181 } 224 }
182 file.close(); 225 file.close();
183 226
184 if( pid == -1){ 227 if( pid == -1){
185 qDebug("Interface: Could not get pid of dhcpc deamon."); 228 qDebug("Interface: Could not get pid of dhcpc deamon.");
186 return false; 229 return false;
187 } 230 }
188 231
189 // Get the start running time of the deamon 232 // Get the start running time of the deamon
190 fileName = (QString("/proc/%1/stat").arg(pid)); 233 fileName = (QString("/proc/%1/stat").arg(pid));
191 file.setName(fileName); 234 file.setName(fileName);
192 stream.setDevice( &file ); 235 stream.setDevice( &file );
193 if (!file.open(IO_ReadOnly)){ 236 if (!file.open(IO_ReadOnly)){
194 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
195 return false; 238 return false;
196 } 239 }
197 while ( !stream.eof() ) { 240 while ( !stream.eof() ) {
198 line = stream.readLine(); 241 line = stream.readLine();
199 } 242 }
200 file.close(); 243 file.close();
201 long time = 0; 244 long time = 0;
202 // Grab the start time 245 // Grab the start time
203 // pid com state ppid pgrp session tty_nr tpgid flags 246 // pid com state ppid pgrp session tty_nr tpgid flags
204 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
205 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
206 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
207 // nice 0 itrealvalue starttime 250 // nice 0 itrealvalue starttime
208 "%*d %*d %*d %lu", (long*) &time); 251 "%*d %*d %*d %lu", (long*) &time);
209 time = time/100; 252 time = time/100;
210 253
211 QDateTime datetime(QDateTime::currentDateTime()); 254 QDateTime datetime(QDateTime::currentDateTime());
212 255
213 // Get the uptime of the computer. 256 // Get the uptime of the computer.
214 QFile f("/proc/uptime"); 257 QFile f("/proc/uptime");
215 if ( f.open(IO_ReadOnly) ) { // file opened successfully 258 if ( f.open(IO_ReadOnly) ) { // file opened successfully
216 QTextStream t( &f ); // use a text stream 259 QTextStream t( &f ); // use a text stream
217 int sec = 0; 260 int sec = 0;
218 t >> sec; 261 t >> sec;
219 datetime = datetime.addSecs((-1*sec)); 262 datetime = datetime.addSecs((-1*sec));
220 f.close(); 263 f.close();
221 } 264 }
222 else{ 265 else{
223 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 266 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
224 return false; 267 return false;
225 } 268 }
226 269
227 datetime = datetime.addSecs(time); 270 datetime = datetime.addSecs(time);
228 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); 271 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
229 272
230 // Calculate the start and renew times 273 // Calculate the start and renew times
231 leaseObtained= datetime.toString(); 274 leaseObtained= datetime.toString();
232 275
233 // Calculate the start and renew times 276 // Calculate the start and renew times
234 datetime = datetime.addSecs(leaseTime); 277 datetime = datetime.addSecs(leaseTime);
235 leaseExpires = datetime.toString(); 278 leaseExpires = datetime.toString();
236 279
237 dhcp = true; 280 dhcp = true;
281
282 emit(updateInterface(this));
238 return true; 283 return true;
239} 284}
240 285
241// interface.cpp 286// interface.cpp
242 287
diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h
index 1406e99..980171a 100644
--- a/noncore/settings/networksettings/interface.h
+++ b/noncore/settings/networksettings/interface.h
@@ -1,67 +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 6
6class Module; 7class Module;
7 8
8class Interface { 9class Interface : public QObject{
10 Q_OBJECT
9 11
12signals:
13 void updateInterface(Interface *i);
14
10public: 15public:
11 Interface(QString name = "unknown", bool status = false); 16 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
12 virtual ~Interface(){}; 17 virtual ~Interface(){};
13 18
19 virtual QString getInterfaceName(){ QString n(this->name()); return n; };
20
14 virtual bool getStatus(){ return status; }; 21 virtual bool getStatus(){ return status; };
15 virtual void setStatus(bool newSatus){ status = newSatus; refresh(); }; 22 virtual void setStatus(bool newStatus);
16 23
17 virtual bool isAttached(){ return attached; }; 24 virtual bool isAttached(){ return attached; };
18 virtual void setAttached(bool isAttached=false){ attached = isAttached; }; 25 virtual void setAttached(bool isAttached=false);
19
20 virtual QString getInterfaceName(){ return interfaceName; };
21 virtual void setInterfaceName(QString name="unknown"){ interfaceName = name; };
22 26
23 virtual QString getHardwareName(){ return hardareName; }; 27 virtual QString getHardwareName(){ return hardareName; };
24 virtual void setHardwareName(QString name="Unknown"){ hardareName = name; }; 28 virtual void setHardwareName(QString name="Unknown");
25 29
26 virtual Module* getModuleOwner(){ return moduleOwner; }; 30 virtual Module* getModuleOwner(){ return moduleOwner; };
27 virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; }; 31 virtual void setModuleOwner(Module *owner=NULL);
28 32
29 // inet information. 33 // inet information.
30 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress(){ return macAddress; };
31 QString getIp(){ return ip; }; 35 QString getIp(){ return ip; };
32 QString getSubnetMask(){ return subnetMask; }; 36 QString getSubnetMask(){ return subnetMask; };
33 QString getBroadcast(){ return broadcast; }; 37 QString getBroadcast(){ return broadcast; };
34 bool isDhcp(){ return dhcp; }; 38 bool isDhcp(){ return dhcp; };
35 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp(){ return dhcpServerIp; };
36 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained(){ return leaseObtained; };
37 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires(){ return leaseExpires; };
38 42
43public slots:
39 bool refresh(); 44 bool refresh();
40 bool start(); 45 void start();
41 bool stop(); 46 void stop();
42 bool restart(); 47 void restart();
43 48
44private: 49private:
45 // Interface information 50 // Interface information
46 bool status; 51 bool status;
47 bool attached; 52 bool attached;
48 QString interfaceName; 53 QString interfaceName;
49 QString hardareName; 54 QString hardareName;
50 Module *moduleOwner; 55 Module *moduleOwner;
51 56
52 // Network information 57 // Network information
53 QString macAddress; 58 QString macAddress;
54 QString ip; 59 QString ip;
55 QString broadcast; 60 QString broadcast;
56 QString subnetMask; 61 QString subnetMask;
57 bool dhcp; 62 bool dhcp;
58 QString dhcpServerIp; 63 QString dhcpServerIp;
59 QString leaseObtained; 64 QString leaseObtained;
60 QString leaseExpires; 65 QString leaseExpires;
61 66
62}; 67};
63 68
64#endif 69#endif
65 70
66// interface.h 71// interface.h
67 72
diff --git a/noncore/settings/networksettings/interfaceadvanced.ui b/noncore/settings/networksettings/interfaceadvanced.ui
index 7520abe..efe67b0 100644
--- a/noncore/settings/networksettings/interfaceadvanced.ui
+++ b/noncore/settings/networksettings/interfaceadvanced.ui
@@ -1,337 +1,344 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>InterfaceAdvanced</class> 2<class>InterfaceAdvanced</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>InterfaceAdvanced</cstring> 7 <cstring>InterfaceAdvanced</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>188</width> 14 <width>214</width>
15 <height>277</height> 15 <height>286</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>320</width>
22 <height>32767</height>
23 </size>
24 </property>
25 <property stdset="1">
19 <name>caption</name> 26 <name>caption</name>
20 <string>Advanced Interface Information</string> 27 <string>Advanced Interface Information</string>
21 </property> 28 </property>
22 <grid> 29 <grid>
23 <property stdset="1"> 30 <property stdset="1">
24 <name>margin</name> 31 <name>margin</name>
25 <number>11</number> 32 <number>11</number>
26 </property> 33 </property>
27 <property stdset="1"> 34 <property stdset="1">
28 <name>spacing</name> 35 <name>spacing</name>
29 <number>6</number> 36 <number>6</number>
30 </property> 37 </property>
31 <widget row="1" column="0" > 38 <widget row="1" column="0" >
32 <class>QLabel</class> 39 <class>QLabel</class>
33 <property stdset="1"> 40 <property stdset="1">
34 <name>name</name> 41 <name>name</name>
35 <cstring>TextLabel1</cstring> 42 <cstring>TextLabel1</cstring>
36 </property> 43 </property>
37 <property stdset="1"> 44 <property stdset="1">
38 <name>text</name> 45 <name>text</name>
39 <string>MAC Address</string> 46 <string>MAC Address</string>
40 </property> 47 </property>
41 </widget> 48 </widget>
42 <widget row="0" column="1" > 49 <widget row="0" column="1" >
43 <class>QLabel</class> 50 <class>QLabel</class>
44 <property stdset="1"> 51 <property stdset="1">
45 <name>name</name> 52 <name>name</name>
46 <cstring>interfaceName</cstring> 53 <cstring>interfaceName</cstring>
47 </property> 54 </property>
48 <property stdset="1"> 55 <property stdset="1">
49 <name>frameShape</name> 56 <name>frameShape</name>
50 <enum>Panel</enum> 57 <enum>Panel</enum>
51 </property> 58 </property>
52 <property stdset="1"> 59 <property stdset="1">
53 <name>frameShadow</name> 60 <name>frameShadow</name>
54 <enum>Sunken</enum> 61 <enum>Sunken</enum>
55 </property> 62 </property>
56 <property stdset="1"> 63 <property stdset="1">
57 <name>text</name> 64 <name>text</name>
58 <string>eth0</string> 65 <string>eth0</string>
59 </property> 66 </property>
60 </widget> 67 </widget>
61 <widget row="2" column="0" > 68 <widget row="2" column="0" >
62 <class>QLabel</class> 69 <class>QLabel</class>
63 <property stdset="1"> 70 <property stdset="1">
64 <name>name</name> 71 <name>name</name>
65 <cstring>TextLabel3</cstring> 72 <cstring>TextLabel3</cstring>
66 </property> 73 </property>
67 <property stdset="1"> 74 <property stdset="1">
68 <name>text</name> 75 <name>text</name>
69 <string>IP Address</string> 76 <string>IP Address</string>
70 </property> 77 </property>
71 </widget> 78 </widget>
72 <widget row="1" column="1" > 79 <widget row="1" column="1" >
73 <class>QLabel</class> 80 <class>QLabel</class>
74 <property stdset="1"> 81 <property stdset="1">
75 <name>name</name> 82 <name>name</name>
76 <cstring>macAddressLabel</cstring> 83 <cstring>macAddressLabel</cstring>
77 </property> 84 </property>
78 <property stdset="1"> 85 <property stdset="1">
79 <name>frameShape</name> 86 <name>frameShape</name>
80 <enum>Panel</enum> 87 <enum>Panel</enum>
81 </property> 88 </property>
82 <property stdset="1"> 89 <property stdset="1">
83 <name>frameShadow</name> 90 <name>frameShadow</name>
84 <enum>Sunken</enum> 91 <enum>Sunken</enum>
85 </property> 92 </property>
86 <property stdset="1"> 93 <property stdset="1">
87 <name>text</name> 94 <name>text</name>
88 <string>00:00:00:00:00:00</string> 95 <string>00:00:00:00:00:00</string>
89 </property> 96 </property>
90 </widget> 97 </widget>
91 <widget row="0" column="0" > 98 <widget row="0" column="0" >
92 <class>QLabel</class> 99 <class>QLabel</class>
93 <property stdset="1"> 100 <property stdset="1">
94 <name>name</name> 101 <name>name</name>
95 <cstring>TextLabel7</cstring> 102 <cstring>TextLabel7</cstring>
96 </property> 103 </property>
97 <property stdset="1"> 104 <property stdset="1">
98 <name>text</name> 105 <name>text</name>
99 <string>Interface</string> 106 <string>Interface</string>
100 </property> 107 </property>
101 </widget> 108 </widget>
102 <widget row="4" column="0" > 109 <widget row="4" column="0" >
103 <class>QLabel</class> 110 <class>QLabel</class>
104 <property stdset="1"> 111 <property stdset="1">
105 <name>name</name> 112 <name>name</name>
106 <cstring>TextLabel4</cstring> 113 <cstring>TextLabel4</cstring>
107 </property> 114 </property>
108 <property stdset="1"> 115 <property stdset="1">
109 <name>enabled</name> 116 <name>enabled</name>
110 <bool>true</bool> 117 <bool>true</bool>
111 </property> 118 </property>
112 <property stdset="1"> 119 <property stdset="1">
113 <name>text</name> 120 <name>text</name>
114 <string>Subnet Mask</string> 121 <string>Subnet Mask</string>
115 </property> 122 </property>
116 </widget> 123 </widget>
117 <widget row="2" column="1" > 124 <widget row="2" column="1" >
118 <class>QLabel</class> 125 <class>QLabel</class>
119 <property stdset="1"> 126 <property stdset="1">
120 <name>name</name> 127 <name>name</name>
121 <cstring>ipAddressLabel</cstring> 128 <cstring>ipAddressLabel</cstring>
122 </property> 129 </property>
123 <property stdset="1"> 130 <property stdset="1">
124 <name>frameShape</name> 131 <name>frameShape</name>
125 <enum>Panel</enum> 132 <enum>Panel</enum>
126 </property> 133 </property>
127 <property stdset="1"> 134 <property stdset="1">
128 <name>frameShadow</name> 135 <name>frameShadow</name>
129 <enum>Sunken</enum> 136 <enum>Sunken</enum>
130 </property> 137 </property>
131 <property stdset="1"> 138 <property stdset="1">
132 <name>text</name> 139 <name>text</name>
133 <string>0.0.0.0</string> 140 <string>0.0.0.0</string>
134 </property> 141 </property>
135 </widget> 142 </widget>
136 <widget row="4" column="1" > 143 <widget row="4" column="1" >
137 <class>QLabel</class> 144 <class>QLabel</class>
138 <property stdset="1"> 145 <property stdset="1">
139 <name>name</name> 146 <name>name</name>
140 <cstring>subnetMaskLabel</cstring> 147 <cstring>subnetMaskLabel</cstring>
141 </property> 148 </property>
142 <property stdset="1"> 149 <property stdset="1">
143 <name>frameShape</name> 150 <name>frameShape</name>
144 <enum>Panel</enum> 151 <enum>Panel</enum>
145 </property> 152 </property>
146 <property stdset="1"> 153 <property stdset="1">
147 <name>frameShadow</name> 154 <name>frameShadow</name>
148 <enum>Sunken</enum> 155 <enum>Sunken</enum>
149 </property> 156 </property>
150 <property stdset="1"> 157 <property stdset="1">
151 <name>text</name> 158 <name>text</name>
152 <string>0.0.0.0</string> 159 <string>0.0.0.0</string>
153 </property> 160 </property>
154 </widget> 161 </widget>
155 <widget row="3" column="0" > 162 <widget row="3" column="0" >
156 <class>QLabel</class> 163 <class>QLabel</class>
157 <property stdset="1"> 164 <property stdset="1">
158 <name>name</name> 165 <name>name</name>
159 <cstring>TextLabel2</cstring> 166 <cstring>TextLabel2</cstring>
160 </property> 167 </property>
161 <property stdset="1"> 168 <property stdset="1">
162 <name>text</name> 169 <name>text</name>
163 <string>Broadcast</string> 170 <string>Broadcast</string>
164 </property> 171 </property>
165 </widget> 172 </widget>
166 <widget row="3" column="1" > 173 <widget row="3" column="1" >
167 <class>QLabel</class> 174 <class>QLabel</class>
168 <property stdset="1"> 175 <property stdset="1">
169 <name>name</name> 176 <name>name</name>
170 <cstring>broadcastLabel</cstring> 177 <cstring>broadcastLabel</cstring>
171 </property> 178 </property>
172 <property stdset="1"> 179 <property stdset="1">
173 <name>frameShape</name> 180 <name>frameShape</name>
174 <enum>Panel</enum> 181 <enum>Panel</enum>
175 </property> 182 </property>
176 <property stdset="1"> 183 <property stdset="1">
177 <name>frameShadow</name> 184 <name>frameShadow</name>
178 <enum>Sunken</enum> 185 <enum>Sunken</enum>
179 </property> 186 </property>
180 </widget> 187 </widget>
181 <widget row="5" column="0" rowspan="1" colspan="2" > 188 <widget row="5" column="0" rowspan="1" colspan="2" >
182 <class>QGroupBox</class> 189 <class>QGroupBox</class>
183 <property stdset="1"> 190 <property stdset="1">
184 <name>name</name> 191 <name>name</name>
185 <cstring>GroupBox2</cstring> 192 <cstring>GroupBox2</cstring>
186 </property> 193 </property>
187 <property stdset="1"> 194 <property stdset="1">
188 <name>title</name> 195 <name>title</name>
189 <string>DHCP Information</string> 196 <string>DHCP Information</string>
190 </property> 197 </property>
191 <grid> 198 <grid>
192 <property stdset="1"> 199 <property stdset="1">
193 <name>margin</name> 200 <name>margin</name>
194 <number>11</number> 201 <number>11</number>
195 </property> 202 </property>
196 <property stdset="1"> 203 <property stdset="1">
197 <name>spacing</name> 204 <name>spacing</name>
198 <number>6</number> 205 <number>6</number>
199 </property> 206 </property>
200 <widget row="0" column="0" > 207 <widget row="0" column="0" >
201 <class>QLabel</class> 208 <class>QLabel</class>
202 <property stdset="1"> 209 <property stdset="1">
203 <name>name</name> 210 <name>name</name>
204 <cstring>TextLabel6</cstring> 211 <cstring>TextLabel6</cstring>
205 </property> 212 </property>
206 <property stdset="1"> 213 <property stdset="1">
207 <name>text</name> 214 <name>text</name>
208 <string>DHCP Server</string> 215 <string>DHCP Server</string>
209 </property> 216 </property>
210 </widget> 217 </widget>
211 <widget row="2" column="1" > 218 <widget row="2" column="1" >
212 <class>QLabel</class> 219 <class>QLabel</class>
213 <property stdset="1"> 220 <property stdset="1">
214 <name>name</name> 221 <name>name</name>
215 <cstring>leaseExpiresLabel</cstring> 222 <cstring>leaseExpiresLabel</cstring>
216 </property> 223 </property>
217 <property stdset="1"> 224 <property stdset="1">
218 <name>frameShape</name> 225 <name>frameShape</name>
219 <enum>Panel</enum> 226 <enum>Panel</enum>
220 </property> 227 </property>
221 <property stdset="1"> 228 <property stdset="1">
222 <name>frameShadow</name> 229 <name>frameShadow</name>
223 <enum>Sunken</enum> 230 <enum>Sunken</enum>
224 </property> 231 </property>
225 <property stdset="1"> 232 <property stdset="1">
226 <name>text</name> 233 <name>text</name>
227 <string></string> 234 <string></string>
228 </property> 235 </property>
229 </widget> 236 </widget>
230 <widget row="1" column="1" > 237 <widget row="1" column="1" >
231 <class>QLabel</class> 238 <class>QLabel</class>
232 <property stdset="1"> 239 <property stdset="1">
233 <name>name</name> 240 <name>name</name>
234 <cstring>leaseObtainedLabel</cstring> 241 <cstring>leaseObtainedLabel</cstring>
235 </property> 242 </property>
236 <property stdset="1"> 243 <property stdset="1">
237 <name>frameShape</name> 244 <name>frameShape</name>
238 <enum>Panel</enum> 245 <enum>Panel</enum>
239 </property> 246 </property>
240 <property stdset="1"> 247 <property stdset="1">
241 <name>frameShadow</name> 248 <name>frameShadow</name>
242 <enum>Sunken</enum> 249 <enum>Sunken</enum>
243 </property> 250 </property>
244 <property stdset="1"> 251 <property stdset="1">
245 <name>text</name> 252 <name>text</name>
246 <string></string> 253 <string></string>
247 </property> 254 </property>
248 </widget> 255 </widget>
249 <widget row="2" column="0" > 256 <widget row="2" column="0" >
250 <class>QLabel</class> 257 <class>QLabel</class>
251 <property stdset="1"> 258 <property stdset="1">
252 <name>name</name> 259 <name>name</name>
253 <cstring>TextLabel9</cstring> 260 <cstring>TextLabel9</cstring>
254 </property> 261 </property>
255 <property stdset="1"> 262 <property stdset="1">
256 <name>text</name> 263 <name>text</name>
257 <string>Lease Expires</string> 264 <string>Lease Expires</string>
258 </property> 265 </property>
259 </widget> 266 </widget>
260 <widget row="1" column="0" > 267 <widget row="1" column="0" >
261 <class>QLabel</class> 268 <class>QLabel</class>
262 <property stdset="1"> 269 <property stdset="1">
263 <name>name</name> 270 <name>name</name>
264 <cstring>TextLabel8</cstring> 271 <cstring>TextLabel8</cstring>
265 </property> 272 </property>
266 <property stdset="1"> 273 <property stdset="1">
267 <name>text</name> 274 <name>text</name>
268 <string>Lease Obtained</string> 275 <string>Lease Obtained</string>
269 </property> 276 </property>
270 </widget> 277 </widget>
271 <widget row="0" column="1" > 278 <widget row="0" column="1" >
272 <class>QLabel</class> 279 <class>QLabel</class>
273 <property stdset="1"> 280 <property stdset="1">
274 <name>name</name> 281 <name>name</name>
275 <cstring>dhcpServerLabel</cstring> 282 <cstring>dhcpServerLabel</cstring>
276 </property> 283 </property>
277 <property stdset="1"> 284 <property stdset="1">
278 <name>frameShape</name> 285 <name>frameShape</name>
279 <enum>Panel</enum> 286 <enum>Panel</enum>
280 </property> 287 </property>
281 <property stdset="1"> 288 <property stdset="1">
282 <name>frameShadow</name> 289 <name>frameShadow</name>
283 <enum>Sunken</enum> 290 <enum>Sunken</enum>
284 </property> 291 </property>
285 <property stdset="1"> 292 <property stdset="1">
286 <name>text</name> 293 <name>text</name>
287 <string></string> 294 <string></string>
288 </property> 295 </property>
289 </widget> 296 </widget>
290 </grid> 297 </grid>
291 </widget> 298 </widget>
292 <spacer row="6" column="1" > 299 <spacer row="6" column="1" >
293 <property> 300 <property>
294 <name>name</name> 301 <name>name</name>
295 <cstring>Spacer2</cstring> 302 <cstring>Spacer2</cstring>
296 </property> 303 </property>
297 <property stdset="1"> 304 <property stdset="1">
298 <name>orientation</name> 305 <name>orientation</name>
299 <enum>Vertical</enum> 306 <enum>Vertical</enum>
300 </property> 307 </property>
301 <property stdset="1"> 308 <property stdset="1">
302 <name>sizeType</name> 309 <name>sizeType</name>
303 <enum>Expanding</enum> 310 <enum>Expanding</enum>
304 </property> 311 </property>
305 <property> 312 <property>
306 <name>sizeHint</name> 313 <name>sizeHint</name>
307 <size> 314 <size>
308 <width>20</width> 315 <width>20</width>
309 <height>20</height> 316 <height>20</height>
310 </size> 317 </size>
311 </property> 318 </property>
312 </spacer> 319 </spacer>
313 </grid> 320 </grid>
314</widget> 321</widget>
315<customwidgets> 322<customwidgets>
316 <customwidget> 323 <customwidget>
317 <class>QWidget</class> 324 <class>QWidget</class>
318 <header location="local">qwidget.h</header> 325 <header location="local">qwidget.h</header>
319 <sizehint> 326 <sizehint>
320 <width>100</width> 327 <width>100</width>
321 <height>100</height> 328 <height>100</height>
322 </sizehint> 329 </sizehint>
323 <container>0</container> 330 <container>0</container>
324 <sizepolicy> 331 <sizepolicy>
325 <hordata>7</hordata> 332 <hordata>7</hordata>
326 <verdata>7</verdata> 333 <verdata>7</verdata>
327 </sizepolicy> 334 </sizepolicy>
328 <pixmap>image0</pixmap> 335 <pixmap>image0</pixmap>
329 </customwidget> 336 </customwidget>
330</customwidgets> 337</customwidgets>
331<images> 338<images>
332 <image> 339 <image>
333 <name>image0</name> 340 <name>image0</name>
334 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> 341 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
335 </image> 342 </image>
336</images> 343</images>
337</UI> 344</UI>
diff --git a/noncore/settings/networksettings/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaceinformationimp.cpp
index e37e0f8..59a6400 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaceinformationimp.cpp
@@ -1,94 +1,67 @@
1#include "interfaceinformationimp.h" 1#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h" 2#include "interfaceadvanced.h"
3 3
4#include <qpushbutton.h> 4#include <qpushbutton.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <assert.h> 6#include <assert.h>
7 7
8/** 8/**
9 * Constructor for the InterfaceInformationImp class. This class pretty much 9 * Constructor for the InterfaceInformationImp class. This class pretty much
10 * just display's information about the interface that is passed to it. 10 * just display's information about the interface that is passed to it.
11 */ 11 */
12InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ 12InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){
13 assert(i); 13 assert(i);
14 14
15 interface = i; 15 interface = i;
16 updateInterface(); 16 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
17 connect(startButton, SIGNAL(clicked()), this, SLOT(start())); 17 updateInterface(interface);
18 connect(stopButton, SIGNAL(clicked()), this, SLOT(stop())); 18 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
19 connect(restartButton, SIGNAL(clicked()), this, SLOT(restart())); 19 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
20 connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); 20 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
21 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
21 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); 22 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
22 23
23} 24}
24 25
25void InterfaceInformationImp::updateInterface(){ 26/**
27 * Update the interface information and buttons.
28 * @param Intarface *i the interface to update (should be the one we already
29 * know about).
30 */
31void InterfaceInformationImp::updateInterface(Interface *i){
26 if(interface->getStatus()){ 32 if(interface->getStatus()){
27 startButton->setEnabled(false); 33 startButton->setEnabled(false);
28 stopButton->setEnabled(true); 34 stopButton->setEnabled(true);
29 restartButton->setEnabled(true); 35 restartButton->setEnabled(true);
30 } 36 }
31 else{ 37 else{
32 startButton->setEnabled(true); 38 startButton->setEnabled(true);
33 stopButton->setEnabled(false); 39 stopButton->setEnabled(false);
34 restartButton->setEnabled(false); 40 restartButton->setEnabled(false);
35 } 41 }
36 macAddressLabel->setText(interface->getMacAddress()); 42 macAddressLabel->setText(interface->getMacAddress());
37 ipAddressLabel->setText(interface->getIp()); 43 ipAddressLabel->setText(interface->getIp());
38 subnetMaskLabel->setText(interface->getSubnetMask()); 44 subnetMaskLabel->setText(interface->getSubnetMask());
39 broadcastLabel->setText(interface->getBroadcast()); 45 broadcastLabel->setText(interface->getBroadcast());
40} 46}
41 47
42/** 48/**
43 * Start the interface. Update the information if successfull
44 */
45void InterfaceInformationImp::start(){
46 if(interface->start()){
47 updateInterface();
48 }
49}
50
51/**
52 * Stop the interface.
53 */
54void InterfaceInformationImp::stop(){
55 if(interface->stop()){
56 updateInterface();
57 }
58}
59
60/***
61 * Tell the interface to refresh its information.
62 **/
63void InterfaceInformationImp::refresh(){
64 if(interface->refresh())
65 updateInterface();
66}
67
68void InterfaceInformationImp::restart(){
69 if(interface->restart()){
70 updateInterface();
71 }
72}
73
74
75/**
76 * Create the advanced widget. Fill it with the current interface's information. 49 * Create the advanced widget. Fill it with the current interface's information.
77 * Display it. 50 * Display it.
78 */ 51 */
79void InterfaceInformationImp::advanced(){ 52void InterfaceInformationImp::advanced(){
80 InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); 53 InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced");
81 a->interfaceName->setText(interface->getInterfaceName()); 54 a->interfaceName->setText(interface->getInterfaceName());
82 a->macAddressLabel->setText(interface->getMacAddress()); 55 a->macAddressLabel->setText(interface->getMacAddress());
83 a->ipAddressLabel->setText(interface->getIp()); 56 a->ipAddressLabel->setText(interface->getIp());
84 a->subnetMaskLabel->setText(interface->getSubnetMask()); 57 a->subnetMaskLabel->setText(interface->getSubnetMask());
85 a->broadcastLabel->setText(interface->getBroadcast()); 58 a->broadcastLabel->setText(interface->getBroadcast());
86 a->dhcpServerLabel->setText(interface->getDhcpServerIp()); 59 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
87 a->leaseObtainedLabel->setText(interface->getLeaseObtained()); 60 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
88 a->leaseExpiresLabel->setText(interface->getLeaseExpires()); 61 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
89 a->showMaximized(); 62 a->showMaximized();
90 a->show(); 63 a->show();
91} 64}
92 65
93// infoimp.cpp 66// infoimp.cpp
94 67
diff --git a/noncore/settings/networksettings/interfaceinformationimp.h b/noncore/settings/networksettings/interfaceinformationimp.h
index c8a478e..42213cc 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaceinformationimp.h
@@ -1,31 +1,27 @@
1#ifndef INTERFACEINFORMATIONIMP_H 1#ifndef INTERFACEINFORMATIONIMP_H
2#define INTERFACEINFORMATIONIMP_H 2#define INTERFACEINFORMATIONIMP_H
3 3
4#include "interfaceinformation.h" 4#include "interfaceinformation.h"
5#include "interface.h" 5#include "interface.h"
6 6
7class InterfaceInformationImp : public InterfaceInformation { 7class InterfaceInformationImp : public InterfaceInformation {
8 8
9Q_OBJECT 9Q_OBJECT
10 10
11public: 11public:
12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); 12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
13 ~InterfaceInformationImp(){}; 13 ~InterfaceInformationImp(){};
14 14
15private slots: 15private slots:
16 void start();
17 void stop();
18 void refresh();
19 void restart();
20 void advanced(); 16 void advanced();
17 void updateInterface(Interface *i);
21 18
22private: 19private:
23 Interface *interface; 20 Interface *interface;
24 void updateInterface();
25 21
26}; 22};
27 23
28#endif 24#endif
29 25
30// addserviceimp.h 26// addserviceimp.h
31 27
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index b46362f..117bac1 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,460 +1,463 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h" 5#include "interfaces.h"
6 6
7#include "module.h" 7#include "module.h"
8 8
9#include "kprocess.h" 9#include "kprocess.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtabwidget.h> 12#include <qtabwidget.h>
13#include <qlistbox.h> 13#include <qlistbox.h>
14#include <qlineedit.h> 14#include <qlineedit.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qheader.h> 16#include <qheader.h>
17#include <qlabel.h> 17#include <qlabel.h>
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qlibrary.h> 23#include <qpe/qlibrary.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26 26
27#include <qlist.h> 27#include <qlist.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
32#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
33#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
34 34
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
40 40
41 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 41 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
42 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 42 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
43 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 43 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
44 44
45 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 45 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
46 // Load connections. 46 // Load connections.
47 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 47 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
48 getInterfaceList(); 48 getInterfaceList();
49 connectionList->header()->hide(); 49 connectionList->header()->hide();
50 50
51 51
52 Config cfg("NetworkSetup"); 52 Config cfg("NetworkSetup");
53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
55 profilesList->insertItem((*it)); 55 profilesList->insertItem((*it));
56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
57} 57}
58 58
59/** 59/**
60 * Deconstructor. Save profiles. Delete loaded libraries. 60 * Deconstructor. Save profiles. Delete loaded libraries.
61 */ 61 */
62MainWindowImp::~MainWindowImp(){ 62MainWindowImp::~MainWindowImp(){
63 // Save profiles. 63 // Save profiles.
64 if(profiles.count() > 1){ 64 if(profiles.count() > 1){
65 Config cfg("NetworkSetup"); 65 Config cfg("NetworkSetup");
66 cfg.setGroup("General"); 66 cfg.setGroup("General");
67 cfg.writeEntry("Profiles", profiles.join(" ")); 67 cfg.writeEntry("Profiles", profiles.join(" "));
68 } 68 }
69 // Delete Modules and Libraries 69 // Delete Modules and Libraries
70 QMap<Module*, QLibrary*>::Iterator it; 70 QMap<Module*, QLibrary*>::Iterator it;
71 for( it = libraries.begin(); it != libraries.end(); ++it ){ 71 for( it = libraries.begin(); it != libraries.end(); ++it ){
72 delete it.key(); 72 delete it.key();
73 delete it.data(); 73 delete it.data();
74 } 74 }
75} 75}
76 76
77/** 77/**
78 * Load all modules that are found in the path 78 * Load all modules that are found in the path
79 * @param path a directory that is scaned for any plugins that can be loaded 79 * @param path a directory that is scaned for any plugins that can be loaded
80 * and attempts to load them 80 * and attempts to load them
81 */ 81 */
82void MainWindowImp::loadModules(QString path){ 82void MainWindowImp::loadModules(QString path){
83 qDebug(path.latin1()); 83 qDebug(path.latin1());
84 QDir d(path); 84 QDir d(path);
85 if(!d.exists()) 85 if(!d.exists())
86 return; 86 return;
87 87
88 // Don't want sym links 88 // Don't want sym links
89 d.setFilter( QDir::Files | QDir::NoSymLinks ); 89 d.setFilter( QDir::Files | QDir::NoSymLinks );
90 const QFileInfoList *list = d.entryInfoList(); 90 const QFileInfoList *list = d.entryInfoList();
91 QFileInfoListIterator it( *list ); 91 QFileInfoListIterator it( *list );
92 QFileInfo *fi; 92 QFileInfo *fi;
93 while ( (fi=it.current()) ) { 93 while ( (fi=it.current()) ) {
94 if(fi->fileName().contains(".so")){ 94 if(fi->fileName().contains(".so")){
95 loadPlugin(path + "/" + fi->fileName()); 95 loadPlugin(path + "/" + fi->fileName());
96 } 96 }
97 ++it; 97 ++it;
98 } 98 }
99} 99}
100 100
101/** 101/**
102 * Attempt to load a function and resolve a function. 102 * Attempt to load a function and resolve a function.
103 * @param pluginFileName - the name of the file in which to attempt to load 103 * @param pluginFileName - the name of the file in which to attempt to load
104 * @param resolveString - function pointer to resolve 104 * @param resolveString - function pointer to resolve
105 * @return pointer to the function with name resolveString or NULL 105 * @return pointer to the function with name resolveString or NULL
106 */ 106 */
107Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 107Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
108 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 108 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
109 QLibrary *lib = new QLibrary(pluginFileName); 109 QLibrary *lib = new QLibrary(pluginFileName);
110 void *functionPointer = lib->resolve(resolveString); 110 void *functionPointer = lib->resolve(resolveString);
111 if( !functionPointer ){ 111 if( !functionPointer ){
112 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 112 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
113 delete lib; 113 delete lib;
114 return NULL; 114 return NULL;
115 } 115 }
116 116
117 // Try to get an object. 117 // Try to get an object.
118 Module *object = ((Module* (*)()) functionPointer)(); 118 Module *object = ((Module* (*)()) functionPointer)();
119 if(object == NULL){ 119 if(object == NULL){
120 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 120 qDebug("MainWindowImp: Couldn't create object, but did load library!");
121 delete lib; 121 delete lib;
122 return NULL; 122 return NULL;
123 } 123 }
124 124
125 // Store for deletion later 125 // Store for deletion later
126 libraries.insert(object, lib); 126 libraries.insert(object, lib);
127 return object; 127 return object;
128} 128}
129 129
130/** 130/**
131 * The Add button was clicked. Bring up the add dialog and if OK is hit 131 * The Add button was clicked. Bring up the add dialog and if OK is hit
132 * load the plugin and append it to the list 132 * load the plugin and append it to the list
133 */ 133 */
134void MainWindowImp::addClicked(){ 134void MainWindowImp::addClicked(){
135 QMap<Module*, QLibrary*>::Iterator it; 135 QMap<Module*, QLibrary*>::Iterator it;
136 QMap<QString, QString> list; 136 QMap<QString, QString> list;
137 QMap<QString, Module*> newInterfaceOwners; 137 QMap<QString, Module*> newInterfaceOwners;
138 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 138 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
139 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 139 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
140 for( it = libraries.begin(); it != libraries.end(); ++it ){ 140 for( it = libraries.begin(); it != libraries.end(); ++it ){
141 if(it.key()){ 141 if(it.key()){
142 (it.key())->possibleNewInterfaces(list); 142 (it.key())->possibleNewInterfaces(list);
143 } 143 }
144 } 144 }
145 // See if the list has anything that we can add. 145 // See if the list has anything that we can add.
146 if(list.count() == 0){ 146 if(list.count() == 0){
147 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 147 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
148 return; 148 return;
149 } 149 }
150 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 150 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
151 addNewConnection.addConnections(list); 151 addNewConnection.addConnections(list);
152 addNewConnection.showMaximized(); 152 addNewConnection.showMaximized();
153 if(QDialog::Accepted == addNewConnection.exec()){ 153 if(QDialog::Accepted == addNewConnection.exec()){
154 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 154 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
155 if(!item) 155 if(!item)
156 return; 156 return;
157 157
158 for( it = libraries.begin(); it != libraries.end(); ++it ){ 158 for( it = libraries.begin(); it != libraries.end(); ++it ){
159 if(it.key()){ 159 if(it.key()){
160 Interface *i = (it.key())->addNewInterface(item->text(0)); 160 Interface *i = (it.key())->addNewInterface(item->text(0));
161 if(i){ 161 if(i){
162 interfaceNames.insert(i->getInterfaceName(), i); 162 interfaceNames.insert(i->getInterfaceName(), i);
163 updateInterface(i); 163 updateInterface(i);
164 } 164 }
165 } 165 }
166 } 166 }
167 } 167 }
168} 168}
169 169
170/** 170/**
171 * Prompt the user to see if they really want to do this. 171 * Prompt the user to see if they really want to do this.
172 * If they do then remove from the list and unload. 172 * If they do then remove from the list and unload.
173 */ 173 */
174void MainWindowImp::removeClicked(){ 174void MainWindowImp::removeClicked(){
175 QListViewItem *item = connectionList->currentItem(); 175 QListViewItem *item = connectionList->currentItem();
176 if(!item) { 176 if(!item) {
177 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 177 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
178 return; 178 return;
179 } 179 }
180 180
181 Interface *i = interfaceItems[item]; 181 Interface *i = interfaceItems[item];
182 if(i->getModuleOwner() == NULL){ 182 if(i->getModuleOwner() == NULL){
183 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 183 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
184 } 184 }
185 else{ 185 else{
186 if(!i->getModuleOwner()->remove(i)) 186 if(!i->getModuleOwner()->remove(i))
187 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 187 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
188 else{ 188 else{
189 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 189 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
190 // TODO memory managment.... 190 // TODO memory managment....
191 // who deletes the interface? 191 // who deletes the interface?
192 } 192 }
193 } 193 }
194} 194}
195 195
196/** 196/**
197 * Pull up the configure about the currently selected interface. 197 * Pull up the configure about the currently selected interface.
198 * Report an error if no interface is selected. 198 * Report an error if no interface is selected.
199 * If the interface has a module owner then request its configure with a empty 199 * If the interface has a module owner then request its configure with a empty
200 * tab. If tab is !NULL then append the interfaces setup widget to it. 200 * tab. If tab is !NULL then append the interfaces setup widget to it.
201 */ 201 */
202void MainWindowImp::configureClicked(){ 202void MainWindowImp::configureClicked(){
203 QListViewItem *item = connectionList->currentItem(); 203 QListViewItem *item = connectionList->currentItem();
204 if(!item){ 204 if(!item){
205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
206 return; 206 return;
207 } 207 }
208 208
209 Interface *i = interfaceItems[item]; 209 Interface *i = interfaceItems[item];
210 if(i->getModuleOwner()){ 210 if(i->getModuleOwner()){
211 QTabWidget *tabWidget = NULL; 211 QTabWidget *tabWidget = NULL;
212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
213 if(moduleConfigure != NULL){ 213 if(moduleConfigure != NULL){
214 if(tabWidget != NULL){ 214 if(tabWidget != NULL){
215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
216 tabWidget->insertTab(configure, "TCP/IP"); 216 tabWidget->insertTab(configure, "TCP/IP");
217 } 217 }
218 moduleConfigure->showMaximized(); 218 moduleConfigure->showMaximized();
219 moduleConfigure->show(); 219 moduleConfigure->show();
220 return; 220 return;
221 } 221 }
222 } 222 }
223 223
224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
225 configure->showMaximized(); 225 configure->showMaximized();
226 configure->show(); 226 configure->show();
227} 227}
228 228
229/** 229/**
230 * Pull up the information about the currently selected interface. 230 * Pull up the information about the currently selected interface.
231 * Report an error if no interface is selected. 231 * Report an error if no interface is selected.
232 * If the interface has a module owner then request its configure with a empty 232 * If the interface has a module owner then request its configure with a empty
233 * tab. If tab is !NULL then append the interfaces setup widget to it. 233 * tab. If tab is !NULL then append the interfaces setup widget to it.
234 */ 234 */
235void MainWindowImp::informationClicked(){ 235void MainWindowImp::informationClicked(){
236 QListViewItem *item = connectionList->currentItem(); 236 QListViewItem *item = connectionList->currentItem();
237 if(!item){ 237 if(!item){
238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
239 return; 239 return;
240 } 240 }
241 241
242 Interface *i = interfaceItems[item]; 242 Interface *i = interfaceItems[item];
243 if(!i->isAttached()){ 243 if(!i->isAttached()){
244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); 244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
245 return; 245 return;
246 } 246 }
247 if(i->getModuleOwner()){ 247 if(i->getModuleOwner()){
248 QTabWidget *tabWidget = NULL; 248 QTabWidget *tabWidget = NULL;
249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
250 if(moduleInformation != NULL){ 250 if(moduleInformation != NULL){
251 if(tabWidget != NULL){ 251 if(tabWidget != NULL){
252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
253 tabWidget->insertTab(information, "TCP/IP"); 253 tabWidget->insertTab(information, "TCP/IP");
254 } 254 }
255 moduleInformation->showMaximized(); 255 moduleInformation->showMaximized();
256 moduleInformation->show(); 256 moduleInformation->show();
257 return; 257 return;
258 } 258 }
259 } 259 }
260 260
261 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 261 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
262 information->showMaximized(); 262 information->showMaximized();
263 information->show(); 263 information->show();
264} 264}
265 265
266/** 266/**
267 * Aquire the list of active interfaces from ifconfig 267 * Aquire the list of active interfaces from ifconfig
268 * Call ifconfig and ifconfig -a 268 * Call ifconfig and ifconfig -a
269 */ 269 */
270void MainWindowImp::getInterfaceList(){ 270void MainWindowImp::getInterfaceList(){
271 KShellProcess *processAll = new KShellProcess(); 271 KShellProcess *processAll = new KShellProcess();
272 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 272 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
273 connect(processAll, SIGNAL(processExited(KProcess *)), 273 connect(processAll, SIGNAL(processExited(KProcess *)),
274 this, SLOT(jobDone(KProcess *))); 274 this, SLOT(jobDone(KProcess *)));
275 threads.insert(processAll, TEMP_ALL); 275 threads.insert(processAll, TEMP_ALL);
276 276
277 KShellProcess *process = new KShellProcess(); 277 KShellProcess *process = new KShellProcess();
278 *process << "/sbin/ifconfig" << " > " TEMP_UP; 278 *process << "/sbin/ifconfig" << " > " TEMP_UP;
279 connect(process, SIGNAL(processExited(KProcess *)), 279 connect(process, SIGNAL(processExited(KProcess *)),
280 this, SLOT(jobDone(KProcess *))); 280 this, SLOT(jobDone(KProcess *)));
281 threads.insert(process, TEMP_UP); 281 threads.insert(process, TEMP_UP);
282 282
283 processAll->start(KShellProcess::NotifyOnExit); 283 processAll->start(KShellProcess::NotifyOnExit);
284 process->start(KShellProcess::NotifyOnExit); 284 process->start(KShellProcess::NotifyOnExit);
285} 285}
286 286
287void MainWindowImp::jobDone(KProcess *process){ 287void MainWindowImp::jobDone(KProcess *process){
288 QString fileName = threads[process]; 288 QString fileName = threads[process];
289 threads.remove(process); 289 threads.remove(process);
290 delete process; 290 delete process;
291 291
292 QFile file(fileName); 292 QFile file(fileName);
293 if (!file.open(IO_ReadOnly)){ 293 if (!file.open(IO_ReadOnly)){
294 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 294 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
295 return; 295 return;
296 } 296 }
297 297
298 QTextStream stream( &file ); 298 QTextStream stream( &file );
299 QString line; 299 QString line;
300 while ( !stream.eof() ) { 300 while ( !stream.eof() ) {
301 line = stream.readLine(); 301 line = stream.readLine();
302 int space = line.find(" "); 302 int space = line.find(" ");
303 if(space > 1){ 303 if(space > 1){
304 // We have found an interface 304 // We have found an interface
305 QString interfaceName = line.mid(0, space); 305 QString interfaceName = line.mid(0, space);
306 Interface *i; 306 Interface *i;
307 // We have found an interface
308 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
307 // See if we already have it 309 // See if we already have it
308 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 310 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
309 if(fileName == TEMP_ALL) 311 if(fileName == TEMP_ALL)
310 i = new Interface(interfaceName, false); 312 i = new Interface(this, interfaceName, false);
311 else 313 else
312 i = new Interface(interfaceName, true); 314 i = new Interface(this, interfaceName, true);
315 i->setAttached(true);
316
317 QString hardName = "Ethernet";
318 int hardwareName = line.find("Link encap:");
319 int macAddress = line.find("HWaddr");
320 if(macAddress == -1)
321 macAddress = line.length();
322 if(hardwareName != -1)
323 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
324
325 interfaceNames.insert(i->getInterfaceName(), i);
326 updateInterface(i);
327 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
313 } 328 }
329 // It was an interface we already had.
314 else{ 330 else{
315 i = interfaceNames[interfaceName]; 331 i = interfaceNames[interfaceName];
316 if(fileName != TEMP_ALL) 332 if(fileName != TEMP_ALL)
317 i->setStatus(true); 333 i->setStatus(true);
318 } 334 }
319
320 i->setAttached(true);
321 i->setInterfaceName(interfaceName);
322
323 QString hardName = "Ethernet";
324 int hardwareName = line.find("Link encap:");
325 int macAddress = line.find("HWaddr");
326 if(macAddress == -1)
327 macAddress = line.length();
328 if(hardwareName != -1)
329 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
330 // We have found an interface
331 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
332 interfaceNames.insert(i->getInterfaceName(), i);
333 updateInterface(i);
334 } 335 }
335 } 336 }
336 file.close(); 337 file.close();
337 QFile::remove(fileName); 338 QFile::remove(fileName);
338 339
339 if(threads.count() == 0){ 340 if(threads.count() == 0){
340 Interfaces i; 341 Interfaces i;
341 QStringList list = i.getInterfaceList(); 342 QStringList list = i.getInterfaceList();
342 QMap<QString, Interface*>::Iterator it; 343 QMap<QString, Interface*>::Iterator it;
343 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 344 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
344 bool found = false; 345 bool found = false;
345 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 346 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
346 if(it.key() == (*ni)) 347 if(it.key() == (*ni))
347 found = true; 348 found = true;
348 } 349 }
349 if(!found){ 350 if(!found){
350 Interface *i = new Interface(*ni, false); 351 Interface *i = new Interface(this, *ni, false);
351 i->setAttached(false); 352 i->setAttached(false);
352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 353 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
353 i->setInterfaceName(*ni);
354 interfaceNames.insert(i->getInterfaceName(), i); 354 interfaceNames.insert(i->getInterfaceName(), i);
355 updateInterface(i); 355 updateInterface(i);
356 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
356 } 357 }
357 } 358 }
358 } 359 }
359} 360}
360 361
361/** 362/**
362 * Update this interface. If no QListViewItem exists create one. 363 * Update this interface. If no QListViewItem exists create one.
363 * @param Interface* pointer to the interface that needs to be updated. 364 * @param Interface* pointer to the interface that needs to be updated.
364 */ 365 */
365void MainWindowImp::updateInterface(Interface *i){ 366void MainWindowImp::updateInterface(Interface *i){
366 if(!advancedUserMode){ 367 if(!advancedUserMode){
367 if(i->getInterfaceName() == "lo") 368 if(i->getInterfaceName() == "lo")
368 return; 369 return;
369 } 370 }
370 371
371 QListViewItem *item = NULL; 372 QListViewItem *item = NULL;
372 373
373 // Find the interface, making it if needed. 374 // Find the interface, making it if needed.
374 if(items.find(i) == items.end()){ 375 if(items.find(i) == items.end()){
375 item = new QListViewItem(connectionList, "", "", ""); 376 item = new QListViewItem(connectionList, "", "", "");
376 // See if you can't find a module owner for this interface 377 // See if you can't find a module owner for this interface
377 QMap<Module*, QLibrary*>::Iterator it; 378 QMap<Module*, QLibrary*>::Iterator it;
378 for( it = libraries.begin(); it != libraries.end(); ++it ){ 379 for( it = libraries.begin(); it != libraries.end(); ++it ){
379 if(it.key()->isOwner(i)) 380 if(it.key()->isOwner(i))
380 i->setModuleOwner(it.key()); 381 i->setModuleOwner(it.key());
381 } 382 }
382 items.insert(i, item); 383 items.insert(i, item);
383 interfaceItems.insert(item, i); 384 interfaceItems.insert(item, i);
384 } 385 }
385 else 386 else
386 item = items[i]; 387 item = items[i];
387 388
388 // Update the icons and information 389 // Update the icons and information
389 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 390 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
390 391
391 QString typeName = "lan"; 392 QString typeName = "lan";
392 if(i->getHardwareName().contains("Local Loopback")) 393 if(i->getHardwareName().contains("Local Loopback"))
393 typeName = "lo"; 394 typeName = "lo";
394 if(i->getInterfaceName().contains("irda")) 395 if(i->getInterfaceName().contains("irda"))
395 typeName = "irda"; 396 typeName = "irda";
396 if(i->getInterfaceName().contains("wlan")) 397 if(i->getInterfaceName().contains("wlan"))
397 typeName = "wlan"; 398 typeName = "wlan";
398 399 if(i->getInterfaceName().contains("usb"))
400 typeName = "usb";
401
399 if(!i->isAttached()) 402 if(!i->isAttached())
400 typeName = "connect_no"; 403 typeName = "connect_no";
401 // Actually try to use the Module 404 // Actually try to use the Module
402 if(i->getModuleOwner() != NULL) 405 if(i->getModuleOwner() != NULL)
403 typeName = i->getModuleOwner()->getPixmapName(i); 406 typeName = i->getModuleOwner()->getPixmapName(i);
404 407
405 item->setPixmap(1, (Resource::loadPixmap(typeName))); 408 item->setPixmap(1, (Resource::loadPixmap(typeName)));
406 item->setText(2, i->getHardwareName()); 409 item->setText(2, i->getHardwareName());
407 item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); 410 item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
408} 411}
409 412
410void MainWindowImp::newProfileChanged(const QString& newText){ 413void MainWindowImp::newProfileChanged(const QString& newText){
411 if(newText.length() > 0) 414 if(newText.length() > 0)
412 newProfileButton->setEnabled(true); 415 newProfileButton->setEnabled(true);
413 else 416 else
414 newProfileButton->setEnabled(false); 417 newProfileButton->setEnabled(false);
415} 418}
416 419
417/** 420/**
418 * Adds a new profile to the list of profiles. 421 * Adds a new profile to the list of profiles.
419 * Don't add profiles that already exists. 422 * Don't add profiles that already exists.
420 * Appends to the list and QStringList 423 * Appends to the list and QStringList
421 */ 424 */
422void MainWindowImp::addProfile(){ 425void MainWindowImp::addProfile(){
423 QString newProfileName = newProfile->text(); 426 QString newProfileName = newProfile->text();
424 if(profiles.grep(newProfileName).count() > 0){ 427 if(profiles.grep(newProfileName).count() > 0){
425 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 428 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
426 return; 429 return;
427 } 430 }
428 profiles.append(newProfileName); 431 profiles.append(newProfileName);
429 profilesList->insertItem(newProfileName); 432 profilesList->insertItem(newProfileName);
430} 433}
431 434
432/** 435/**
433 * Removes the currently selected profile in the combo. 436 * Removes the currently selected profile in the combo.
434 * Doesn't delete if there are less then 2 profiles. 437 * Doesn't delete if there are less then 2 profiles.
435 */ 438 */
436void MainWindowImp::removeProfile(){ 439void MainWindowImp::removeProfile(){
437 if(profilesList->count() <= 1){ 440 if(profilesList->count() <= 1){
438 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok"); 441 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
439 return; 442 return;
440 } 443 }
441 QString profileToRemove = profilesList->currentText(); 444 QString profileToRemove = profilesList->currentText();
442 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 445 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
443 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 446 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
444 profilesList->clear(); 447 profilesList->clear();
445 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 448 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
446 profilesList->insertItem((*it)); 449 profilesList->insertItem((*it));
447 } 450 }
448 451
449} 452}
450 453
451/** 454/**
452 * A new profile has been selected, change. 455 * A new profile has been selected, change.
453 * @param newProfile the new profile. 456 * @param newProfile the new profile.
454 */ 457 */
455void MainWindowImp::changeProfile(){ 458void MainWindowImp::changeProfile(){
456 currentProfileLabel->setText(profilesList->text(profilesList->currentItem())); 459 currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
457} 460}
458 461
459// mainwindowimp.cpp 462// mainwindowimp.cpp
460 463
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 98d2eb6..f0394b4 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,84 +1,86 @@
1#include "wlanmodule.h" 1#include "wlanmodule.h"
2#include <qpe/config.h> 2#include <qpe/config.h>
3#include "wlanimp.h" 3#include "wlanimp.h"
4 4
5/** 5/**
6 * Constructor, find all of the possible interfaces 6 * Constructor, find all of the possible interfaces
7 */ 7 */
8WLANModule::WLANModule() : Module() { 8WLANModule::WLANModule() : Module() {
9 // get output from iwconfig 9 // get output from iwconfig
10} 10}
11 11
12/** 12/**
13 * get the icon name for this device. 13 * get the icon name for this device.
14 * @param Interface* can be used in determining the icon. 14 * @param Interface* can be used in determining the icon.
15 * @return QString the icon name (minus .png, .gif etc) 15 * @return QString the icon name (minus .png, .gif etc)
16 */ 16 */
17QString WLANModule::getPixmapName(Interface* ){ 17QString WLANModule::getPixmapName(Interface* ){
18 return "wlan"; 18 return "wlan";
19} 19}
20 20
21/** 21/**
22 * Check to see if the interface i is owned by this module. 22 * Check to see if the interface i is owned by this module.
23 * @param Interface* interface to check against 23 * @param Interface* interface to check against
24 * @return bool true if i is owned by this module, false otherwise. 24 * @return bool true if i is owned by this module, false otherwise.
25 */ 25 */
26bool WLANModule::isOwner(Interface *i){ 26bool WLANModule::isOwner(Interface *i){
27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0") 27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
28 i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName()));
28 return true; 29 return true;
30 }
29 return false; 31 return false;
30} 32}
31 33
32/** 34/**
33 * Create, set tabWiget and return the WLANConfigure Module 35 * Create, set tabWiget and return the WLANConfigure Module
34 * @param tabWidget a pointer to the tab widget that this configure has. 36 * @param tabWidget a pointer to the tab widget that this configure has.
35 * @return QWidget* pointer to the tab widget in this modules configure. 37 * @return QWidget* pointer to the tab widget in this modules configure.
36 */ 38 */
37QWidget *WLANModule::configure(QTabWidget **tabWidget){ 39QWidget *WLANModule::configure(QTabWidget **tabWidget){
38 Config *cfg = new Config("wireless"); 40 Config *cfg = new Config("wireless");
39 WLANImp *wlanconfig = new WLANImp(*cfg); 41 WLANImp *wlanconfig = new WLANImp(*cfg);
40 (*tabWidget) = wlanconfig->tabWidget; 42 (*tabWidget) = wlanconfig->tabWidget;
41 return wlanconfig; 43 return wlanconfig;
42} 44}
43 45
44/** 46/**
45 * Create, set tabWiget and return the Information Module 47 * Create, set tabWiget and return the Information Module
46 * @param tabWidget a pointer to the tab widget that this information has. 48 * @param tabWidget a pointer to the tab widget that this information has.
47 * @return QWidget* pointer to the tab widget in this modules info. 49 * @return QWidget* pointer to the tab widget in this modules info.
48 */ 50 */
49QWidget *WLANModule::information(QTabWidget **tabWidget){ 51QWidget *WLANModule::information(QTabWidget **tabWidget){
50 return NULL; 52 return NULL;
51} 53}
52 54
53/** 55/**
54 * Get all active (up or down) interfaces 56 * Get all active (up or down) interfaces
55 * @return QList<Interface> A list of interfaces that exsist that havn't 57 * @return QList<Interface> A list of interfaces that exsist that havn't
56 * been called by isOwner() 58 * been called by isOwner()
57 */ 59 */
58QList<Interface> WLANModule::getInterfaces(){ 60QList<Interface> WLANModule::getInterfaces(){
59 return list; 61 return list;
60} 62}
61 63
62/** 64/**
63 * Attempt to add a new interface as defined by name 65 * Attempt to add a new interface as defined by name
64 * @param name the name of the type of interface that should be created given 66 * @param name the name of the type of interface that should be created given
65 * by possibleNewInterfaces(); 67 * by possibleNewInterfaces();
66 * @return Interface* NULL if it was unable to be created. 68 * @return Interface* NULL if it was unable to be created.
67 */ 69 */
68Interface *WLANModule::addNewInterface(QString ){ 70Interface *WLANModule::addNewInterface(QString ){
69 // We can't add a 802.11 interface, either the hardware will be there 71 // We can't add a 802.11 interface, either the hardware will be there
70 // or it wont. 72 // or it wont.
71 return NULL; 73 return NULL;
72} 74}
73 75
74/** 76/**
75 * Attempts to remove the interface, doesn't delete i 77 * Attempts to remove the interface, doesn't delete i
76 * @return bool true if successfull, false otherwise. 78 * @return bool true if successfull, false otherwise.
77 */ 79 */
78bool WLANModule::remove(Interface*){ 80bool WLANModule::remove(Interface*){
79 // Can't remove a hardware device, you can stop it though. 81 // Can't remove a hardware device, you can stop it though.
80 return false; 82 return false;
81} 83}
82 84
83// wlanmodule.cpp 85// wlanmodule.cpp
84 86