summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-25 19:34:32 (UTC)
committer benmeyer <benmeyer>2002-10-25 19:34:32 (UTC)
commitf16dd7fc272f3f8354dc696fcc881dfe74755a21 (patch) (unidiff)
treeedaab125b322744d8684e6aee4d2c5955b68689b
parent77347ba522a5913ff17561e6fd2c15981d42e86b (diff)
downloadopie-f16dd7fc272f3f8354dc696fcc881dfe74755a21.zip
opie-f16dd7fc272f3f8354dc696fcc881dfe74755a21.tar.gz
opie-f16dd7fc272f3f8354dc696fcc881dfe74755a21.tar.bz2
Moved Interfaces into a library
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO2
-rw-r--r--noncore/net/networksetup/interface.cpp287
-rw-r--r--noncore/net/networksetup/interface.h71
-rw-r--r--noncore/net/networksetup/interfaceadvanced.ui344
-rw-r--r--noncore/net/networksetup/interfaceedit.cpp141
-rw-r--r--noncore/net/networksetup/interfaceedit.h56
-rw-r--r--noncore/net/networksetup/interfaceinformation.ui343
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.cpp70
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.h27
-rw-r--r--noncore/net/networksetup/interfaces.cpp638
-rw-r--r--noncore/net/networksetup/interfaces.h76
-rw-r--r--noncore/net/networksetup/interfacesetup.ui284
-rw-r--r--noncore/net/networksetup/interfacesetupimp.cpp147
-rw-r--r--noncore/net/networksetup/interfacesetupimp.h31
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp28
-rw-r--r--noncore/net/networksetup/module.h14
-rw-r--r--noncore/net/networksetup/networksetup.pro14
-rw-r--r--noncore/net/networksetup/wlan/wextensions.cpp6
-rw-r--r--noncore/net/networksetup/wlan/wlan.pro4
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.cpp14
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.h8
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp22
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.h4
-rw-r--r--noncore/settings/networksettings/TODO2
-rw-r--r--noncore/settings/networksettings/interface.cpp287
-rw-r--r--noncore/settings/networksettings/interface.h71
-rw-r--r--noncore/settings/networksettings/interfaceadvanced.ui344
-rw-r--r--noncore/settings/networksettings/interfaceedit.cpp141
-rw-r--r--noncore/settings/networksettings/interfaceedit.h56
-rw-r--r--noncore/settings/networksettings/interfaceinformation.ui343
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.cpp70
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.h27
-rw-r--r--noncore/settings/networksettings/interfaces.cpp638
-rw-r--r--noncore/settings/networksettings/interfaces.h76
-rw-r--r--noncore/settings/networksettings/interfacesetup.ui284
-rw-r--r--noncore/settings/networksettings/interfacesetupimp.cpp147
-rw-r--r--noncore/settings/networksettings/interfacesetupimp.h31
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp28
-rw-r--r--noncore/settings/networksettings/module.h14
-rw-r--r--noncore/settings/networksettings/networksetup.pro14
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp6
-rw-r--r--noncore/settings/networksettings/wlan/wlan.pro4
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp14
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.h8
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp22
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.h4
46 files changed, 116 insertions, 5146 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index d61c510..c83d909 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,3 +1,5 @@
1Make sure the C code in wextensions is clean.
2
1WLAN needs to be re-written to not use Config 3WLAN needs to be re-written to not use Config
2WHERE Is DHCP info stored??? 4WHERE Is DHCP info stored???
3 5
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
deleted file mode 100644
index 929b3a1..0000000
--- a/noncore/net/networksetup/interface.cpp
+++ b/dev/null
@@ -1,287 +0,0 @@
1#include "interface.h"
2#include <qdatetime.h>
3#include <qfile.h>
4#include <qdir.h>
5#include <qfileinfo.h>
6#include <qtextstream.h>
7
8#define IFCONFIG "/sbin/ifconfig"
9#define DHCP_INFO_DIR "/etc/dhcpc"
10
11#include <stdio.h>
12#include <stdlib.h>
13
14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
15 refresh();
16}
17
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 hardwareName = 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/**
62 * Try to start the interface.
63 */
64void Interface::start(){
65 // check to see if we are already running.
66 if(true == status)
67 return;
68
69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
70 // See if it was successfull...
71 if(ret != 0)
72 return;
73
74 status = true;
75 refresh();
76}
77
78/**
79 * Try to stop the interface.
80 */
81void Interface::stop(){
82 // check to see if we are already stopped.
83 if(false == status)
84 return;
85
86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
87 if(ret != 0)
88 return;
89
90 status = true;
91 refresh();
92}
93
94/**
95 * Try to restart the interface.
96 */
97void Interface::restart(){
98 stop();
99 start();
100}
101
102/**
103 * Try to refresh the information about the interface.
104 * First call ifconfig, then check the dhcp-info file
105 * @return bool true if successfull.
106 */
107bool Interface::refresh(){
108 // See if we are up.
109 if(status == false){
110 macAddress = "";
111 ip = "0.0.0.0";
112 subnetMask = "0.0.0.0";
113 broadcast = "";
114 dhcp = false;
115 dhcpServerIp = "";
116 leaseObtained = "";
117 leaseExpires = "";
118 emit(updateInterface(this));
119 return true;
120 }
121
122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
124 if(ret != 0){
125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
126 return false;
127 }
128
129 QFile file(fileName);
130 if (!file.open(IO_ReadOnly)){
131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
132 return false;
133 }
134
135 // Set to the defaults
136 macAddress = "";
137 ip = "0.0.0.0";
138 subnetMask = "0.0.0.0";
139 broadcast = "";
140
141 QTextStream stream( &file );
142 QString line;
143 while ( !stream.eof() ) {
144 line = stream.readLine();
145 if(line.contains("HWaddr")){
146 int mac = line.find("HWaddr");
147 macAddress = line.mid(mac+7, line.length());
148 }
149 if(line.contains("inet addr")){
150 int ipl = line.find("inet addr");
151 int space = line.find(" ", ipl+10);
152 ip = line.mid(ipl+10, space-ipl-10);
153 }
154 if(line.contains("Mask")){
155 int mask = line.find("Mask");
156 subnetMask = line.mid(mask+5, line.length());
157 }
158 if(line.contains("Bcast")){
159 int mask = line.find("Bcast");
160 int space = line.find(" ", mask+6);
161 broadcast = line.mid(mask+6, space-mask-6);
162 }
163 }
164 file.close();
165 QFile::remove(fileName);
166
167 // DHCP TESTING
168 // reset DHCP info
169 dhcpServerIp = "";
170 leaseObtained = "";
171 leaseExpires = "";
172 dhcp = false;
173
174 QString dhcpDirectory(DHCP_INFO_DIR);
175 QDir d(dhcpDirectory);
176 if(!d.exists(dhcpDirectory))
177 dhcpDirectory = "/var/run";
178
179 // See if we have
180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
181 // If there is no DHCP information then exit now with no errors.
182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this));
184 return true;
185 }
186
187 file.setName(dhcpFile);
188 if (!file.open(IO_ReadOnly)){
189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
190 return false;
191 }
192
193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
194 int leaseTime = 0;
195 int renewalTime = 0;
196
197 stream.setDevice( &file );
198 while ( !stream.eof() ) {
199 line = stream.readLine();
200 if(line.contains("DHCPSIADDR="))
201 dhcpServerIp = line.mid(11, line.length());
202 if(line.contains("LEASETIME="))
203 leaseTime = line.mid(10, line.length()).toInt();
204 if(line.contains("RENEWALTIME="))
205 renewalTime = line.mid(12, line.length()).toInt();
206 }
207 file.close();
208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
210
211 // Get the pid of the deamond
212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
213 file.setName(dhcpFile);
214 if (!file.open(IO_ReadOnly)){
215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
216 return false;
217 }
218
219 int pid = -1;
220 stream.setDevice( &file );
221 while ( !stream.eof() ) {
222 line = stream.readLine();
223 pid = line.toInt();
224 }
225 file.close();
226
227 if( pid == -1){
228 qDebug("Interface: Could not get pid of dhcpc deamon.");
229 return false;
230 }
231
232 // Get the start running time of the deamon
233 fileName = (QString("/proc/%1/stat").arg(pid));
234 file.setName(fileName);
235 stream.setDevice( &file );
236 if (!file.open(IO_ReadOnly)){
237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
238 return false;
239 }
240 while ( !stream.eof() ) {
241 line = stream.readLine();
242 }
243 file.close();
244 long time = 0;
245 // Grab the start time
246 // pid com state ppid pgrp session tty_nr tpgid flags
247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
250 // nice 0 itrealvalue starttime
251 "%*d %*d %*d %lu", (long*) &time);
252 time = time/100;
253
254 QDateTime datetime(QDateTime::currentDateTime());
255
256 // Get the uptime of the computer.
257 QFile f("/proc/uptime");
258 if ( f.open(IO_ReadOnly) ) { // file opened successfully
259 QTextStream t( &f ); // use a text stream
260 int sec = 0;
261 t >> sec;
262 datetime = datetime.addSecs((-1*sec));
263 f.close();
264 }
265 else{
266 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
267 return false;
268 }
269
270 datetime = datetime.addSecs(time);
271 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
272
273 // Calculate the start and renew times
274 leaseObtained= datetime.toString();
275
276 // Calculate the start and renew times
277 datetime = datetime.addSecs(leaseTime);
278 leaseExpires = datetime.toString();
279
280 dhcp = true;
281
282 emit(updateInterface(this));
283 return true;
284}
285
286// interface.cpp
287
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h
deleted file mode 100644
index dc9c6d3..0000000
--- a/noncore/net/networksetup/interface.h
+++ b/dev/null
@@ -1,71 +0,0 @@
1#ifndef INTERFACE_H
2#define INTERFACE_H
3
4#include <qstring.h>
5#include <qobject.h>
6
7class Module;
8
9class Interface : public QObject{
10 Q_OBJECT
11
12signals:
13 void updateInterface(Interface *i);
14
15public:
16 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
17 virtual ~Interface(){};
18
19 virtual QString getInterfaceName(){ QString n(this->name()); return n; };
20
21 virtual bool getStatus(){ return status; };
22 virtual void setStatus(bool newStatus);
23
24 virtual bool isAttached(){ return attached; };
25 virtual void setAttached(bool isAttached=false);
26
27 virtual QString getHardwareName(){ return hardwareName; };
28 virtual void setHardwareName(QString name="Unknown");
29
30 virtual Module* getModuleOwner(){ return moduleOwner; };
31 virtual void setModuleOwner(Module *owner=NULL);
32
33 // inet information.
34 QString getMacAddress(){ return macAddress; };
35 QString getIp(){ return ip; };
36 QString getSubnetMask(){ return subnetMask; };
37 QString getBroadcast(){ return broadcast; };
38 bool isDhcp(){ return dhcp; };
39 QString getDhcpServerIp(){ return dhcpServerIp; };
40 QString getLeaseObtained(){ return leaseObtained; };
41 QString getLeaseExpires(){ return leaseExpires; };
42
43public slots:
44 bool refresh();
45 void start();
46 void stop();
47 void restart();
48
49private:
50 // Interface information
51 bool status;
52 bool attached;
53 QString hardwareName;
54 Module *moduleOwner;
55
56 // Network information
57 QString macAddress;
58 QString ip;
59 QString broadcast;
60 QString subnetMask;
61 bool dhcp;
62 QString dhcpServerIp;
63 QString leaseObtained;
64 QString leaseExpires;
65
66};
67
68#endif
69
70// interface.h
71
diff --git a/noncore/net/networksetup/interfaceadvanced.ui b/noncore/net/networksetup/interfaceadvanced.ui
deleted file mode 100644
index 0ec67c2..0000000
--- a/noncore/net/networksetup/interfaceadvanced.ui
+++ b/dev/null
@@ -1,344 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>InterfaceAdvanced</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InterfaceAdvanced</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>214</width>
15 <height>286</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>240</width>
22 <height>32767</height>
23 </size>
24 </property>
25 <property stdset="1">
26 <name>caption</name>
27 <string>Advanced Interface Information</string>
28 </property>
29 <grid>
30 <property stdset="1">
31 <name>margin</name>
32 <number>11</number>
33 </property>
34 <property stdset="1">
35 <name>spacing</name>
36 <number>6</number>
37 </property>
38 <widget row="1" column="0" >
39 <class>QLabel</class>
40 <property stdset="1">
41 <name>name</name>
42 <cstring>TextLabel1</cstring>
43 </property>
44 <property stdset="1">
45 <name>text</name>
46 <string>MAC Address</string>
47 </property>
48 </widget>
49 <widget row="0" column="1" >
50 <class>QLabel</class>
51 <property stdset="1">
52 <name>name</name>
53 <cstring>interfaceName</cstring>
54 </property>
55 <property stdset="1">
56 <name>frameShape</name>
57 <enum>Panel</enum>
58 </property>
59 <property stdset="1">
60 <name>frameShadow</name>
61 <enum>Sunken</enum>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>eth0</string>
66 </property>
67 </widget>
68 <widget row="2" column="0" >
69 <class>QLabel</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>TextLabel3</cstring>
73 </property>
74 <property stdset="1">
75 <name>text</name>
76 <string>IP Address</string>
77 </property>
78 </widget>
79 <widget row="1" column="1" >
80 <class>QLabel</class>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>macAddressLabel</cstring>
84 </property>
85 <property stdset="1">
86 <name>frameShape</name>
87 <enum>Panel</enum>
88 </property>
89 <property stdset="1">
90 <name>frameShadow</name>
91 <enum>Sunken</enum>
92 </property>
93 <property stdset="1">
94 <name>text</name>
95 <string>00:00:00:00:00:00</string>
96 </property>
97 </widget>
98 <widget row="0" column="0" >
99 <class>QLabel</class>
100 <property stdset="1">
101 <name>name</name>
102 <cstring>TextLabel7</cstring>
103 </property>
104 <property stdset="1">
105 <name>text</name>
106 <string>Interface</string>
107 </property>
108 </widget>
109 <widget row="4" column="0" >
110 <class>QLabel</class>
111 <property stdset="1">
112 <name>name</name>
113 <cstring>TextLabel4</cstring>
114 </property>
115 <property stdset="1">
116 <name>enabled</name>
117 <bool>true</bool>
118 </property>
119 <property stdset="1">
120 <name>text</name>
121 <string>Subnet Mask</string>
122 </property>
123 </widget>
124 <widget row="2" column="1" >
125 <class>QLabel</class>
126 <property stdset="1">
127 <name>name</name>
128 <cstring>ipAddressLabel</cstring>
129 </property>
130 <property stdset="1">
131 <name>frameShape</name>
132 <enum>Panel</enum>
133 </property>
134 <property stdset="1">
135 <name>frameShadow</name>
136 <enum>Sunken</enum>
137 </property>
138 <property stdset="1">
139 <name>text</name>
140 <string>0.0.0.0</string>
141 </property>
142 </widget>
143 <widget row="4" column="1" >
144 <class>QLabel</class>
145 <property stdset="1">
146 <name>name</name>
147 <cstring>subnetMaskLabel</cstring>
148 </property>
149 <property stdset="1">
150 <name>frameShape</name>
151 <enum>Panel</enum>
152 </property>
153 <property stdset="1">
154 <name>frameShadow</name>
155 <enum>Sunken</enum>
156 </property>
157 <property stdset="1">
158 <name>text</name>
159 <string>0.0.0.0</string>
160 </property>
161 </widget>
162 <widget row="3" column="0" >
163 <class>QLabel</class>
164 <property stdset="1">
165 <name>name</name>
166 <cstring>TextLabel2</cstring>
167 </property>
168 <property stdset="1">
169 <name>text</name>
170 <string>Broadcast</string>
171 </property>
172 </widget>
173 <widget row="3" column="1" >
174 <class>QLabel</class>
175 <property stdset="1">
176 <name>name</name>
177 <cstring>broadcastLabel</cstring>
178 </property>
179 <property stdset="1">
180 <name>frameShape</name>
181 <enum>Panel</enum>
182 </property>
183 <property stdset="1">
184 <name>frameShadow</name>
185 <enum>Sunken</enum>
186 </property>
187 </widget>
188 <widget row="5" column="0" rowspan="1" colspan="2" >
189 <class>QGroupBox</class>
190 <property stdset="1">
191 <name>name</name>
192 <cstring>dhcpInformation</cstring>
193 </property>
194 <property stdset="1">
195 <name>title</name>
196 <string>DHCP Information</string>
197 </property>
198 <grid>
199 <property stdset="1">
200 <name>margin</name>
201 <number>11</number>
202 </property>
203 <property stdset="1">
204 <name>spacing</name>
205 <number>6</number>
206 </property>
207 <widget row="0" column="0" >
208 <class>QLabel</class>
209 <property stdset="1">
210 <name>name</name>
211 <cstring>TextLabel6</cstring>
212 </property>
213 <property stdset="1">
214 <name>text</name>
215 <string>DHCP Server</string>
216 </property>
217 </widget>
218 <widget row="2" column="1" >
219 <class>QLabel</class>
220 <property stdset="1">
221 <name>name</name>
222 <cstring>leaseExpiresLabel</cstring>
223 </property>
224 <property stdset="1">
225 <name>frameShape</name>
226 <enum>Panel</enum>
227 </property>
228 <property stdset="1">
229 <name>frameShadow</name>
230 <enum>Sunken</enum>
231 </property>
232 <property stdset="1">
233 <name>text</name>
234 <string></string>
235 </property>
236 </widget>
237 <widget row="1" column="1" >
238 <class>QLabel</class>
239 <property stdset="1">
240 <name>name</name>
241 <cstring>leaseObtainedLabel</cstring>
242 </property>
243 <property stdset="1">
244 <name>frameShape</name>
245 <enum>Panel</enum>
246 </property>
247 <property stdset="1">
248 <name>frameShadow</name>
249 <enum>Sunken</enum>
250 </property>
251 <property stdset="1">
252 <name>text</name>
253 <string></string>
254 </property>
255 </widget>
256 <widget row="2" column="0" >
257 <class>QLabel</class>
258 <property stdset="1">
259 <name>name</name>
260 <cstring>TextLabel9</cstring>
261 </property>
262 <property stdset="1">
263 <name>text</name>
264 <string>Lease Expires</string>
265 </property>
266 </widget>
267 <widget row="1" column="0" >
268 <class>QLabel</class>
269 <property stdset="1">
270 <name>name</name>
271 <cstring>TextLabel8</cstring>
272 </property>
273 <property stdset="1">
274 <name>text</name>
275 <string>Lease Obtained</string>
276 </property>
277 </widget>
278 <widget row="0" column="1" >
279 <class>QLabel</class>
280 <property stdset="1">
281 <name>name</name>
282 <cstring>dhcpServerLabel</cstring>
283 </property>
284 <property stdset="1">
285 <name>frameShape</name>
286 <enum>Panel</enum>
287 </property>
288 <property stdset="1">
289 <name>frameShadow</name>
290 <enum>Sunken</enum>
291 </property>
292 <property stdset="1">
293 <name>text</name>
294 <string></string>
295 </property>
296 </widget>
297 </grid>
298 </widget>
299 <spacer row="6" column="1" >
300 <property>
301 <name>name</name>
302 <cstring>Spacer2</cstring>
303 </property>
304 <property stdset="1">
305 <name>orientation</name>
306 <enum>Vertical</enum>
307 </property>
308 <property stdset="1">
309 <name>sizeType</name>
310 <enum>Expanding</enum>
311 </property>
312 <property>
313 <name>sizeHint</name>
314 <size>
315 <width>20</width>
316 <height>20</height>
317 </size>
318 </property>
319 </spacer>
320 </grid>
321</widget>
322<customwidgets>
323 <customwidget>
324 <class>QWidget</class>
325 <header location="local">qwidget.h</header>
326 <sizehint>
327 <width>100</width>
328 <height>100</height>
329 </sizehint>
330 <container>0</container>
331 <sizepolicy>
332 <hordata>7</hordata>
333 <verdata>7</verdata>
334 </sizepolicy>
335 <pixmap>image0</pixmap>
336 </customwidget>
337</customwidgets>
338<images>
339 <image>
340 <name>image0</name>
341 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
342 </image>
343</images>
344</UI>
diff --git a/noncore/net/networksetup/interfaceedit.cpp b/noncore/net/networksetup/interfaceedit.cpp
deleted file mode 100644
index 25599ef..0000000
--- a/noncore/net/networksetup/interfaceedit.cpp
+++ b/dev/null
@@ -1,141 +0,0 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'interfaceedit.ui'
3**
4** Created: Mon Sep 23 12:18:55 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "interfaceedit.h"
10
11#include <qcheckbox.h>
12#include <qcombobox.h>
13#include <qframe.h>
14#include <qgroupbox.h>
15#include <qlabel.h>
16#include <qlineedit.h>
17#include <qpushbutton.h>
18#include <qspinbox.h>
19#include "qwidget.h"
20#include <qlayout.h>
21#include <qvariant.h>
22#include <qtooltip.h>
23#include <qwhatsthis.h>
24
25/*
26 * Constructs a InterfaceConfiguration which is a child of 'parent', with the
27 * name 'name' and widget flags set to 'f'
28 */
29InterfaceConfiguration::InterfaceConfiguration( QWidget* parent, const char* name, WFlags fl )
30 : QWidget( parent, name, fl )
31{
32 if ( !name )
33 setName( "InterfaceConfiguration" );
34 resize( 177, 306 );
35 setCaption( tr( "Interface Configuration" ) );
36 InterfaceConfigurationLayout = new QGridLayout( this );
37 InterfaceConfigurationLayout->setSpacing( 6 );
38 InterfaceConfigurationLayout->setMargin( 11 );
39
40 profile = new QComboBox( FALSE, this, "profile" );
41 profile->insertItem( tr( "All" ) );
42
43 InterfaceConfigurationLayout->addWidget( profile, 2, 1 );
44
45 TextLabel1 = new QLabel( this, "TextLabel1" );
46 TextLabel1->setText( tr( "Profile:" ) );
47
48 InterfaceConfigurationLayout->addWidget( TextLabel1, 2, 0 );
49
50 Line1 = new QFrame( this, "Line1" );
51 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
52
53 InterfaceConfigurationLayout->addMultiCellWidget( Line1, 1, 1, 0, 1 );
54
55 CheckBox3 = new QCheckBox( this, "CheckBox3" );
56 CheckBox3->setText( tr( "Automaticly bring up" ) );
57
58 InterfaceConfigurationLayout->addMultiCellWidget( CheckBox3, 0, 0, 0, 1 );
59
60 dhcpCheckBox = new QCheckBox( this, "dhcpCheckBox" );
61 dhcpCheckBox->setText( tr( "DHCP" ) );
62
63 InterfaceConfigurationLayout->addMultiCellWidget( dhcpCheckBox, 3, 3, 0, 1 );
64
65 TextLabel3_3_2 = new QLabel( this, "TextLabel3_3_2" );
66 TextLabel3_3_2->setText( tr( "Lease Hours" ) );
67
68 InterfaceConfigurationLayout->addWidget( TextLabel3_3_2, 4, 0 );
69
70 SpinBox1_2 = new QSpinBox( this, "SpinBox1_2" );
71 SpinBox1_2->setMaxValue( 336 );
72 SpinBox1_2->setMinValue( 1 );
73 SpinBox1_2->setValue( 24 );
74
75 InterfaceConfigurationLayout->addWidget( SpinBox1_2, 4, 1 );
76 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
77 InterfaceConfigurationLayout->addItem( spacer, 11, 1 );
78
79 TextLabel4 = new QLabel( this, "TextLabel4" );
80 TextLabel4->setText( tr( "IP Address" ) );
81
82 InterfaceConfigurationLayout->addWidget( TextLabel4, 6, 0 );
83
84 ipAddressEdit = new QLineEdit( this, "ipAddressEdit" );
85
86 InterfaceConfigurationLayout->addWidget( ipAddressEdit, 6, 1 );
87
88 TextLabel5 = new QLabel( this, "TextLabel5" );
89 TextLabel5->setText( tr( "Subnet Mask" ) );
90
91 InterfaceConfigurationLayout->addWidget( TextLabel5, 7, 0 );
92
93 firstDNSLineEdit = new QLineEdit( this, "firstDNSLineEdit" );
94
95 InterfaceConfigurationLayout->addWidget( firstDNSLineEdit, 9, 1 );
96
97 TextLabel3 = new QLabel( this, "TextLabel3" );
98 TextLabel3->setText( tr( "Second DNS" ) );
99
100 InterfaceConfigurationLayout->addWidget( TextLabel3, 10, 0 );
101
102 subnetMaskEdit = new QLineEdit( this, "subnetMaskEdit" );
103
104 InterfaceConfigurationLayout->addWidget( subnetMaskEdit, 7, 1 );
105
106 gatewayEdit = new QLineEdit( this, "gatewayEdit" );
107
108 InterfaceConfigurationLayout->addWidget( gatewayEdit, 8, 1 );
109
110 TextLabel7 = new QLabel( this, "TextLabel7" );
111 TextLabel7->setText( tr( "Gateway" ) );
112
113 InterfaceConfigurationLayout->addWidget( TextLabel7, 8, 0 );
114
115 TextLabel2 = new QLabel( this, "TextLabel2" );
116 TextLabel2->setText( tr( "First DNS" ) );
117
118 InterfaceConfigurationLayout->addWidget( TextLabel2, 9, 0 );
119
120 secondDNSLineEdit = new QLineEdit( this, "secondDNSLineEdit" );
121
122 InterfaceConfigurationLayout->addWidget( secondDNSLineEdit, 10, 1 );
123
124 GroupBox2 = new QGroupBox( this, "GroupBox2" );
125 GroupBox2->setTitle( tr( "Static Ip Configuration" ) );
126
127 InterfaceConfigurationLayout->addMultiCellWidget( GroupBox2, 5, 5, 0, 1 );
128
129 // signals and slots connections
130 connect( dhcpCheckBox, SIGNAL( toggled(bool) ), SpinBox1_2, SLOT( setEnabled(bool) ) );
131 connect( dhcpCheckBox, SIGNAL( toggled(bool) ), GroupBox2, SLOT( setDisabled(bool) ) );
132}
133
134/*
135 * Destroys the object and frees any allocated resources
136 */
137InterfaceConfiguration::~InterfaceConfiguration()
138{
139 // no need to delete child widgets, Qt does it all for us
140}
141
diff --git a/noncore/net/networksetup/interfaceedit.h b/noncore/net/networksetup/interfaceedit.h
deleted file mode 100644
index a65c030..0000000
--- a/noncore/net/networksetup/interfaceedit.h
+++ b/dev/null
@@ -1,56 +0,0 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'interfaceedit.ui'
3**
4** Created: Mon Sep 23 12:18:55 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef INTERFACECONFIGURATION_H
10#define INTERFACECONFIGURATION_H
11
12#include <qvariant.h>
13#include <qwidget.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QCheckBox;
18class QComboBox;
19class QFrame;
20class QGroupBox;
21class QLabel;
22class QLineEdit;
23class QSpinBox;
24
25class InterfaceConfiguration : public QWidget
26{
27 Q_OBJECT
28
29public:
30 InterfaceConfiguration( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
31 ~InterfaceConfiguration();
32
33 QComboBox* profile;
34 QLabel* TextLabel1;
35 QFrame* Line1;
36 QCheckBox* CheckBox3;
37 QCheckBox* dhcpCheckBox;
38 QLabel* TextLabel3_3_2;
39 QSpinBox* SpinBox1_2;
40 QLabel* TextLabel4;
41 QLineEdit* ipAddressEdit;
42 QLabel* TextLabel5;
43 QLineEdit* firstDNSLineEdit;
44 QLabel* TextLabel3;
45 QLineEdit* subnetMaskEdit;
46 QLineEdit* gatewayEdit;
47 QLabel* TextLabel7;
48 QLabel* TextLabel2;
49 QLineEdit* secondDNSLineEdit;
50 QGroupBox* GroupBox2;
51
52protected:
53 QGridLayout* InterfaceConfigurationLayout;
54};
55
56#endif // INTERFACECONFIGURATION_H
diff --git a/noncore/net/networksetup/interfaceinformation.ui b/noncore/net/networksetup/interfaceinformation.ui
deleted file mode 100644
index 2838d19..0000000
--- a/noncore/net/networksetup/interfaceinformation.ui
+++ b/dev/null
@@ -1,343 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>InterfaceInformation</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InterfaceInformation</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>219</width>
15 <height>255</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Interface Information</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget row="4" column="0" rowspan="1" colspan="2" >
32 <class>QLayoutWidget</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>Layout1</cstring>
36 </property>
37 <grid>
38 <property stdset="1">
39 <name>margin</name>
40 <number>0</number>
41 </property>
42 <property stdset="1">
43 <name>spacing</name>
44 <number>6</number>
45 </property>
46 <widget row="1" column="0" >
47 <class>QPushButton</class>
48 <property stdset="1">
49 <name>name</name>
50 <cstring>refreshButton</cstring>
51 </property>
52 <property stdset="1">
53 <name>text</name>
54 <string>&amp;Refresh</string>
55 </property>
56 </widget>
57 <widget row="0" column="1" >
58 <class>QPushButton</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>stopButton</cstring>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>S&amp;top</string>
66 </property>
67 </widget>
68 <widget row="1" column="1" >
69 <class>QPushButton</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>restartButton</cstring>
73 </property>
74 <property stdset="1">
75 <name>text</name>
76 <string>R&amp;estart</string>
77 </property>
78 </widget>
79 <widget row="0" column="0" >
80 <class>QPushButton</class>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>startButton</cstring>
84 </property>
85 <property stdset="1">
86 <name>text</name>
87 <string>&amp;Start</string>
88 </property>
89 </widget>
90 </grid>
91 </widget>
92 <widget row="0" column="0" >
93 <class>Line</class>
94 <property stdset="1">
95 <name>name</name>
96 <cstring>Line1</cstring>
97 </property>
98 <property stdset="1">
99 <name>orientation</name>
100 <enum>Horizontal</enum>
101 </property>
102 </widget>
103 <widget row="0" column="0" >
104 <class>QLabel</class>
105 <property stdset="1">
106 <name>name</name>
107 <cstring>TextLabel22</cstring>
108 </property>
109 <property stdset="1">
110 <name>text</name>
111 <string>IP Address</string>
112 </property>
113 </widget>
114 <widget row="1" column="0" >
115 <class>QLabel</class>
116 <property stdset="1">
117 <name>name</name>
118 <cstring>TextLabel23</cstring>
119 </property>
120 <property stdset="1">
121 <name>text</name>
122 <string>Subnet Mask</string>
123 </property>
124 </widget>
125 <widget row="2" column="0" >
126 <class>QLabel</class>
127 <property stdset="1">
128 <name>name</name>
129 <cstring>TextLabel21</cstring>
130 </property>
131 <property stdset="1">
132 <name>text</name>
133 <string>MAC Address</string>
134 </property>
135 </widget>
136 <widget row="3" column="0" >
137 <class>QLabel</class>
138 <property stdset="1">
139 <name>name</name>
140 <cstring>TextLabel24</cstring>
141 </property>
142 <property stdset="1">
143 <name>frameShape</name>
144 <enum>MShape</enum>
145 </property>
146 <property stdset="1">
147 <name>frameShadow</name>
148 <enum>MShadow</enum>
149 </property>
150 <property stdset="1">
151 <name>text</name>
152 <string>Broadcast</string>
153 </property>
154 </widget>
155 <widget row="1" column="1" >
156 <class>QLabel</class>
157 <property stdset="1">
158 <name>name</name>
159 <cstring>subnetMaskLabel</cstring>
160 </property>
161 <property stdset="1">
162 <name>frameShape</name>
163 <enum>Panel</enum>
164 </property>
165 <property stdset="1">
166 <name>frameShadow</name>
167 <enum>Sunken</enum>
168 </property>
169 <property stdset="1">
170 <name>text</name>
171 <string>0.0.0.0</string>
172 </property>
173 </widget>
174 <widget row="2" column="1" >
175 <class>QLabel</class>
176 <property stdset="1">
177 <name>name</name>
178 <cstring>macAddressLabel</cstring>
179 </property>
180 <property stdset="1">
181 <name>frameShape</name>
182 <enum>Panel</enum>
183 </property>
184 <property stdset="1">
185 <name>frameShadow</name>
186 <enum>Sunken</enum>
187 </property>
188 <property stdset="1">
189 <name>text</name>
190 <string>00:00:00:00:00:00</string>
191 </property>
192 </widget>
193 <widget row="3" column="1" >
194 <class>QLabel</class>
195 <property stdset="1">
196 <name>name</name>
197 <cstring>broadcastLabel</cstring>
198 </property>
199 <property stdset="1">
200 <name>frameShape</name>
201 <enum>Panel</enum>
202 </property>
203 <property stdset="1">
204 <name>frameShadow</name>
205 <enum>Sunken</enum>
206 </property>
207 <property stdset="1">
208 <name>text</name>
209 <string></string>
210 </property>
211 </widget>
212 <widget row="0" column="1" >
213 <class>QLabel</class>
214 <property stdset="1">
215 <name>name</name>
216 <cstring>ipAddressLabel</cstring>
217 </property>
218 <property stdset="1">
219 <name>frameShape</name>
220 <enum>Panel</enum>
221 </property>
222 <property stdset="1">
223 <name>frameShadow</name>
224 <enum>Sunken</enum>
225 </property>
226 <property stdset="1">
227 <name>text</name>
228 <string>0.0.0.0</string>
229 </property>
230 </widget>
231 <spacer row="7" column="1" >
232 <property>
233 <name>name</name>
234 <cstring>Spacer18</cstring>
235 </property>
236 <property stdset="1">
237 <name>orientation</name>
238 <enum>Vertical</enum>
239 </property>
240 <property stdset="1">
241 <name>sizeType</name>
242 <enum>Expanding</enum>
243 </property>
244 <property>
245 <name>sizeHint</name>
246 <size>
247 <width>20</width>
248 <height>20</height>
249 </size>
250 </property>
251 </spacer>
252 <widget row="6" column="0" rowspan="1" colspan="2" >
253 <class>QLayoutWidget</class>
254 <property stdset="1">
255 <name>name</name>
256 <cstring>Layout2</cstring>
257 </property>
258 <hbox>
259 <property stdset="1">
260 <name>margin</name>
261 <number>0</number>
262 </property>
263 <property stdset="1">
264 <name>spacing</name>
265 <number>6</number>
266 </property>
267 <spacer>
268 <property>
269 <name>name</name>
270 <cstring>Spacer10</cstring>
271 </property>
272 <property stdset="1">
273 <name>orientation</name>
274 <enum>Horizontal</enum>
275 </property>
276 <property stdset="1">
277 <name>sizeType</name>
278 <enum>Expanding</enum>
279 </property>
280 <property>
281 <name>sizeHint</name>
282 <size>
283 <width>20</width>
284 <height>20</height>
285 </size>
286 </property>
287 </spacer>
288 <widget>
289 <class>QPushButton</class>
290 <property stdset="1">
291 <name>name</name>
292 <cstring>advancedButton</cstring>
293 </property>
294 <property stdset="1">
295 <name>text</name>
296 <string>View &amp;Advanced Information</string>
297 </property>
298 </widget>
299 </hbox>
300 </widget>
301 <widget row="5" column="0" rowspan="1" colspan="2" >
302 <class>Line</class>
303 <property stdset="1">
304 <name>name</name>
305 <cstring>Line5</cstring>
306 </property>
307 <property stdset="1">
308 <name>orientation</name>
309 <enum>Horizontal</enum>
310 </property>
311 </widget>
312 </grid>
313</widget>
314<customwidgets>
315 <customwidget>
316 <class>QWidget</class>
317 <header location="local">qwidget.h</header>
318 <sizehint>
319 <width>100</width>
320 <height>100</height>
321 </sizehint>
322 <container>0</container>
323 <sizepolicy>
324 <hordata>7</hordata>
325 <verdata>7</verdata>
326 </sizepolicy>
327 <pixmap>image0</pixmap>
328 </customwidget>
329</customwidgets>
330<images>
331 <image>
332 <name>image0</name>
333 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
334 </image>
335</images>
336<tabstops>
337 <tabstop>startButton</tabstop>
338 <tabstop>stopButton</tabstop>
339 <tabstop>refreshButton</tabstop>
340 <tabstop>restartButton</tabstop>
341 <tabstop>advancedButton</tabstop>
342</tabstops>
343</UI>
diff --git a/noncore/net/networksetup/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaceinformationimp.cpp
deleted file mode 100644
index 43483fb..0000000
--- a/noncore/net/networksetup/interfaceinformationimp.cpp
+++ b/dev/null
@@ -1,70 +0,0 @@
1#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h"
3
4#include <qpushbutton.h>
5#include <qlabel.h>
6#include <qgroupbox.h>
7#include <assert.h>
8
9/**
10 * Constructor for the InterfaceInformationImp class. This class pretty much
11 * just display's information about the interface that is passed to it.
12 */
13InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){
14 assert(i);
15
16 interface = i;
17 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
18 updateInterface(interface);
19 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
20 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
21 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
22 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
23 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
24
25}
26
27/**
28 * Update the interface information and buttons.
29 * @param Intarface *i the interface to update (should be the one we already
30 * know about).
31 */
32void InterfaceInformationImp::updateInterface(Interface *i){
33 if(interface->getStatus()){
34 startButton->setEnabled(false);
35 stopButton->setEnabled(true);
36 restartButton->setEnabled(true);
37 }
38 else{
39 startButton->setEnabled(true);
40 stopButton->setEnabled(false);
41 restartButton->setEnabled(false);
42 }
43 macAddressLabel->setText(interface->getMacAddress());
44 ipAddressLabel->setText(interface->getIp());
45 subnetMaskLabel->setText(interface->getSubnetMask());
46 broadcastLabel->setText(interface->getBroadcast());
47}
48
49/**
50 * Create the advanced widget. Fill it with the current interface's information.
51 * Display it.
52 */
53void InterfaceInformationImp::advanced(){
54 InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced");
55 a->interfaceName->setText(interface->getInterfaceName());
56 a->macAddressLabel->setText(interface->getMacAddress());
57 a->ipAddressLabel->setText(interface->getIp());
58 a->subnetMaskLabel->setText(interface->getSubnetMask());
59 a->broadcastLabel->setText(interface->getBroadcast());
60 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
61 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
62 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
63 a->dhcpInformation->setEnabled(interface->isDhcp());
64
65 a->showMaximized();
66 a->show();
67}
68
69// infoimp.cpp
70
diff --git a/noncore/net/networksetup/interfaceinformationimp.h b/noncore/net/networksetup/interfaceinformationimp.h
deleted file mode 100644
index 42213cc..0000000
--- a/noncore/net/networksetup/interfaceinformationimp.h
+++ b/dev/null
@@ -1,27 +0,0 @@
1#ifndef INTERFACEINFORMATIONIMP_H
2#define INTERFACEINFORMATIONIMP_H
3
4#include "interfaceinformation.h"
5#include "interface.h"
6
7class InterfaceInformationImp : public InterfaceInformation {
8
9Q_OBJECT
10
11public:
12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
13 ~InterfaceInformationImp(){};
14
15private slots:
16 void advanced();
17 void updateInterface(Interface *i);
18
19private:
20 Interface *interface;
21
22};
23
24#endif
25
26// addserviceimp.h
27
diff --git a/noncore/net/networksetup/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp
deleted file mode 100644
index 377a6db..0000000
--- a/noncore/net/networksetup/interfaces.cpp
+++ b/dev/null
@@ -1,638 +0,0 @@
1#include "interfaces.h"
2
3#include <qfile.h>
4#include <qtextstream.h>
5#include <qregexp.h>
6
7#define AUTO "auto"
8#define IFACE "iface"
9#define MAPPING "mapping"
10
11/**
12 * Constructor. Reads in the interfaces file and then split the file up by
13 * the \n for interfaces variable.
14 * @param useInterfacesFile if an interface file other then the default is
15 * desired to be used it should be passed in.
16 */
17Interfaces::Interfaces(QString useInterfacesFile){
18 acceptedFamily.append(INTERFACES_FAMILY_INET);
19 acceptedFamily.append(INTERFACES_FAMILY_IPX);
20 acceptedFamily.append(INTERFACES_FAMILY_INET6);
21
22 interfacesFile = useInterfacesFile;
23 QFile file(interfacesFile);
24 if (!file.open(IO_ReadOnly)){
25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
26 currentIface = interfaces.end();
27 currentMapping = interfaces.end();
28 return;
29 }
30 QTextStream stream( &file );
31 QString line;
32 while ( !stream.eof() ) {
33 line += stream.readLine();
34 line += "\n";
35 }
36 file.close();
37 interfaces = QStringList::split("\n", line, true);
38
39 currentIface = interfaces.end();
40 currentMapping = interfaces.end();
41}
42
43
44/**
45 * Get a list of all interfaces in the interface file. Usefull for
46 * hardware that is not currently connected such as an 802.11b card
47 * not plugged in, but configured for when it is plugged in.
48 * @return Return string list of interfaces.
49 **/
50QStringList Interfaces::getInterfaceList(){
51 QStringList list;
52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
53 QString line = (*it).simplifyWhiteSpace();
54 if(line.contains(IFACE) && line.at(0) != '#'){
55 line = line.mid(QString(IFACE).length() +1, line.length());
56 line = line.simplifyWhiteSpace();
57 int findSpace = line.find(" ");
58 if( findSpace >= 0){
59 line = line.mid(0, findSpace);
60 list.append(line);
61 }
62 }
63 }
64 return list;
65}
66
67/**
68 * Find out if interface is in an "auto" group or not.
69 * Report any duplicates such as eth0 being in two differnt auto's
70 * @param interface interface to check to see if it is on or not.
71 * @return true is interface is in auto
72 */
73bool Interfaces::isAuto(QString interface){
74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
75 QStringList awi = autoLines.grep(QRegExp(interface));
76 if(awi.count() > 1)
77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
78 if(awi.count() < 1)
79 return false;
80 return true;
81}
82
83/**
84 * Attempt to set the auto option for interface to setAuto.
85 * @param interface the interface to set
86 * @param setAuto the value to set interface to.
87 * @return false if already set to setAuto.
88 * */
89bool Interfaces::setAuto(QString interface, bool setAuto){
90 // Don't need to set it if it is already set.
91 if(isAuto(interface) == setAuto)
92 return false;
93
94 bool changed = false;
95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
96 if((*it).contains(AUTO)){
97 //We know that they are not in any group so let add to this auto.
98 if(setAuto){
99 (*it) = (*it) += " " + interface;
100 // Don't care to have such thins as: auto eth0 lo usb0
101 (*it) = (*it).simplifyWhiteSpace();
102 changed = true;
103 break;
104 }
105 else{
106 if((*it).contains(interface)){
107 (*it) = (*it).replace(QRegExp(interface), "");
108 // clean up
109 QString line = (*it).simplifyWhiteSpace();
110 line = line.replace(QRegExp(" "),"");
111 if(line == AUTO)
112 (*it) = "";
113 changed = true;
114 // Don't break because we want to make sure we remove all cases.
115 }
116 }
117 }
118 }
119 if(changed == false){
120 if(setAuto == true)
121 interfaces.append(QString(AUTO" %1").arg(interface));
122 else{
123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
124 }
125 }
126 return true;
127}
128
129/**
130 * Set the current interface to interface. This needs to be done before you
131 * can call getFamily(), getMethod, and get/setOption().
132 * @param interface the name of the interface to set. All whitespace is
133 * removed from the interface name.
134 * @return bool true if it is successfull.
135 */
136bool Interfaces::setInterface(QString interface){
137 interface = interface.simplifyWhiteSpace();
138 interface = interface.replace(QRegExp(" "), "");
139 return setStanza(IFACE, interface, currentIface);
140}
141
142/**
143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise.
145 */
146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end());
148}
149
150/**
151 * Add a new interface of with the settings - family and method
152 * @param interface the name of the interface to set. All whitespace is
153 * removed from the interface name.
154 * @param family the family of this interface inet or inet, ipx or inet6
155 * Must of one of the families defined in interfaces.h
156 * @param method for the family. see interfaces man page for family methods.
157 * @return true if successfull.
158 */
159bool Interfaces::addInterface(QString interface, QString family, QString method){
160 if(acceptedFamily.contains(family)==0)
161 return false;
162 interface = interface.simplifyWhiteSpace();
163 interface = interface.replace(QRegExp(" "), "");
164 interfaces.append("");
165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
166 return true;
167}
168
169/**
170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface.
172 * @return bool true if successfull
173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){
175 if(!setInterface(interface)) return false;
176
177 QStringList::Iterator it = currentIface;
178 it++;
179
180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface;
184 newIface++;
185
186 for ( it; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break;
189 newIface = interfaces.insert(newIface, *it);
190 }
191
192 return true;
193}
194
195/**
196 * Remove the currently selected interface and all of its options.
197 * @return bool if successfull or not.
198 */
199bool Interfaces::removeInterface(){
200 if(currentIface == interfaces.end())
201 return false;
202 (*currentIface) = "";
203 return removeAllInterfaceOptions();
204}
205
206/**
207 * Gets the hardware name of the interface that is currently selected.
208 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
209 * @param error set to true if any error occurs, false otherwise.
210 */
211QString Interfaces::getInterfaceName(bool &error){
212 if(currentIface == interfaces.end()){
213 error = true;
214 return QString();
215 }
216 QString line = (*currentIface);
217 line = line.mid(QString(IFACE).length() +1, line.length());
218 line = line.simplifyWhiteSpace();
219 int findSpace = line.find(" ");
220 if( findSpace < 0){
221 error = true;
222 return QString();
223 }
224 error = false;
225 return line.mid(0, findSpace);
226}
227
228/**
229 * Gets the family name of the interface that is currently selected.
230 * @return QString name of the family (inet, inet6, ipx).
231 * @param error set to true if any error occurs, false otherwise.
232 */
233QString Interfaces::getInterfaceFamily(bool &error){
234 QString name = getInterfaceName(error);
235 if(error){
236 error = true;
237 return QString();
238 }
239 QString line = (*currentIface);
240 line = line.mid(QString(IFACE).length() +1, line.length());
241 line = line.mid(name.length()+1, line.length());
242 line = line.simplifyWhiteSpace();
243 int findSpace = line.find(" ");
244 if( findSpace < 0){
245 error = true;
246 return QString();
247 }
248 error = false;
249 return line.mid(0, findSpace);
250}
251
252/**
253 * Gets the method of the interface that is currently selected.
254 * @return QString name of the method such as staic or dhcp.
255 * See the man page of interfaces for possible methods depending on the family.
256 * @param error set to true if any error occurs, false otherwise.
257 */
258QString Interfaces::getInterfaceMethod(bool &error){
259 QString name = getInterfaceName(error);
260 if(error){
261 error = true;
262 return QString();
263 }
264 QString family = getInterfaceFamily(error);
265 if(error){
266 error = true;
267 return QString();
268 }
269 QString line = (*currentIface);
270 line = line.mid(QString(IFACE).length()+1, line.length());
271 line = line.mid(name.length()+1, line.length());
272 line = line.mid(family.length()+1, line.length());
273 line = line.simplifyWhiteSpace();
274 error = false;
275 return line;
276}
277
278/**
279 * Sets the interface name to newName.
280 * @param newName the new name of the interface. All whitespace is removed.
281 * @return bool true if successfull.
282 */
283bool Interfaces::setInterfaceName(QString newName){
284 if(currentIface == interfaces.end())
285 return false;
286 newName = newName.simplifyWhiteSpace();
287 newName = newName.replace(QRegExp(" "), "");
288 bool returnValue = false;
289 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
290 return !returnValue;
291}
292
293/**
294 * Sets the interface family to newName.
295 * @param newName the new name of the interface. Must be one of the families
296 * defined in the interfaces.h file.
297 * @return bool true if successfull.
298 */
299bool Interfaces::setInterfaceFamily(QString newName){
300 if(currentIface == interfaces.end())
301 return false;
302 if(acceptedFamily.contains(newName)==0)
303 return false;
304 bool returnValue = false;
305 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
306 return !returnValue;
307}
308
309/**
310 * Sets the interface method to newName
311 * @param newName the new name of the interface
312 * @return bool true if successfull.
313 */
314bool Interfaces::setInterfaceMethod(QString newName){
315 if(currentIface == interfaces.end())
316 return false;
317 bool returnValue = false;
318 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
319 return !returnValue;
320}
321
322/**
323 * Get a value for an option in the currently selected interface. For example
324 * calling getInterfaceOption("address") on the following stanza would
325 * return 192.168.1.1.
326 * iface eth0 static
327 * address 192.168.1.1
328 * @param option the options to get the value.
329 * @param error set to true if any error occurs, false otherwise.
330 * @return QString the options value. QString::null if error == true
331 */
332QString Interfaces::getInterfaceOption(QString option, bool &error){
333 return getOption(currentIface, option, error);
334}
335
336/**
337 * Set a value for an option in the currently selected interface. If option
338 * doesn't exist then it is added along with the value.
339 * @param option the options to set the value.
340 * @param value the value that option should be set to.
341 * @param error set to true if any error occurs, false otherwise.
342 * @return QString the options value. QString::null if error == true
343 */
344bool Interfaces::setInterfaceOption(QString option, QString value){
345 return setOption(currentIface, option, value);
346}
347
348/**
349 * Removes a value for an option in the currently selected interface.
350 * @param option the options to set the value.
351 * @param value the value that option should be set to.
352 * @param error set to true if any error occurs, false otherwise.
353 * @return QString the options value. QString::null if error == true
354 */
355bool Interfaces::removeInterfaceOption(QString option, QString value){
356 return removeOption(currentIface, option, value);
357}
358
359/**
360 * Removes all of the options from the currently selected interface.
361 * @return bool error if if successfull
362 */
363bool Interfaces::removeAllInterfaceOptions(){
364 return removeAllOptions(currentIface);
365}
366
367/**
368 * Set the current map to interface's map. This needs to be done before you
369 * can call addMapping(), set/getMap(), and get/setScript().
370 * @param interface the name of the interface to set. All whitespace is
371 * removed from the interface name.
372 * @return bool true if it is successfull.
373 */
374bool Interfaces::setMapping(QString interface){
375 interface = interface.simplifyWhiteSpace();
376 interface = interface.replace(QRegExp(" "), "");
377 return setStanza(MAPPING, interface, currentMapping);
378}
379
380/**
381 * Adds a new Mapping to the interfaces file with interfaces.
382 * @param interface the name(s) of the interfaces to set to this mapping
383 */
384void Interfaces::addMapping(QString option){
385 interfaces.append("");
386 interfaces.append(QString(MAPPING " %1").arg(option));
387}
388
389/**
390 * Remove the currently selected map and all of its options.
391 * @return bool if successfull or not.
392 */
393bool Interfaces::removeMapping(){
394 if(currentMapping == interfaces.end())
395 return false;
396 (*currentMapping) = "";
397 return removeAllOptions(currentMapping);
398}
399
400/**
401 * Set a map option within a mapping.
402 * @param map map to use
403 * @param value value to go with map
404 * @return bool true if it is successfull.
405 */
406bool Interfaces::setMap(QString map, QString value){
407 return setOption(currentMapping, map, value);
408}
409
410/**
411 * Removes a map option within a mapping.
412 * @param map map to use
413 * @param value value to go with map
414 * @return bool true if it is successfull.
415 */
416bool Interfaces::removeMap(QString map, QString value){
417 return removeOption(currentMapping, map, value);
418}
419
420/**
421 * Get a map value within a mapping.
422 * @param map map to get value of
423 * @param bool true if it is successfull.
424 * @return value that goes to the map
425 */
426QString Interfaces::getMap(QString map, bool &error){
427 return getOption(currentMapping, map, error);
428}
429
430/**
431 * Sets a script value of the current mapping to argument.
432 * @param argument the script name.
433 * @return true if successfull.
434 */
435bool Interfaces::setScript(QString argument){
436 return setOption(currentMapping, "script", argument);
437}
438
439/**
440 * @param error true if could not retrieve the current script argument.
441 * @return QString the argument of the script for the current mapping.
442 */
443QString Interfaces::getScript(bool &error){
444 return getOption(currentMapping, "script", error);
445}
446
447/**
448 * Helper function used to parse through the QStringList and put pointers in
449 * the correct place.
450 * @param stanza The stanza (auto, iface, mapping) to look for.
451 * @param option string that must be in the stanza's main line.
452 * @param interator interator to place at location of stanza if successfull.
453 * @return bool true if the stanza is found.
454 */
455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){
456 bool found = false;
457 iterator = interfaces.end();
458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
459 QString line = (*it).simplifyWhiteSpace();
460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
461 uint point = line.find(option);
462 bool valid = true;
463 if(point > 0){
464 // There are more chars in the line. check +1
465 if(line.at(point-1) != ' ')
466 valid = false;
467 }
468 point += option.length();
469 if(point < line.length()-1){
470 // There are more chars in the line. check -1
471 if(line.at(point) != ' ')
472 valid = false;
473 }
474 if(valid){
475 if(found == true){
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 }
478 found = true;
479 iterator = it;
480 }
481 }
482 }
483 return found;
484}
485
486/**
487 * Sets a value of an option in a stanza
488 * @param start the start of the stanza
489 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise.
491 */
492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){
493 if(start == interfaces.end())
494 return false;
495
496 bool found = false;
497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
499 if(!found && value != ""){
500 // Got to the end of the stanza without finding it, so append it.
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
502 }
503 found = true;
504 break;
505 }
506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it.
508 if(found)
509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
510 found = true;
511 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 }
513 }
514 if(!found){
515 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true;
518 }
519 return found;
520}
521/**
522 * Removes a option in a stanza
523 * @param start the start of the stanza
524 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise.
526 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
528 if(start == interfaces.end())
529 return false;
530
531 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it
535 break;
536 }
537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it.
539 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true;
542 (*it) = "";
543 }
544 }
545 return found;
546}
547
548/**
549 * Removes all options in a stanza
550 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise.
552 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){
554 if(start == interfaces.end())
555 return false;
556
557 QStringList::Iterator it = start;
558 it = ++it;
559 for (it; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break;
562 }
563 it = interfaces.remove(it);
564 it = --it;
565 }
566 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString(""));
568 return true;
569}
570
571/**
572 * Gets a value of an option in a stanza
573 * @param start the start of the stanza
574 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true.
577 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
579 if(start == interfaces.end()){
580 error = false;
581 return QString();
582 }
583
584 QString value;
585 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break;
589 }
590 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true;
594 QString line = (*it).simplifyWhiteSpace();
595 int space = line.find(" ", option.length());
596 if(space != -1)
597 value = line.mid(space+1, line.length());
598 else
599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
600 }
601 }
602 error = !found;
603 return value;
604}
605
606/**
607 * Write out the interfaces file to the file passed into the constructor.
608 * Removes any excess blank lines over 1 line long.
609 * @return bool true if successfull, false if not.
610 */
611bool Interfaces::write(){
612 QFile::remove(interfacesFile);
613 QFile file(interfacesFile);
614
615 if (!file.open(IO_ReadWrite)){
616 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
617 return false;
618 }
619 QTextStream stream( &file );
620 int whiteSpaceCount = 0;
621 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
622 QString line = (*it).simplifyWhiteSpace();
623 line = line.replace(QRegExp(" "),"");
624 if(line.length() == 0)
625 whiteSpaceCount++;
626 else
627 whiteSpaceCount = 0;
628 if(whiteSpaceCount < 2){
629 qDebug((*it).latin1());
630 stream << (*it) << '\n';
631 }
632 }
633 file.close();
634 return true;
635}
636
637// interfaces.cpp
638
diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h
deleted file mode 100644
index e09ea71..0000000
--- a/noncore/net/networksetup/interfaces.h
+++ b/dev/null
@@ -1,76 +0,0 @@
1#ifndef INTERFACES_H
2#define INTERFACES_H
3
4#include <qstring.h>
5#include <qstringlist.h>
6
7#define INTERFACES_LOOPBACK "loopback"
8
9#define INTERFACES_FAMILY_INET "inet"
10#define INTERFACES_FAMILY_IPX "ipx"
11#define INTERFACES_FAMILY_INET6 "inet6"
12
13#define INTERFACES_METHOD_DHCP "dhcp"
14#define INTERFACES_METHOD_STATIC "static"
15#define INTERFACES_METHOD_PPP "ppp"
16
17/**
18 * This class provides a clean frontend for parsing the network interfaces file.
19 * It provides helper functions to minipulate the options within the file.
20 * See the interfaces man page for the syntax rules.
21 */
22class Interfaces {
23
24public:
25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
26 QStringList getInterfaceList();
27
28 bool isAuto(QString interface);
29 bool setAuto(QString interface, bool setAuto);
30
31 bool removeInterface();
32 bool addInterface(QString interface, QString family, QString method);
33 bool copyInterface(QString oldInterface, QString newInterface);
34 bool setInterface(QString interface);
35 bool isInterfaceSet();
36 QString getInterfaceName(bool &error);
37 bool setInterfaceName(QString newName);
38 QString getInterfaceFamily(bool &error);
39 bool setInterfaceFamily(QString newName);
40 QString getInterfaceMethod(bool &error);
41 bool setInterfaceMethod(QString newName);
42 QString getInterfaceOption(QString option, bool &error);
43 bool setInterfaceOption(QString option, QString value);
44 bool removeInterfaceOption(QString option, QString value);
45 bool removeAllInterfaceOptions();
46
47 bool setMapping(QString interface);
48 bool removeMapping();
49 void addMapping(QString options);
50 bool setMap(QString map, QString value);
51 bool removeMap(QString map, QString value);
52 QString getMap(QString map, bool &error);
53 bool setScript(QString);
54 QString getScript(bool &error);
55
56 bool write();
57
58private:
59 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator);
60 bool setOption(QStringList::Iterator start, QString option, QString value);
61 bool removeOption(QStringList::Iterator start, QString option, QString value);
62 QString getOption(QStringList::Iterator start, QString option, bool &error);
63 bool removeAllOptions(QStringList::Iterator start);
64
65 QString interfacesFile;
66 QStringList interfaces;
67 QStringList::Iterator currentIface;
68 QStringList::Iterator currentMapping;
69
70 QStringList acceptedFamily;
71};
72
73#endif
74
75// interfaces
76
diff --git a/noncore/net/networksetup/interfacesetup.ui b/noncore/net/networksetup/interfacesetup.ui
deleted file mode 100644
index 0c834fe..0000000
--- a/noncore/net/networksetup/interfacesetup.ui
+++ b/dev/null
@@ -1,284 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>InterfaceSetup</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InterfaceSetup</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>290</width>
15 <height>280</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Interface Configuration</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QCheckBox</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>autoStart</cstring>
36 </property>
37 <property stdset="1">
38 <name>text</name>
39 <string>Automatically bring up</string>
40 </property>
41 </widget>
42 <widget>
43 <class>QLayoutWidget</class>
44 <property stdset="1">
45 <name>name</name>
46 <cstring>Layout9</cstring>
47 </property>
48 <hbox>
49 <property stdset="1">
50 <name>margin</name>
51 <number>0</number>
52 </property>
53 <property stdset="1">
54 <name>spacing</name>
55 <number>6</number>
56 </property>
57 <widget>
58 <class>QCheckBox</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>dhcpCheckBox</cstring>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>DHCP</string>
66 </property>
67 <property stdset="1">
68 <name>checked</name>
69 <bool>true</bool>
70 </property>
71 </widget>
72 <widget>
73 <class>QLabel</class>
74 <property stdset="1">
75 <name>name</name>
76 <cstring>leaseHoursLabel</cstring>
77 </property>
78 <property stdset="1">
79 <name>text</name>
80 <string>Requested Lease</string>
81 </property>
82 </widget>
83 <widget>
84 <class>QSpinBox</class>
85 <property stdset="1">
86 <name>name</name>
87 <cstring>leaseTime</cstring>
88 </property>
89 <property stdset="1">
90 <name>suffix</name>
91 <string> hours</string>
92 </property>
93 <property stdset="1">
94 <name>maxValue</name>
95 <number>87600</number>
96 </property>
97 <property stdset="1">
98 <name>minValue</name>
99 <number>1</number>
100 </property>
101 <property stdset="1">
102 <name>value</name>
103 <number>168</number>
104 </property>
105 </widget>
106 </hbox>
107 </widget>
108 <widget>
109 <class>QGroupBox</class>
110 <property stdset="1">
111 <name>name</name>
112 <cstring>staticGroupBox</cstring>
113 </property>
114 <property stdset="1">
115 <name>enabled</name>
116 <bool>false</bool>
117 </property>
118 <property stdset="1">
119 <name>frameShape</name>
120 <enum>Box</enum>
121 </property>
122 <property stdset="1">
123 <name>frameShadow</name>
124 <enum>Sunken</enum>
125 </property>
126 <property stdset="1">
127 <name>title</name>
128 <string>Static Ip Configuration</string>
129 </property>
130 <grid>
131 <property stdset="1">
132 <name>margin</name>
133 <number>11</number>
134 </property>
135 <property stdset="1">
136 <name>spacing</name>
137 <number>6</number>
138 </property>
139 <widget row="1" column="0" >
140 <class>QLabel</class>
141 <property stdset="1">
142 <name>name</name>
143 <cstring>TextLabel5</cstring>
144 </property>
145 <property stdset="1">
146 <name>text</name>
147 <string>Subnet Mask</string>
148 </property>
149 </widget>
150 <widget row="2" column="1" >
151 <class>QLineEdit</class>
152 <property stdset="1">
153 <name>name</name>
154 <cstring>gatewayEdit</cstring>
155 </property>
156 </widget>
157 <widget row="1" column="1" >
158 <class>QLineEdit</class>
159 <property stdset="1">
160 <name>name</name>
161 <cstring>subnetMaskEdit</cstring>
162 </property>
163 </widget>
164 <widget row="0" column="1" >
165 <class>QLineEdit</class>
166 <property stdset="1">
167 <name>name</name>
168 <cstring>ipAddressEdit</cstring>
169 </property>
170 </widget>
171 <widget row="3" column="0" >
172 <class>QLabel</class>
173 <property stdset="1">
174 <name>name</name>
175 <cstring>TextLabel2</cstring>
176 </property>
177 <property stdset="1">
178 <name>text</name>
179 <string>First DNS</string>
180 </property>
181 </widget>
182 <widget row="0" column="0" >
183 <class>QLabel</class>
184 <property stdset="1">
185 <name>name</name>
186 <cstring>TextLabel4</cstring>
187 </property>
188 <property stdset="1">
189 <name>text</name>
190 <string>IP Address</string>
191 </property>
192 </widget>
193 <widget row="2" column="0" >
194 <class>QLabel</class>
195 <property stdset="1">
196 <name>name</name>
197 <cstring>TextLabel1_2</cstring>
198 </property>
199 <property stdset="1">
200 <name>text</name>
201 <string>Gateway</string>
202 </property>
203 </widget>
204 <widget row="4" column="0" >
205 <class>QLabel</class>
206 <property stdset="1">
207 <name>name</name>
208 <cstring>TextLabel3</cstring>
209 </property>
210 <property stdset="1">
211 <name>text</name>
212 <string>Second DNS</string>
213 </property>
214 </widget>
215 <widget row="3" column="1" >
216 <class>QLineEdit</class>
217 <property stdset="1">
218 <name>name</name>
219 <cstring>firstDNSLineEdit</cstring>
220 </property>
221 </widget>
222 <widget row="4" column="1" >
223 <class>QLineEdit</class>
224 <property stdset="1">
225 <name>name</name>
226 <cstring>secondDNSLineEdit</cstring>
227 </property>
228 </widget>
229 </grid>
230 </widget>
231 <spacer>
232 <property>
233 <name>name</name>
234 <cstring>Spacer9</cstring>
235 </property>
236 <property stdset="1">
237 <name>orientation</name>
238 <enum>Vertical</enum>
239 </property>
240 <property stdset="1">
241 <name>sizeType</name>
242 <enum>Expanding</enum>
243 </property>
244 <property>
245 <name>sizeHint</name>
246 <size>
247 <width>20</width>
248 <height>20</height>
249 </size>
250 </property>
251 </spacer>
252 </vbox>
253</widget>
254<connections>
255 <connection>
256 <sender>dhcpCheckBox</sender>
257 <signal>toggled(bool)</signal>
258 <receiver>leaseHoursLabel</receiver>
259 <slot>setEnabled(bool)</slot>
260 </connection>
261 <connection>
262 <sender>dhcpCheckBox</sender>
263 <signal>toggled(bool)</signal>
264 <receiver>leaseTime</receiver>
265 <slot>setEnabled(bool)</slot>
266 </connection>
267 <connection>
268 <sender>dhcpCheckBox</sender>
269 <signal>toggled(bool)</signal>
270 <receiver>staticGroupBox</receiver>
271 <slot>setDisabled(bool)</slot>
272 </connection>
273</connections>
274<tabstops>
275 <tabstop>autoStart</tabstop>
276 <tabstop>dhcpCheckBox</tabstop>
277 <tabstop>leaseTime</tabstop>
278 <tabstop>ipAddressEdit</tabstop>
279 <tabstop>subnetMaskEdit</tabstop>
280 <tabstop>gatewayEdit</tabstop>
281 <tabstop>firstDNSLineEdit</tabstop>
282 <tabstop>secondDNSLineEdit</tabstop>
283</tabstops>
284</UI>
diff --git a/noncore/net/networksetup/interfacesetupimp.cpp b/noncore/net/networksetup/interfacesetupimp.cpp
deleted file mode 100644
index a8731a9..0000000
--- a/noncore/net/networksetup/interfacesetupimp.cpp
+++ b/dev/null
@@ -1,147 +0,0 @@
1#include "interfacesetupimp.h"
2#include "interface.h"
3#include "interfaces.h"
4
5#include <qcombobox.h>
6#include <qcheckbox.h>
7#include <qlineedit.h>
8#include <qspinbox.h>
9#include <qgroupbox.h>
10#include <qlabel.h>
11
12#include <qmessagebox.h>
13
14#include <assert.h>
15
16#define DNSSCRIPT "interfacednsscript"
17
18/**
19 * Constuctor. Set up the connection and load the first profile.
20 */
21InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){
22 assert(i);
23 interface = i;
24 interfaces = new Interfaces();
25 bool error = false;
26 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
27 staticGroupBox->hide();
28 dhcpCheckBox->hide();
29 leaseTime->hide();
30 leaseHoursLabel->hide();
31 }
32}
33
34/**
35 * Save the current settings, then write out the interfaces file and close.
36 */
37void InterfaceSetupImp::accept(){
38 if(!saveSettings())
39 return;
40 interfaces->write();
41 QDialog::accept();
42}
43
44/**
45 * Save the settings for the current Interface.
46 * @return bool true if successfull, false otherwise
47 */
48bool InterfaceSetupImp::saveSettings(){
49 // eh can't really do anything about it other then return. :-D
50 if(!interfaces->isInterfaceSet())
51 return true;
52
53 bool error = false;
54 // Loopback case
55 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
56 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
57 return true;
58 }
59
60 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){
61 QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok");
62 return false;
63 }
64 interfaces->removeAllInterfaceOptions();
65
66 // DHCP
67 if(dhcpCheckBox->isChecked()){
68 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
69 interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value()));
70 interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60));
71 }
72 else{
73 interfaces->setInterfaceMethod("static");
74 interfaces->setInterfaceOption("address", ipAddressEdit->text());
75 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
76 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
77 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
78 interfaces->setInterfaceOption("up "DNSSCRIPT" add ", dns);
79 interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns);
80 }
81
82 // IP Information
83 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
84 return true;
85}
86
87/**
88 * The Profile has changed.
89 * @profile the new profile.
90 */
91void InterfaceSetupImp::setProfile(const QString &profile){
92 QString newInterfaceName = interface->getInterfaceName();
93 if(profile.length() > 0)
94 newInterfaceName += "_" + profile;
95 // See if we have to make a interface.
96 if(!interfaces->setInterface(newInterfaceName)){
97 // Add making for this new interface if need too
98 if(profile != ""){
99 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
100 if(!interfaces->setMapping(interface->getInterfaceName())){
101 interfaces->addMapping(interface->getInterfaceName());
102 if(!interfaces->setMapping(interface->getInterfaceName())){
103 qDebug("InterfaceSetupImp: Added Mapping, but still can't set.");
104 return;
105 }
106 }
107 interfaces->setMap("map", newInterfaceName);
108 interfaces->setScript("getprofile.sh");
109 }
110 else{
111 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
112 if(!interfaces->setInterface(newInterfaceName)){
113 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
114 return;
115 }
116 }
117 }
118
119 // We must have a valid interface to get this far so read some settings.
120
121 // DHCP
122 bool error = false;
123 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
124 dhcpCheckBox->setChecked(true);
125 else
126 dhcpCheckBox->setChecked(false);
127 leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt());
128 if(error)
129 leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60);
130 if(error)
131 leaseTime->setValue(24);
132
133 // IP Information
134 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
135 QString dns = interfaces->getInterfaceOption("up interfacednsscript add", error);
136 if(dns.contains(" ")){
137 firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
138 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
139 }
140 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
141 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
142 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
143}
144
145
146// interfacesetup.cpp
147
diff --git a/noncore/net/networksetup/interfacesetupimp.h b/noncore/net/networksetup/interfacesetupimp.h
deleted file mode 100644
index a0bec32..0000000
--- a/noncore/net/networksetup/interfacesetupimp.h
+++ b/dev/null
@@ -1,31 +0,0 @@
1#ifndef INTERFACESETUPIMP_H
2#define INTERFACESETUPIMP_H
3
4#include "interfacesetup.h"
5
6class Interface;
7class Interfaces;
8
9class InterfaceSetupImp : public InterfaceSetup {
10 Q_OBJECT
11
12public:
13 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0);
14
15protected slots:
16 void accept();
17
18public slots:
19 void setProfile(const QString &profile);
20
21private:
22 bool saveSettings();
23 Interfaces *interfaces;
24 Interface *interface;
25
26};
27
28#endif
29
30// interfacesetupimp.h
31
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index f9ca83b..b9fff56 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -9,7 +9,6 @@
9#include "kprocess.h" 9#include "kprocess.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtabwidget.h>
13#include <qlistbox.h> 12#include <qlistbox.h>
14#include <qlineedit.h> 13#include <qlineedit.h>
15#include <qlistview.h> 14#include <qlistview.h>
@@ -95,6 +94,7 @@ MainWindowImp::~MainWindowImp(){
95 for( it = libraries.begin(); it != libraries.end(); ++it ){ 94 for( it = libraries.begin(); it != libraries.end(); ++it ){
96 delete it.key(); 95 delete it.key();
97 // I wonder why I can't delete the libraries 96 // I wonder why I can't delete the libraries
97 // What fucking shit this is.
98 //delete it.data(); 98 //delete it.data();
99 } 99 }
100} 100}
@@ -221,8 +221,7 @@ void MainWindowImp::removeClicked(){
221/** 221/**
222 * Pull up the configure about the currently selected interface. 222 * Pull up the configure about the currently selected interface.
223 * Report an error if no interface is selected. 223 * Report an error if no interface is selected.
224 * If the interface has a module owner then request its configure with a empty 224 * If the interface has a module owner then request its configure.
225 * tab. If tab is !NULL then append the interfaces setup widget to it.
226 */ 225 */
227void MainWindowImp::configureClicked(){ 226void MainWindowImp::configureClicked(){
228 QListViewItem *item = connectionList->currentItem(); 227 QListViewItem *item = connectionList->currentItem();
@@ -239,22 +238,16 @@ void MainWindowImp::configureClicked(){
239 Interface *i = interfaceItems[item]; 238 Interface *i = interfaceItems[item];
240 if(i->getModuleOwner()){ 239 if(i->getModuleOwner()){
241 i->getModuleOwner()->setProfile(currentProfile); 240 i->getModuleOwner()->setProfile(currentProfile);
242 QTabWidget *tabWidget = NULL; 241 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
243 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
244 if(moduleConfigure != NULL){ 242 if(moduleConfigure != NULL){
245 if(tabWidget != NULL){
246 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
247 configure->setProfile(currentProfile);
248 tabWidget->insertTab(configure, "TCP/IP");
249 }
250 moduleConfigure->showMaximized(); 243 moduleConfigure->showMaximized();
251 moduleConfigure->show(); 244 moduleConfigure->show();
252 return; 245 return;
253 } 246 }
254 } 247 }
255 248
256 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose); 249 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose);
257 configure->setProfile(currentProfile); 250 //configure->setProfile(currentProfile);
258 configure->showMaximized(); 251 configure->showMaximized();
259 configure->show(); 252 configure->show();
260} 253}
@@ -262,8 +255,7 @@ void MainWindowImp::configureClicked(){
262/** 255/**
263 * Pull up the information about the currently selected interface. 256 * Pull up the information about the currently selected interface.
264 * Report an error if no interface is selected. 257 * Report an error if no interface is selected.
265 * If the interface has a module owner then request its configure with a empty 258 * If the interface has a module owner then request its configure.
266 * tab. If tab is !NULL then append the interfaces setup widget to it.
267 */ 259 */
268void MainWindowImp::informationClicked(){ 260void MainWindowImp::informationClicked(){
269 QListViewItem *item = connectionList->currentItem(); 261 QListViewItem *item = connectionList->currentItem();
@@ -284,19 +276,13 @@ void MainWindowImp::informationClicked(){
284 } 276 }
285 277
286 if(i->getModuleOwner()){ 278 if(i->getModuleOwner()){
287 QTabWidget *tabWidget = NULL; 279 QWidget *moduleInformation = i->getModuleOwner()->information(i);
288 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
289 if(moduleInformation != NULL){ 280 if(moduleInformation != NULL){
290 if(tabWidget != NULL){
291 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
292 tabWidget->insertTab(information, "TCP/IP");
293 }
294 moduleInformation->showMaximized(); 281 moduleInformation->showMaximized();
295 moduleInformation->show(); 282 moduleInformation->show();
296 return; 283 return;
297 } 284 }
298 } 285 }
299
300 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 286 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
301 information->showMaximized(); 287 information->showMaximized();
302 information->show(); 288 information->show();
diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h
index 96db5b3..92b125a 100644
--- a/noncore/net/networksetup/module.h
+++ b/noncore/net/networksetup/module.h
@@ -39,20 +39,18 @@ public:
39 virtual bool isOwner(Interface *){ return false; }; 39 virtual bool isOwner(Interface *){ return false; };
40 40
41 /** 41 /**
42 * Create, set tabWiget and return the WLANConfigure Module 42 * Create and return the WLANConfigure Module
43 * @param Interface *i the interface to configure. 43 * @param Interface *i the interface to configure.
44 * @param tabWidget a pointer to the tab widget that this configure has. 44 * @return QWidget* pointer to this modules configure.
45 * @return QWidget* pointer to the tab widget in this modules configure.
46 */ 45 */
47 virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ; 46 virtual QWidget *configure(Interface *){ return NULL; } ;
48 47
49 /** 48 /**
50 * Create, set tabWiget and return the Information Module 49 * Create, and return the Information Module
51 * @param Interface *i the interface to get info on. 50 * @param Interface *i the interface to get info on.
52 * @param tabWidget a pointer to the tab widget that this information has. 51 * @return QWidget* pointer to this modules info.
53 * @return QWidget* pointer to the tab widget in this modules info.
54 */ 52 */
55 virtual QWidget *information(Interface *, QTabWidget **){ return NULL; }; 53 virtual QWidget *information(Interface *){ return NULL; };
56 54
57 /** 55 /**
58 * Get all active (up or down) interfaces 56 * Get all active (up or down) interfaces
diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro
index f09db93..9f28fbd 100644
--- a/noncore/net/networksetup/networksetup.pro
+++ b/noncore/net/networksetup/networksetup.pro
@@ -1,11 +1,11 @@
1 DESTDIR = $(OPIEDIR)/bin 1 #DESTDIR = $(OPIEDIR)/bin
2 TEMPLATE= app 2 TEMPLATE= app
3 #CONFIG = qt warn_on debug 3 #CONFIG = qt warn_on debug
4 CONFIG = qt warn_on release 4 CONFIG = qt warn_on release
5 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h 5 HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h
6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp 6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include 7 INCLUDEPATH+= $(OPIEDIR)/include interfaces/
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include interfaces/ wlan
9LIBS += -lqpe 9LIBS += -lqpe -Linterfaces -linterfaces
10 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui 10 INTERFACES= mainwindow.ui addconnection.ui
11 TARGET = networksetup 11 TARGET = networksetup
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp
index e545bd1..eb6fc42 100644
--- a/noncore/net/networksetup/wlan/wextensions.cpp
+++ b/noncore/net/networksetup/wlan/wextensions.cpp
@@ -16,9 +16,11 @@
16/** 16/**
17 * Constructor. Sets hasWirelessExtensions 17 * Constructor. Sets hasWirelessExtensions
18 */ 18 */
19WExtensions::WExtensions(QString interfaceName){ 19WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){
20 interface = interfaceName; 20 interface = interfaceName;
21 fd = socket( AF_INET, SOCK_DGRAM, 0 ); 21 fd = socket( AF_INET, SOCK_DGRAM, 0 );
22 if(fd == -1)
23 return;
22 24
23 const char* buffer[200]; 25 const char* buffer[200];
24 memset( &iwr, 0, sizeof( iwr ) ); 26 memset( &iwr, 0, sizeof( iwr ) );
@@ -35,8 +37,6 @@ WExtensions::WExtensions(QString interfaceName){
35 strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); 37 strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
36 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) 38 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) )
37 hasWirelessExtensions = true; 39 hasWirelessExtensions = true;
38 else
39 hasWirelessExtensions = false;
40} 40}
41 41
42/** 42/**
diff --git a/noncore/net/networksetup/wlan/wlan.pro b/noncore/net/networksetup/wlan/wlan.pro
index f28feb2..23fc39a 100644
--- a/noncore/net/networksetup/wlan/wlan.pro
+++ b/noncore/net/networksetup/wlan/wlan.pro
@@ -4,9 +4,9 @@ CONFIG += qt warn_on release
4DESTDIR = $(OPIEDIR)/plugins/networksetup 4DESTDIR = $(OPIEDIR)/plugins/networksetup
5 HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h 5 HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h
6 SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp 6 SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include ../ 7 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe -L../interfaces/ -linterfaces
10 INTERFACES= wlan.ui info.ui 10 INTERFACES= wlan.ui info.ui
11 TARGET = wlanplugin 11 TARGET = wlanplugin
12 VERSION = 1.0.0 12 VERSION = 1.0.0
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp
index 45952b9..7c902e0 100644
--- a/noncore/net/networksetup/wlan/wlanimp.cpp
+++ b/noncore/net/networksetup/wlan/wlanimp.cpp
@@ -15,10 +15,18 @@
15#include <qradiobutton.h> 15#include <qradiobutton.h>
16#include <qcheckbox.h> 16#include <qcheckbox.h>
17#include <qregexp.h> 17#include <qregexp.h>
18#include <qpe/config.h>
19#include <qtabwidget.h>
20#include "interfacesetupimp.h"
18 21
19WLANImp::WLANImp( QWidget* parent, const char* name, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ 22WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){
20 config = new Config("wireless"); 23 config = new Config("wireless");
24 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose);
25 //configure->setProfile(currentProfile);
26 tabWidget->insertTab(interfaceSetup, "TCP/IP");
27
21 readConfig(); 28 readConfig();
29
22} 30}
23 31
24WLANImp::~WLANImp( ){ 32WLANImp::~WLANImp( ){
@@ -109,8 +117,10 @@ bool WLANImp::writeConfig()
109 */ 117 */
110void WLANImp::accept() 118void WLANImp::accept()
111{ 119{
112 if ( writeConfig() ) 120 if ( writeConfig() ){
121 interfaceSetup->saveChanges();
113 QDialog::accept(); 122 QDialog::accept();
123 }
114} 124}
115 125
116bool WLANImp::writeWirelessOpts( QString scheme ) 126bool WLANImp::writeWirelessOpts( QString scheme )
diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h
index 59b7c59..608d681 100644
--- a/noncore/net/networksetup/wlan/wlanimp.h
+++ b/noncore/net/networksetup/wlan/wlanimp.h
@@ -3,13 +3,15 @@
3 3
4#include "wlan.h" 4#include "wlan.h"
5 5
6#include <qpe/config.h> 6class InterfaceSetupImp;
7class Interface;
8class Config;
7 9
8class WLANImp : public WLAN { 10class WLANImp : public WLAN {
9 Q_OBJECT 11 Q_OBJECT
10 12
11public: 13public:
12 WLANImp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 14 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
13 ~WLANImp( ); 15 ~WLANImp( );
14 16
15protected: 17protected:
@@ -21,6 +23,8 @@ private:
21 bool writeWirelessOpts( QString scheme = "*" ); 23 bool writeWirelessOpts( QString scheme = "*" );
22 bool writeWlanngOpts( QString scheme = "*" ); 24 bool writeWlanngOpts( QString scheme = "*" );
23 Config* config; 25 Config* config;
26 InterfaceSetupImp *interfaceSetup;
27
24}; 28};
25 29
26#endif 30#endif
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 9ab3b76..c8becb0 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -2,9 +2,11 @@
2#include "wlanimp.h" 2#include "wlanimp.h"
3#include "infoimp.h" 3#include "infoimp.h"
4#include "wextensions.h" 4#include "wextensions.h"
5#include "interfaceinformationimp.h"
5 6
6#include <qlabel.h> 7#include <qlabel.h>
7#include <qprogressbar.h> 8#include <qprogressbar.h>
9#include <qtabwidget.h>
8 10
9/** 11/**
10 * Constructor, find all of the possible interfaces 12 * Constructor, find all of the possible interfaces
@@ -53,28 +55,26 @@ bool WLANModule::isOwner(Interface *i){
53} 55}
54 56
55/** 57/**
56 * Create, set tabWiget and return the WLANConfigure Module 58 * Create, and return the WLANConfigure Module
57 * @param tabWidget a pointer to the tab widget that this configure has. 59 * @return QWidget* pointer to this modules configure.
58 * @return QWidget* pointer to the tab widget in this modules configure.
59 */ 60 */
60QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ 61QWidget *WLANModule::configure(Interface *i){
61 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose); 62 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose);
62 (*tabWidget) = wlanconfig->tabWidget;
63 return wlanconfig; 63 return wlanconfig;
64} 64}
65 65
66/** 66/**
67 * Create, set tabWiget and return the Information Module 67 * Create, and return the Information Module
68 * @param tabWidget a pointer to the tab widget that this information has. 68 * @return QWidget* pointer to this modules info.
69 * @return QWidget* pointer to the tab widget in this modules info.
70 */ 69 */
71QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 70QWidget *WLANModule::information(Interface *i){
72 WExtensions we(i->getInterfaceName()); 71 WExtensions we(i->getInterfaceName());
73 if(!we.doesHaveWirelessExtensions()) 72 if(!we.doesHaveWirelessExtensions())
74 return NULL; 73 return NULL;
75 74
76 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 75 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
77 (*tabWidget) = info->tabWidget; 76 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
77 info->tabWidget->insertTab(information, "TCP/IP");
78 return info; 78 return info;
79} 79}
80 80
diff --git a/noncore/net/networksetup/wlan/wlanmodule.h b/noncore/net/networksetup/wlan/wlanmodule.h
index 1418ce8..a81ccff 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.h
+++ b/noncore/net/networksetup/wlan/wlanmodule.h
@@ -14,8 +14,8 @@ public:
14 14
15 virtual void setProfile(QString newProfile); 15 virtual void setProfile(QString newProfile);
16 virtual bool isOwner(Interface *); 16 virtual bool isOwner(Interface *);
17 virtual QWidget *configure(Interface *i, QTabWidget **tabWidget); 17 virtual QWidget *configure(Interface *i);
18 virtual QWidget *information(Interface *i, QTabWidget **tabWidget); 18 virtual QWidget *information(Interface *i);
19 virtual QList<Interface> getInterfaces(); 19 virtual QList<Interface> getInterfaces();
20 virtual void possibleNewInterfaces(QMap<QString, QString> &){}; 20 virtual void possibleNewInterfaces(QMap<QString, QString> &){};
21 virtual Interface *addNewInterface(QString name); 21 virtual Interface *addNewInterface(QString name);
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index d61c510..c83d909 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,3 +1,5 @@
1Make sure the C code in wextensions is clean.
2
1WLAN needs to be re-written to not use Config 3WLAN needs to be re-written to not use Config
2WHERE Is DHCP info stored??? 4WHERE Is DHCP info stored???
3 5
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
deleted file mode 100644
index 929b3a1..0000000
--- a/noncore/settings/networksettings/interface.cpp
+++ b/dev/null
@@ -1,287 +0,0 @@
1#include "interface.h"
2#include <qdatetime.h>
3#include <qfile.h>
4#include <qdir.h>
5#include <qfileinfo.h>
6#include <qtextstream.h>
7
8#define IFCONFIG "/sbin/ifconfig"
9#define DHCP_INFO_DIR "/etc/dhcpc"
10
11#include <stdio.h>
12#include <stdlib.h>
13
14Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
15 refresh();
16}
17
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 hardwareName = 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/**
62 * Try to start the interface.
63 */
64void Interface::start(){
65 // check to see if we are already running.
66 if(true == status)
67 return;
68
69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
70 // See if it was successfull...
71 if(ret != 0)
72 return;
73
74 status = true;
75 refresh();
76}
77
78/**
79 * Try to stop the interface.
80 */
81void Interface::stop(){
82 // check to see if we are already stopped.
83 if(false == status)
84 return;
85
86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
87 if(ret != 0)
88 return;
89
90 status = true;
91 refresh();
92}
93
94/**
95 * Try to restart the interface.
96 */
97void Interface::restart(){
98 stop();
99 start();
100}
101
102/**
103 * Try to refresh the information about the interface.
104 * First call ifconfig, then check the dhcp-info file
105 * @return bool true if successfull.
106 */
107bool Interface::refresh(){
108 // See if we are up.
109 if(status == false){
110 macAddress = "";
111 ip = "0.0.0.0";
112 subnetMask = "0.0.0.0";
113 broadcast = "";
114 dhcp = false;
115 dhcpServerIp = "";
116 leaseObtained = "";
117 leaseExpires = "";
118 emit(updateInterface(this));
119 return true;
120 }
121
122 QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
123 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
124 if(ret != 0){
125 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
126 return false;
127 }
128
129 QFile file(fileName);
130 if (!file.open(IO_ReadOnly)){
131 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
132 return false;
133 }
134
135 // Set to the defaults
136 macAddress = "";
137 ip = "0.0.0.0";
138 subnetMask = "0.0.0.0";
139 broadcast = "";
140
141 QTextStream stream( &file );
142 QString line;
143 while ( !stream.eof() ) {
144 line = stream.readLine();
145 if(line.contains("HWaddr")){
146 int mac = line.find("HWaddr");
147 macAddress = line.mid(mac+7, line.length());
148 }
149 if(line.contains("inet addr")){
150 int ipl = line.find("inet addr");
151 int space = line.find(" ", ipl+10);
152 ip = line.mid(ipl+10, space-ipl-10);
153 }
154 if(line.contains("Mask")){
155 int mask = line.find("Mask");
156 subnetMask = line.mid(mask+5, line.length());
157 }
158 if(line.contains("Bcast")){
159 int mask = line.find("Bcast");
160 int space = line.find(" ", mask+6);
161 broadcast = line.mid(mask+6, space-mask-6);
162 }
163 }
164 file.close();
165 QFile::remove(fileName);
166
167 // DHCP TESTING
168 // reset DHCP info
169 dhcpServerIp = "";
170 leaseObtained = "";
171 leaseExpires = "";
172 dhcp = false;
173
174 QString dhcpDirectory(DHCP_INFO_DIR);
175 QDir d(dhcpDirectory);
176 if(!d.exists(dhcpDirectory))
177 dhcpDirectory = "/var/run";
178
179 // See if we have
180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
181 // If there is no DHCP information then exit now with no errors.
182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this));
184 return true;
185 }
186
187 file.setName(dhcpFile);
188 if (!file.open(IO_ReadOnly)){
189 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
190 return false;
191 }
192
193 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
194 int leaseTime = 0;
195 int renewalTime = 0;
196
197 stream.setDevice( &file );
198 while ( !stream.eof() ) {
199 line = stream.readLine();
200 if(line.contains("DHCPSIADDR="))
201 dhcpServerIp = line.mid(11, line.length());
202 if(line.contains("LEASETIME="))
203 leaseTime = line.mid(10, line.length()).toInt();
204 if(line.contains("RENEWALTIME="))
205 renewalTime = line.mid(12, line.length()).toInt();
206 }
207 file.close();
208 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
209 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
210
211 // Get the pid of the deamond
212 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
213 file.setName(dhcpFile);
214 if (!file.open(IO_ReadOnly)){
215 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
216 return false;
217 }
218
219 int pid = -1;
220 stream.setDevice( &file );
221 while ( !stream.eof() ) {
222 line = stream.readLine();
223 pid = line.toInt();
224 }
225 file.close();
226
227 if( pid == -1){
228 qDebug("Interface: Could not get pid of dhcpc deamon.");
229 return false;
230 }
231
232 // Get the start running time of the deamon
233 fileName = (QString("/proc/%1/stat").arg(pid));
234 file.setName(fileName);
235 stream.setDevice( &file );
236 if (!file.open(IO_ReadOnly)){
237 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
238 return false;
239 }
240 while ( !stream.eof() ) {
241 line = stream.readLine();
242 }
243 file.close();
244 long time = 0;
245 // Grab the start time
246 // pid com state ppid pgrp session tty_nr tpgid flags
247 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
248 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
249 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
250 // nice 0 itrealvalue starttime
251 "%*d %*d %*d %lu", (long*) &time);
252 time = time/100;
253
254 QDateTime datetime(QDateTime::currentDateTime());
255
256 // Get the uptime of the computer.
257 QFile f("/proc/uptime");
258 if ( f.open(IO_ReadOnly) ) { // file opened successfully
259 QTextStream t( &f ); // use a text stream
260 int sec = 0;
261 t >> sec;
262 datetime = datetime.addSecs((-1*sec));
263 f.close();
264 }
265 else{
266 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
267 return false;
268 }
269
270 datetime = datetime.addSecs(time);
271 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
272
273 // Calculate the start and renew times
274 leaseObtained= datetime.toString();
275
276 // Calculate the start and renew times
277 datetime = datetime.addSecs(leaseTime);
278 leaseExpires = datetime.toString();
279
280 dhcp = true;
281
282 emit(updateInterface(this));
283 return true;
284}
285
286// interface.cpp
287
diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h
deleted file mode 100644
index dc9c6d3..0000000
--- a/noncore/settings/networksettings/interface.h
+++ b/dev/null
@@ -1,71 +0,0 @@
1#ifndef INTERFACE_H
2#define INTERFACE_H
3
4#include <qstring.h>
5#include <qobject.h>
6
7class Module;
8
9class Interface : public QObject{
10 Q_OBJECT
11
12signals:
13 void updateInterface(Interface *i);
14
15public:
16 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
17 virtual ~Interface(){};
18
19 virtual QString getInterfaceName(){ QString n(this->name()); return n; };
20
21 virtual bool getStatus(){ return status; };
22 virtual void setStatus(bool newStatus);
23
24 virtual bool isAttached(){ return attached; };
25 virtual void setAttached(bool isAttached=false);
26
27 virtual QString getHardwareName(){ return hardwareName; };
28 virtual void setHardwareName(QString name="Unknown");
29
30 virtual Module* getModuleOwner(){ return moduleOwner; };
31 virtual void setModuleOwner(Module *owner=NULL);
32
33 // inet information.
34 QString getMacAddress(){ return macAddress; };
35 QString getIp(){ return ip; };
36 QString getSubnetMask(){ return subnetMask; };
37 QString getBroadcast(){ return broadcast; };
38 bool isDhcp(){ return dhcp; };
39 QString getDhcpServerIp(){ return dhcpServerIp; };
40 QString getLeaseObtained(){ return leaseObtained; };
41 QString getLeaseExpires(){ return leaseExpires; };
42
43public slots:
44 bool refresh();
45 void start();
46 void stop();
47 void restart();
48
49private:
50 // Interface information
51 bool status;
52 bool attached;
53 QString hardwareName;
54 Module *moduleOwner;
55
56 // Network information
57 QString macAddress;
58 QString ip;
59 QString broadcast;
60 QString subnetMask;
61 bool dhcp;
62 QString dhcpServerIp;
63 QString leaseObtained;
64 QString leaseExpires;
65
66};
67
68#endif
69
70// interface.h
71
diff --git a/noncore/settings/networksettings/interfaceadvanced.ui b/noncore/settings/networksettings/interfaceadvanced.ui
deleted file mode 100644
index 0ec67c2..0000000
--- a/noncore/settings/networksettings/interfaceadvanced.ui
+++ b/dev/null
@@ -1,344 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>InterfaceAdvanced</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InterfaceAdvanced</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>214</width>
15 <height>286</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>240</width>
22 <height>32767</height>
23 </size>
24 </property>
25 <property stdset="1">
26 <name>caption</name>
27 <string>Advanced Interface Information</string>
28 </property>
29 <grid>
30 <property stdset="1">
31 <name>margin</name>
32 <number>11</number>
33 </property>
34 <property stdset="1">
35 <name>spacing</name>
36 <number>6</number>
37 </property>
38 <widget row="1" column="0" >
39 <class>QLabel</class>
40 <property stdset="1">
41 <name>name</name>
42 <cstring>TextLabel1</cstring>
43 </property>
44 <property stdset="1">
45 <name>text</name>
46 <string>MAC Address</string>
47 </property>
48 </widget>
49 <widget row="0" column="1" >
50 <class>QLabel</class>
51 <property stdset="1">
52 <name>name</name>
53 <cstring>interfaceName</cstring>
54 </property>
55 <property stdset="1">
56 <name>frameShape</name>
57 <enum>Panel</enum>
58 </property>
59 <property stdset="1">
60 <name>frameShadow</name>
61 <enum>Sunken</enum>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>eth0</string>
66 </property>
67 </widget>
68 <widget row="2" column="0" >
69 <class>QLabel</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>TextLabel3</cstring>
73 </property>
74 <property stdset="1">
75 <name>text</name>
76 <string>IP Address</string>
77 </property>
78 </widget>
79 <widget row="1" column="1" >
80 <class>QLabel</class>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>macAddressLabel</cstring>
84 </property>
85 <property stdset="1">
86 <name>frameShape</name>
87 <enum>Panel</enum>
88 </property>
89 <property stdset="1">
90 <name>frameShadow</name>
91 <enum>Sunken</enum>
92 </property>
93 <property stdset="1">
94 <name>text</name>
95 <string>00:00:00:00:00:00</string>
96 </property>
97 </widget>
98 <widget row="0" column="0" >
99 <class>QLabel</class>
100 <property stdset="1">
101 <name>name</name>
102 <cstring>TextLabel7</cstring>
103 </property>
104 <property stdset="1">
105 <name>text</name>
106 <string>Interface</string>
107 </property>
108 </widget>
109 <widget row="4" column="0" >
110 <class>QLabel</class>
111 <property stdset="1">
112 <name>name</name>
113 <cstring>TextLabel4</cstring>
114 </property>
115 <property stdset="1">
116 <name>enabled</name>
117 <bool>true</bool>
118 </property>
119 <property stdset="1">
120 <name>text</name>
121 <string>Subnet Mask</string>
122 </property>
123 </widget>
124 <widget row="2" column="1" >
125 <class>QLabel</class>
126 <property stdset="1">
127 <name>name</name>
128 <cstring>ipAddressLabel</cstring>
129 </property>
130 <property stdset="1">
131 <name>frameShape</name>
132 <enum>Panel</enum>
133 </property>
134 <property stdset="1">
135 <name>frameShadow</name>
136 <enum>Sunken</enum>
137 </property>
138 <property stdset="1">
139 <name>text</name>
140 <string>0.0.0.0</string>
141 </property>
142 </widget>
143 <widget row="4" column="1" >
144 <class>QLabel</class>
145 <property stdset="1">
146 <name>name</name>
147 <cstring>subnetMaskLabel</cstring>
148 </property>
149 <property stdset="1">
150 <name>frameShape</name>
151 <enum>Panel</enum>
152 </property>
153 <property stdset="1">
154 <name>frameShadow</name>
155 <enum>Sunken</enum>
156 </property>
157 <property stdset="1">
158 <name>text</name>
159 <string>0.0.0.0</string>
160 </property>
161 </widget>
162 <widget row="3" column="0" >
163 <class>QLabel</class>
164 <property stdset="1">
165 <name>name</name>
166 <cstring>TextLabel2</cstring>
167 </property>
168 <property stdset="1">
169 <name>text</name>
170 <string>Broadcast</string>
171 </property>
172 </widget>
173 <widget row="3" column="1" >
174 <class>QLabel</class>
175 <property stdset="1">
176 <name>name</name>
177 <cstring>broadcastLabel</cstring>
178 </property>
179 <property stdset="1">
180 <name>frameShape</name>
181 <enum>Panel</enum>
182 </property>
183 <property stdset="1">
184 <name>frameShadow</name>
185 <enum>Sunken</enum>
186 </property>
187 </widget>
188 <widget row="5" column="0" rowspan="1" colspan="2" >
189 <class>QGroupBox</class>
190 <property stdset="1">
191 <name>name</name>
192 <cstring>dhcpInformation</cstring>
193 </property>
194 <property stdset="1">
195 <name>title</name>
196 <string>DHCP Information</string>
197 </property>
198 <grid>
199 <property stdset="1">
200 <name>margin</name>
201 <number>11</number>
202 </property>
203 <property stdset="1">
204 <name>spacing</name>
205 <number>6</number>
206 </property>
207 <widget row="0" column="0" >
208 <class>QLabel</class>
209 <property stdset="1">
210 <name>name</name>
211 <cstring>TextLabel6</cstring>
212 </property>
213 <property stdset="1">
214 <name>text</name>
215 <string>DHCP Server</string>
216 </property>
217 </widget>
218 <widget row="2" column="1" >
219 <class>QLabel</class>
220 <property stdset="1">
221 <name>name</name>
222 <cstring>leaseExpiresLabel</cstring>
223 </property>
224 <property stdset="1">
225 <name>frameShape</name>
226 <enum>Panel</enum>
227 </property>
228 <property stdset="1">
229 <name>frameShadow</name>
230 <enum>Sunken</enum>
231 </property>
232 <property stdset="1">
233 <name>text</name>
234 <string></string>
235 </property>
236 </widget>
237 <widget row="1" column="1" >
238 <class>QLabel</class>
239 <property stdset="1">
240 <name>name</name>
241 <cstring>leaseObtainedLabel</cstring>
242 </property>
243 <property stdset="1">
244 <name>frameShape</name>
245 <enum>Panel</enum>
246 </property>
247 <property stdset="1">
248 <name>frameShadow</name>
249 <enum>Sunken</enum>
250 </property>
251 <property stdset="1">
252 <name>text</name>
253 <string></string>
254 </property>
255 </widget>
256 <widget row="2" column="0" >
257 <class>QLabel</class>
258 <property stdset="1">
259 <name>name</name>
260 <cstring>TextLabel9</cstring>
261 </property>
262 <property stdset="1">
263 <name>text</name>
264 <string>Lease Expires</string>
265 </property>
266 </widget>
267 <widget row="1" column="0" >
268 <class>QLabel</class>
269 <property stdset="1">
270 <name>name</name>
271 <cstring>TextLabel8</cstring>
272 </property>
273 <property stdset="1">
274 <name>text</name>
275 <string>Lease Obtained</string>
276 </property>
277 </widget>
278 <widget row="0" column="1" >
279 <class>QLabel</class>
280 <property stdset="1">
281 <name>name</name>
282 <cstring>dhcpServerLabel</cstring>
283 </property>
284 <property stdset="1">
285 <name>frameShape</name>
286 <enum>Panel</enum>
287 </property>
288 <property stdset="1">
289 <name>frameShadow</name>
290 <enum>Sunken</enum>
291 </property>
292 <property stdset="1">
293 <name>text</name>
294 <string></string>
295 </property>
296 </widget>
297 </grid>
298 </widget>
299 <spacer row="6" column="1" >
300 <property>
301 <name>name</name>
302 <cstring>Spacer2</cstring>
303 </property>
304 <property stdset="1">
305 <name>orientation</name>
306 <enum>Vertical</enum>
307 </property>
308 <property stdset="1">
309 <name>sizeType</name>
310 <enum>Expanding</enum>
311 </property>
312 <property>
313 <name>sizeHint</name>
314 <size>
315 <width>20</width>
316 <height>20</height>
317 </size>
318 </property>
319 </spacer>
320 </grid>
321</widget>
322<customwidgets>
323 <customwidget>
324 <class>QWidget</class>
325 <header location="local">qwidget.h</header>
326 <sizehint>
327 <width>100</width>
328 <height>100</height>
329 </sizehint>
330 <container>0</container>
331 <sizepolicy>
332 <hordata>7</hordata>
333 <verdata>7</verdata>
334 </sizepolicy>
335 <pixmap>image0</pixmap>
336 </customwidget>
337</customwidgets>
338<images>
339 <image>
340 <name>image0</name>
341 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
342 </image>
343</images>
344</UI>
diff --git a/noncore/settings/networksettings/interfaceedit.cpp b/noncore/settings/networksettings/interfaceedit.cpp
deleted file mode 100644
index 25599ef..0000000
--- a/noncore/settings/networksettings/interfaceedit.cpp
+++ b/dev/null
@@ -1,141 +0,0 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'interfaceedit.ui'
3**
4** Created: Mon Sep 23 12:18:55 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "interfaceedit.h"
10
11#include <qcheckbox.h>
12#include <qcombobox.h>
13#include <qframe.h>
14#include <qgroupbox.h>
15#include <qlabel.h>
16#include <qlineedit.h>
17#include <qpushbutton.h>
18#include <qspinbox.h>
19#include "qwidget.h"
20#include <qlayout.h>
21#include <qvariant.h>
22#include <qtooltip.h>
23#include <qwhatsthis.h>
24
25/*
26 * Constructs a InterfaceConfiguration which is a child of 'parent', with the
27 * name 'name' and widget flags set to 'f'
28 */
29InterfaceConfiguration::InterfaceConfiguration( QWidget* parent, const char* name, WFlags fl )
30 : QWidget( parent, name, fl )
31{
32 if ( !name )
33 setName( "InterfaceConfiguration" );
34 resize( 177, 306 );
35 setCaption( tr( "Interface Configuration" ) );
36 InterfaceConfigurationLayout = new QGridLayout( this );
37 InterfaceConfigurationLayout->setSpacing( 6 );
38 InterfaceConfigurationLayout->setMargin( 11 );
39
40 profile = new QComboBox( FALSE, this, "profile" );
41 profile->insertItem( tr( "All" ) );
42
43 InterfaceConfigurationLayout->addWidget( profile, 2, 1 );
44
45 TextLabel1 = new QLabel( this, "TextLabel1" );
46 TextLabel1->setText( tr( "Profile:" ) );
47
48 InterfaceConfigurationLayout->addWidget( TextLabel1, 2, 0 );
49
50 Line1 = new QFrame( this, "Line1" );
51 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
52
53 InterfaceConfigurationLayout->addMultiCellWidget( Line1, 1, 1, 0, 1 );
54
55 CheckBox3 = new QCheckBox( this, "CheckBox3" );
56 CheckBox3->setText( tr( "Automaticly bring up" ) );
57
58 InterfaceConfigurationLayout->addMultiCellWidget( CheckBox3, 0, 0, 0, 1 );
59
60 dhcpCheckBox = new QCheckBox( this, "dhcpCheckBox" );
61 dhcpCheckBox->setText( tr( "DHCP" ) );
62
63 InterfaceConfigurationLayout->addMultiCellWidget( dhcpCheckBox, 3, 3, 0, 1 );
64
65 TextLabel3_3_2 = new QLabel( this, "TextLabel3_3_2" );
66 TextLabel3_3_2->setText( tr( "Lease Hours" ) );
67
68 InterfaceConfigurationLayout->addWidget( TextLabel3_3_2, 4, 0 );
69
70 SpinBox1_2 = new QSpinBox( this, "SpinBox1_2" );
71 SpinBox1_2->setMaxValue( 336 );
72 SpinBox1_2->setMinValue( 1 );
73 SpinBox1_2->setValue( 24 );
74
75 InterfaceConfigurationLayout->addWidget( SpinBox1_2, 4, 1 );
76 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
77 InterfaceConfigurationLayout->addItem( spacer, 11, 1 );
78
79 TextLabel4 = new QLabel( this, "TextLabel4" );
80 TextLabel4->setText( tr( "IP Address" ) );
81
82 InterfaceConfigurationLayout->addWidget( TextLabel4, 6, 0 );
83
84 ipAddressEdit = new QLineEdit( this, "ipAddressEdit" );
85
86 InterfaceConfigurationLayout->addWidget( ipAddressEdit, 6, 1 );
87
88 TextLabel5 = new QLabel( this, "TextLabel5" );
89 TextLabel5->setText( tr( "Subnet Mask" ) );
90
91 InterfaceConfigurationLayout->addWidget( TextLabel5, 7, 0 );
92
93 firstDNSLineEdit = new QLineEdit( this, "firstDNSLineEdit" );
94
95 InterfaceConfigurationLayout->addWidget( firstDNSLineEdit, 9, 1 );
96
97 TextLabel3 = new QLabel( this, "TextLabel3" );
98 TextLabel3->setText( tr( "Second DNS" ) );
99
100 InterfaceConfigurationLayout->addWidget( TextLabel3, 10, 0 );
101
102 subnetMaskEdit = new QLineEdit( this, "subnetMaskEdit" );
103
104 InterfaceConfigurationLayout->addWidget( subnetMaskEdit, 7, 1 );
105
106 gatewayEdit = new QLineEdit( this, "gatewayEdit" );
107
108 InterfaceConfigurationLayout->addWidget( gatewayEdit, 8, 1 );
109
110 TextLabel7 = new QLabel( this, "TextLabel7" );
111 TextLabel7->setText( tr( "Gateway" ) );
112
113 InterfaceConfigurationLayout->addWidget( TextLabel7, 8, 0 );
114
115 TextLabel2 = new QLabel( this, "TextLabel2" );
116 TextLabel2->setText( tr( "First DNS" ) );
117
118 InterfaceConfigurationLayout->addWidget( TextLabel2, 9, 0 );
119
120 secondDNSLineEdit = new QLineEdit( this, "secondDNSLineEdit" );
121
122 InterfaceConfigurationLayout->addWidget( secondDNSLineEdit, 10, 1 );
123
124 GroupBox2 = new QGroupBox( this, "GroupBox2" );
125 GroupBox2->setTitle( tr( "Static Ip Configuration" ) );
126
127 InterfaceConfigurationLayout->addMultiCellWidget( GroupBox2, 5, 5, 0, 1 );
128
129 // signals and slots connections
130 connect( dhcpCheckBox, SIGNAL( toggled(bool) ), SpinBox1_2, SLOT( setEnabled(bool) ) );
131 connect( dhcpCheckBox, SIGNAL( toggled(bool) ), GroupBox2, SLOT( setDisabled(bool) ) );
132}
133
134/*
135 * Destroys the object and frees any allocated resources
136 */
137InterfaceConfiguration::~InterfaceConfiguration()
138{
139 // no need to delete child widgets, Qt does it all for us
140}
141
diff --git a/noncore/settings/networksettings/interfaceedit.h b/noncore/settings/networksettings/interfaceedit.h
deleted file mode 100644
index a65c030..0000000
--- a/noncore/settings/networksettings/interfaceedit.h
+++ b/dev/null
@@ -1,56 +0,0 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'interfaceedit.ui'
3**
4** Created: Mon Sep 23 12:18:55 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef INTERFACECONFIGURATION_H
10#define INTERFACECONFIGURATION_H
11
12#include <qvariant.h>
13#include <qwidget.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QCheckBox;
18class QComboBox;
19class QFrame;
20class QGroupBox;
21class QLabel;
22class QLineEdit;
23class QSpinBox;
24
25class InterfaceConfiguration : public QWidget
26{
27 Q_OBJECT
28
29public:
30 InterfaceConfiguration( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
31 ~InterfaceConfiguration();
32
33 QComboBox* profile;
34 QLabel* TextLabel1;
35 QFrame* Line1;
36 QCheckBox* CheckBox3;
37 QCheckBox* dhcpCheckBox;
38 QLabel* TextLabel3_3_2;
39 QSpinBox* SpinBox1_2;
40 QLabel* TextLabel4;
41 QLineEdit* ipAddressEdit;
42 QLabel* TextLabel5;
43 QLineEdit* firstDNSLineEdit;
44 QLabel* TextLabel3;
45 QLineEdit* subnetMaskEdit;
46 QLineEdit* gatewayEdit;
47 QLabel* TextLabel7;
48 QLabel* TextLabel2;
49 QLineEdit* secondDNSLineEdit;
50 QGroupBox* GroupBox2;
51
52protected:
53 QGridLayout* InterfaceConfigurationLayout;
54};
55
56#endif // INTERFACECONFIGURATION_H
diff --git a/noncore/settings/networksettings/interfaceinformation.ui b/noncore/settings/networksettings/interfaceinformation.ui
deleted file mode 100644
index 2838d19..0000000
--- a/noncore/settings/networksettings/interfaceinformation.ui
+++ b/dev/null
@@ -1,343 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>InterfaceInformation</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InterfaceInformation</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>219</width>
15 <height>255</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Interface Information</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget row="4" column="0" rowspan="1" colspan="2" >
32 <class>QLayoutWidget</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>Layout1</cstring>
36 </property>
37 <grid>
38 <property stdset="1">
39 <name>margin</name>
40 <number>0</number>
41 </property>
42 <property stdset="1">
43 <name>spacing</name>
44 <number>6</number>
45 </property>
46 <widget row="1" column="0" >
47 <class>QPushButton</class>
48 <property stdset="1">
49 <name>name</name>
50 <cstring>refreshButton</cstring>
51 </property>
52 <property stdset="1">
53 <name>text</name>
54 <string>&amp;Refresh</string>
55 </property>
56 </widget>
57 <widget row="0" column="1" >
58 <class>QPushButton</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>stopButton</cstring>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>S&amp;top</string>
66 </property>
67 </widget>
68 <widget row="1" column="1" >
69 <class>QPushButton</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>restartButton</cstring>
73 </property>
74 <property stdset="1">
75 <name>text</name>
76 <string>R&amp;estart</string>
77 </property>
78 </widget>
79 <widget row="0" column="0" >
80 <class>QPushButton</class>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>startButton</cstring>
84 </property>
85 <property stdset="1">
86 <name>text</name>
87 <string>&amp;Start</string>
88 </property>
89 </widget>
90 </grid>
91 </widget>
92 <widget row="0" column="0" >
93 <class>Line</class>
94 <property stdset="1">
95 <name>name</name>
96 <cstring>Line1</cstring>
97 </property>
98 <property stdset="1">
99 <name>orientation</name>
100 <enum>Horizontal</enum>
101 </property>
102 </widget>
103 <widget row="0" column="0" >
104 <class>QLabel</class>
105 <property stdset="1">
106 <name>name</name>
107 <cstring>TextLabel22</cstring>
108 </property>
109 <property stdset="1">
110 <name>text</name>
111 <string>IP Address</string>
112 </property>
113 </widget>
114 <widget row="1" column="0" >
115 <class>QLabel</class>
116 <property stdset="1">
117 <name>name</name>
118 <cstring>TextLabel23</cstring>
119 </property>
120 <property stdset="1">
121 <name>text</name>
122 <string>Subnet Mask</string>
123 </property>
124 </widget>
125 <widget row="2" column="0" >
126 <class>QLabel</class>
127 <property stdset="1">
128 <name>name</name>
129 <cstring>TextLabel21</cstring>
130 </property>
131 <property stdset="1">
132 <name>text</name>
133 <string>MAC Address</string>
134 </property>
135 </widget>
136 <widget row="3" column="0" >
137 <class>QLabel</class>
138 <property stdset="1">
139 <name>name</name>
140 <cstring>TextLabel24</cstring>
141 </property>
142 <property stdset="1">
143 <name>frameShape</name>
144 <enum>MShape</enum>
145 </property>
146 <property stdset="1">
147 <name>frameShadow</name>
148 <enum>MShadow</enum>
149 </property>
150 <property stdset="1">
151 <name>text</name>
152 <string>Broadcast</string>
153 </property>
154 </widget>
155 <widget row="1" column="1" >
156 <class>QLabel</class>
157 <property stdset="1">
158 <name>name</name>
159 <cstring>subnetMaskLabel</cstring>
160 </property>
161 <property stdset="1">
162 <name>frameShape</name>
163 <enum>Panel</enum>
164 </property>
165 <property stdset="1">
166 <name>frameShadow</name>
167 <enum>Sunken</enum>
168 </property>
169 <property stdset="1">
170 <name>text</name>
171 <string>0.0.0.0</string>
172 </property>
173 </widget>
174 <widget row="2" column="1" >
175 <class>QLabel</class>
176 <property stdset="1">
177 <name>name</name>
178 <cstring>macAddressLabel</cstring>
179 </property>
180 <property stdset="1">
181 <name>frameShape</name>
182 <enum>Panel</enum>
183 </property>
184 <property stdset="1">
185 <name>frameShadow</name>
186 <enum>Sunken</enum>
187 </property>
188 <property stdset="1">
189 <name>text</name>
190 <string>00:00:00:00:00:00</string>
191 </property>
192 </widget>
193 <widget row="3" column="1" >
194 <class>QLabel</class>
195 <property stdset="1">
196 <name>name</name>
197 <cstring>broadcastLabel</cstring>
198 </property>
199 <property stdset="1">
200 <name>frameShape</name>
201 <enum>Panel</enum>
202 </property>
203 <property stdset="1">
204 <name>frameShadow</name>
205 <enum>Sunken</enum>
206 </property>
207 <property stdset="1">
208 <name>text</name>
209 <string></string>
210 </property>
211 </widget>
212 <widget row="0" column="1" >
213 <class>QLabel</class>
214 <property stdset="1">
215 <name>name</name>
216 <cstring>ipAddressLabel</cstring>
217 </property>
218 <property stdset="1">
219 <name>frameShape</name>
220 <enum>Panel</enum>
221 </property>
222 <property stdset="1">
223 <name>frameShadow</name>
224 <enum>Sunken</enum>
225 </property>
226 <property stdset="1">
227 <name>text</name>
228 <string>0.0.0.0</string>
229 </property>
230 </widget>
231 <spacer row="7" column="1" >
232 <property>
233 <name>name</name>
234 <cstring>Spacer18</cstring>
235 </property>
236 <property stdset="1">
237 <name>orientation</name>
238 <enum>Vertical</enum>
239 </property>
240 <property stdset="1">
241 <name>sizeType</name>
242 <enum>Expanding</enum>
243 </property>
244 <property>
245 <name>sizeHint</name>
246 <size>
247 <width>20</width>
248 <height>20</height>
249 </size>
250 </property>
251 </spacer>
252 <widget row="6" column="0" rowspan="1" colspan="2" >
253 <class>QLayoutWidget</class>
254 <property stdset="1">
255 <name>name</name>
256 <cstring>Layout2</cstring>
257 </property>
258 <hbox>
259 <property stdset="1">
260 <name>margin</name>
261 <number>0</number>
262 </property>
263 <property stdset="1">
264 <name>spacing</name>
265 <number>6</number>
266 </property>
267 <spacer>
268 <property>
269 <name>name</name>
270 <cstring>Spacer10</cstring>
271 </property>
272 <property stdset="1">
273 <name>orientation</name>
274 <enum>Horizontal</enum>
275 </property>
276 <property stdset="1">
277 <name>sizeType</name>
278 <enum>Expanding</enum>
279 </property>
280 <property>
281 <name>sizeHint</name>
282 <size>
283 <width>20</width>
284 <height>20</height>
285 </size>
286 </property>
287 </spacer>
288 <widget>
289 <class>QPushButton</class>
290 <property stdset="1">
291 <name>name</name>
292 <cstring>advancedButton</cstring>
293 </property>
294 <property stdset="1">
295 <name>text</name>
296 <string>View &amp;Advanced Information</string>
297 </property>
298 </widget>
299 </hbox>
300 </widget>
301 <widget row="5" column="0" rowspan="1" colspan="2" >
302 <class>Line</class>
303 <property stdset="1">
304 <name>name</name>
305 <cstring>Line5</cstring>
306 </property>
307 <property stdset="1">
308 <name>orientation</name>
309 <enum>Horizontal</enum>
310 </property>
311 </widget>
312 </grid>
313</widget>
314<customwidgets>
315 <customwidget>
316 <class>QWidget</class>
317 <header location="local">qwidget.h</header>
318 <sizehint>
319 <width>100</width>
320 <height>100</height>
321 </sizehint>
322 <container>0</container>
323 <sizepolicy>
324 <hordata>7</hordata>
325 <verdata>7</verdata>
326 </sizepolicy>
327 <pixmap>image0</pixmap>
328 </customwidget>
329</customwidgets>
330<images>
331 <image>
332 <name>image0</name>
333 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
334 </image>
335</images>
336<tabstops>
337 <tabstop>startButton</tabstop>
338 <tabstop>stopButton</tabstop>
339 <tabstop>refreshButton</tabstop>
340 <tabstop>restartButton</tabstop>
341 <tabstop>advancedButton</tabstop>
342</tabstops>
343</UI>
diff --git a/noncore/settings/networksettings/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaceinformationimp.cpp
deleted file mode 100644
index 43483fb..0000000
--- a/noncore/settings/networksettings/interfaceinformationimp.cpp
+++ b/dev/null
@@ -1,70 +0,0 @@
1#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h"
3
4#include <qpushbutton.h>
5#include <qlabel.h>
6#include <qgroupbox.h>
7#include <assert.h>
8
9/**
10 * Constructor for the InterfaceInformationImp class. This class pretty much
11 * just display's information about the interface that is passed to it.
12 */
13InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){
14 assert(i);
15
16 interface = i;
17 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
18 updateInterface(interface);
19 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
20 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
21 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
22 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
23 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
24
25}
26
27/**
28 * Update the interface information and buttons.
29 * @param Intarface *i the interface to update (should be the one we already
30 * know about).
31 */
32void InterfaceInformationImp::updateInterface(Interface *i){
33 if(interface->getStatus()){
34 startButton->setEnabled(false);
35 stopButton->setEnabled(true);
36 restartButton->setEnabled(true);
37 }
38 else{
39 startButton->setEnabled(true);
40 stopButton->setEnabled(false);
41 restartButton->setEnabled(false);
42 }
43 macAddressLabel->setText(interface->getMacAddress());
44 ipAddressLabel->setText(interface->getIp());
45 subnetMaskLabel->setText(interface->getSubnetMask());
46 broadcastLabel->setText(interface->getBroadcast());
47}
48
49/**
50 * Create the advanced widget. Fill it with the current interface's information.
51 * Display it.
52 */
53void InterfaceInformationImp::advanced(){
54 InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced");
55 a->interfaceName->setText(interface->getInterfaceName());
56 a->macAddressLabel->setText(interface->getMacAddress());
57 a->ipAddressLabel->setText(interface->getIp());
58 a->subnetMaskLabel->setText(interface->getSubnetMask());
59 a->broadcastLabel->setText(interface->getBroadcast());
60 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
61 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
62 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
63 a->dhcpInformation->setEnabled(interface->isDhcp());
64
65 a->showMaximized();
66 a->show();
67}
68
69// infoimp.cpp
70
diff --git a/noncore/settings/networksettings/interfaceinformationimp.h b/noncore/settings/networksettings/interfaceinformationimp.h
deleted file mode 100644
index 42213cc..0000000
--- a/noncore/settings/networksettings/interfaceinformationimp.h
+++ b/dev/null
@@ -1,27 +0,0 @@
1#ifndef INTERFACEINFORMATIONIMP_H
2#define INTERFACEINFORMATIONIMP_H
3
4#include "interfaceinformation.h"
5#include "interface.h"
6
7class InterfaceInformationImp : public InterfaceInformation {
8
9Q_OBJECT
10
11public:
12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
13 ~InterfaceInformationImp(){};
14
15private slots:
16 void advanced();
17 void updateInterface(Interface *i);
18
19private:
20 Interface *interface;
21
22};
23
24#endif
25
26// addserviceimp.h
27
diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp
deleted file mode 100644
index 377a6db..0000000
--- a/noncore/settings/networksettings/interfaces.cpp
+++ b/dev/null
@@ -1,638 +0,0 @@
1#include "interfaces.h"
2
3#include <qfile.h>
4#include <qtextstream.h>
5#include <qregexp.h>
6
7#define AUTO "auto"
8#define IFACE "iface"
9#define MAPPING "mapping"
10
11/**
12 * Constructor. Reads in the interfaces file and then split the file up by
13 * the \n for interfaces variable.
14 * @param useInterfacesFile if an interface file other then the default is
15 * desired to be used it should be passed in.
16 */
17Interfaces::Interfaces(QString useInterfacesFile){
18 acceptedFamily.append(INTERFACES_FAMILY_INET);
19 acceptedFamily.append(INTERFACES_FAMILY_IPX);
20 acceptedFamily.append(INTERFACES_FAMILY_INET6);
21
22 interfacesFile = useInterfacesFile;
23 QFile file(interfacesFile);
24 if (!file.open(IO_ReadOnly)){
25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
26 currentIface = interfaces.end();
27 currentMapping = interfaces.end();
28 return;
29 }
30 QTextStream stream( &file );
31 QString line;
32 while ( !stream.eof() ) {
33 line += stream.readLine();
34 line += "\n";
35 }
36 file.close();
37 interfaces = QStringList::split("\n", line, true);
38
39 currentIface = interfaces.end();
40 currentMapping = interfaces.end();
41}
42
43
44/**
45 * Get a list of all interfaces in the interface file. Usefull for
46 * hardware that is not currently connected such as an 802.11b card
47 * not plugged in, but configured for when it is plugged in.
48 * @return Return string list of interfaces.
49 **/
50QStringList Interfaces::getInterfaceList(){
51 QStringList list;
52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
53 QString line = (*it).simplifyWhiteSpace();
54 if(line.contains(IFACE) && line.at(0) != '#'){
55 line = line.mid(QString(IFACE).length() +1, line.length());
56 line = line.simplifyWhiteSpace();
57 int findSpace = line.find(" ");
58 if( findSpace >= 0){
59 line = line.mid(0, findSpace);
60 list.append(line);
61 }
62 }
63 }
64 return list;
65}
66
67/**
68 * Find out if interface is in an "auto" group or not.
69 * Report any duplicates such as eth0 being in two differnt auto's
70 * @param interface interface to check to see if it is on or not.
71 * @return true is interface is in auto
72 */
73bool Interfaces::isAuto(QString interface){
74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
75 QStringList awi = autoLines.grep(QRegExp(interface));
76 if(awi.count() > 1)
77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
78 if(awi.count() < 1)
79 return false;
80 return true;
81}
82
83/**
84 * Attempt to set the auto option for interface to setAuto.
85 * @param interface the interface to set
86 * @param setAuto the value to set interface to.
87 * @return false if already set to setAuto.
88 * */
89bool Interfaces::setAuto(QString interface, bool setAuto){
90 // Don't need to set it if it is already set.
91 if(isAuto(interface) == setAuto)
92 return false;
93
94 bool changed = false;
95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
96 if((*it).contains(AUTO)){
97 //We know that they are not in any group so let add to this auto.
98 if(setAuto){
99 (*it) = (*it) += " " + interface;
100 // Don't care to have such thins as: auto eth0 lo usb0
101 (*it) = (*it).simplifyWhiteSpace();
102 changed = true;
103 break;
104 }
105 else{
106 if((*it).contains(interface)){
107 (*it) = (*it).replace(QRegExp(interface), "");
108 // clean up
109 QString line = (*it).simplifyWhiteSpace();
110 line = line.replace(QRegExp(" "),"");
111 if(line == AUTO)
112 (*it) = "";
113 changed = true;
114 // Don't break because we want to make sure we remove all cases.
115 }
116 }
117 }
118 }
119 if(changed == false){
120 if(setAuto == true)
121 interfaces.append(QString(AUTO" %1").arg(interface));
122 else{
123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
124 }
125 }
126 return true;
127}
128
129/**
130 * Set the current interface to interface. This needs to be done before you
131 * can call getFamily(), getMethod, and get/setOption().
132 * @param interface the name of the interface to set. All whitespace is
133 * removed from the interface name.
134 * @return bool true if it is successfull.
135 */
136bool Interfaces::setInterface(QString interface){
137 interface = interface.simplifyWhiteSpace();
138 interface = interface.replace(QRegExp(" "), "");
139 return setStanza(IFACE, interface, currentIface);
140}
141
142/**
143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise.
145 */
146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end());
148}
149
150/**
151 * Add a new interface of with the settings - family and method
152 * @param interface the name of the interface to set. All whitespace is
153 * removed from the interface name.
154 * @param family the family of this interface inet or inet, ipx or inet6
155 * Must of one of the families defined in interfaces.h
156 * @param method for the family. see interfaces man page for family methods.
157 * @return true if successfull.
158 */
159bool Interfaces::addInterface(QString interface, QString family, QString method){
160 if(acceptedFamily.contains(family)==0)
161 return false;
162 interface = interface.simplifyWhiteSpace();
163 interface = interface.replace(QRegExp(" "), "");
164 interfaces.append("");
165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
166 return true;
167}
168
169/**
170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface.
172 * @return bool true if successfull
173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){
175 if(!setInterface(interface)) return false;
176
177 QStringList::Iterator it = currentIface;
178 it++;
179
180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface;
184 newIface++;
185
186 for ( it; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break;
189 newIface = interfaces.insert(newIface, *it);
190 }
191
192 return true;
193}
194
195/**
196 * Remove the currently selected interface and all of its options.
197 * @return bool if successfull or not.
198 */
199bool Interfaces::removeInterface(){
200 if(currentIface == interfaces.end())
201 return false;
202 (*currentIface) = "";
203 return removeAllInterfaceOptions();
204}
205
206/**
207 * Gets the hardware name of the interface that is currently selected.
208 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
209 * @param error set to true if any error occurs, false otherwise.
210 */
211QString Interfaces::getInterfaceName(bool &error){
212 if(currentIface == interfaces.end()){
213 error = true;
214 return QString();
215 }
216 QString line = (*currentIface);
217 line = line.mid(QString(IFACE).length() +1, line.length());
218 line = line.simplifyWhiteSpace();
219 int findSpace = line.find(" ");
220 if( findSpace < 0){
221 error = true;
222 return QString();
223 }
224 error = false;
225 return line.mid(0, findSpace);
226}
227
228/**
229 * Gets the family name of the interface that is currently selected.
230 * @return QString name of the family (inet, inet6, ipx).
231 * @param error set to true if any error occurs, false otherwise.
232 */
233QString Interfaces::getInterfaceFamily(bool &error){
234 QString name = getInterfaceName(error);
235 if(error){
236 error = true;
237 return QString();
238 }
239 QString line = (*currentIface);
240 line = line.mid(QString(IFACE).length() +1, line.length());
241 line = line.mid(name.length()+1, line.length());
242 line = line.simplifyWhiteSpace();
243 int findSpace = line.find(" ");
244 if( findSpace < 0){
245 error = true;
246 return QString();
247 }
248 error = false;
249 return line.mid(0, findSpace);
250}
251
252/**
253 * Gets the method of the interface that is currently selected.
254 * @return QString name of the method such as staic or dhcp.
255 * See the man page of interfaces for possible methods depending on the family.
256 * @param error set to true if any error occurs, false otherwise.
257 */
258QString Interfaces::getInterfaceMethod(bool &error){
259 QString name = getInterfaceName(error);
260 if(error){
261 error = true;
262 return QString();
263 }
264 QString family = getInterfaceFamily(error);
265 if(error){
266 error = true;
267 return QString();
268 }
269 QString line = (*currentIface);
270 line = line.mid(QString(IFACE).length()+1, line.length());
271 line = line.mid(name.length()+1, line.length());
272 line = line.mid(family.length()+1, line.length());
273 line = line.simplifyWhiteSpace();
274 error = false;
275 return line;
276}
277
278/**
279 * Sets the interface name to newName.
280 * @param newName the new name of the interface. All whitespace is removed.
281 * @return bool true if successfull.
282 */
283bool Interfaces::setInterfaceName(QString newName){
284 if(currentIface == interfaces.end())
285 return false;
286 newName = newName.simplifyWhiteSpace();
287 newName = newName.replace(QRegExp(" "), "");
288 bool returnValue = false;
289 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
290 return !returnValue;
291}
292
293/**
294 * Sets the interface family to newName.
295 * @param newName the new name of the interface. Must be one of the families
296 * defined in the interfaces.h file.
297 * @return bool true if successfull.
298 */
299bool Interfaces::setInterfaceFamily(QString newName){
300 if(currentIface == interfaces.end())
301 return false;
302 if(acceptedFamily.contains(newName)==0)
303 return false;
304 bool returnValue = false;
305 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
306 return !returnValue;
307}
308
309/**
310 * Sets the interface method to newName
311 * @param newName the new name of the interface
312 * @return bool true if successfull.
313 */
314bool Interfaces::setInterfaceMethod(QString newName){
315 if(currentIface == interfaces.end())
316 return false;
317 bool returnValue = false;
318 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
319 return !returnValue;
320}
321
322/**
323 * Get a value for an option in the currently selected interface. For example
324 * calling getInterfaceOption("address") on the following stanza would
325 * return 192.168.1.1.
326 * iface eth0 static
327 * address 192.168.1.1
328 * @param option the options to get the value.
329 * @param error set to true if any error occurs, false otherwise.
330 * @return QString the options value. QString::null if error == true
331 */
332QString Interfaces::getInterfaceOption(QString option, bool &error){
333 return getOption(currentIface, option, error);
334}
335
336/**
337 * Set a value for an option in the currently selected interface. If option
338 * doesn't exist then it is added along with the value.
339 * @param option the options to set the value.
340 * @param value the value that option should be set to.
341 * @param error set to true if any error occurs, false otherwise.
342 * @return QString the options value. QString::null if error == true
343 */
344bool Interfaces::setInterfaceOption(QString option, QString value){
345 return setOption(currentIface, option, value);
346}
347
348/**
349 * Removes a value for an option in the currently selected interface.
350 * @param option the options to set the value.
351 * @param value the value that option should be set to.
352 * @param error set to true if any error occurs, false otherwise.
353 * @return QString the options value. QString::null if error == true
354 */
355bool Interfaces::removeInterfaceOption(QString option, QString value){
356 return removeOption(currentIface, option, value);
357}
358
359/**
360 * Removes all of the options from the currently selected interface.
361 * @return bool error if if successfull
362 */
363bool Interfaces::removeAllInterfaceOptions(){
364 return removeAllOptions(currentIface);
365}
366
367/**
368 * Set the current map to interface's map. This needs to be done before you
369 * can call addMapping(), set/getMap(), and get/setScript().
370 * @param interface the name of the interface to set. All whitespace is
371 * removed from the interface name.
372 * @return bool true if it is successfull.
373 */
374bool Interfaces::setMapping(QString interface){
375 interface = interface.simplifyWhiteSpace();
376 interface = interface.replace(QRegExp(" "), "");
377 return setStanza(MAPPING, interface, currentMapping);
378}
379
380/**
381 * Adds a new Mapping to the interfaces file with interfaces.
382 * @param interface the name(s) of the interfaces to set to this mapping
383 */
384void Interfaces::addMapping(QString option){
385 interfaces.append("");
386 interfaces.append(QString(MAPPING " %1").arg(option));
387}
388
389/**
390 * Remove the currently selected map and all of its options.
391 * @return bool if successfull or not.
392 */
393bool Interfaces::removeMapping(){
394 if(currentMapping == interfaces.end())
395 return false;
396 (*currentMapping) = "";
397 return removeAllOptions(currentMapping);
398}
399
400/**
401 * Set a map option within a mapping.
402 * @param map map to use
403 * @param value value to go with map
404 * @return bool true if it is successfull.
405 */
406bool Interfaces::setMap(QString map, QString value){
407 return setOption(currentMapping, map, value);
408}
409
410/**
411 * Removes a map option within a mapping.
412 * @param map map to use
413 * @param value value to go with map
414 * @return bool true if it is successfull.
415 */
416bool Interfaces::removeMap(QString map, QString value){
417 return removeOption(currentMapping, map, value);
418}
419
420/**
421 * Get a map value within a mapping.
422 * @param map map to get value of
423 * @param bool true if it is successfull.
424 * @return value that goes to the map
425 */
426QString Interfaces::getMap(QString map, bool &error){
427 return getOption(currentMapping, map, error);
428}
429
430/**
431 * Sets a script value of the current mapping to argument.
432 * @param argument the script name.
433 * @return true if successfull.
434 */
435bool Interfaces::setScript(QString argument){
436 return setOption(currentMapping, "script", argument);
437}
438
439/**
440 * @param error true if could not retrieve the current script argument.
441 * @return QString the argument of the script for the current mapping.
442 */
443QString Interfaces::getScript(bool &error){
444 return getOption(currentMapping, "script", error);
445}
446
447/**
448 * Helper function used to parse through the QStringList and put pointers in
449 * the correct place.
450 * @param stanza The stanza (auto, iface, mapping) to look for.
451 * @param option string that must be in the stanza's main line.
452 * @param interator interator to place at location of stanza if successfull.
453 * @return bool true if the stanza is found.
454 */
455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){
456 bool found = false;
457 iterator = interfaces.end();
458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
459 QString line = (*it).simplifyWhiteSpace();
460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
461 uint point = line.find(option);
462 bool valid = true;
463 if(point > 0){
464 // There are more chars in the line. check +1
465 if(line.at(point-1) != ' ')
466 valid = false;
467 }
468 point += option.length();
469 if(point < line.length()-1){
470 // There are more chars in the line. check -1
471 if(line.at(point) != ' ')
472 valid = false;
473 }
474 if(valid){
475 if(found == true){
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 }
478 found = true;
479 iterator = it;
480 }
481 }
482 }
483 return found;
484}
485
486/**
487 * Sets a value of an option in a stanza
488 * @param start the start of the stanza
489 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise.
491 */
492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){
493 if(start == interfaces.end())
494 return false;
495
496 bool found = false;
497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
499 if(!found && value != ""){
500 // Got to the end of the stanza without finding it, so append it.
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
502 }
503 found = true;
504 break;
505 }
506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it.
508 if(found)
509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
510 found = true;
511 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 }
513 }
514 if(!found){
515 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true;
518 }
519 return found;
520}
521/**
522 * Removes a option in a stanza
523 * @param start the start of the stanza
524 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise.
526 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
528 if(start == interfaces.end())
529 return false;
530
531 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it
535 break;
536 }
537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it.
539 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true;
542 (*it) = "";
543 }
544 }
545 return found;
546}
547
548/**
549 * Removes all options in a stanza
550 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise.
552 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){
554 if(start == interfaces.end())
555 return false;
556
557 QStringList::Iterator it = start;
558 it = ++it;
559 for (it; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break;
562 }
563 it = interfaces.remove(it);
564 it = --it;
565 }
566 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString(""));
568 return true;
569}
570
571/**
572 * Gets a value of an option in a stanza
573 * @param start the start of the stanza
574 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true.
577 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
579 if(start == interfaces.end()){
580 error = false;
581 return QString();
582 }
583
584 QString value;
585 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break;
589 }
590 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true;
594 QString line = (*it).simplifyWhiteSpace();
595 int space = line.find(" ", option.length());
596 if(space != -1)
597 value = line.mid(space+1, line.length());
598 else
599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
600 }
601 }
602 error = !found;
603 return value;
604}
605
606/**
607 * Write out the interfaces file to the file passed into the constructor.
608 * Removes any excess blank lines over 1 line long.
609 * @return bool true if successfull, false if not.
610 */
611bool Interfaces::write(){
612 QFile::remove(interfacesFile);
613 QFile file(interfacesFile);
614
615 if (!file.open(IO_ReadWrite)){
616 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
617 return false;
618 }
619 QTextStream stream( &file );
620 int whiteSpaceCount = 0;
621 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
622 QString line = (*it).simplifyWhiteSpace();
623 line = line.replace(QRegExp(" "),"");
624 if(line.length() == 0)
625 whiteSpaceCount++;
626 else
627 whiteSpaceCount = 0;
628 if(whiteSpaceCount < 2){
629 qDebug((*it).latin1());
630 stream << (*it) << '\n';
631 }
632 }
633 file.close();
634 return true;
635}
636
637// interfaces.cpp
638
diff --git a/noncore/settings/networksettings/interfaces.h b/noncore/settings/networksettings/interfaces.h
deleted file mode 100644
index e09ea71..0000000
--- a/noncore/settings/networksettings/interfaces.h
+++ b/dev/null
@@ -1,76 +0,0 @@
1#ifndef INTERFACES_H
2#define INTERFACES_H
3
4#include <qstring.h>
5#include <qstringlist.h>
6
7#define INTERFACES_LOOPBACK "loopback"
8
9#define INTERFACES_FAMILY_INET "inet"
10#define INTERFACES_FAMILY_IPX "ipx"
11#define INTERFACES_FAMILY_INET6 "inet6"
12
13#define INTERFACES_METHOD_DHCP "dhcp"
14#define INTERFACES_METHOD_STATIC "static"
15#define INTERFACES_METHOD_PPP "ppp"
16
17/**
18 * This class provides a clean frontend for parsing the network interfaces file.
19 * It provides helper functions to minipulate the options within the file.
20 * See the interfaces man page for the syntax rules.
21 */
22class Interfaces {
23
24public:
25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
26 QStringList getInterfaceList();
27
28 bool isAuto(QString interface);
29 bool setAuto(QString interface, bool setAuto);
30
31 bool removeInterface();
32 bool addInterface(QString interface, QString family, QString method);
33 bool copyInterface(QString oldInterface, QString newInterface);
34 bool setInterface(QString interface);
35 bool isInterfaceSet();
36 QString getInterfaceName(bool &error);
37 bool setInterfaceName(QString newName);
38 QString getInterfaceFamily(bool &error);
39 bool setInterfaceFamily(QString newName);
40 QString getInterfaceMethod(bool &error);
41 bool setInterfaceMethod(QString newName);
42 QString getInterfaceOption(QString option, bool &error);
43 bool setInterfaceOption(QString option, QString value);
44 bool removeInterfaceOption(QString option, QString value);
45 bool removeAllInterfaceOptions();
46
47 bool setMapping(QString interface);
48 bool removeMapping();
49 void addMapping(QString options);
50 bool setMap(QString map, QString value);
51 bool removeMap(QString map, QString value);
52 QString getMap(QString map, bool &error);
53 bool setScript(QString);
54 QString getScript(bool &error);
55
56 bool write();
57
58private:
59 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator);
60 bool setOption(QStringList::Iterator start, QString option, QString value);
61 bool removeOption(QStringList::Iterator start, QString option, QString value);
62 QString getOption(QStringList::Iterator start, QString option, bool &error);
63 bool removeAllOptions(QStringList::Iterator start);
64
65 QString interfacesFile;
66 QStringList interfaces;
67 QStringList::Iterator currentIface;
68 QStringList::Iterator currentMapping;
69
70 QStringList acceptedFamily;
71};
72
73#endif
74
75// interfaces
76
diff --git a/noncore/settings/networksettings/interfacesetup.ui b/noncore/settings/networksettings/interfacesetup.ui
deleted file mode 100644
index 0c834fe..0000000
--- a/noncore/settings/networksettings/interfacesetup.ui
+++ b/dev/null
@@ -1,284 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>InterfaceSetup</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>InterfaceSetup</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>290</width>
15 <height>280</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Interface Configuration</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QCheckBox</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>autoStart</cstring>
36 </property>
37 <property stdset="1">
38 <name>text</name>
39 <string>Automatically bring up</string>
40 </property>
41 </widget>
42 <widget>
43 <class>QLayoutWidget</class>
44 <property stdset="1">
45 <name>name</name>
46 <cstring>Layout9</cstring>
47 </property>
48 <hbox>
49 <property stdset="1">
50 <name>margin</name>
51 <number>0</number>
52 </property>
53 <property stdset="1">
54 <name>spacing</name>
55 <number>6</number>
56 </property>
57 <widget>
58 <class>QCheckBox</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>dhcpCheckBox</cstring>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>DHCP</string>
66 </property>
67 <property stdset="1">
68 <name>checked</name>
69 <bool>true</bool>
70 </property>
71 </widget>
72 <widget>
73 <class>QLabel</class>
74 <property stdset="1">
75 <name>name</name>
76 <cstring>leaseHoursLabel</cstring>
77 </property>
78 <property stdset="1">
79 <name>text</name>
80 <string>Requested Lease</string>
81 </property>
82 </widget>
83 <widget>
84 <class>QSpinBox</class>
85 <property stdset="1">
86 <name>name</name>
87 <cstring>leaseTime</cstring>
88 </property>
89 <property stdset="1">
90 <name>suffix</name>
91 <string> hours</string>
92 </property>
93 <property stdset="1">
94 <name>maxValue</name>
95 <number>87600</number>
96 </property>
97 <property stdset="1">
98 <name>minValue</name>
99 <number>1</number>
100 </property>
101 <property stdset="1">
102 <name>value</name>
103 <number>168</number>
104 </property>
105 </widget>
106 </hbox>
107 </widget>
108 <widget>
109 <class>QGroupBox</class>
110 <property stdset="1">
111 <name>name</name>
112 <cstring>staticGroupBox</cstring>
113 </property>
114 <property stdset="1">
115 <name>enabled</name>
116 <bool>false</bool>
117 </property>
118 <property stdset="1">
119 <name>frameShape</name>
120 <enum>Box</enum>
121 </property>
122 <property stdset="1">
123 <name>frameShadow</name>
124 <enum>Sunken</enum>
125 </property>
126 <property stdset="1">
127 <name>title</name>
128 <string>Static Ip Configuration</string>
129 </property>
130 <grid>
131 <property stdset="1">
132 <name>margin</name>
133 <number>11</number>
134 </property>
135 <property stdset="1">
136 <name>spacing</name>
137 <number>6</number>
138 </property>
139 <widget row="1" column="0" >
140 <class>QLabel</class>
141 <property stdset="1">
142 <name>name</name>
143 <cstring>TextLabel5</cstring>
144 </property>
145 <property stdset="1">
146 <name>text</name>
147 <string>Subnet Mask</string>
148 </property>
149 </widget>
150 <widget row="2" column="1" >
151 <class>QLineEdit</class>
152 <property stdset="1">
153 <name>name</name>
154 <cstring>gatewayEdit</cstring>
155 </property>
156 </widget>
157 <widget row="1" column="1" >
158 <class>QLineEdit</class>
159 <property stdset="1">
160 <name>name</name>
161 <cstring>subnetMaskEdit</cstring>
162 </property>
163 </widget>
164 <widget row="0" column="1" >
165 <class>QLineEdit</class>
166 <property stdset="1">
167 <name>name</name>
168 <cstring>ipAddressEdit</cstring>
169 </property>
170 </widget>
171 <widget row="3" column="0" >
172 <class>QLabel</class>
173 <property stdset="1">
174 <name>name</name>
175 <cstring>TextLabel2</cstring>
176 </property>
177 <property stdset="1">
178 <name>text</name>
179 <string>First DNS</string>
180 </property>
181 </widget>
182 <widget row="0" column="0" >
183 <class>QLabel</class>
184 <property stdset="1">
185 <name>name</name>
186 <cstring>TextLabel4</cstring>
187 </property>
188 <property stdset="1">
189 <name>text</name>
190 <string>IP Address</string>
191 </property>
192 </widget>
193 <widget row="2" column="0" >
194 <class>QLabel</class>
195 <property stdset="1">
196 <name>name</name>
197 <cstring>TextLabel1_2</cstring>
198 </property>
199 <property stdset="1">
200 <name>text</name>
201 <string>Gateway</string>
202 </property>
203 </widget>
204 <widget row="4" column="0" >
205 <class>QLabel</class>
206 <property stdset="1">
207 <name>name</name>
208 <cstring>TextLabel3</cstring>
209 </property>
210 <property stdset="1">
211 <name>text</name>
212 <string>Second DNS</string>
213 </property>
214 </widget>
215 <widget row="3" column="1" >
216 <class>QLineEdit</class>
217 <property stdset="1">
218 <name>name</name>
219 <cstring>firstDNSLineEdit</cstring>
220 </property>
221 </widget>
222 <widget row="4" column="1" >
223 <class>QLineEdit</class>
224 <property stdset="1">
225 <name>name</name>
226 <cstring>secondDNSLineEdit</cstring>
227 </property>
228 </widget>
229 </grid>
230 </widget>
231 <spacer>
232 <property>
233 <name>name</name>
234 <cstring>Spacer9</cstring>
235 </property>
236 <property stdset="1">
237 <name>orientation</name>
238 <enum>Vertical</enum>
239 </property>
240 <property stdset="1">
241 <name>sizeType</name>
242 <enum>Expanding</enum>
243 </property>
244 <property>
245 <name>sizeHint</name>
246 <size>
247 <width>20</width>
248 <height>20</height>
249 </size>
250 </property>
251 </spacer>
252 </vbox>
253</widget>
254<connections>
255 <connection>
256 <sender>dhcpCheckBox</sender>
257 <signal>toggled(bool)</signal>
258 <receiver>leaseHoursLabel</receiver>
259 <slot>setEnabled(bool)</slot>
260 </connection>
261 <connection>
262 <sender>dhcpCheckBox</sender>
263 <signal>toggled(bool)</signal>
264 <receiver>leaseTime</receiver>
265 <slot>setEnabled(bool)</slot>
266 </connection>
267 <connection>
268 <sender>dhcpCheckBox</sender>
269 <signal>toggled(bool)</signal>
270 <receiver>staticGroupBox</receiver>
271 <slot>setDisabled(bool)</slot>
272 </connection>
273</connections>
274<tabstops>
275 <tabstop>autoStart</tabstop>
276 <tabstop>dhcpCheckBox</tabstop>
277 <tabstop>leaseTime</tabstop>
278 <tabstop>ipAddressEdit</tabstop>
279 <tabstop>subnetMaskEdit</tabstop>
280 <tabstop>gatewayEdit</tabstop>
281 <tabstop>firstDNSLineEdit</tabstop>
282 <tabstop>secondDNSLineEdit</tabstop>
283</tabstops>
284</UI>
diff --git a/noncore/settings/networksettings/interfacesetupimp.cpp b/noncore/settings/networksettings/interfacesetupimp.cpp
deleted file mode 100644
index a8731a9..0000000
--- a/noncore/settings/networksettings/interfacesetupimp.cpp
+++ b/dev/null
@@ -1,147 +0,0 @@
1#include "interfacesetupimp.h"
2#include "interface.h"
3#include "interfaces.h"
4
5#include <qcombobox.h>
6#include <qcheckbox.h>
7#include <qlineedit.h>
8#include <qspinbox.h>
9#include <qgroupbox.h>
10#include <qlabel.h>
11
12#include <qmessagebox.h>
13
14#include <assert.h>
15
16#define DNSSCRIPT "interfacednsscript"
17
18/**
19 * Constuctor. Set up the connection and load the first profile.
20 */
21InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){
22 assert(i);
23 interface = i;
24 interfaces = new Interfaces();
25 bool error = false;
26 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
27 staticGroupBox->hide();
28 dhcpCheckBox->hide();
29 leaseTime->hide();
30 leaseHoursLabel->hide();
31 }
32}
33
34/**
35 * Save the current settings, then write out the interfaces file and close.
36 */
37void InterfaceSetupImp::accept(){
38 if(!saveSettings())
39 return;
40 interfaces->write();
41 QDialog::accept();
42}
43
44/**
45 * Save the settings for the current Interface.
46 * @return bool true if successfull, false otherwise
47 */
48bool InterfaceSetupImp::saveSettings(){
49 // eh can't really do anything about it other then return. :-D
50 if(!interfaces->isInterfaceSet())
51 return true;
52
53 bool error = false;
54 // Loopback case
55 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
56 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
57 return true;
58 }
59
60 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){
61 QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok");
62 return false;
63 }
64 interfaces->removeAllInterfaceOptions();
65
66 // DHCP
67 if(dhcpCheckBox->isChecked()){
68 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
69 interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value()));
70 interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60));
71 }
72 else{
73 interfaces->setInterfaceMethod("static");
74 interfaces->setInterfaceOption("address", ipAddressEdit->text());
75 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
76 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
77 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
78 interfaces->setInterfaceOption("up "DNSSCRIPT" add ", dns);
79 interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns);
80 }
81
82 // IP Information
83 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
84 return true;
85}
86
87/**
88 * The Profile has changed.
89 * @profile the new profile.
90 */
91void InterfaceSetupImp::setProfile(const QString &profile){
92 QString newInterfaceName = interface->getInterfaceName();
93 if(profile.length() > 0)
94 newInterfaceName += "_" + profile;
95 // See if we have to make a interface.
96 if(!interfaces->setInterface(newInterfaceName)){
97 // Add making for this new interface if need too
98 if(profile != ""){
99 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
100 if(!interfaces->setMapping(interface->getInterfaceName())){
101 interfaces->addMapping(interface->getInterfaceName());
102 if(!interfaces->setMapping(interface->getInterfaceName())){
103 qDebug("InterfaceSetupImp: Added Mapping, but still can't set.");
104 return;
105 }
106 }
107 interfaces->setMap("map", newInterfaceName);
108 interfaces->setScript("getprofile.sh");
109 }
110 else{
111 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
112 if(!interfaces->setInterface(newInterfaceName)){
113 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
114 return;
115 }
116 }
117 }
118
119 // We must have a valid interface to get this far so read some settings.
120
121 // DHCP
122 bool error = false;
123 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
124 dhcpCheckBox->setChecked(true);
125 else
126 dhcpCheckBox->setChecked(false);
127 leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt());
128 if(error)
129 leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60);
130 if(error)
131 leaseTime->setValue(24);
132
133 // IP Information
134 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
135 QString dns = interfaces->getInterfaceOption("up interfacednsscript add", error);
136 if(dns.contains(" ")){
137 firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
138 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
139 }
140 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
141 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
142 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
143}
144
145
146// interfacesetup.cpp
147
diff --git a/noncore/settings/networksettings/interfacesetupimp.h b/noncore/settings/networksettings/interfacesetupimp.h
deleted file mode 100644
index a0bec32..0000000
--- a/noncore/settings/networksettings/interfacesetupimp.h
+++ b/dev/null
@@ -1,31 +0,0 @@
1#ifndef INTERFACESETUPIMP_H
2#define INTERFACESETUPIMP_H
3
4#include "interfacesetup.h"
5
6class Interface;
7class Interfaces;
8
9class InterfaceSetupImp : public InterfaceSetup {
10 Q_OBJECT
11
12public:
13 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0);
14
15protected slots:
16 void accept();
17
18public slots:
19 void setProfile(const QString &profile);
20
21private:
22 bool saveSettings();
23 Interfaces *interfaces;
24 Interface *interface;
25
26};
27
28#endif
29
30// interfacesetupimp.h
31
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index f9ca83b..b9fff56 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -9,7 +9,6 @@
9#include "kprocess.h" 9#include "kprocess.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtabwidget.h>
13#include <qlistbox.h> 12#include <qlistbox.h>
14#include <qlineedit.h> 13#include <qlineedit.h>
15#include <qlistview.h> 14#include <qlistview.h>
@@ -95,6 +94,7 @@ MainWindowImp::~MainWindowImp(){
95 for( it = libraries.begin(); it != libraries.end(); ++it ){ 94 for( it = libraries.begin(); it != libraries.end(); ++it ){
96 delete it.key(); 95 delete it.key();
97 // I wonder why I can't delete the libraries 96 // I wonder why I can't delete the libraries
97 // What fucking shit this is.
98 //delete it.data(); 98 //delete it.data();
99 } 99 }
100} 100}
@@ -221,8 +221,7 @@ void MainWindowImp::removeClicked(){
221/** 221/**
222 * Pull up the configure about the currently selected interface. 222 * Pull up the configure about the currently selected interface.
223 * Report an error if no interface is selected. 223 * Report an error if no interface is selected.
224 * If the interface has a module owner then request its configure with a empty 224 * If the interface has a module owner then request its configure.
225 * tab. If tab is !NULL then append the interfaces setup widget to it.
226 */ 225 */
227void MainWindowImp::configureClicked(){ 226void MainWindowImp::configureClicked(){
228 QListViewItem *item = connectionList->currentItem(); 227 QListViewItem *item = connectionList->currentItem();
@@ -239,22 +238,16 @@ void MainWindowImp::configureClicked(){
239 Interface *i = interfaceItems[item]; 238 Interface *i = interfaceItems[item];
240 if(i->getModuleOwner()){ 239 if(i->getModuleOwner()){
241 i->getModuleOwner()->setProfile(currentProfile); 240 i->getModuleOwner()->setProfile(currentProfile);
242 QTabWidget *tabWidget = NULL; 241 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
243 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
244 if(moduleConfigure != NULL){ 242 if(moduleConfigure != NULL){
245 if(tabWidget != NULL){
246 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
247 configure->setProfile(currentProfile);
248 tabWidget->insertTab(configure, "TCP/IP");
249 }
250 moduleConfigure->showMaximized(); 243 moduleConfigure->showMaximized();
251 moduleConfigure->show(); 244 moduleConfigure->show();
252 return; 245 return;
253 } 246 }
254 } 247 }
255 248
256 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose); 249 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose);
257 configure->setProfile(currentProfile); 250 //configure->setProfile(currentProfile);
258 configure->showMaximized(); 251 configure->showMaximized();
259 configure->show(); 252 configure->show();
260} 253}
@@ -262,8 +255,7 @@ void MainWindowImp::configureClicked(){
262/** 255/**
263 * Pull up the information about the currently selected interface. 256 * Pull up the information about the currently selected interface.
264 * Report an error if no interface is selected. 257 * Report an error if no interface is selected.
265 * If the interface has a module owner then request its configure with a empty 258 * If the interface has a module owner then request its configure.
266 * tab. If tab is !NULL then append the interfaces setup widget to it.
267 */ 259 */
268void MainWindowImp::informationClicked(){ 260void MainWindowImp::informationClicked(){
269 QListViewItem *item = connectionList->currentItem(); 261 QListViewItem *item = connectionList->currentItem();
@@ -284,19 +276,13 @@ void MainWindowImp::informationClicked(){
284 } 276 }
285 277
286 if(i->getModuleOwner()){ 278 if(i->getModuleOwner()){
287 QTabWidget *tabWidget = NULL; 279 QWidget *moduleInformation = i->getModuleOwner()->information(i);
288 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
289 if(moduleInformation != NULL){ 280 if(moduleInformation != NULL){
290 if(tabWidget != NULL){
291 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
292 tabWidget->insertTab(information, "TCP/IP");
293 }
294 moduleInformation->showMaximized(); 281 moduleInformation->showMaximized();
295 moduleInformation->show(); 282 moduleInformation->show();
296 return; 283 return;
297 } 284 }
298 } 285 }
299
300 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 286 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
301 information->showMaximized(); 287 information->showMaximized();
302 information->show(); 288 information->show();
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h
index 96db5b3..92b125a 100644
--- a/noncore/settings/networksettings/module.h
+++ b/noncore/settings/networksettings/module.h
@@ -39,20 +39,18 @@ public:
39 virtual bool isOwner(Interface *){ return false; }; 39 virtual bool isOwner(Interface *){ return false; };
40 40
41 /** 41 /**
42 * Create, set tabWiget and return the WLANConfigure Module 42 * Create and return the WLANConfigure Module
43 * @param Interface *i the interface to configure. 43 * @param Interface *i the interface to configure.
44 * @param tabWidget a pointer to the tab widget that this configure has. 44 * @return QWidget* pointer to this modules configure.
45 * @return QWidget* pointer to the tab widget in this modules configure.
46 */ 45 */
47 virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ; 46 virtual QWidget *configure(Interface *){ return NULL; } ;
48 47
49 /** 48 /**
50 * Create, set tabWiget and return the Information Module 49 * Create, and return the Information Module
51 * @param Interface *i the interface to get info on. 50 * @param Interface *i the interface to get info on.
52 * @param tabWidget a pointer to the tab widget that this information has. 51 * @return QWidget* pointer to this modules info.
53 * @return QWidget* pointer to the tab widget in this modules info.
54 */ 52 */
55 virtual QWidget *information(Interface *, QTabWidget **){ return NULL; }; 53 virtual QWidget *information(Interface *){ return NULL; };
56 54
57 /** 55 /**
58 * Get all active (up or down) interfaces 56 * Get all active (up or down) interfaces
diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro
index f09db93..9f28fbd 100644
--- a/noncore/settings/networksettings/networksetup.pro
+++ b/noncore/settings/networksettings/networksetup.pro
@@ -1,11 +1,11 @@
1 DESTDIR = $(OPIEDIR)/bin 1 #DESTDIR = $(OPIEDIR)/bin
2 TEMPLATE= app 2 TEMPLATE= app
3 #CONFIG = qt warn_on debug 3 #CONFIG = qt warn_on debug
4 CONFIG = qt warn_on release 4 CONFIG = qt warn_on release
5 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h 5 HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h
6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp 6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include 7 INCLUDEPATH+= $(OPIEDIR)/include interfaces/
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include interfaces/ wlan
9LIBS += -lqpe 9LIBS += -lqpe -Linterfaces -linterfaces
10 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui 10 INTERFACES= mainwindow.ui addconnection.ui
11 TARGET = networksetup 11 TARGET = networksetup
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp
index e545bd1..eb6fc42 100644
--- a/noncore/settings/networksettings/wlan/wextensions.cpp
+++ b/noncore/settings/networksettings/wlan/wextensions.cpp
@@ -16,9 +16,11 @@
16/** 16/**
17 * Constructor. Sets hasWirelessExtensions 17 * Constructor. Sets hasWirelessExtensions
18 */ 18 */
19WExtensions::WExtensions(QString interfaceName){ 19WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){
20 interface = interfaceName; 20 interface = interfaceName;
21 fd = socket( AF_INET, SOCK_DGRAM, 0 ); 21 fd = socket( AF_INET, SOCK_DGRAM, 0 );
22 if(fd == -1)
23 return;
22 24
23 const char* buffer[200]; 25 const char* buffer[200];
24 memset( &iwr, 0, sizeof( iwr ) ); 26 memset( &iwr, 0, sizeof( iwr ) );
@@ -35,8 +37,6 @@ WExtensions::WExtensions(QString interfaceName){
35 strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); 37 strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
36 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) 38 if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) )
37 hasWirelessExtensions = true; 39 hasWirelessExtensions = true;
38 else
39 hasWirelessExtensions = false;
40} 40}
41 41
42/** 42/**
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro
index f28feb2..23fc39a 100644
--- a/noncore/settings/networksettings/wlan/wlan.pro
+++ b/noncore/settings/networksettings/wlan/wlan.pro
@@ -4,9 +4,9 @@ CONFIG += qt warn_on release
4DESTDIR = $(OPIEDIR)/plugins/networksetup 4DESTDIR = $(OPIEDIR)/plugins/networksetup
5 HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h 5 HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h
6 SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp 6 SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include ../ 7 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe -L../interfaces/ -linterfaces
10 INTERFACES= wlan.ui info.ui 10 INTERFACES= wlan.ui info.ui
11 TARGET = wlanplugin 11 TARGET = wlanplugin
12 VERSION = 1.0.0 12 VERSION = 1.0.0
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 45952b9..7c902e0 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -15,10 +15,18 @@
15#include <qradiobutton.h> 15#include <qradiobutton.h>
16#include <qcheckbox.h> 16#include <qcheckbox.h>
17#include <qregexp.h> 17#include <qregexp.h>
18#include <qpe/config.h>
19#include <qtabwidget.h>
20#include "interfacesetupimp.h"
18 21
19WLANImp::WLANImp( QWidget* parent, const char* name, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ 22WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){
20 config = new Config("wireless"); 23 config = new Config("wireless");
24 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose);
25 //configure->setProfile(currentProfile);
26 tabWidget->insertTab(interfaceSetup, "TCP/IP");
27
21 readConfig(); 28 readConfig();
29
22} 30}
23 31
24WLANImp::~WLANImp( ){ 32WLANImp::~WLANImp( ){
@@ -109,8 +117,10 @@ bool WLANImp::writeConfig()
109 */ 117 */
110void WLANImp::accept() 118void WLANImp::accept()
111{ 119{
112 if ( writeConfig() ) 120 if ( writeConfig() ){
121 interfaceSetup->saveChanges();
113 QDialog::accept(); 122 QDialog::accept();
123 }
114} 124}
115 125
116bool WLANImp::writeWirelessOpts( QString scheme ) 126bool WLANImp::writeWirelessOpts( QString scheme )
diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h
index 59b7c59..608d681 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.h
+++ b/noncore/settings/networksettings/wlan/wlanimp.h
@@ -3,13 +3,15 @@
3 3
4#include "wlan.h" 4#include "wlan.h"
5 5
6#include <qpe/config.h> 6class InterfaceSetupImp;
7class Interface;
8class Config;
7 9
8class WLANImp : public WLAN { 10class WLANImp : public WLAN {
9 Q_OBJECT 11 Q_OBJECT
10 12
11public: 13public:
12 WLANImp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 14 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
13 ~WLANImp( ); 15 ~WLANImp( );
14 16
15protected: 17protected:
@@ -21,6 +23,8 @@ private:
21 bool writeWirelessOpts( QString scheme = "*" ); 23 bool writeWirelessOpts( QString scheme = "*" );
22 bool writeWlanngOpts( QString scheme = "*" ); 24 bool writeWlanngOpts( QString scheme = "*" );
23 Config* config; 25 Config* config;
26 InterfaceSetupImp *interfaceSetup;
27
24}; 28};
25 29
26#endif 30#endif
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 9ab3b76..c8becb0 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -2,9 +2,11 @@
2#include "wlanimp.h" 2#include "wlanimp.h"
3#include "infoimp.h" 3#include "infoimp.h"
4#include "wextensions.h" 4#include "wextensions.h"
5#include "interfaceinformationimp.h"
5 6
6#include <qlabel.h> 7#include <qlabel.h>
7#include <qprogressbar.h> 8#include <qprogressbar.h>
9#include <qtabwidget.h>
8 10
9/** 11/**
10 * Constructor, find all of the possible interfaces 12 * Constructor, find all of the possible interfaces
@@ -53,28 +55,26 @@ bool WLANModule::isOwner(Interface *i){
53} 55}
54 56
55/** 57/**
56 * Create, set tabWiget and return the WLANConfigure Module 58 * Create, and return the WLANConfigure Module
57 * @param tabWidget a pointer to the tab widget that this configure has. 59 * @return QWidget* pointer to this modules configure.
58 * @return QWidget* pointer to the tab widget in this modules configure.
59 */ 60 */
60QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ 61QWidget *WLANModule::configure(Interface *i){
61 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose); 62 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose);
62 (*tabWidget) = wlanconfig->tabWidget;
63 return wlanconfig; 63 return wlanconfig;
64} 64}
65 65
66/** 66/**
67 * Create, set tabWiget and return the Information Module 67 * Create, and return the Information Module
68 * @param tabWidget a pointer to the tab widget that this information has. 68 * @return QWidget* pointer to this modules info.
69 * @return QWidget* pointer to the tab widget in this modules info.
70 */ 69 */
71QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 70QWidget *WLANModule::information(Interface *i){
72 WExtensions we(i->getInterfaceName()); 71 WExtensions we(i->getInterfaceName());
73 if(!we.doesHaveWirelessExtensions()) 72 if(!we.doesHaveWirelessExtensions())
74 return NULL; 73 return NULL;
75 74
76 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 75 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
77 (*tabWidget) = info->tabWidget; 76 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
77 info->tabWidget->insertTab(information, "TCP/IP");
78 return info; 78 return info;
79} 79}
80 80
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h
index 1418ce8..a81ccff 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.h
+++ b/noncore/settings/networksettings/wlan/wlanmodule.h
@@ -14,8 +14,8 @@ public:
14 14
15 virtual void setProfile(QString newProfile); 15 virtual void setProfile(QString newProfile);
16 virtual bool isOwner(Interface *); 16 virtual bool isOwner(Interface *);
17 virtual QWidget *configure(Interface *i, QTabWidget **tabWidget); 17 virtual QWidget *configure(Interface *i);
18 virtual QWidget *information(Interface *i, QTabWidget **tabWidget); 18 virtual QWidget *information(Interface *i);
19 virtual QList<Interface> getInterfaces(); 19 virtual QList<Interface> getInterfaces();
20 virtual void possibleNewInterfaces(QMap<QString, QString> &){}; 20 virtual void possibleNewInterfaces(QMap<QString, QString> &){};
21 virtual Interface *addNewInterface(QString name); 21 virtual Interface *addNewInterface(QString name);