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,9 +1,11 @@ | |||
1 | Make sure the C code in wextensions is clean. | ||
2 | |||
1 | WLAN needs to be re-written to not use Config | 3 | WLAN needs to be re-written to not use Config |
2 | WHERE Is DHCP info stored??? | 4 | WHERE Is DHCP info stored??? |
3 | 5 | ||
4 | PPP module needs to be written | 6 | PPP module needs to be written |
5 | 7 | ||
6 | Write a class that parses /proc and not ifconfig | 8 | Write a class that parses /proc and not ifconfig |
7 | 9 | ||
8 | Possible other modules: ipsec, bluetooth, ipchains | 10 | Possible other modules: ipsec, bluetooth, ipchains |
9 | 11 | ||
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 | |||
14 | Interface::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 | */ | ||
23 | void 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 | */ | ||
35 | void 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 | */ | ||
45 | void 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 | */ | ||
55 | void Interface::setModuleOwner(Module *owner){ | ||
56 | moduleOwner = owner; | ||
57 | emit(updateInterface(this)); | ||
58 | }; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Try to start the interface. | ||
63 | */ | ||
64 | void 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 | */ | ||
81 | void 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 | */ | ||
97 | void 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 | */ | ||
107 | bool 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 | |||
7 | class Module; | ||
8 | |||
9 | class Interface : public QObject{ | ||
10 | Q_OBJECT | ||
11 | |||
12 | signals: | ||
13 | void updateInterface(Interface *i); | ||
14 | |||
15 | public: | ||
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 | |||
43 | public slots: | ||
44 | bool refresh(); | ||
45 | void start(); | ||
46 | void stop(); | ||
47 | void restart(); | ||
48 | |||
49 | private: | ||
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 | */ | ||
29 | InterfaceConfiguration::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 | */ | ||
137 | InterfaceConfiguration::~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> | ||
14 | class QVBoxLayout; | ||
15 | class QHBoxLayout; | ||
16 | class QGridLayout; | ||
17 | class QCheckBox; | ||
18 | class QComboBox; | ||
19 | class QFrame; | ||
20 | class QGroupBox; | ||
21 | class QLabel; | ||
22 | class QLineEdit; | ||
23 | class QSpinBox; | ||
24 | |||
25 | class InterfaceConfiguration : public QWidget | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | |||
29 | public: | ||
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 | |||
52 | protected: | ||
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>&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&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&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>&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 &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 | */ | ||
13 | InterfaceInformationImp::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 | */ | ||
32 | void 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 | */ | ||
53 | void 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 | |||
7 | class InterfaceInformationImp : public InterfaceInformation { | ||
8 | |||
9 | Q_OBJECT | ||
10 | |||
11 | public: | ||
12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | ||
13 | ~InterfaceInformationImp(){}; | ||
14 | |||
15 | private slots: | ||
16 | void advanced(); | ||
17 | void updateInterface(Interface *i); | ||
18 | |||
19 | private: | ||
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 | */ | ||
17 | Interfaces::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 | **/ | ||
50 | QStringList 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 | */ | ||
73 | bool 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 | * */ | ||
89 | bool 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 | */ | ||
136 | bool 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 | */ | ||
146 | bool 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 | */ | ||
159 | bool 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 | */ | ||
174 | bool 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 | */ | ||
199 | bool 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 | */ | ||
211 | QString 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 | */ | ||
233 | QString 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 | */ | ||
258 | QString 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 | */ | ||
283 | bool 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 | */ | ||
299 | bool 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 | */ | ||
314 | bool 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 | */ | ||
332 | QString 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 | */ | ||
344 | bool 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 | */ | ||
355 | bool 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 | */ | ||
363 | bool 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 | */ | ||
374 | bool 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 | */ | ||
384 | void 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 | */ | ||
393 | bool 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 | */ | ||
406 | bool 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 | */ | ||
416 | bool 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 | */ | ||
426 | QString 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 | */ | ||
435 | bool 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 | */ | ||
443 | QString 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 | */ | ||
455 | bool 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 | */ | ||
492 | bool 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 | */ | ||
527 | bool 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 | */ | ||
553 | bool 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 | */ | ||
578 | QString 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 | */ | ||
611 | bool 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 | */ | ||
22 | class Interfaces { | ||
23 | |||
24 | public: | ||
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 | |||
58 | private: | ||
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 | */ | ||
21 | InterfaceSetupImp::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 | */ | ||
37 | void 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 | */ | ||
48 | bool 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 | */ | ||
91 | void 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 | |||
6 | class Interface; | ||
7 | class Interfaces; | ||
8 | |||
9 | class InterfaceSetupImp : public InterfaceSetup { | ||
10 | Q_OBJECT | ||
11 | |||
12 | public: | ||
13 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0); | ||
14 | |||
15 | protected slots: | ||
16 | void accept(); | ||
17 | |||
18 | public slots: | ||
19 | void setProfile(const QString &profile); | ||
20 | |||
21 | private: | ||
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 | |||
@@ -1,558 +1,544 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 2 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | #include "interfacesetupimp.h" | 4 | #include "interfacesetupimp.h" |
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | 6 | ||
7 | #include "module.h" | 7 | #include "module.h" |
8 | 8 | ||
9 | #include "kprocess.h" | 9 | #include "kprocess.h" |
10 | 10 | ||
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qtabwidget.h> | ||
13 | #include <qlistbox.h> | 12 | #include <qlistbox.h> |
14 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
15 | #include <qlistview.h> | 14 | #include <qlistview.h> |
16 | #include <qheader.h> | 15 | #include <qheader.h> |
17 | #include <qlabel.h> | 16 | #include <qlabel.h> |
18 | 17 | ||
19 | #include <qmainwindow.h> | 18 | #include <qmainwindow.h> |
20 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
21 | 20 | ||
22 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
23 | #include <qpe/qlibrary.h> | 22 | #include <qpe/qlibrary.h> |
24 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
25 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
26 | 25 | ||
27 | #include <qlist.h> | 26 | #include <qlist.h> |
28 | #include <qdir.h> | 27 | #include <qdir.h> |
29 | #include <qfile.h> | 28 | #include <qfile.h> |
30 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
31 | 30 | ||
32 | #define TEMP_ALL "/tmp/ifconfig-a" | 31 | #define TEMP_ALL "/tmp/ifconfig-a" |
33 | #define TEMP_UP "/tmp/ifconfig" | 32 | #define TEMP_UP "/tmp/ifconfig" |
34 | 33 | ||
35 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 34 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
36 | 35 | ||
37 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ | 36 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ |
38 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 37 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
39 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 38 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
40 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 39 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
41 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 40 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
42 | 41 | ||
43 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 42 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
44 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 43 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
45 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 44 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
46 | 45 | ||
47 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 46 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
48 | // Load connections. | 47 | // Load connections. |
49 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); | 48 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); |
50 | getInterfaceList(); | 49 | getInterfaceList(); |
51 | connectionList->header()->hide(); | 50 | connectionList->header()->hide(); |
52 | 51 | ||
53 | 52 | ||
54 | Config cfg("NetworkSetup"); | 53 | Config cfg("NetworkSetup"); |
55 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 54 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
56 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 55 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
57 | profilesList->insertItem((*it)); | 56 | profilesList->insertItem((*it)); |
58 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 57 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
59 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 58 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
60 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 59 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
61 | 60 | ||
62 | QFile file(scheme); | 61 | QFile file(scheme); |
63 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 62 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
64 | QTextStream stream( &file ); // use a text stream | 63 | QTextStream stream( &file ); // use a text stream |
65 | while ( !stream.eof() ) { // until end of file... | 64 | while ( !stream.eof() ) { // until end of file... |
66 | QString line = stream.readLine(); // line of text excluding '\n' | 65 | QString line = stream.readLine(); // line of text excluding '\n' |
67 | if(line.contains("SCHEME")){ | 66 | if(line.contains("SCHEME")){ |
68 | line = line.mid(7, line.length()); | 67 | line = line.mid(7, line.length()); |
69 | currentProfileLabel->setText(line); | 68 | currentProfileLabel->setText(line); |
70 | break; | 69 | break; |
71 | } | 70 | } |
72 | } | 71 | } |
73 | file.close(); | 72 | file.close(); |
74 | } | 73 | } |
75 | } | 74 | } |
76 | 75 | ||
77 | /** | 76 | /** |
78 | * Deconstructor. Save profiles. Delete loaded libraries. | 77 | * Deconstructor. Save profiles. Delete loaded libraries. |
79 | */ | 78 | */ |
80 | MainWindowImp::~MainWindowImp(){ | 79 | MainWindowImp::~MainWindowImp(){ |
81 | // Save profiles. | 80 | // Save profiles. |
82 | Config cfg("NetworkSetup"); | 81 | Config cfg("NetworkSetup"); |
83 | cfg.setGroup("General"); | 82 | cfg.setGroup("General"); |
84 | cfg.writeEntry("Profiles", profiles.join(" ")); | 83 | cfg.writeEntry("Profiles", profiles.join(" ")); |
85 | 84 | ||
86 | // Delete all interfaces that don't have owners. | 85 | // Delete all interfaces that don't have owners. |
87 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 86 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
88 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
89 | if(iIt.key()->getModuleOwner() == NULL) | 88 | if(iIt.key()->getModuleOwner() == NULL) |
90 | delete iIt.key(); | 89 | delete iIt.key(); |
91 | } | 90 | } |
92 | 91 | ||
93 | // Delete Modules and Libraries | 92 | // Delete Modules and Libraries |
94 | QMap<Module*, QLibrary*>::Iterator it; | 93 | QMap<Module*, QLibrary*>::Iterator it; |
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 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Load all modules that are found in the path | 103 | * Load all modules that are found in the path |
104 | * @param path a directory that is scaned for any plugins that can be loaded | 104 | * @param path a directory that is scaned for any plugins that can be loaded |
105 | * and attempts to load them | 105 | * and attempts to load them |
106 | */ | 106 | */ |
107 | void MainWindowImp::loadModules(QString path){ | 107 | void MainWindowImp::loadModules(QString path){ |
108 | //qDebug(path.latin1()); | 108 | //qDebug(path.latin1()); |
109 | QDir d(path); | 109 | QDir d(path); |
110 | if(!d.exists()) | 110 | if(!d.exists()) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Don't want sym links | 113 | // Don't want sym links |
114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
115 | const QFileInfoList *list = d.entryInfoList(); | 115 | const QFileInfoList *list = d.entryInfoList(); |
116 | QFileInfoListIterator it( *list ); | 116 | QFileInfoListIterator it( *list ); |
117 | QFileInfo *fi; | 117 | QFileInfo *fi; |
118 | while ( (fi=it.current()) ) { | 118 | while ( (fi=it.current()) ) { |
119 | if(fi->fileName().contains(".so")){ | 119 | if(fi->fileName().contains(".so")){ |
120 | loadPlugin(path + "/" + fi->fileName()); | 120 | loadPlugin(path + "/" + fi->fileName()); |
121 | } | 121 | } |
122 | ++it; | 122 | ++it; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Attempt to load a function and resolve a function. | 127 | * Attempt to load a function and resolve a function. |
128 | * @param pluginFileName - the name of the file in which to attempt to load | 128 | * @param pluginFileName - the name of the file in which to attempt to load |
129 | * @param resolveString - function pointer to resolve | 129 | * @param resolveString - function pointer to resolve |
130 | * @return pointer to the function with name resolveString or NULL | 130 | * @return pointer to the function with name resolveString or NULL |
131 | */ | 131 | */ |
132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
134 | QLibrary *lib = new QLibrary(pluginFileName); | 134 | QLibrary *lib = new QLibrary(pluginFileName); |
135 | void *functionPointer = lib->resolve(resolveString); | 135 | void *functionPointer = lib->resolve(resolveString); |
136 | if( !functionPointer ){ | 136 | if( !functionPointer ){ |
137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Try to get an object. | 142 | // Try to get an object. |
143 | Module *object = ((Module* (*)()) functionPointer)(); | 143 | Module *object = ((Module* (*)()) functionPointer)(); |
144 | if(object == NULL){ | 144 | if(object == NULL){ |
145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
146 | delete lib; | 146 | delete lib; |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Store for deletion later | 150 | // Store for deletion later |
151 | libraries.insert(object, lib); | 151 | libraries.insert(object, lib); |
152 | return object; | 152 | return object; |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 156 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
157 | * load the plugin and append it to the list | 157 | * load the plugin and append it to the list |
158 | */ | 158 | */ |
159 | void MainWindowImp::addClicked(){ | 159 | void MainWindowImp::addClicked(){ |
160 | QMap<Module*, QLibrary*>::Iterator it; | 160 | QMap<Module*, QLibrary*>::Iterator it; |
161 | QMap<QString, QString> list; | 161 | QMap<QString, QString> list; |
162 | QMap<QString, Module*> newInterfaceOwners; | 162 | QMap<QString, Module*> newInterfaceOwners; |
163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
166 | if(it.key()){ | 166 | if(it.key()){ |
167 | (it.key())->possibleNewInterfaces(list); | 167 | (it.key())->possibleNewInterfaces(list); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | // See if the list has anything that we can add. | 170 | // See if the list has anything that we can add. |
171 | if(list.count() == 0){ | 171 | if(list.count() == 0){ |
172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
176 | addNewConnection.addConnections(list); | 176 | addNewConnection.addConnections(list); |
177 | addNewConnection.showMaximized(); | 177 | addNewConnection.showMaximized(); |
178 | if(QDialog::Accepted == addNewConnection.exec()){ | 178 | if(QDialog::Accepted == addNewConnection.exec()){ |
179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
180 | if(!item) | 180 | if(!item) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
184 | if(it.key()){ | 184 | if(it.key()){ |
185 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 185 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
186 | if(i){ | 186 | if(i){ |
187 | interfaceNames.insert(i->getInterfaceName(), i); | 187 | interfaceNames.insert(i->getInterfaceName(), i); |
188 | updateInterface(i); | 188 | updateInterface(i); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Prompt the user to see if they really want to do this. | 196 | * Prompt the user to see if they really want to do this. |
197 | * If they do then remove from the list and unload. | 197 | * If they do then remove from the list and unload. |
198 | */ | 198 | */ |
199 | void MainWindowImp::removeClicked(){ | 199 | void MainWindowImp::removeClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 200 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item) { | 201 | if(!item) { |
202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); | 202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | 205 | ||
206 | Interface *i = interfaceItems[item]; | 206 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner() == NULL){ | 207 | if(i->getModuleOwner() == NULL){ |
208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
209 | } | 209 | } |
210 | else{ | 210 | else{ |
211 | if(!i->getModuleOwner()->remove(i)) | 211 | if(!i->getModuleOwner()->remove(i)) |
212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
213 | else{ | 213 | else{ |
214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
215 | // TODO memory managment.... | 215 | // TODO memory managment.... |
216 | // who deletes the interface? | 216 | // who deletes the interface? |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
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 | */ |
227 | void MainWindowImp::configureClicked(){ | 226 | void MainWindowImp::configureClicked(){ |
228 | QListViewItem *item = connectionList->currentItem(); | 227 | QListViewItem *item = connectionList->currentItem(); |
229 | if(!item){ | 228 | if(!item){ |
230 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
231 | return; | 230 | return; |
232 | } | 231 | } |
233 | 232 | ||
234 | QString currentProfile = currentProfileLabel->text(); | 233 | QString currentProfile = currentProfileLabel->text(); |
235 | if(profilesList->count() <= 1 || currentProfile == "All"){ | 234 | if(profilesList->count() <= 1 || currentProfile == "All"){ |
236 | currentProfile = ""; | 235 | currentProfile = ""; |
237 | } | 236 | } |
238 | 237 | ||
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 | } |
261 | 254 | ||
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 | */ |
268 | void MainWindowImp::informationClicked(){ | 260 | void MainWindowImp::informationClicked(){ |
269 | QListViewItem *item = connectionList->currentItem(); | 261 | QListViewItem *item = connectionList->currentItem(); |
270 | if(!item){ | 262 | if(!item){ |
271 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 263 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
272 | return; | 264 | return; |
273 | } | 265 | } |
274 | 266 | ||
275 | Interface *i = interfaceItems[item]; | 267 | Interface *i = interfaceItems[item]; |
276 | if(!i->isAttached()){ | 268 | if(!i->isAttached()){ |
277 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 269 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
278 | return; | 270 | return; |
279 | } | 271 | } |
280 | 272 | ||
281 | QStringList list; | 273 | QStringList list; |
282 | for(uint i = 0; i < profilesList->count(); i++){ | 274 | for(uint i = 0; i < profilesList->count(); i++){ |
283 | list.append(profilesList->text(i)); | 275 | list.append(profilesList->text(i)); |
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(); |
303 | } | 289 | } |
304 | 290 | ||
305 | /** | 291 | /** |
306 | * Aquire the list of active interfaces from ifconfig | 292 | * Aquire the list of active interfaces from ifconfig |
307 | * Call ifconfig and ifconfig -a | 293 | * Call ifconfig and ifconfig -a |
308 | */ | 294 | */ |
309 | void MainWindowImp::getInterfaceList(){ | 295 | void MainWindowImp::getInterfaceList(){ |
310 | KShellProcess *processAll = new KShellProcess(); | 296 | KShellProcess *processAll = new KShellProcess(); |
311 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 297 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
312 | connect(processAll, SIGNAL(processExited(KProcess *)), | 298 | connect(processAll, SIGNAL(processExited(KProcess *)), |
313 | this, SLOT(jobDone(KProcess *))); | 299 | this, SLOT(jobDone(KProcess *))); |
314 | threads.insert(processAll, TEMP_ALL); | 300 | threads.insert(processAll, TEMP_ALL); |
315 | 301 | ||
316 | KShellProcess *process = new KShellProcess(); | 302 | KShellProcess *process = new KShellProcess(); |
317 | *process << "/sbin/ifconfig" << " > " TEMP_UP; | 303 | *process << "/sbin/ifconfig" << " > " TEMP_UP; |
318 | connect(process, SIGNAL(processExited(KProcess *)), | 304 | connect(process, SIGNAL(processExited(KProcess *)), |
319 | this, SLOT(jobDone(KProcess *))); | 305 | this, SLOT(jobDone(KProcess *))); |
320 | threads.insert(process, TEMP_UP); | 306 | threads.insert(process, TEMP_UP); |
321 | 307 | ||
322 | processAll->start(KShellProcess::NotifyOnExit); | 308 | processAll->start(KShellProcess::NotifyOnExit); |
323 | process->start(KShellProcess::NotifyOnExit); | 309 | process->start(KShellProcess::NotifyOnExit); |
324 | } | 310 | } |
325 | 311 | ||
326 | void MainWindowImp::jobDone(KProcess *process){ | 312 | void MainWindowImp::jobDone(KProcess *process){ |
327 | QString fileName = threads[process]; | 313 | QString fileName = threads[process]; |
328 | threads.remove(process); | 314 | threads.remove(process); |
329 | delete process; | 315 | delete process; |
330 | 316 | ||
331 | QFile file(fileName); | 317 | QFile file(fileName); |
332 | if (!file.open(IO_ReadOnly)){ | 318 | if (!file.open(IO_ReadOnly)){ |
333 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); | 319 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); |
334 | return; | 320 | return; |
335 | } | 321 | } |
336 | 322 | ||
337 | QTextStream stream( &file ); | 323 | QTextStream stream( &file ); |
338 | QString line; | 324 | QString line; |
339 | while ( !stream.eof() ) { | 325 | while ( !stream.eof() ) { |
340 | line = stream.readLine(); | 326 | line = stream.readLine(); |
341 | int space = line.find(" "); | 327 | int space = line.find(" "); |
342 | if(space > 1){ | 328 | if(space > 1){ |
343 | // We have found an interface | 329 | // We have found an interface |
344 | QString interfaceName = line.mid(0, space); | 330 | QString interfaceName = line.mid(0, space); |
345 | Interface *i; | 331 | Interface *i; |
346 | // We have found an interface | 332 | // We have found an interface |
347 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | 333 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); |
348 | // See if we already have it | 334 | // See if we already have it |
349 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 335 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
350 | if(fileName == TEMP_ALL) | 336 | if(fileName == TEMP_ALL) |
351 | i = new Interface(this, interfaceName, false); | 337 | i = new Interface(this, interfaceName, false); |
352 | else | 338 | else |
353 | i = new Interface(this, interfaceName, true); | 339 | i = new Interface(this, interfaceName, true); |
354 | i->setAttached(true); | 340 | i->setAttached(true); |
355 | 341 | ||
356 | QString hardName = "Ethernet"; | 342 | QString hardName = "Ethernet"; |
357 | int hardwareName = line.find("Link encap:"); | 343 | int hardwareName = line.find("Link encap:"); |
358 | int macAddress = line.find("HWaddr"); | 344 | int macAddress = line.find("HWaddr"); |
359 | if(macAddress == -1) | 345 | if(macAddress == -1) |
360 | macAddress = line.length(); | 346 | macAddress = line.length(); |
361 | if(hardwareName != -1) | 347 | if(hardwareName != -1) |
362 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); | 348 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); |
363 | 349 | ||
364 | interfaceNames.insert(i->getInterfaceName(), i); | 350 | interfaceNames.insert(i->getInterfaceName(), i); |
365 | updateInterface(i); | 351 | updateInterface(i); |
366 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 352 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
367 | } | 353 | } |
368 | // It was an interface we already had. | 354 | // It was an interface we already had. |
369 | else{ | 355 | else{ |
370 | if(fileName != TEMP_ALL) | 356 | if(fileName != TEMP_ALL) |
371 | (interfaceNames[interfaceName])->setStatus(true); | 357 | (interfaceNames[interfaceName])->setStatus(true); |
372 | } | 358 | } |
373 | } | 359 | } |
374 | } | 360 | } |
375 | file.close(); | 361 | file.close(); |
376 | QFile::remove(fileName); | 362 | QFile::remove(fileName); |
377 | 363 | ||
378 | if(threads.count() == 0){ | 364 | if(threads.count() == 0){ |
379 | Interfaces i; | 365 | Interfaces i; |
380 | QStringList list = i.getInterfaceList(); | 366 | QStringList list = i.getInterfaceList(); |
381 | QMap<QString, Interface*>::Iterator it; | 367 | QMap<QString, Interface*>::Iterator it; |
382 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 368 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
383 | bool found = false; | 369 | bool found = false; |
384 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 370 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
385 | if(it.key() == (*ni)) | 371 | if(it.key() == (*ni)) |
386 | found = true; | 372 | found = true; |
387 | } | 373 | } |
388 | if(!found){ | 374 | if(!found){ |
389 | if(!(*ni).contains("_")){ | 375 | if(!(*ni).contains("_")){ |
390 | Interface *i = new Interface(this, *ni, false); | 376 | Interface *i = new Interface(this, *ni, false); |
391 | i->setAttached(false); | 377 | i->setAttached(false); |
392 | i->setHardwareName("Disconnected"); | 378 | i->setHardwareName("Disconnected"); |
393 | interfaceNames.insert(i->getInterfaceName(), i); | 379 | interfaceNames.insert(i->getInterfaceName(), i); |
394 | updateInterface(i); | 380 | updateInterface(i); |
395 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 381 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
396 | } | 382 | } |
397 | } | 383 | } |
398 | } | 384 | } |
399 | } | 385 | } |
400 | } | 386 | } |
401 | 387 | ||
402 | /** | 388 | /** |
403 | * Update this interface. If no QListViewItem exists create one. | 389 | * Update this interface. If no QListViewItem exists create one. |
404 | * @param Interface* pointer to the interface that needs to be updated. | 390 | * @param Interface* pointer to the interface that needs to be updated. |
405 | */ | 391 | */ |
406 | void MainWindowImp::updateInterface(Interface *i){ | 392 | void MainWindowImp::updateInterface(Interface *i){ |
407 | if(!advancedUserMode){ | 393 | if(!advancedUserMode){ |
408 | if(i->getInterfaceName() == "lo") | 394 | if(i->getInterfaceName() == "lo") |
409 | return; | 395 | return; |
410 | } | 396 | } |
411 | 397 | ||
412 | QListViewItem *item = NULL; | 398 | QListViewItem *item = NULL; |
413 | 399 | ||
414 | // Find the interface, making it if needed. | 400 | // Find the interface, making it if needed. |
415 | if(items.find(i) == items.end()){ | 401 | if(items.find(i) == items.end()){ |
416 | item = new QListViewItem(connectionList, "", "", ""); | 402 | item = new QListViewItem(connectionList, "", "", ""); |
417 | // See if you can't find a module owner for this interface | 403 | // See if you can't find a module owner for this interface |
418 | QMap<Module*, QLibrary*>::Iterator it; | 404 | QMap<Module*, QLibrary*>::Iterator it; |
419 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 405 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
420 | if(it.key()->isOwner(i)) | 406 | if(it.key()->isOwner(i)) |
421 | i->setModuleOwner(it.key()); | 407 | i->setModuleOwner(it.key()); |
422 | } | 408 | } |
423 | items.insert(i, item); | 409 | items.insert(i, item); |
424 | interfaceItems.insert(item, i); | 410 | interfaceItems.insert(item, i); |
425 | } | 411 | } |
426 | else | 412 | else |
427 | item = items[i]; | 413 | item = items[i]; |
428 | 414 | ||
429 | // Update the icons and information | 415 | // Update the icons and information |
430 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 416 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
431 | 417 | ||
432 | QString typeName = "lan"; | 418 | QString typeName = "lan"; |
433 | if(i->getHardwareName().contains("Local Loopback")) | 419 | if(i->getHardwareName().contains("Local Loopback")) |
434 | typeName = "lo"; | 420 | typeName = "lo"; |
435 | if(i->getInterfaceName().contains("irda")) | 421 | if(i->getInterfaceName().contains("irda")) |
436 | typeName = "irda"; | 422 | typeName = "irda"; |
437 | if(i->getInterfaceName().contains("wlan")) | 423 | if(i->getInterfaceName().contains("wlan")) |
438 | typeName = "wlan"; | 424 | typeName = "wlan"; |
439 | if(i->getInterfaceName().contains("usb")) | 425 | if(i->getInterfaceName().contains("usb")) |
440 | typeName = "usb"; | 426 | typeName = "usb"; |
441 | 427 | ||
442 | if(!i->isAttached()) | 428 | if(!i->isAttached()) |
443 | typeName = "connect_no"; | 429 | typeName = "connect_no"; |
444 | // Actually try to use the Module | 430 | // Actually try to use the Module |
445 | if(i->getModuleOwner() != NULL) | 431 | if(i->getModuleOwner() != NULL) |
446 | typeName = i->getModuleOwner()->getPixmapName(i); | 432 | typeName = i->getModuleOwner()->getPixmapName(i); |
447 | 433 | ||
448 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 434 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
449 | item->setText(2, i->getHardwareName()); | 435 | item->setText(2, i->getHardwareName()); |
450 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 436 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
451 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 437 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
452 | } | 438 | } |
453 | 439 | ||
454 | void MainWindowImp::newProfileChanged(const QString& newText){ | 440 | void MainWindowImp::newProfileChanged(const QString& newText){ |
455 | if(newText.length() > 0) | 441 | if(newText.length() > 0) |
456 | newProfileButton->setEnabled(true); | 442 | newProfileButton->setEnabled(true); |
457 | else | 443 | else |
458 | newProfileButton->setEnabled(false); | 444 | newProfileButton->setEnabled(false); |
459 | } | 445 | } |
460 | 446 | ||
461 | /** | 447 | /** |
462 | * Adds a new profile to the list of profiles. | 448 | * Adds a new profile to the list of profiles. |
463 | * Don't add profiles that already exists. | 449 | * Don't add profiles that already exists. |
464 | * Appends to the list and QStringList | 450 | * Appends to the list and QStringList |
465 | */ | 451 | */ |
466 | void MainWindowImp::addProfile(){ | 452 | void MainWindowImp::addProfile(){ |
467 | QString newProfileName = newProfile->text(); | 453 | QString newProfileName = newProfile->text(); |
468 | if(profiles.grep(newProfileName).count() > 0){ | 454 | if(profiles.grep(newProfileName).count() > 0){ |
469 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); | 455 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); |
470 | return; | 456 | return; |
471 | } | 457 | } |
472 | profiles.append(newProfileName); | 458 | profiles.append(newProfileName); |
473 | profilesList->insertItem(newProfileName); | 459 | profilesList->insertItem(newProfileName); |
474 | } | 460 | } |
475 | 461 | ||
476 | /** | 462 | /** |
477 | * Removes the currently selected profile in the combo. | 463 | * Removes the currently selected profile in the combo. |
478 | * Doesn't delete if there are less then 2 profiles. | 464 | * Doesn't delete if there are less then 2 profiles. |
479 | */ | 465 | */ |
480 | void MainWindowImp::removeProfile(){ | 466 | void MainWindowImp::removeProfile(){ |
481 | if(profilesList->count() <= 1){ | 467 | if(profilesList->count() <= 1){ |
482 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); | 468 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); |
483 | return; | 469 | return; |
484 | } | 470 | } |
485 | QString profileToRemove = profilesList->currentText(); | 471 | QString profileToRemove = profilesList->currentText(); |
486 | if(profileToRemove == "All"){ | 472 | if(profileToRemove == "All"){ |
487 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); | 473 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); |
488 | return; | 474 | return; |
489 | } | 475 | } |
490 | // Can't remove the curent profile | 476 | // Can't remove the curent profile |
491 | if(profileToRemove == currentProfileLabel->text()){ | 477 | if(profileToRemove == currentProfileLabel->text()){ |
492 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); | 478 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); |
493 | return; | 479 | return; |
494 | 480 | ||
495 | } | 481 | } |
496 | 482 | ||
497 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 483 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
498 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 484 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
499 | profilesList->clear(); | 485 | profilesList->clear(); |
500 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 486 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
501 | profilesList->insertItem((*it)); | 487 | profilesList->insertItem((*it)); |
502 | 488 | ||
503 | // Remove any interface settings and mappings. | 489 | // Remove any interface settings and mappings. |
504 | Interfaces interfaces; | 490 | Interfaces interfaces; |
505 | // Go through them one by one | 491 | // Go through them one by one |
506 | QMap<Interface*, QListViewItem*>::Iterator it; | 492 | QMap<Interface*, QListViewItem*>::Iterator it; |
507 | for( it = items.begin(); it != items.end(); ++it ){ | 493 | for( it = items.begin(); it != items.end(); ++it ){ |
508 | QString interfaceName = it.key()->getInterfaceName(); | 494 | QString interfaceName = it.key()->getInterfaceName(); |
509 | qDebug(interfaceName.latin1()); | 495 | qDebug(interfaceName.latin1()); |
510 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 496 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
511 | interfaces.removeInterface(); | 497 | interfaces.removeInterface(); |
512 | if(interfaces.setMapping(interfaceName)){ | 498 | if(interfaces.setMapping(interfaceName)){ |
513 | if(profilesList->count() == 1) | 499 | if(profilesList->count() == 1) |
514 | interfaces.removeMapping(); | 500 | interfaces.removeMapping(); |
515 | else{ | 501 | else{ |
516 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 502 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
517 | } | 503 | } |
518 | } | 504 | } |
519 | interfaces.write(); | 505 | interfaces.write(); |
520 | break; | 506 | break; |
521 | } | 507 | } |
522 | } | 508 | } |
523 | } | 509 | } |
524 | } | 510 | } |
525 | 511 | ||
526 | /** | 512 | /** |
527 | * A new profile has been selected, change. | 513 | * A new profile has been selected, change. |
528 | * @param newProfile the new profile. | 514 | * @param newProfile the new profile. |
529 | */ | 515 | */ |
530 | void MainWindowImp::changeProfile(){ | 516 | void MainWindowImp::changeProfile(){ |
531 | if(profilesList->currentItem() == -1){ | 517 | if(profilesList->currentItem() == -1){ |
532 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); | 518 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); |
533 | return; | 519 | return; |
534 | } | 520 | } |
535 | QString newProfile = profilesList->text(profilesList->currentItem()); | 521 | QString newProfile = profilesList->text(profilesList->currentItem()); |
536 | if(newProfile != currentProfileLabel->text()){ | 522 | if(newProfile != currentProfileLabel->text()){ |
537 | currentProfileLabel->setText(newProfile); | 523 | currentProfileLabel->setText(newProfile); |
538 | QFile::remove(scheme); | 524 | QFile::remove(scheme); |
539 | QFile file(scheme); | 525 | QFile file(scheme); |
540 | if ( file.open(IO_ReadWrite) ) { | 526 | if ( file.open(IO_ReadWrite) ) { |
541 | QTextStream stream( &file ); | 527 | QTextStream stream( &file ); |
542 | stream << QString("SCHEME=%1").arg(newProfile); | 528 | stream << QString("SCHEME=%1").arg(newProfile); |
543 | file.close(); | 529 | file.close(); |
544 | } | 530 | } |
545 | // restart all up devices? | 531 | // restart all up devices? |
546 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 532 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
547 | // Go through them one by one | 533 | // Go through them one by one |
548 | QMap<Interface*, QListViewItem*>::Iterator it; | 534 | QMap<Interface*, QListViewItem*>::Iterator it; |
549 | for( it = items.begin(); it != items.end(); ++it ){ | 535 | for( it = items.begin(); it != items.end(); ++it ){ |
550 | if(it.key()->getStatus() == true) | 536 | if(it.key()->getStatus() == true) |
551 | it.key()->restart(); | 537 | it.key()->restart(); |
552 | } | 538 | } |
553 | } | 539 | } |
554 | } | 540 | } |
555 | } | 541 | } |
556 | 542 | ||
557 | // mainwindowimp.cpp | 543 | // mainwindowimp.cpp |
558 | 544 | ||
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 | |||
@@ -1,88 +1,86 @@ | |||
1 | #ifndef NETCONF_MODULE_H | 1 | #ifndef NETCONF_MODULE_H |
2 | #define NETCONF_MODULE_H | 2 | #define NETCONF_MODULE_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include "interface.h" | 7 | #include "interface.h" |
8 | 8 | ||
9 | class QWidget; | 9 | class QWidget; |
10 | class QTabWidget; | 10 | class QTabWidget; |
11 | 11 | ||
12 | class Module : QObject{ | 12 | class Module : QObject{ |
13 | 13 | ||
14 | signals: | 14 | signals: |
15 | void updateInterface(Interface *i); | 15 | void updateInterface(Interface *i); |
16 | 16 | ||
17 | public: | 17 | public: |
18 | Module(){}; | 18 | Module(){}; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * The current profile has been changed and the module should do any | 21 | * The current profile has been changed and the module should do any |
22 | * neccesary changes also. | 22 | * neccesary changes also. |
23 | * @param newProfile what the profile should be changed to. | 23 | * @param newProfile what the profile should be changed to. |
24 | */ | 24 | */ |
25 | virtual void setProfile(QString newProfile) = 0; | 25 | virtual void setProfile(QString newProfile) = 0; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * get the icon name for this device. | 28 | * get the icon name for this device. |
29 | * @param Interface* can be used in determining the icon. | 29 | * @param Interface* can be used in determining the icon. |
30 | * @return QString the icon name (minus .png, .gif etc) | 30 | * @return QString the icon name (minus .png, .gif etc) |
31 | */ | 31 | */ |
32 | virtual QString getPixmapName(Interface *) = 0; | 32 | virtual QString getPixmapName(Interface *) = 0; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Check to see if the interface i is owned by this module. | 35 | * Check to see if the interface i is owned by this module. |
36 | * @param Interface* interface to check against | 36 | * @param Interface* interface to check against |
37 | * @return bool true if i is owned by this module, false otherwise. | 37 | * @return bool true if i is owned by this module, false otherwise. |
38 | */ | 38 | */ |
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 |
59 | * @return QList<Interface> A list of interfaces that exsist that havn't | 57 | * @return QList<Interface> A list of interfaces that exsist that havn't |
60 | * been called by isOwner() | 58 | * been called by isOwner() |
61 | */ | 59 | */ |
62 | virtual QList<Interface> getInterfaces() = 0; | 60 | virtual QList<Interface> getInterfaces() = 0; |
63 | 61 | ||
64 | /** | 62 | /** |
65 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), | 63 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), |
66 | * modem ppp) | 64 | * modem ppp) |
67 | */ | 65 | */ |
68 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; | 66 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; |
69 | 67 | ||
70 | /** | 68 | /** |
71 | * Attempts to create a new interface from name | 69 | * Attempts to create a new interface from name |
72 | * @return Interface* NULL if it was unable to be created. | 70 | * @return Interface* NULL if it was unable to be created. |
73 | * @param name the type of interface to create | 71 | * @param name the type of interface to create |
74 | */ | 72 | */ |
75 | virtual Interface *addNewInterface(QString name) = 0; | 73 | virtual Interface *addNewInterface(QString name) = 0; |
76 | 74 | ||
77 | /** | 75 | /** |
78 | * Attempts to remove the interface, doesn't delete i | 76 | * Attempts to remove the interface, doesn't delete i |
79 | * @return bool true if successfull, false otherwise. | 77 | * @return bool true if successfull, false otherwise. |
80 | */ | 78 | */ |
81 | virtual bool remove(Interface* i) = 0; | 79 | virtual bool remove(Interface* i) = 0; |
82 | 80 | ||
83 | }; | 81 | }; |
84 | 82 | ||
85 | #endif | 83 | #endif |
86 | 84 | ||
87 | // module.h | 85 | // module.h |
88 | 86 | ||
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 |
9 | LIBS += -lqpe | 9 | LIBS += -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 | |||
@@ -1,175 +1,175 @@ | |||
1 | #include "wextensions.h" | 1 | #include "wextensions.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | 5 | ||
6 | #include <arpa/inet.h> | 6 | #include <arpa/inet.h> |
7 | #include <sys/socket.h> | 7 | #include <sys/socket.h> |
8 | #include <sys/ioctl.h> | 8 | #include <sys/ioctl.h> |
9 | 9 | ||
10 | #include <math.h> | 10 | #include <math.h> |
11 | 11 | ||
12 | #define PROCNETWIRELESS "/proc/net/wireless" | 12 | #define PROCNETWIRELESS "/proc/net/wireless" |
13 | #define IW_LOWER 0 | 13 | #define IW_LOWER 0 |
14 | #define IW_UPPER 256 | 14 | #define IW_UPPER 256 |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructor. Sets hasWirelessExtensions | 17 | * Constructor. Sets hasWirelessExtensions |
18 | */ | 18 | */ |
19 | WExtensions::WExtensions(QString interfaceName){ | 19 | WExtensions::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 ) ); |
25 | iwr.u.essid.pointer = (caddr_t) buffer; | 27 | iwr.u.essid.pointer = (caddr_t) buffer; |
26 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 28 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
27 | iwr.u.essid.flags = 0; | 29 | iwr.u.essid.flags = 0; |
28 | 30 | ||
29 | // check if it is an IEEE 802.11 standard conform | 31 | // check if it is an IEEE 802.11 standard conform |
30 | // wireless device by sending SIOCGIWESSID | 32 | // wireless device by sending SIOCGIWESSID |
31 | // which also gives back the Extended Service Set ID | 33 | // which also gives back the Extended Service Set ID |
32 | // (see IEEE 802.11 for more information) | 34 | // (see IEEE 802.11 for more information) |
33 | 35 | ||
34 | const char* iname = interface.latin1(); | 36 | const char* iname = interface.latin1(); |
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 | /** |
43 | * @return QString the station name of the access point. | 43 | * @return QString the station name of the access point. |
44 | */ | 44 | */ |
45 | QString WExtensions::station(){ | 45 | QString WExtensions::station(){ |
46 | if(!hasWirelessExtensions) | 46 | if(!hasWirelessExtensions) |
47 | return QString(); | 47 | return QString(); |
48 | const char* buffer[200]; | 48 | const char* buffer[200]; |
49 | iwr.u.data.pointer = (caddr_t) buffer; | 49 | iwr.u.data.pointer = (caddr_t) buffer; |
50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
51 | iwr.u.data.flags = 0; | 51 | iwr.u.data.flags = 0; |
52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | 52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ |
53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
54 | return QString(iwr.u.data.pointer); | 54 | return QString(iwr.u.data.pointer); |
55 | } | 55 | } |
56 | return QString(); | 56 | return QString(); |
57 | } | 57 | } |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * @return QString the essid of the host 802.11 access point. | 60 | * @return QString the essid of the host 802.11 access point. |
61 | */ | 61 | */ |
62 | QString WExtensions::essid(){ | 62 | QString WExtensions::essid(){ |
63 | if(!hasWirelessExtensions) | 63 | if(!hasWirelessExtensions) |
64 | return QString(); | 64 | return QString(); |
65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | 66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; |
67 | return QString(iwr.u.essid.pointer); | 67 | return QString(iwr.u.essid.pointer); |
68 | } | 68 | } |
69 | return QString(); | 69 | return QString(); |
70 | } | 70 | } |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * @return QString the mode of interface | 73 | * @return QString the mode of interface |
74 | */ | 74 | */ |
75 | QString WExtensions::mode(){ | 75 | QString WExtensions::mode(){ |
76 | if(!hasWirelessExtensions) | 76 | if(!hasWirelessExtensions) |
77 | return QString(); | 77 | return QString(); |
78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
80 | return QString(); | 80 | return QString(); |
81 | } | 81 | } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Get the frequency that the interface is running at. | 84 | * Get the frequency that the interface is running at. |
85 | * @return int the frequency that the interfacae is running at. | 85 | * @return int the frequency that the interfacae is running at. |
86 | */ | 86 | */ |
87 | double WExtensions::frequency(){ | 87 | double WExtensions::frequency(){ |
88 | if(!hasWirelessExtensions) | 88 | if(!hasWirelessExtensions) |
89 | return 0; | 89 | return 0; |
90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
92 | return 0; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | /*** | 95 | /*** |
96 | * Get the current rate that the card is transmiting at. | 96 | * Get the current rate that the card is transmiting at. |
97 | */ | 97 | */ |
98 | double WExtensions::rate(){ | 98 | double WExtensions::rate(){ |
99 | if(!hasWirelessExtensions) | 99 | if(!hasWirelessExtensions) |
100 | return 0; | 100 | return 0; |
101 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | 101 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ |
102 | return ((double)iwr.u.bitrate.value)/1000000; | 102 | return ((double)iwr.u.bitrate.value)/1000000; |
103 | } | 103 | } |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | /** | 108 | /** |
109 | * @return QString the AccessPoint that the interface is connected to. | 109 | * @return QString the AccessPoint that the interface is connected to. |
110 | */ | 110 | */ |
111 | QString WExtensions::ap(){ | 111 | QString WExtensions::ap(){ |
112 | if(!hasWirelessExtensions) | 112 | if(!hasWirelessExtensions) |
113 | return QString(); | 113 | return QString(); |
114 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ | 114 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ |
115 | QString ap; | 115 | QString ap; |
116 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 116 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
117 | iwr.u.ap_addr.sa_data[0]&0xff, | 117 | iwr.u.ap_addr.sa_data[0]&0xff, |
118 | iwr.u.ap_addr.sa_data[1]&0xff, | 118 | iwr.u.ap_addr.sa_data[1]&0xff, |
119 | iwr.u.ap_addr.sa_data[2]&0xff, | 119 | iwr.u.ap_addr.sa_data[2]&0xff, |
120 | iwr.u.ap_addr.sa_data[3]&0xff, | 120 | iwr.u.ap_addr.sa_data[3]&0xff, |
121 | iwr.u.ap_addr.sa_data[4]&0xff, | 121 | iwr.u.ap_addr.sa_data[4]&0xff, |
122 | iwr.u.ap_addr.sa_data[5]&0xff ); | 122 | iwr.u.ap_addr.sa_data[5]&0xff ); |
123 | return ap; | 123 | return ap; |
124 | } | 124 | } |
125 | else return QString(); | 125 | else return QString(); |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Get the stats for interfaces | 129 | * Get the stats for interfaces |
130 | * @param signal the signal strength of interface | 130 | * @param signal the signal strength of interface |
131 | * @param noise the noise level of the interface | 131 | * @param noise the noise level of the interface |
132 | * @param quality the quality level of the interface | 132 | * @param quality the quality level of the interface |
133 | * @return bool true if successfull | 133 | * @return bool true if successfull |
134 | */ | 134 | */ |
135 | bool WExtensions::stats(int &signal, int &noise, int &quality){ | 135 | bool WExtensions::stats(int &signal, int &noise, int &quality){ |
136 | // gather link quality from /proc/net/wireless | 136 | // gather link quality from /proc/net/wireless |
137 | if(!QFile::exists(PROCNETWIRELESS)) | 137 | if(!QFile::exists(PROCNETWIRELESS)) |
138 | return false; | 138 | return false; |
139 | 139 | ||
140 | char c; | 140 | char c; |
141 | QString status; | 141 | QString status; |
142 | QString name; | 142 | QString name; |
143 | 143 | ||
144 | QFile wfile( PROCNETWIRELESS ); | 144 | QFile wfile( PROCNETWIRELESS ); |
145 | if(!wfile.open( IO_ReadOnly )) | 145 | if(!wfile.open( IO_ReadOnly )) |
146 | return false; | 146 | return false; |
147 | 147 | ||
148 | QTextStream wstream( &wfile ); | 148 | QTextStream wstream( &wfile ); |
149 | wstream.readLine(); // skip the first two lines | 149 | wstream.readLine(); // skip the first two lines |
150 | wstream.readLine(); // because they only contain headers | 150 | wstream.readLine(); // because they only contain headers |
151 | while(!wstream.atEnd()){ | 151 | while(!wstream.atEnd()){ |
152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
153 | if(name == QString("%1:").arg(interface)){ | 153 | if(name == QString("%1:").arg(interface)){ |
154 | if ( quality > 92 ) | 154 | if ( quality > 92 ) |
155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
160 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); | 160 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | 161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; |
162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | 162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; |
163 | quality = ( quality*100 ) / 92; | 163 | quality = ( quality*100 ) / 92; |
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | qDebug("WExtensions::statsCard no longer present."); | 168 | qDebug("WExtensions::statsCard no longer present."); |
169 | quality = -1; | 169 | quality = -1; |
170 | signal = IW_LOWER; | 170 | signal = IW_LOWER; |
171 | noise = IW_LOWER; | 171 | noise = IW_LOWER; |
172 | return false; | 172 | return false; |
173 | } | 173 | } |
174 | 174 | ||
175 | // wextensions.cpp | 175 | // wextensions.cpp |
diff --git a/noncore/net/networksetup/wlan/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 | |||
@@ -1,12 +1,12 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 3 | #CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/plugins/networksetup | 4 | DESTDIR = $(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 |
9 | LIBS += -lqpe | 9 | LIBS += -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 | |||
@@ -1,234 +1,244 @@ | |||
1 | #include "wlanimp.h" | 1 | #include "wlanimp.h" |
2 | 2 | ||
3 | /* Config class */ | 3 | /* Config class */ |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | /* Global namespace */ | 5 | /* Global namespace */ |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | #include <qpe/config.h> | ||
19 | #include <qtabwidget.h> | ||
20 | #include "interfacesetupimp.h" | ||
18 | 21 | ||
19 | WLANImp::WLANImp( QWidget* parent, const char* name, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ | 22 | WLANImp::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 | ||
24 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
25 | delete config; | 33 | delete config; |
26 | } | 34 | } |
27 | 35 | ||
28 | void WLANImp::readConfig() | 36 | void WLANImp::readConfig() |
29 | { | 37 | { |
30 | qWarning( "WLANImp::readConfig() called." ); | 38 | qWarning( "WLANImp::readConfig() called." ); |
31 | config->setGroup( "Properties" ); | 39 | config->setGroup( "Properties" ); |
32 | QString ssid = config->readEntry( "SSID", "any" ); | 40 | QString ssid = config->readEntry( "SSID", "any" ); |
33 | if( ssid == "any" || ssid == "ANY" ){ | 41 | if( ssid == "any" || ssid == "ANY" ){ |
34 | essNon->setChecked( true ); | 42 | essNon->setChecked( true ); |
35 | } else { | 43 | } else { |
36 | essSpecific->setChecked( true ); | 44 | essSpecific->setChecked( true ); |
37 | essSpecificLineEdit->setText( ssid ); | 45 | essSpecificLineEdit->setText( ssid ); |
38 | } | 46 | } |
39 | QString mode = config->readEntry( "Mode", "Managed" ); | 47 | QString mode = config->readEntry( "Mode", "Managed" ); |
40 | if( mode == "adhoc" ) { | 48 | if( mode == "adhoc" ) { |
41 | network802->setChecked( true ); | 49 | network802->setChecked( true ); |
42 | } else { | 50 | } else { |
43 | networkInfrastructure->setChecked( true ); | 51 | networkInfrastructure->setChecked( true ); |
44 | } | 52 | } |
45 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
46 | // config->readEntry( "RATE", "auto" ); | 54 | // config->readEntry( "RATE", "auto" ); |
47 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
48 | config->readEntry( "AuthType", "opensystem" ); | 56 | config->readEntry( "AuthType", "opensystem" ); |
49 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
50 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
51 | switch( defaultkey ){ | 59 | switch( defaultkey ){ |
52 | case 0: | 60 | case 0: |
53 | keyRadio0->setChecked( true ); | 61 | keyRadio0->setChecked( true ); |
54 | break; | 62 | break; |
55 | case 1: | 63 | case 1: |
56 | keyRadio1->setChecked( true ); | 64 | keyRadio1->setChecked( true ); |
57 | break; | 65 | break; |
58 | case 2: | 66 | case 2: |
59 | keyRadio2->setChecked( true ); | 67 | keyRadio2->setChecked( true ); |
60 | break; | 68 | break; |
61 | case 3: | 69 | case 3: |
62 | keyRadio3->setChecked( true ); | 70 | keyRadio3->setChecked( true ); |
63 | break; | 71 | break; |
64 | } | 72 | } |
65 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
66 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
67 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
68 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
69 | return; | 77 | return; |
70 | } | 78 | } |
71 | 79 | ||
72 | bool WLANImp::writeConfig() | 80 | bool WLANImp::writeConfig() |
73 | { | 81 | { |
74 | qWarning( "WLANImp::writeConfig() called." ); | 82 | qWarning( "WLANImp::writeConfig() called." ); |
75 | config->setGroup( "Properties" ); | 83 | config->setGroup( "Properties" ); |
76 | if( essNon->isChecked() ) { | 84 | if( essNon->isChecked() ) { |
77 | config->writeEntry( "SSID", "any" ); | 85 | config->writeEntry( "SSID", "any" ); |
78 | } else { | 86 | } else { |
79 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
80 | } | 88 | } |
81 | if( networkInfrastructure->isChecked() ){ | 89 | if( networkInfrastructure->isChecked() ){ |
82 | config->writeEntry( "Mode", "Managed" ); | 90 | config->writeEntry( "Mode", "Managed" ); |
83 | } else if( network802->isChecked() ){ | 91 | } else if( network802->isChecked() ){ |
84 | config->writeEntry( "Mode", "adhoc" ); | 92 | config->writeEntry( "Mode", "adhoc" ); |
85 | } | 93 | } |
86 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 94 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
87 | // config->readEntry( "RATE", "auto" ); | 95 | // config->readEntry( "RATE", "auto" ); |
88 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
89 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
90 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
91 | if( keyRadio0->isChecked() ){ | 99 | if( keyRadio0->isChecked() ){ |
92 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
93 | } else if( keyRadio1->isChecked() ){ | 101 | } else if( keyRadio1->isChecked() ){ |
94 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
95 | } else if( keyRadio2->isChecked() ){ | 103 | } else if( keyRadio2->isChecked() ){ |
96 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
97 | } else if( keyRadio3->isChecked() ){ | 105 | } else if( keyRadio3->isChecked() ){ |
98 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
99 | } | 107 | } |
100 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
101 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
102 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
103 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
104 | return true; | 112 | return true; |
105 | return writeWirelessOpts( ); | 113 | return writeWirelessOpts( ); |
106 | } | 114 | } |
107 | 115 | ||
108 | /** | 116 | /** |
109 | */ | 117 | */ |
110 | void WLANImp::accept() | 118 | void WLANImp::accept() |
111 | { | 119 | { |
112 | if ( writeConfig() ) | 120 | if ( writeConfig() ){ |
121 | interfaceSetup->saveChanges(); | ||
113 | QDialog::accept(); | 122 | QDialog::accept(); |
123 | } | ||
114 | } | 124 | } |
115 | 125 | ||
116 | bool WLANImp::writeWirelessOpts( QString scheme ) | 126 | bool WLANImp::writeWirelessOpts( QString scheme ) |
117 | { | 127 | { |
118 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 128 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
119 | QString prev = "/etc/pcmcia/wireless.opts"; | 129 | QString prev = "/etc/pcmcia/wireless.opts"; |
120 | QFile prevFile(prev); | 130 | QFile prevFile(prev); |
121 | if ( !prevFile.open( IO_ReadOnly ) ) | 131 | if ( !prevFile.open( IO_ReadOnly ) ) |
122 | return false; | 132 | return false; |
123 | 133 | ||
124 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 134 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
125 | QFile tmpFile(tmp); | 135 | QFile tmpFile(tmp); |
126 | if ( !tmpFile.open( IO_WriteOnly ) ) | 136 | if ( !tmpFile.open( IO_WriteOnly ) ) |
127 | return false; | 137 | return false; |
128 | 138 | ||
129 | bool retval = true; | 139 | bool retval = true; |
130 | 140 | ||
131 | QTextStream in( &prevFile ); | 141 | QTextStream in( &prevFile ); |
132 | QTextStream out( &tmpFile ); | 142 | QTextStream out( &tmpFile ); |
133 | 143 | ||
134 | config->setGroup("Properties"); | 144 | config->setGroup("Properties"); |
135 | 145 | ||
136 | QString line; | 146 | QString line; |
137 | bool found=false; | 147 | bool found=false; |
138 | bool done=false; | 148 | bool done=false; |
139 | while ( !in.atEnd() ) { | 149 | while ( !in.atEnd() ) { |
140 | QString line = in.readLine(); | 150 | QString line = in.readLine(); |
141 | QString wline = line.simplifyWhiteSpace(); | 151 | QString wline = line.simplifyWhiteSpace(); |
142 | if ( !done ) { | 152 | if ( !done ) { |
143 | if ( found ) { | 153 | if ( found ) { |
144 | // skip existing entry for this scheme, and write our own. | 154 | // skip existing entry for this scheme, and write our own. |
145 | if ( wline == ";;" ) { | 155 | if ( wline == ";;" ) { |
146 | found = false; | 156 | found = false; |
147 | continue; | 157 | continue; |
148 | } else { | 158 | } else { |
149 | continue; | 159 | continue; |
150 | } | 160 | } |
151 | } else { | 161 | } else { |
152 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 162 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
153 | found=true; | 163 | found=true; |
154 | continue; // skip this line | 164 | continue; // skip this line |
155 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 165 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
156 | // end - add new entry | 166 | // end - add new entry |
157 | // Not all fields have a GUI, but all are supported | 167 | // Not all fields have a GUI, but all are supported |
158 | // in the letwork configuration files. | 168 | // in the letwork configuration files. |
159 | static const char* txtfields[] = { | 169 | static const char* txtfields[] = { |
160 | 0 | 170 | 0 |
161 | }; | 171 | }; |
162 | QString readmode = config->readEntry( "Mode", "Managed" ); | 172 | QString readmode = config->readEntry( "Mode", "Managed" ); |
163 | QString mode; | 173 | QString mode; |
164 | if( readmode == "Managed" ){ | 174 | if( readmode == "Managed" ){ |
165 | mode = readmode; | 175 | mode = readmode; |
166 | } else if( readmode == "adhoc" ){ | 176 | } else if( readmode == "adhoc" ){ |
167 | mode = "Ad-Hoc"; | 177 | mode = "Ad-Hoc"; |
168 | } | 178 | } |
169 | QString key; | 179 | QString key; |
170 | if( wepEnabled->isChecked() ){ | 180 | if( wepEnabled->isChecked() ){ |
171 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 181 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
172 | switch( defaultkey ){ | 182 | switch( defaultkey ){ |
173 | case 0: | 183 | case 0: |
174 | key += keyLineEdit0->text(); | 184 | key += keyLineEdit0->text(); |
175 | break; | 185 | break; |
176 | case 1: | 186 | case 1: |
177 | key += keyLineEdit1->text(); | 187 | key += keyLineEdit1->text(); |
178 | break; | 188 | break; |
179 | case 2: | 189 | case 2: |
180 | key += keyLineEdit2->text(); | 190 | key += keyLineEdit2->text(); |
181 | break; | 191 | break; |
182 | case 3: | 192 | case 3: |
183 | key += keyLineEdit3->text(); | 193 | key += keyLineEdit3->text(); |
184 | break; | 194 | break; |
185 | } | 195 | } |
186 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 196 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
187 | key += " open"; | 197 | key += " open"; |
188 | } | 198 | } |
189 | out << scheme << ",*,*,*)" << "\n" | 199 | out << scheme << ",*,*,*)" << "\n" |
190 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 200 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
191 | << " MODE=" << mode << "\n" | 201 | << " MODE=" << mode << "\n" |
192 | << " KEY=" << Global::shellQuote( key ) << "\n" | 202 | << " KEY=" << Global::shellQuote( key ) << "\n" |
193 | << " RATE=" << "auto" << "\n" | 203 | << " RATE=" << "auto" << "\n" |
194 | ; | 204 | ; |
195 | if( mode != "Managed" ) | 205 | if( mode != "Managed" ) |
196 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 206 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
197 | const char** f = txtfields; | 207 | const char** f = txtfields; |
198 | while (*f) { | 208 | while (*f) { |
199 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 209 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
200 | ++f; | 210 | ++f; |
201 | } | 211 | } |
202 | out << " ;;\n"; | 212 | out << " ;;\n"; |
203 | done = true; | 213 | done = true; |
204 | } | 214 | } |
205 | } | 215 | } |
206 | } | 216 | } |
207 | out << line << "\n"; | 217 | out << line << "\n"; |
208 | } | 218 | } |
209 | 219 | ||
210 | prevFile.close(); | 220 | prevFile.close(); |
211 | tmpFile.close(); | 221 | tmpFile.close(); |
212 | QString initpath; | 222 | QString initpath; |
213 | //system("cardctl suspend"); | 223 | //system("cardctl suspend"); |
214 | if( QDir("/etc/rc.d/init.d").exists() ){ | 224 | if( QDir("/etc/rc.d/init.d").exists() ){ |
215 | initpath = "/etc/rc.d/init.d"; | 225 | initpath = "/etc/rc.d/init.d"; |
216 | } else if( QDir("/etc/init.d").exists() ){ | 226 | } else if( QDir("/etc/init.d").exists() ){ |
217 | initpath = "/etc/init.d"; | 227 | initpath = "/etc/init.d"; |
218 | } | 228 | } |
219 | if( initpath ) | 229 | if( initpath ) |
220 | system(QString("%1/pcmcia stop").arg(initpath)); | 230 | system(QString("%1/pcmcia stop").arg(initpath)); |
221 | 231 | ||
222 | if( system( "mv " + tmp + " " + prev ) ) | 232 | if( system( "mv " + tmp + " " + prev ) ) |
223 | retval = false; | 233 | retval = false; |
224 | //#ifdef USE_SCHEMES | 234 | //#ifdef USE_SCHEMES |
225 | // if ( retval ) | 235 | // if ( retval ) |
226 | //SchemeChanger::changeScheme(scheme); | 236 | //SchemeChanger::changeScheme(scheme); |
227 | //#endif | 237 | //#endif |
228 | 238 | ||
229 | //system("cardctl resume"); | 239 | //system("cardctl resume"); |
230 | if( initpath ) | 240 | if( initpath ) |
231 | system(QString("%1/pcmcia start").arg(initpath)); | 241 | system(QString("%1/pcmcia start").arg(initpath)); |
232 | 242 | ||
233 | return retval; | 243 | return retval; |
234 | } | 244 | } |
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 | |||
@@ -1,27 +1,31 @@ | |||
1 | #ifndef WLANIMP_H | 1 | #ifndef WLANIMP_H |
2 | #define WLANIMP_H | 2 | #define WLANIMP_H |
3 | 3 | ||
4 | #include "wlan.h" | 4 | #include "wlan.h" |
5 | 5 | ||
6 | #include <qpe/config.h> | 6 | class InterfaceSetupImp; |
7 | class Interface; | ||
8 | class Config; | ||
7 | 9 | ||
8 | class WLANImp : public WLAN { | 10 | class WLANImp : public WLAN { |
9 | Q_OBJECT | 11 | Q_OBJECT |
10 | 12 | ||
11 | public: | 13 | public: |
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 | ||
15 | protected: | 17 | protected: |
16 | void accept(); | 18 | void accept(); |
17 | 19 | ||
18 | private: | 20 | private: |
19 | void readConfig(); | 21 | void readConfig(); |
20 | bool writeConfig(); | 22 | bool writeConfig(); |
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 |
27 | 31 | ||
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 | |||
@@ -1,112 +1,112 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
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 |
11 | */ | 13 | */ |
12 | WLANModule::WLANModule() : Module() { | 14 | WLANModule::WLANModule() : Module() { |
13 | } | 15 | } |
14 | 16 | ||
15 | /** | 17 | /** |
16 | * Delete any interfaces that we own. | 18 | * Delete any interfaces that we own. |
17 | */ | 19 | */ |
18 | WLANModule::~WLANModule(){ | 20 | WLANModule::~WLANModule(){ |
19 | Interface *i; | 21 | Interface *i; |
20 | for ( i=list.first(); i != 0; i=list.next() ) | 22 | for ( i=list.first(); i != 0; i=list.next() ) |
21 | delete i; | 23 | delete i; |
22 | } | 24 | } |
23 | 25 | ||
24 | /** | 26 | /** |
25 | * Change the current profile | 27 | * Change the current profile |
26 | */ | 28 | */ |
27 | void WLANModule::setProfile(QString newProfile){ | 29 | void WLANModule::setProfile(QString newProfile){ |
28 | profile = newProfile; | 30 | profile = newProfile; |
29 | } | 31 | } |
30 | 32 | ||
31 | /** | 33 | /** |
32 | * get the icon name for this device. | 34 | * get the icon name for this device. |
33 | * @param Interface* can be used in determining the icon. | 35 | * @param Interface* can be used in determining the icon. |
34 | * @return QString the icon name (minus .png, .gif etc) | 36 | * @return QString the icon name (minus .png, .gif etc) |
35 | */ | 37 | */ |
36 | QString WLANModule::getPixmapName(Interface* ){ | 38 | QString WLANModule::getPixmapName(Interface* ){ |
37 | return "wlan"; | 39 | return "wlan"; |
38 | } | 40 | } |
39 | 41 | ||
40 | /** | 42 | /** |
41 | * Check to see if the interface i is owned by this module. | 43 | * Check to see if the interface i is owned by this module. |
42 | * @param Interface* interface to check against | 44 | * @param Interface* interface to check against |
43 | * @return bool true if i is owned by this module, false otherwise. | 45 | * @return bool true if i is owned by this module, false otherwise. |
44 | */ | 46 | */ |
45 | bool WLANModule::isOwner(Interface *i){ | 47 | bool WLANModule::isOwner(Interface *i){ |
46 | WExtensions we(i->getInterfaceName()); | 48 | WExtensions we(i->getInterfaceName()); |
47 | if(!we.doesHaveWirelessExtensions()) | 49 | if(!we.doesHaveWirelessExtensions()) |
48 | return false; | 50 | return false; |
49 | 51 | ||
50 | i->setHardwareName("802.11b"); | 52 | i->setHardwareName("802.11b"); |
51 | list.append(i); | 53 | list.append(i); |
52 | return true; | 54 | return true; |
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 | */ |
60 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ | 61 | QWidget *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 | */ |
71 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 70 | QWidget *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 | ||
81 | /** | 81 | /** |
82 | * Get all active (up or down) interfaces | 82 | * Get all active (up or down) interfaces |
83 | * @return QList<Interface> A list of interfaces that exsist that havn't | 83 | * @return QList<Interface> A list of interfaces that exsist that havn't |
84 | * been called by isOwner() | 84 | * been called by isOwner() |
85 | */ | 85 | */ |
86 | QList<Interface> WLANModule::getInterfaces(){ | 86 | QList<Interface> WLANModule::getInterfaces(){ |
87 | return list; | 87 | return list; |
88 | } | 88 | } |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Attempt to add a new interface as defined by name | 91 | * Attempt to add a new interface as defined by name |
92 | * @param name the name of the type of interface that should be created given | 92 | * @param name the name of the type of interface that should be created given |
93 | * by possibleNewInterfaces(); | 93 | * by possibleNewInterfaces(); |
94 | * @return Interface* NULL if it was unable to be created. | 94 | * @return Interface* NULL if it was unable to be created. |
95 | */ | 95 | */ |
96 | Interface *WLANModule::addNewInterface(QString ){ | 96 | Interface *WLANModule::addNewInterface(QString ){ |
97 | // We can't add a 802.11 interface, either the hardware will be there | 97 | // We can't add a 802.11 interface, either the hardware will be there |
98 | // or it wont. | 98 | // or it wont. |
99 | return NULL; | 99 | return NULL; |
100 | } | 100 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Attempts to remove the interface, doesn't delete i | 103 | * Attempts to remove the interface, doesn't delete i |
104 | * @return bool true if successfull, false otherwise. | 104 | * @return bool true if successfull, false otherwise. |
105 | */ | 105 | */ |
106 | bool WLANModule::remove(Interface*){ | 106 | bool WLANModule::remove(Interface*){ |
107 | // Can't remove a hardware device, you can stop it though. | 107 | // Can't remove a hardware device, you can stop it though. |
108 | return false; | 108 | return false; |
109 | } | 109 | } |
110 | 110 | ||
111 | // wlanmodule.cpp | 111 | // wlanmodule.cpp |
112 | 112 | ||
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 | |||
@@ -1,41 +1,41 @@ | |||
1 | #ifndef WLAN_MODULE_H | 1 | #ifndef WLAN_MODULE_H |
2 | #define WLAN_MODULE_H | 2 | #define WLAN_MODULE_H |
3 | 3 | ||
4 | #include "module.h" | 4 | #include "module.h" |
5 | 5 | ||
6 | class WLANModule : Module{ | 6 | class WLANModule : Module{ |
7 | 7 | ||
8 | signals: | 8 | signals: |
9 | void updateInterface(Interface *i); | 9 | void updateInterface(Interface *i); |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WLANModule(); | 12 | WLANModule(); |
13 | ~WLANModule(); | 13 | ~WLANModule(); |
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); |
22 | virtual bool remove(Interface* i); | 22 | virtual bool remove(Interface* i); |
23 | virtual QString getPixmapName(Interface* i); | 23 | virtual QString getPixmapName(Interface* i); |
24 | 24 | ||
25 | private: | 25 | private: |
26 | QList<Interface> list; | 26 | QList<Interface> list; |
27 | QString profile; | 27 | QString profile; |
28 | 28 | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | extern "C" | 31 | extern "C" |
32 | { | 32 | { |
33 | void* create_plugin() { | 33 | void* create_plugin() { |
34 | return new WLANModule(); | 34 | return new WLANModule(); |
35 | } | 35 | } |
36 | }; | 36 | }; |
37 | 37 | ||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | // wlanmodule.h | 40 | // wlanmodule.h |
41 | 41 | ||
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,9 +1,11 @@ | |||
1 | Make sure the C code in wextensions is clean. | ||
2 | |||
1 | WLAN needs to be re-written to not use Config | 3 | WLAN needs to be re-written to not use Config |
2 | WHERE Is DHCP info stored??? | 4 | WHERE Is DHCP info stored??? |
3 | 5 | ||
4 | PPP module needs to be written | 6 | PPP module needs to be written |
5 | 7 | ||
6 | Write a class that parses /proc and not ifconfig | 8 | Write a class that parses /proc and not ifconfig |
7 | 9 | ||
8 | Possible other modules: ipsec, bluetooth, ipchains | 10 | Possible other modules: ipsec, bluetooth, ipchains |
9 | 11 | ||
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 | |||
14 | Interface::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 | */ | ||
23 | void 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 | */ | ||
35 | void 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 | */ | ||
45 | void 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 | */ | ||
55 | void Interface::setModuleOwner(Module *owner){ | ||
56 | moduleOwner = owner; | ||
57 | emit(updateInterface(this)); | ||
58 | }; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Try to start the interface. | ||
63 | */ | ||
64 | void 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 | */ | ||
81 | void 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 | */ | ||
97 | void 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 | */ | ||
107 | bool 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 | |||
7 | class Module; | ||
8 | |||
9 | class Interface : public QObject{ | ||
10 | Q_OBJECT | ||
11 | |||
12 | signals: | ||
13 | void updateInterface(Interface *i); | ||
14 | |||
15 | public: | ||
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 | |||
43 | public slots: | ||
44 | bool refresh(); | ||
45 | void start(); | ||
46 | void stop(); | ||
47 | void restart(); | ||
48 | |||
49 | private: | ||
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 | */ | ||
29 | InterfaceConfiguration::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 | */ | ||
137 | InterfaceConfiguration::~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> | ||
14 | class QVBoxLayout; | ||
15 | class QHBoxLayout; | ||
16 | class QGridLayout; | ||
17 | class QCheckBox; | ||
18 | class QComboBox; | ||
19 | class QFrame; | ||
20 | class QGroupBox; | ||
21 | class QLabel; | ||
22 | class QLineEdit; | ||
23 | class QSpinBox; | ||
24 | |||
25 | class InterfaceConfiguration : public QWidget | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | |||
29 | public: | ||
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 | |||
52 | protected: | ||
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>&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&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&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>&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 &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 | */ | ||
13 | InterfaceInformationImp::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 | */ | ||
32 | void 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 | */ | ||
53 | void 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 | |||
7 | class InterfaceInformationImp : public InterfaceInformation { | ||
8 | |||
9 | Q_OBJECT | ||
10 | |||
11 | public: | ||
12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | ||
13 | ~InterfaceInformationImp(){}; | ||
14 | |||
15 | private slots: | ||
16 | void advanced(); | ||
17 | void updateInterface(Interface *i); | ||
18 | |||
19 | private: | ||
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 | */ | ||
17 | Interfaces::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 | **/ | ||
50 | QStringList 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 | */ | ||
73 | bool 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 | * */ | ||
89 | bool 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 | */ | ||
136 | bool 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 | */ | ||
146 | bool 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 | */ | ||
159 | bool 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 | */ | ||
174 | bool 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 | */ | ||
199 | bool 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 | */ | ||
211 | QString 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 | */ | ||
233 | QString 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 | */ | ||
258 | QString 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 | */ | ||
283 | bool 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 | */ | ||
299 | bool 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 | */ | ||
314 | bool 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 | */ | ||
332 | QString 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 | */ | ||
344 | bool 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 | */ | ||
355 | bool 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 | */ | ||
363 | bool 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 | */ | ||
374 | bool 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 | */ | ||
384 | void 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 | */ | ||
393 | bool 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 | */ | ||
406 | bool 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 | */ | ||
416 | bool 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 | */ | ||
426 | QString 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 | */ | ||
435 | bool 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 | */ | ||
443 | QString 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 | */ | ||
455 | bool 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 | */ | ||
492 | bool 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 | */ | ||
527 | bool 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 | */ | ||
553 | bool 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 | */ | ||
578 | QString 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 | */ | ||
611 | bool 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 | */ | ||
22 | class Interfaces { | ||
23 | |||
24 | public: | ||
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 | |||
58 | private: | ||
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 | */ | ||
21 | InterfaceSetupImp::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 | */ | ||
37 | void 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 | */ | ||
48 | bool 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 | */ | ||
91 | void 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 | |||
6 | class Interface; | ||
7 | class Interfaces; | ||
8 | |||
9 | class InterfaceSetupImp : public InterfaceSetup { | ||
10 | Q_OBJECT | ||
11 | |||
12 | public: | ||
13 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0); | ||
14 | |||
15 | protected slots: | ||
16 | void accept(); | ||
17 | |||
18 | public slots: | ||
19 | void setProfile(const QString &profile); | ||
20 | |||
21 | private: | ||
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 | |||
@@ -1,558 +1,544 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 2 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | #include "interfacesetupimp.h" | 4 | #include "interfacesetupimp.h" |
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | 6 | ||
7 | #include "module.h" | 7 | #include "module.h" |
8 | 8 | ||
9 | #include "kprocess.h" | 9 | #include "kprocess.h" |
10 | 10 | ||
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qtabwidget.h> | ||
13 | #include <qlistbox.h> | 12 | #include <qlistbox.h> |
14 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
15 | #include <qlistview.h> | 14 | #include <qlistview.h> |
16 | #include <qheader.h> | 15 | #include <qheader.h> |
17 | #include <qlabel.h> | 16 | #include <qlabel.h> |
18 | 17 | ||
19 | #include <qmainwindow.h> | 18 | #include <qmainwindow.h> |
20 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
21 | 20 | ||
22 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
23 | #include <qpe/qlibrary.h> | 22 | #include <qpe/qlibrary.h> |
24 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
25 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
26 | 25 | ||
27 | #include <qlist.h> | 26 | #include <qlist.h> |
28 | #include <qdir.h> | 27 | #include <qdir.h> |
29 | #include <qfile.h> | 28 | #include <qfile.h> |
30 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
31 | 30 | ||
32 | #define TEMP_ALL "/tmp/ifconfig-a" | 31 | #define TEMP_ALL "/tmp/ifconfig-a" |
33 | #define TEMP_UP "/tmp/ifconfig" | 32 | #define TEMP_UP "/tmp/ifconfig" |
34 | 33 | ||
35 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 34 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
36 | 35 | ||
37 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ | 36 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ |
38 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 37 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
39 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 38 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
40 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 39 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
41 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 40 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
42 | 41 | ||
43 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 42 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
44 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 43 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
45 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 44 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
46 | 45 | ||
47 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 46 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
48 | // Load connections. | 47 | // Load connections. |
49 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); | 48 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); |
50 | getInterfaceList(); | 49 | getInterfaceList(); |
51 | connectionList->header()->hide(); | 50 | connectionList->header()->hide(); |
52 | 51 | ||
53 | 52 | ||
54 | Config cfg("NetworkSetup"); | 53 | Config cfg("NetworkSetup"); |
55 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 54 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
56 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 55 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
57 | profilesList->insertItem((*it)); | 56 | profilesList->insertItem((*it)); |
58 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 57 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
59 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 58 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
60 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 59 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
61 | 60 | ||
62 | QFile file(scheme); | 61 | QFile file(scheme); |
63 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 62 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
64 | QTextStream stream( &file ); // use a text stream | 63 | QTextStream stream( &file ); // use a text stream |
65 | while ( !stream.eof() ) { // until end of file... | 64 | while ( !stream.eof() ) { // until end of file... |
66 | QString line = stream.readLine(); // line of text excluding '\n' | 65 | QString line = stream.readLine(); // line of text excluding '\n' |
67 | if(line.contains("SCHEME")){ | 66 | if(line.contains("SCHEME")){ |
68 | line = line.mid(7, line.length()); | 67 | line = line.mid(7, line.length()); |
69 | currentProfileLabel->setText(line); | 68 | currentProfileLabel->setText(line); |
70 | break; | 69 | break; |
71 | } | 70 | } |
72 | } | 71 | } |
73 | file.close(); | 72 | file.close(); |
74 | } | 73 | } |
75 | } | 74 | } |
76 | 75 | ||
77 | /** | 76 | /** |
78 | * Deconstructor. Save profiles. Delete loaded libraries. | 77 | * Deconstructor. Save profiles. Delete loaded libraries. |
79 | */ | 78 | */ |
80 | MainWindowImp::~MainWindowImp(){ | 79 | MainWindowImp::~MainWindowImp(){ |
81 | // Save profiles. | 80 | // Save profiles. |
82 | Config cfg("NetworkSetup"); | 81 | Config cfg("NetworkSetup"); |
83 | cfg.setGroup("General"); | 82 | cfg.setGroup("General"); |
84 | cfg.writeEntry("Profiles", profiles.join(" ")); | 83 | cfg.writeEntry("Profiles", profiles.join(" ")); |
85 | 84 | ||
86 | // Delete all interfaces that don't have owners. | 85 | // Delete all interfaces that don't have owners. |
87 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 86 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
88 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
89 | if(iIt.key()->getModuleOwner() == NULL) | 88 | if(iIt.key()->getModuleOwner() == NULL) |
90 | delete iIt.key(); | 89 | delete iIt.key(); |
91 | } | 90 | } |
92 | 91 | ||
93 | // Delete Modules and Libraries | 92 | // Delete Modules and Libraries |
94 | QMap<Module*, QLibrary*>::Iterator it; | 93 | QMap<Module*, QLibrary*>::Iterator it; |
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 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Load all modules that are found in the path | 103 | * Load all modules that are found in the path |
104 | * @param path a directory that is scaned for any plugins that can be loaded | 104 | * @param path a directory that is scaned for any plugins that can be loaded |
105 | * and attempts to load them | 105 | * and attempts to load them |
106 | */ | 106 | */ |
107 | void MainWindowImp::loadModules(QString path){ | 107 | void MainWindowImp::loadModules(QString path){ |
108 | //qDebug(path.latin1()); | 108 | //qDebug(path.latin1()); |
109 | QDir d(path); | 109 | QDir d(path); |
110 | if(!d.exists()) | 110 | if(!d.exists()) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Don't want sym links | 113 | // Don't want sym links |
114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
115 | const QFileInfoList *list = d.entryInfoList(); | 115 | const QFileInfoList *list = d.entryInfoList(); |
116 | QFileInfoListIterator it( *list ); | 116 | QFileInfoListIterator it( *list ); |
117 | QFileInfo *fi; | 117 | QFileInfo *fi; |
118 | while ( (fi=it.current()) ) { | 118 | while ( (fi=it.current()) ) { |
119 | if(fi->fileName().contains(".so")){ | 119 | if(fi->fileName().contains(".so")){ |
120 | loadPlugin(path + "/" + fi->fileName()); | 120 | loadPlugin(path + "/" + fi->fileName()); |
121 | } | 121 | } |
122 | ++it; | 122 | ++it; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Attempt to load a function and resolve a function. | 127 | * Attempt to load a function and resolve a function. |
128 | * @param pluginFileName - the name of the file in which to attempt to load | 128 | * @param pluginFileName - the name of the file in which to attempt to load |
129 | * @param resolveString - function pointer to resolve | 129 | * @param resolveString - function pointer to resolve |
130 | * @return pointer to the function with name resolveString or NULL | 130 | * @return pointer to the function with name resolveString or NULL |
131 | */ | 131 | */ |
132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
134 | QLibrary *lib = new QLibrary(pluginFileName); | 134 | QLibrary *lib = new QLibrary(pluginFileName); |
135 | void *functionPointer = lib->resolve(resolveString); | 135 | void *functionPointer = lib->resolve(resolveString); |
136 | if( !functionPointer ){ | 136 | if( !functionPointer ){ |
137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Try to get an object. | 142 | // Try to get an object. |
143 | Module *object = ((Module* (*)()) functionPointer)(); | 143 | Module *object = ((Module* (*)()) functionPointer)(); |
144 | if(object == NULL){ | 144 | if(object == NULL){ |
145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
146 | delete lib; | 146 | delete lib; |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Store for deletion later | 150 | // Store for deletion later |
151 | libraries.insert(object, lib); | 151 | libraries.insert(object, lib); |
152 | return object; | 152 | return object; |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 156 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
157 | * load the plugin and append it to the list | 157 | * load the plugin and append it to the list |
158 | */ | 158 | */ |
159 | void MainWindowImp::addClicked(){ | 159 | void MainWindowImp::addClicked(){ |
160 | QMap<Module*, QLibrary*>::Iterator it; | 160 | QMap<Module*, QLibrary*>::Iterator it; |
161 | QMap<QString, QString> list; | 161 | QMap<QString, QString> list; |
162 | QMap<QString, Module*> newInterfaceOwners; | 162 | QMap<QString, Module*> newInterfaceOwners; |
163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
166 | if(it.key()){ | 166 | if(it.key()){ |
167 | (it.key())->possibleNewInterfaces(list); | 167 | (it.key())->possibleNewInterfaces(list); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | // See if the list has anything that we can add. | 170 | // See if the list has anything that we can add. |
171 | if(list.count() == 0){ | 171 | if(list.count() == 0){ |
172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
176 | addNewConnection.addConnections(list); | 176 | addNewConnection.addConnections(list); |
177 | addNewConnection.showMaximized(); | 177 | addNewConnection.showMaximized(); |
178 | if(QDialog::Accepted == addNewConnection.exec()){ | 178 | if(QDialog::Accepted == addNewConnection.exec()){ |
179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
180 | if(!item) | 180 | if(!item) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
184 | if(it.key()){ | 184 | if(it.key()){ |
185 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 185 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
186 | if(i){ | 186 | if(i){ |
187 | interfaceNames.insert(i->getInterfaceName(), i); | 187 | interfaceNames.insert(i->getInterfaceName(), i); |
188 | updateInterface(i); | 188 | updateInterface(i); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Prompt the user to see if they really want to do this. | 196 | * Prompt the user to see if they really want to do this. |
197 | * If they do then remove from the list and unload. | 197 | * If they do then remove from the list and unload. |
198 | */ | 198 | */ |
199 | void MainWindowImp::removeClicked(){ | 199 | void MainWindowImp::removeClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 200 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item) { | 201 | if(!item) { |
202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); | 202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | 205 | ||
206 | Interface *i = interfaceItems[item]; | 206 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner() == NULL){ | 207 | if(i->getModuleOwner() == NULL){ |
208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
209 | } | 209 | } |
210 | else{ | 210 | else{ |
211 | if(!i->getModuleOwner()->remove(i)) | 211 | if(!i->getModuleOwner()->remove(i)) |
212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
213 | else{ | 213 | else{ |
214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
215 | // TODO memory managment.... | 215 | // TODO memory managment.... |
216 | // who deletes the interface? | 216 | // who deletes the interface? |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
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 | */ |
227 | void MainWindowImp::configureClicked(){ | 226 | void MainWindowImp::configureClicked(){ |
228 | QListViewItem *item = connectionList->currentItem(); | 227 | QListViewItem *item = connectionList->currentItem(); |
229 | if(!item){ | 228 | if(!item){ |
230 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
231 | return; | 230 | return; |
232 | } | 231 | } |
233 | 232 | ||
234 | QString currentProfile = currentProfileLabel->text(); | 233 | QString currentProfile = currentProfileLabel->text(); |
235 | if(profilesList->count() <= 1 || currentProfile == "All"){ | 234 | if(profilesList->count() <= 1 || currentProfile == "All"){ |
236 | currentProfile = ""; | 235 | currentProfile = ""; |
237 | } | 236 | } |
238 | 237 | ||
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 | } |
261 | 254 | ||
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 | */ |
268 | void MainWindowImp::informationClicked(){ | 260 | void MainWindowImp::informationClicked(){ |
269 | QListViewItem *item = connectionList->currentItem(); | 261 | QListViewItem *item = connectionList->currentItem(); |
270 | if(!item){ | 262 | if(!item){ |
271 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 263 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
272 | return; | 264 | return; |
273 | } | 265 | } |
274 | 266 | ||
275 | Interface *i = interfaceItems[item]; | 267 | Interface *i = interfaceItems[item]; |
276 | if(!i->isAttached()){ | 268 | if(!i->isAttached()){ |
277 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 269 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
278 | return; | 270 | return; |
279 | } | 271 | } |
280 | 272 | ||
281 | QStringList list; | 273 | QStringList list; |
282 | for(uint i = 0; i < profilesList->count(); i++){ | 274 | for(uint i = 0; i < profilesList->count(); i++){ |
283 | list.append(profilesList->text(i)); | 275 | list.append(profilesList->text(i)); |
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(); |
303 | } | 289 | } |
304 | 290 | ||
305 | /** | 291 | /** |
306 | * Aquire the list of active interfaces from ifconfig | 292 | * Aquire the list of active interfaces from ifconfig |
307 | * Call ifconfig and ifconfig -a | 293 | * Call ifconfig and ifconfig -a |
308 | */ | 294 | */ |
309 | void MainWindowImp::getInterfaceList(){ | 295 | void MainWindowImp::getInterfaceList(){ |
310 | KShellProcess *processAll = new KShellProcess(); | 296 | KShellProcess *processAll = new KShellProcess(); |
311 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 297 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
312 | connect(processAll, SIGNAL(processExited(KProcess *)), | 298 | connect(processAll, SIGNAL(processExited(KProcess *)), |
313 | this, SLOT(jobDone(KProcess *))); | 299 | this, SLOT(jobDone(KProcess *))); |
314 | threads.insert(processAll, TEMP_ALL); | 300 | threads.insert(processAll, TEMP_ALL); |
315 | 301 | ||
316 | KShellProcess *process = new KShellProcess(); | 302 | KShellProcess *process = new KShellProcess(); |
317 | *process << "/sbin/ifconfig" << " > " TEMP_UP; | 303 | *process << "/sbin/ifconfig" << " > " TEMP_UP; |
318 | connect(process, SIGNAL(processExited(KProcess *)), | 304 | connect(process, SIGNAL(processExited(KProcess *)), |
319 | this, SLOT(jobDone(KProcess *))); | 305 | this, SLOT(jobDone(KProcess *))); |
320 | threads.insert(process, TEMP_UP); | 306 | threads.insert(process, TEMP_UP); |
321 | 307 | ||
322 | processAll->start(KShellProcess::NotifyOnExit); | 308 | processAll->start(KShellProcess::NotifyOnExit); |
323 | process->start(KShellProcess::NotifyOnExit); | 309 | process->start(KShellProcess::NotifyOnExit); |
324 | } | 310 | } |
325 | 311 | ||
326 | void MainWindowImp::jobDone(KProcess *process){ | 312 | void MainWindowImp::jobDone(KProcess *process){ |
327 | QString fileName = threads[process]; | 313 | QString fileName = threads[process]; |
328 | threads.remove(process); | 314 | threads.remove(process); |
329 | delete process; | 315 | delete process; |
330 | 316 | ||
331 | QFile file(fileName); | 317 | QFile file(fileName); |
332 | if (!file.open(IO_ReadOnly)){ | 318 | if (!file.open(IO_ReadOnly)){ |
333 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); | 319 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); |
334 | return; | 320 | return; |
335 | } | 321 | } |
336 | 322 | ||
337 | QTextStream stream( &file ); | 323 | QTextStream stream( &file ); |
338 | QString line; | 324 | QString line; |
339 | while ( !stream.eof() ) { | 325 | while ( !stream.eof() ) { |
340 | line = stream.readLine(); | 326 | line = stream.readLine(); |
341 | int space = line.find(" "); | 327 | int space = line.find(" "); |
342 | if(space > 1){ | 328 | if(space > 1){ |
343 | // We have found an interface | 329 | // We have found an interface |
344 | QString interfaceName = line.mid(0, space); | 330 | QString interfaceName = line.mid(0, space); |
345 | Interface *i; | 331 | Interface *i; |
346 | // We have found an interface | 332 | // We have found an interface |
347 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | 333 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); |
348 | // See if we already have it | 334 | // See if we already have it |
349 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 335 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
350 | if(fileName == TEMP_ALL) | 336 | if(fileName == TEMP_ALL) |
351 | i = new Interface(this, interfaceName, false); | 337 | i = new Interface(this, interfaceName, false); |
352 | else | 338 | else |
353 | i = new Interface(this, interfaceName, true); | 339 | i = new Interface(this, interfaceName, true); |
354 | i->setAttached(true); | 340 | i->setAttached(true); |
355 | 341 | ||
356 | QString hardName = "Ethernet"; | 342 | QString hardName = "Ethernet"; |
357 | int hardwareName = line.find("Link encap:"); | 343 | int hardwareName = line.find("Link encap:"); |
358 | int macAddress = line.find("HWaddr"); | 344 | int macAddress = line.find("HWaddr"); |
359 | if(macAddress == -1) | 345 | if(macAddress == -1) |
360 | macAddress = line.length(); | 346 | macAddress = line.length(); |
361 | if(hardwareName != -1) | 347 | if(hardwareName != -1) |
362 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); | 348 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); |
363 | 349 | ||
364 | interfaceNames.insert(i->getInterfaceName(), i); | 350 | interfaceNames.insert(i->getInterfaceName(), i); |
365 | updateInterface(i); | 351 | updateInterface(i); |
366 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 352 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
367 | } | 353 | } |
368 | // It was an interface we already had. | 354 | // It was an interface we already had. |
369 | else{ | 355 | else{ |
370 | if(fileName != TEMP_ALL) | 356 | if(fileName != TEMP_ALL) |
371 | (interfaceNames[interfaceName])->setStatus(true); | 357 | (interfaceNames[interfaceName])->setStatus(true); |
372 | } | 358 | } |
373 | } | 359 | } |
374 | } | 360 | } |
375 | file.close(); | 361 | file.close(); |
376 | QFile::remove(fileName); | 362 | QFile::remove(fileName); |
377 | 363 | ||
378 | if(threads.count() == 0){ | 364 | if(threads.count() == 0){ |
379 | Interfaces i; | 365 | Interfaces i; |
380 | QStringList list = i.getInterfaceList(); | 366 | QStringList list = i.getInterfaceList(); |
381 | QMap<QString, Interface*>::Iterator it; | 367 | QMap<QString, Interface*>::Iterator it; |
382 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 368 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
383 | bool found = false; | 369 | bool found = false; |
384 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 370 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
385 | if(it.key() == (*ni)) | 371 | if(it.key() == (*ni)) |
386 | found = true; | 372 | found = true; |
387 | } | 373 | } |
388 | if(!found){ | 374 | if(!found){ |
389 | if(!(*ni).contains("_")){ | 375 | if(!(*ni).contains("_")){ |
390 | Interface *i = new Interface(this, *ni, false); | 376 | Interface *i = new Interface(this, *ni, false); |
391 | i->setAttached(false); | 377 | i->setAttached(false); |
392 | i->setHardwareName("Disconnected"); | 378 | i->setHardwareName("Disconnected"); |
393 | interfaceNames.insert(i->getInterfaceName(), i); | 379 | interfaceNames.insert(i->getInterfaceName(), i); |
394 | updateInterface(i); | 380 | updateInterface(i); |
395 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 381 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
396 | } | 382 | } |
397 | } | 383 | } |
398 | } | 384 | } |
399 | } | 385 | } |
400 | } | 386 | } |
401 | 387 | ||
402 | /** | 388 | /** |
403 | * Update this interface. If no QListViewItem exists create one. | 389 | * Update this interface. If no QListViewItem exists create one. |
404 | * @param Interface* pointer to the interface that needs to be updated. | 390 | * @param Interface* pointer to the interface that needs to be updated. |
405 | */ | 391 | */ |
406 | void MainWindowImp::updateInterface(Interface *i){ | 392 | void MainWindowImp::updateInterface(Interface *i){ |
407 | if(!advancedUserMode){ | 393 | if(!advancedUserMode){ |
408 | if(i->getInterfaceName() == "lo") | 394 | if(i->getInterfaceName() == "lo") |
409 | return; | 395 | return; |
410 | } | 396 | } |
411 | 397 | ||
412 | QListViewItem *item = NULL; | 398 | QListViewItem *item = NULL; |
413 | 399 | ||
414 | // Find the interface, making it if needed. | 400 | // Find the interface, making it if needed. |
415 | if(items.find(i) == items.end()){ | 401 | if(items.find(i) == items.end()){ |
416 | item = new QListViewItem(connectionList, "", "", ""); | 402 | item = new QListViewItem(connectionList, "", "", ""); |
417 | // See if you can't find a module owner for this interface | 403 | // See if you can't find a module owner for this interface |
418 | QMap<Module*, QLibrary*>::Iterator it; | 404 | QMap<Module*, QLibrary*>::Iterator it; |
419 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 405 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
420 | if(it.key()->isOwner(i)) | 406 | if(it.key()->isOwner(i)) |
421 | i->setModuleOwner(it.key()); | 407 | i->setModuleOwner(it.key()); |
422 | } | 408 | } |
423 | items.insert(i, item); | 409 | items.insert(i, item); |
424 | interfaceItems.insert(item, i); | 410 | interfaceItems.insert(item, i); |
425 | } | 411 | } |
426 | else | 412 | else |
427 | item = items[i]; | 413 | item = items[i]; |
428 | 414 | ||
429 | // Update the icons and information | 415 | // Update the icons and information |
430 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 416 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
431 | 417 | ||
432 | QString typeName = "lan"; | 418 | QString typeName = "lan"; |
433 | if(i->getHardwareName().contains("Local Loopback")) | 419 | if(i->getHardwareName().contains("Local Loopback")) |
434 | typeName = "lo"; | 420 | typeName = "lo"; |
435 | if(i->getInterfaceName().contains("irda")) | 421 | if(i->getInterfaceName().contains("irda")) |
436 | typeName = "irda"; | 422 | typeName = "irda"; |
437 | if(i->getInterfaceName().contains("wlan")) | 423 | if(i->getInterfaceName().contains("wlan")) |
438 | typeName = "wlan"; | 424 | typeName = "wlan"; |
439 | if(i->getInterfaceName().contains("usb")) | 425 | if(i->getInterfaceName().contains("usb")) |
440 | typeName = "usb"; | 426 | typeName = "usb"; |
441 | 427 | ||
442 | if(!i->isAttached()) | 428 | if(!i->isAttached()) |
443 | typeName = "connect_no"; | 429 | typeName = "connect_no"; |
444 | // Actually try to use the Module | 430 | // Actually try to use the Module |
445 | if(i->getModuleOwner() != NULL) | 431 | if(i->getModuleOwner() != NULL) |
446 | typeName = i->getModuleOwner()->getPixmapName(i); | 432 | typeName = i->getModuleOwner()->getPixmapName(i); |
447 | 433 | ||
448 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 434 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
449 | item->setText(2, i->getHardwareName()); | 435 | item->setText(2, i->getHardwareName()); |
450 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 436 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
451 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 437 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
452 | } | 438 | } |
453 | 439 | ||
454 | void MainWindowImp::newProfileChanged(const QString& newText){ | 440 | void MainWindowImp::newProfileChanged(const QString& newText){ |
455 | if(newText.length() > 0) | 441 | if(newText.length() > 0) |
456 | newProfileButton->setEnabled(true); | 442 | newProfileButton->setEnabled(true); |
457 | else | 443 | else |
458 | newProfileButton->setEnabled(false); | 444 | newProfileButton->setEnabled(false); |
459 | } | 445 | } |
460 | 446 | ||
461 | /** | 447 | /** |
462 | * Adds a new profile to the list of profiles. | 448 | * Adds a new profile to the list of profiles. |
463 | * Don't add profiles that already exists. | 449 | * Don't add profiles that already exists. |
464 | * Appends to the list and QStringList | 450 | * Appends to the list and QStringList |
465 | */ | 451 | */ |
466 | void MainWindowImp::addProfile(){ | 452 | void MainWindowImp::addProfile(){ |
467 | QString newProfileName = newProfile->text(); | 453 | QString newProfileName = newProfile->text(); |
468 | if(profiles.grep(newProfileName).count() > 0){ | 454 | if(profiles.grep(newProfileName).count() > 0){ |
469 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); | 455 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); |
470 | return; | 456 | return; |
471 | } | 457 | } |
472 | profiles.append(newProfileName); | 458 | profiles.append(newProfileName); |
473 | profilesList->insertItem(newProfileName); | 459 | profilesList->insertItem(newProfileName); |
474 | } | 460 | } |
475 | 461 | ||
476 | /** | 462 | /** |
477 | * Removes the currently selected profile in the combo. | 463 | * Removes the currently selected profile in the combo. |
478 | * Doesn't delete if there are less then 2 profiles. | 464 | * Doesn't delete if there are less then 2 profiles. |
479 | */ | 465 | */ |
480 | void MainWindowImp::removeProfile(){ | 466 | void MainWindowImp::removeProfile(){ |
481 | if(profilesList->count() <= 1){ | 467 | if(profilesList->count() <= 1){ |
482 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); | 468 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); |
483 | return; | 469 | return; |
484 | } | 470 | } |
485 | QString profileToRemove = profilesList->currentText(); | 471 | QString profileToRemove = profilesList->currentText(); |
486 | if(profileToRemove == "All"){ | 472 | if(profileToRemove == "All"){ |
487 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); | 473 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); |
488 | return; | 474 | return; |
489 | } | 475 | } |
490 | // Can't remove the curent profile | 476 | // Can't remove the curent profile |
491 | if(profileToRemove == currentProfileLabel->text()){ | 477 | if(profileToRemove == currentProfileLabel->text()){ |
492 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); | 478 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); |
493 | return; | 479 | return; |
494 | 480 | ||
495 | } | 481 | } |
496 | 482 | ||
497 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 483 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
498 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 484 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
499 | profilesList->clear(); | 485 | profilesList->clear(); |
500 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 486 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
501 | profilesList->insertItem((*it)); | 487 | profilesList->insertItem((*it)); |
502 | 488 | ||
503 | // Remove any interface settings and mappings. | 489 | // Remove any interface settings and mappings. |
504 | Interfaces interfaces; | 490 | Interfaces interfaces; |
505 | // Go through them one by one | 491 | // Go through them one by one |
506 | QMap<Interface*, QListViewItem*>::Iterator it; | 492 | QMap<Interface*, QListViewItem*>::Iterator it; |
507 | for( it = items.begin(); it != items.end(); ++it ){ | 493 | for( it = items.begin(); it != items.end(); ++it ){ |
508 | QString interfaceName = it.key()->getInterfaceName(); | 494 | QString interfaceName = it.key()->getInterfaceName(); |
509 | qDebug(interfaceName.latin1()); | 495 | qDebug(interfaceName.latin1()); |
510 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 496 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
511 | interfaces.removeInterface(); | 497 | interfaces.removeInterface(); |
512 | if(interfaces.setMapping(interfaceName)){ | 498 | if(interfaces.setMapping(interfaceName)){ |
513 | if(profilesList->count() == 1) | 499 | if(profilesList->count() == 1) |
514 | interfaces.removeMapping(); | 500 | interfaces.removeMapping(); |
515 | else{ | 501 | else{ |
516 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 502 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
517 | } | 503 | } |
518 | } | 504 | } |
519 | interfaces.write(); | 505 | interfaces.write(); |
520 | break; | 506 | break; |
521 | } | 507 | } |
522 | } | 508 | } |
523 | } | 509 | } |
524 | } | 510 | } |
525 | 511 | ||
526 | /** | 512 | /** |
527 | * A new profile has been selected, change. | 513 | * A new profile has been selected, change. |
528 | * @param newProfile the new profile. | 514 | * @param newProfile the new profile. |
529 | */ | 515 | */ |
530 | void MainWindowImp::changeProfile(){ | 516 | void MainWindowImp::changeProfile(){ |
531 | if(profilesList->currentItem() == -1){ | 517 | if(profilesList->currentItem() == -1){ |
532 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); | 518 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); |
533 | return; | 519 | return; |
534 | } | 520 | } |
535 | QString newProfile = profilesList->text(profilesList->currentItem()); | 521 | QString newProfile = profilesList->text(profilesList->currentItem()); |
536 | if(newProfile != currentProfileLabel->text()){ | 522 | if(newProfile != currentProfileLabel->text()){ |
537 | currentProfileLabel->setText(newProfile); | 523 | currentProfileLabel->setText(newProfile); |
538 | QFile::remove(scheme); | 524 | QFile::remove(scheme); |
539 | QFile file(scheme); | 525 | QFile file(scheme); |
540 | if ( file.open(IO_ReadWrite) ) { | 526 | if ( file.open(IO_ReadWrite) ) { |
541 | QTextStream stream( &file ); | 527 | QTextStream stream( &file ); |
542 | stream << QString("SCHEME=%1").arg(newProfile); | 528 | stream << QString("SCHEME=%1").arg(newProfile); |
543 | file.close(); | 529 | file.close(); |
544 | } | 530 | } |
545 | // restart all up devices? | 531 | // restart all up devices? |
546 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 532 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
547 | // Go through them one by one | 533 | // Go through them one by one |
548 | QMap<Interface*, QListViewItem*>::Iterator it; | 534 | QMap<Interface*, QListViewItem*>::Iterator it; |
549 | for( it = items.begin(); it != items.end(); ++it ){ | 535 | for( it = items.begin(); it != items.end(); ++it ){ |
550 | if(it.key()->getStatus() == true) | 536 | if(it.key()->getStatus() == true) |
551 | it.key()->restart(); | 537 | it.key()->restart(); |
552 | } | 538 | } |
553 | } | 539 | } |
554 | } | 540 | } |
555 | } | 541 | } |
556 | 542 | ||
557 | // mainwindowimp.cpp | 543 | // mainwindowimp.cpp |
558 | 544 | ||
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 | |||
@@ -1,88 +1,86 @@ | |||
1 | #ifndef NETCONF_MODULE_H | 1 | #ifndef NETCONF_MODULE_H |
2 | #define NETCONF_MODULE_H | 2 | #define NETCONF_MODULE_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <qmap.h> | 6 | #include <qmap.h> |
7 | #include "interface.h" | 7 | #include "interface.h" |
8 | 8 | ||
9 | class QWidget; | 9 | class QWidget; |
10 | class QTabWidget; | 10 | class QTabWidget; |
11 | 11 | ||
12 | class Module : QObject{ | 12 | class Module : QObject{ |
13 | 13 | ||
14 | signals: | 14 | signals: |
15 | void updateInterface(Interface *i); | 15 | void updateInterface(Interface *i); |
16 | 16 | ||
17 | public: | 17 | public: |
18 | Module(){}; | 18 | Module(){}; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * The current profile has been changed and the module should do any | 21 | * The current profile has been changed and the module should do any |
22 | * neccesary changes also. | 22 | * neccesary changes also. |
23 | * @param newProfile what the profile should be changed to. | 23 | * @param newProfile what the profile should be changed to. |
24 | */ | 24 | */ |
25 | virtual void setProfile(QString newProfile) = 0; | 25 | virtual void setProfile(QString newProfile) = 0; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * get the icon name for this device. | 28 | * get the icon name for this device. |
29 | * @param Interface* can be used in determining the icon. | 29 | * @param Interface* can be used in determining the icon. |
30 | * @return QString the icon name (minus .png, .gif etc) | 30 | * @return QString the icon name (minus .png, .gif etc) |
31 | */ | 31 | */ |
32 | virtual QString getPixmapName(Interface *) = 0; | 32 | virtual QString getPixmapName(Interface *) = 0; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Check to see if the interface i is owned by this module. | 35 | * Check to see if the interface i is owned by this module. |
36 | * @param Interface* interface to check against | 36 | * @param Interface* interface to check against |
37 | * @return bool true if i is owned by this module, false otherwise. | 37 | * @return bool true if i is owned by this module, false otherwise. |
38 | */ | 38 | */ |
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 |
59 | * @return QList<Interface> A list of interfaces that exsist that havn't | 57 | * @return QList<Interface> A list of interfaces that exsist that havn't |
60 | * been called by isOwner() | 58 | * been called by isOwner() |
61 | */ | 59 | */ |
62 | virtual QList<Interface> getInterfaces() = 0; | 60 | virtual QList<Interface> getInterfaces() = 0; |
63 | 61 | ||
64 | /** | 62 | /** |
65 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), | 63 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), |
66 | * modem ppp) | 64 | * modem ppp) |
67 | */ | 65 | */ |
68 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; | 66 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; |
69 | 67 | ||
70 | /** | 68 | /** |
71 | * Attempts to create a new interface from name | 69 | * Attempts to create a new interface from name |
72 | * @return Interface* NULL if it was unable to be created. | 70 | * @return Interface* NULL if it was unable to be created. |
73 | * @param name the type of interface to create | 71 | * @param name the type of interface to create |
74 | */ | 72 | */ |
75 | virtual Interface *addNewInterface(QString name) = 0; | 73 | virtual Interface *addNewInterface(QString name) = 0; |
76 | 74 | ||
77 | /** | 75 | /** |
78 | * Attempts to remove the interface, doesn't delete i | 76 | * Attempts to remove the interface, doesn't delete i |
79 | * @return bool true if successfull, false otherwise. | 77 | * @return bool true if successfull, false otherwise. |
80 | */ | 78 | */ |
81 | virtual bool remove(Interface* i) = 0; | 79 | virtual bool remove(Interface* i) = 0; |
82 | 80 | ||
83 | }; | 81 | }; |
84 | 82 | ||
85 | #endif | 83 | #endif |
86 | 84 | ||
87 | // module.h | 85 | // module.h |
88 | 86 | ||
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 |
9 | LIBS += -lqpe | 9 | LIBS += -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 | |||
@@ -1,175 +1,175 @@ | |||
1 | #include "wextensions.h" | 1 | #include "wextensions.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | 5 | ||
6 | #include <arpa/inet.h> | 6 | #include <arpa/inet.h> |
7 | #include <sys/socket.h> | 7 | #include <sys/socket.h> |
8 | #include <sys/ioctl.h> | 8 | #include <sys/ioctl.h> |
9 | 9 | ||
10 | #include <math.h> | 10 | #include <math.h> |
11 | 11 | ||
12 | #define PROCNETWIRELESS "/proc/net/wireless" | 12 | #define PROCNETWIRELESS "/proc/net/wireless" |
13 | #define IW_LOWER 0 | 13 | #define IW_LOWER 0 |
14 | #define IW_UPPER 256 | 14 | #define IW_UPPER 256 |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructor. Sets hasWirelessExtensions | 17 | * Constructor. Sets hasWirelessExtensions |
18 | */ | 18 | */ |
19 | WExtensions::WExtensions(QString interfaceName){ | 19 | WExtensions::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 ) ); |
25 | iwr.u.essid.pointer = (caddr_t) buffer; | 27 | iwr.u.essid.pointer = (caddr_t) buffer; |
26 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 28 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
27 | iwr.u.essid.flags = 0; | 29 | iwr.u.essid.flags = 0; |
28 | 30 | ||
29 | // check if it is an IEEE 802.11 standard conform | 31 | // check if it is an IEEE 802.11 standard conform |
30 | // wireless device by sending SIOCGIWESSID | 32 | // wireless device by sending SIOCGIWESSID |
31 | // which also gives back the Extended Service Set ID | 33 | // which also gives back the Extended Service Set ID |
32 | // (see IEEE 802.11 for more information) | 34 | // (see IEEE 802.11 for more information) |
33 | 35 | ||
34 | const char* iname = interface.latin1(); | 36 | const char* iname = interface.latin1(); |
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 | /** |
43 | * @return QString the station name of the access point. | 43 | * @return QString the station name of the access point. |
44 | */ | 44 | */ |
45 | QString WExtensions::station(){ | 45 | QString WExtensions::station(){ |
46 | if(!hasWirelessExtensions) | 46 | if(!hasWirelessExtensions) |
47 | return QString(); | 47 | return QString(); |
48 | const char* buffer[200]; | 48 | const char* buffer[200]; |
49 | iwr.u.data.pointer = (caddr_t) buffer; | 49 | iwr.u.data.pointer = (caddr_t) buffer; |
50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
51 | iwr.u.data.flags = 0; | 51 | iwr.u.data.flags = 0; |
52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | 52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ |
53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
54 | return QString(iwr.u.data.pointer); | 54 | return QString(iwr.u.data.pointer); |
55 | } | 55 | } |
56 | return QString(); | 56 | return QString(); |
57 | } | 57 | } |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * @return QString the essid of the host 802.11 access point. | 60 | * @return QString the essid of the host 802.11 access point. |
61 | */ | 61 | */ |
62 | QString WExtensions::essid(){ | 62 | QString WExtensions::essid(){ |
63 | if(!hasWirelessExtensions) | 63 | if(!hasWirelessExtensions) |
64 | return QString(); | 64 | return QString(); |
65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | 66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; |
67 | return QString(iwr.u.essid.pointer); | 67 | return QString(iwr.u.essid.pointer); |
68 | } | 68 | } |
69 | return QString(); | 69 | return QString(); |
70 | } | 70 | } |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * @return QString the mode of interface | 73 | * @return QString the mode of interface |
74 | */ | 74 | */ |
75 | QString WExtensions::mode(){ | 75 | QString WExtensions::mode(){ |
76 | if(!hasWirelessExtensions) | 76 | if(!hasWirelessExtensions) |
77 | return QString(); | 77 | return QString(); |
78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
80 | return QString(); | 80 | return QString(); |
81 | } | 81 | } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Get the frequency that the interface is running at. | 84 | * Get the frequency that the interface is running at. |
85 | * @return int the frequency that the interfacae is running at. | 85 | * @return int the frequency that the interfacae is running at. |
86 | */ | 86 | */ |
87 | double WExtensions::frequency(){ | 87 | double WExtensions::frequency(){ |
88 | if(!hasWirelessExtensions) | 88 | if(!hasWirelessExtensions) |
89 | return 0; | 89 | return 0; |
90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
92 | return 0; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | /*** | 95 | /*** |
96 | * Get the current rate that the card is transmiting at. | 96 | * Get the current rate that the card is transmiting at. |
97 | */ | 97 | */ |
98 | double WExtensions::rate(){ | 98 | double WExtensions::rate(){ |
99 | if(!hasWirelessExtensions) | 99 | if(!hasWirelessExtensions) |
100 | return 0; | 100 | return 0; |
101 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | 101 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ |
102 | return ((double)iwr.u.bitrate.value)/1000000; | 102 | return ((double)iwr.u.bitrate.value)/1000000; |
103 | } | 103 | } |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | /** | 108 | /** |
109 | * @return QString the AccessPoint that the interface is connected to. | 109 | * @return QString the AccessPoint that the interface is connected to. |
110 | */ | 110 | */ |
111 | QString WExtensions::ap(){ | 111 | QString WExtensions::ap(){ |
112 | if(!hasWirelessExtensions) | 112 | if(!hasWirelessExtensions) |
113 | return QString(); | 113 | return QString(); |
114 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ | 114 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ |
115 | QString ap; | 115 | QString ap; |
116 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 116 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
117 | iwr.u.ap_addr.sa_data[0]&0xff, | 117 | iwr.u.ap_addr.sa_data[0]&0xff, |
118 | iwr.u.ap_addr.sa_data[1]&0xff, | 118 | iwr.u.ap_addr.sa_data[1]&0xff, |
119 | iwr.u.ap_addr.sa_data[2]&0xff, | 119 | iwr.u.ap_addr.sa_data[2]&0xff, |
120 | iwr.u.ap_addr.sa_data[3]&0xff, | 120 | iwr.u.ap_addr.sa_data[3]&0xff, |
121 | iwr.u.ap_addr.sa_data[4]&0xff, | 121 | iwr.u.ap_addr.sa_data[4]&0xff, |
122 | iwr.u.ap_addr.sa_data[5]&0xff ); | 122 | iwr.u.ap_addr.sa_data[5]&0xff ); |
123 | return ap; | 123 | return ap; |
124 | } | 124 | } |
125 | else return QString(); | 125 | else return QString(); |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Get the stats for interfaces | 129 | * Get the stats for interfaces |
130 | * @param signal the signal strength of interface | 130 | * @param signal the signal strength of interface |
131 | * @param noise the noise level of the interface | 131 | * @param noise the noise level of the interface |
132 | * @param quality the quality level of the interface | 132 | * @param quality the quality level of the interface |
133 | * @return bool true if successfull | 133 | * @return bool true if successfull |
134 | */ | 134 | */ |
135 | bool WExtensions::stats(int &signal, int &noise, int &quality){ | 135 | bool WExtensions::stats(int &signal, int &noise, int &quality){ |
136 | // gather link quality from /proc/net/wireless | 136 | // gather link quality from /proc/net/wireless |
137 | if(!QFile::exists(PROCNETWIRELESS)) | 137 | if(!QFile::exists(PROCNETWIRELESS)) |
138 | return false; | 138 | return false; |
139 | 139 | ||
140 | char c; | 140 | char c; |
141 | QString status; | 141 | QString status; |
142 | QString name; | 142 | QString name; |
143 | 143 | ||
144 | QFile wfile( PROCNETWIRELESS ); | 144 | QFile wfile( PROCNETWIRELESS ); |
145 | if(!wfile.open( IO_ReadOnly )) | 145 | if(!wfile.open( IO_ReadOnly )) |
146 | return false; | 146 | return false; |
147 | 147 | ||
148 | QTextStream wstream( &wfile ); | 148 | QTextStream wstream( &wfile ); |
149 | wstream.readLine(); // skip the first two lines | 149 | wstream.readLine(); // skip the first two lines |
150 | wstream.readLine(); // because they only contain headers | 150 | wstream.readLine(); // because they only contain headers |
151 | while(!wstream.atEnd()){ | 151 | while(!wstream.atEnd()){ |
152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
153 | if(name == QString("%1:").arg(interface)){ | 153 | if(name == QString("%1:").arg(interface)){ |
154 | if ( quality > 92 ) | 154 | if ( quality > 92 ) |
155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
160 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); | 160 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | 161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; |
162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | 162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; |
163 | quality = ( quality*100 ) / 92; | 163 | quality = ( quality*100 ) / 92; |
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | qDebug("WExtensions::statsCard no longer present."); | 168 | qDebug("WExtensions::statsCard no longer present."); |
169 | quality = -1; | 169 | quality = -1; |
170 | signal = IW_LOWER; | 170 | signal = IW_LOWER; |
171 | noise = IW_LOWER; | 171 | noise = IW_LOWER; |
172 | return false; | 172 | return false; |
173 | } | 173 | } |
174 | 174 | ||
175 | // wextensions.cpp | 175 | // wextensions.cpp |
diff --git a/noncore/settings/networksettings/wlan/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 | |||
@@ -1,12 +1,12 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 3 | #CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/plugins/networksetup | 4 | DESTDIR = $(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 |
9 | LIBS += -lqpe | 9 | LIBS += -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 | |||
@@ -1,234 +1,244 @@ | |||
1 | #include "wlanimp.h" | 1 | #include "wlanimp.h" |
2 | 2 | ||
3 | /* Config class */ | 3 | /* Config class */ |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | /* Global namespace */ | 5 | /* Global namespace */ |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | #include <qpe/config.h> | ||
19 | #include <qtabwidget.h> | ||
20 | #include "interfacesetupimp.h" | ||
18 | 21 | ||
19 | WLANImp::WLANImp( QWidget* parent, const char* name, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ | 22 | WLANImp::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 | ||
24 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
25 | delete config; | 33 | delete config; |
26 | } | 34 | } |
27 | 35 | ||
28 | void WLANImp::readConfig() | 36 | void WLANImp::readConfig() |
29 | { | 37 | { |
30 | qWarning( "WLANImp::readConfig() called." ); | 38 | qWarning( "WLANImp::readConfig() called." ); |
31 | config->setGroup( "Properties" ); | 39 | config->setGroup( "Properties" ); |
32 | QString ssid = config->readEntry( "SSID", "any" ); | 40 | QString ssid = config->readEntry( "SSID", "any" ); |
33 | if( ssid == "any" || ssid == "ANY" ){ | 41 | if( ssid == "any" || ssid == "ANY" ){ |
34 | essNon->setChecked( true ); | 42 | essNon->setChecked( true ); |
35 | } else { | 43 | } else { |
36 | essSpecific->setChecked( true ); | 44 | essSpecific->setChecked( true ); |
37 | essSpecificLineEdit->setText( ssid ); | 45 | essSpecificLineEdit->setText( ssid ); |
38 | } | 46 | } |
39 | QString mode = config->readEntry( "Mode", "Managed" ); | 47 | QString mode = config->readEntry( "Mode", "Managed" ); |
40 | if( mode == "adhoc" ) { | 48 | if( mode == "adhoc" ) { |
41 | network802->setChecked( true ); | 49 | network802->setChecked( true ); |
42 | } else { | 50 | } else { |
43 | networkInfrastructure->setChecked( true ); | 51 | networkInfrastructure->setChecked( true ); |
44 | } | 52 | } |
45 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
46 | // config->readEntry( "RATE", "auto" ); | 54 | // config->readEntry( "RATE", "auto" ); |
47 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
48 | config->readEntry( "AuthType", "opensystem" ); | 56 | config->readEntry( "AuthType", "opensystem" ); |
49 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
50 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
51 | switch( defaultkey ){ | 59 | switch( defaultkey ){ |
52 | case 0: | 60 | case 0: |
53 | keyRadio0->setChecked( true ); | 61 | keyRadio0->setChecked( true ); |
54 | break; | 62 | break; |
55 | case 1: | 63 | case 1: |
56 | keyRadio1->setChecked( true ); | 64 | keyRadio1->setChecked( true ); |
57 | break; | 65 | break; |
58 | case 2: | 66 | case 2: |
59 | keyRadio2->setChecked( true ); | 67 | keyRadio2->setChecked( true ); |
60 | break; | 68 | break; |
61 | case 3: | 69 | case 3: |
62 | keyRadio3->setChecked( true ); | 70 | keyRadio3->setChecked( true ); |
63 | break; | 71 | break; |
64 | } | 72 | } |
65 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
66 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
67 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
68 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
69 | return; | 77 | return; |
70 | } | 78 | } |
71 | 79 | ||
72 | bool WLANImp::writeConfig() | 80 | bool WLANImp::writeConfig() |
73 | { | 81 | { |
74 | qWarning( "WLANImp::writeConfig() called." ); | 82 | qWarning( "WLANImp::writeConfig() called." ); |
75 | config->setGroup( "Properties" ); | 83 | config->setGroup( "Properties" ); |
76 | if( essNon->isChecked() ) { | 84 | if( essNon->isChecked() ) { |
77 | config->writeEntry( "SSID", "any" ); | 85 | config->writeEntry( "SSID", "any" ); |
78 | } else { | 86 | } else { |
79 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
80 | } | 88 | } |
81 | if( networkInfrastructure->isChecked() ){ | 89 | if( networkInfrastructure->isChecked() ){ |
82 | config->writeEntry( "Mode", "Managed" ); | 90 | config->writeEntry( "Mode", "Managed" ); |
83 | } else if( network802->isChecked() ){ | 91 | } else if( network802->isChecked() ){ |
84 | config->writeEntry( "Mode", "adhoc" ); | 92 | config->writeEntry( "Mode", "adhoc" ); |
85 | } | 93 | } |
86 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 94 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
87 | // config->readEntry( "RATE", "auto" ); | 95 | // config->readEntry( "RATE", "auto" ); |
88 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
89 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
90 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
91 | if( keyRadio0->isChecked() ){ | 99 | if( keyRadio0->isChecked() ){ |
92 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
93 | } else if( keyRadio1->isChecked() ){ | 101 | } else if( keyRadio1->isChecked() ){ |
94 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
95 | } else if( keyRadio2->isChecked() ){ | 103 | } else if( keyRadio2->isChecked() ){ |
96 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
97 | } else if( keyRadio3->isChecked() ){ | 105 | } else if( keyRadio3->isChecked() ){ |
98 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
99 | } | 107 | } |
100 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
101 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
102 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
103 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
104 | return true; | 112 | return true; |
105 | return writeWirelessOpts( ); | 113 | return writeWirelessOpts( ); |
106 | } | 114 | } |
107 | 115 | ||
108 | /** | 116 | /** |
109 | */ | 117 | */ |
110 | void WLANImp::accept() | 118 | void WLANImp::accept() |
111 | { | 119 | { |
112 | if ( writeConfig() ) | 120 | if ( writeConfig() ){ |
121 | interfaceSetup->saveChanges(); | ||
113 | QDialog::accept(); | 122 | QDialog::accept(); |
123 | } | ||
114 | } | 124 | } |
115 | 125 | ||
116 | bool WLANImp::writeWirelessOpts( QString scheme ) | 126 | bool WLANImp::writeWirelessOpts( QString scheme ) |
117 | { | 127 | { |
118 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 128 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
119 | QString prev = "/etc/pcmcia/wireless.opts"; | 129 | QString prev = "/etc/pcmcia/wireless.opts"; |
120 | QFile prevFile(prev); | 130 | QFile prevFile(prev); |
121 | if ( !prevFile.open( IO_ReadOnly ) ) | 131 | if ( !prevFile.open( IO_ReadOnly ) ) |
122 | return false; | 132 | return false; |
123 | 133 | ||
124 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 134 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
125 | QFile tmpFile(tmp); | 135 | QFile tmpFile(tmp); |
126 | if ( !tmpFile.open( IO_WriteOnly ) ) | 136 | if ( !tmpFile.open( IO_WriteOnly ) ) |
127 | return false; | 137 | return false; |
128 | 138 | ||
129 | bool retval = true; | 139 | bool retval = true; |
130 | 140 | ||
131 | QTextStream in( &prevFile ); | 141 | QTextStream in( &prevFile ); |
132 | QTextStream out( &tmpFile ); | 142 | QTextStream out( &tmpFile ); |
133 | 143 | ||
134 | config->setGroup("Properties"); | 144 | config->setGroup("Properties"); |
135 | 145 | ||
136 | QString line; | 146 | QString line; |
137 | bool found=false; | 147 | bool found=false; |
138 | bool done=false; | 148 | bool done=false; |
139 | while ( !in.atEnd() ) { | 149 | while ( !in.atEnd() ) { |
140 | QString line = in.readLine(); | 150 | QString line = in.readLine(); |
141 | QString wline = line.simplifyWhiteSpace(); | 151 | QString wline = line.simplifyWhiteSpace(); |
142 | if ( !done ) { | 152 | if ( !done ) { |
143 | if ( found ) { | 153 | if ( found ) { |
144 | // skip existing entry for this scheme, and write our own. | 154 | // skip existing entry for this scheme, and write our own. |
145 | if ( wline == ";;" ) { | 155 | if ( wline == ";;" ) { |
146 | found = false; | 156 | found = false; |
147 | continue; | 157 | continue; |
148 | } else { | 158 | } else { |
149 | continue; | 159 | continue; |
150 | } | 160 | } |
151 | } else { | 161 | } else { |
152 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 162 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
153 | found=true; | 163 | found=true; |
154 | continue; // skip this line | 164 | continue; // skip this line |
155 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 165 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
156 | // end - add new entry | 166 | // end - add new entry |
157 | // Not all fields have a GUI, but all are supported | 167 | // Not all fields have a GUI, but all are supported |
158 | // in the letwork configuration files. | 168 | // in the letwork configuration files. |
159 | static const char* txtfields[] = { | 169 | static const char* txtfields[] = { |
160 | 0 | 170 | 0 |
161 | }; | 171 | }; |
162 | QString readmode = config->readEntry( "Mode", "Managed" ); | 172 | QString readmode = config->readEntry( "Mode", "Managed" ); |
163 | QString mode; | 173 | QString mode; |
164 | if( readmode == "Managed" ){ | 174 | if( readmode == "Managed" ){ |
165 | mode = readmode; | 175 | mode = readmode; |
166 | } else if( readmode == "adhoc" ){ | 176 | } else if( readmode == "adhoc" ){ |
167 | mode = "Ad-Hoc"; | 177 | mode = "Ad-Hoc"; |
168 | } | 178 | } |
169 | QString key; | 179 | QString key; |
170 | if( wepEnabled->isChecked() ){ | 180 | if( wepEnabled->isChecked() ){ |
171 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 181 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
172 | switch( defaultkey ){ | 182 | switch( defaultkey ){ |
173 | case 0: | 183 | case 0: |
174 | key += keyLineEdit0->text(); | 184 | key += keyLineEdit0->text(); |
175 | break; | 185 | break; |
176 | case 1: | 186 | case 1: |
177 | key += keyLineEdit1->text(); | 187 | key += keyLineEdit1->text(); |
178 | break; | 188 | break; |
179 | case 2: | 189 | case 2: |
180 | key += keyLineEdit2->text(); | 190 | key += keyLineEdit2->text(); |
181 | break; | 191 | break; |
182 | case 3: | 192 | case 3: |
183 | key += keyLineEdit3->text(); | 193 | key += keyLineEdit3->text(); |
184 | break; | 194 | break; |
185 | } | 195 | } |
186 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 196 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
187 | key += " open"; | 197 | key += " open"; |
188 | } | 198 | } |
189 | out << scheme << ",*,*,*)" << "\n" | 199 | out << scheme << ",*,*,*)" << "\n" |
190 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 200 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
191 | << " MODE=" << mode << "\n" | 201 | << " MODE=" << mode << "\n" |
192 | << " KEY=" << Global::shellQuote( key ) << "\n" | 202 | << " KEY=" << Global::shellQuote( key ) << "\n" |
193 | << " RATE=" << "auto" << "\n" | 203 | << " RATE=" << "auto" << "\n" |
194 | ; | 204 | ; |
195 | if( mode != "Managed" ) | 205 | if( mode != "Managed" ) |
196 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 206 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
197 | const char** f = txtfields; | 207 | const char** f = txtfields; |
198 | while (*f) { | 208 | while (*f) { |
199 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 209 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
200 | ++f; | 210 | ++f; |
201 | } | 211 | } |
202 | out << " ;;\n"; | 212 | out << " ;;\n"; |
203 | done = true; | 213 | done = true; |
204 | } | 214 | } |
205 | } | 215 | } |
206 | } | 216 | } |
207 | out << line << "\n"; | 217 | out << line << "\n"; |
208 | } | 218 | } |
209 | 219 | ||
210 | prevFile.close(); | 220 | prevFile.close(); |
211 | tmpFile.close(); | 221 | tmpFile.close(); |
212 | QString initpath; | 222 | QString initpath; |
213 | //system("cardctl suspend"); | 223 | //system("cardctl suspend"); |
214 | if( QDir("/etc/rc.d/init.d").exists() ){ | 224 | if( QDir("/etc/rc.d/init.d").exists() ){ |
215 | initpath = "/etc/rc.d/init.d"; | 225 | initpath = "/etc/rc.d/init.d"; |
216 | } else if( QDir("/etc/init.d").exists() ){ | 226 | } else if( QDir("/etc/init.d").exists() ){ |
217 | initpath = "/etc/init.d"; | 227 | initpath = "/etc/init.d"; |
218 | } | 228 | } |
219 | if( initpath ) | 229 | if( initpath ) |
220 | system(QString("%1/pcmcia stop").arg(initpath)); | 230 | system(QString("%1/pcmcia stop").arg(initpath)); |
221 | 231 | ||
222 | if( system( "mv " + tmp + " " + prev ) ) | 232 | if( system( "mv " + tmp + " " + prev ) ) |
223 | retval = false; | 233 | retval = false; |
224 | //#ifdef USE_SCHEMES | 234 | //#ifdef USE_SCHEMES |
225 | // if ( retval ) | 235 | // if ( retval ) |
226 | //SchemeChanger::changeScheme(scheme); | 236 | //SchemeChanger::changeScheme(scheme); |
227 | //#endif | 237 | //#endif |
228 | 238 | ||
229 | //system("cardctl resume"); | 239 | //system("cardctl resume"); |
230 | if( initpath ) | 240 | if( initpath ) |
231 | system(QString("%1/pcmcia start").arg(initpath)); | 241 | system(QString("%1/pcmcia start").arg(initpath)); |
232 | 242 | ||
233 | return retval; | 243 | return retval; |
234 | } | 244 | } |
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 | |||
@@ -1,27 +1,31 @@ | |||
1 | #ifndef WLANIMP_H | 1 | #ifndef WLANIMP_H |
2 | #define WLANIMP_H | 2 | #define WLANIMP_H |
3 | 3 | ||
4 | #include "wlan.h" | 4 | #include "wlan.h" |
5 | 5 | ||
6 | #include <qpe/config.h> | 6 | class InterfaceSetupImp; |
7 | class Interface; | ||
8 | class Config; | ||
7 | 9 | ||
8 | class WLANImp : public WLAN { | 10 | class WLANImp : public WLAN { |
9 | Q_OBJECT | 11 | Q_OBJECT |
10 | 12 | ||
11 | public: | 13 | public: |
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 | ||
15 | protected: | 17 | protected: |
16 | void accept(); | 18 | void accept(); |
17 | 19 | ||
18 | private: | 20 | private: |
19 | void readConfig(); | 21 | void readConfig(); |
20 | bool writeConfig(); | 22 | bool writeConfig(); |
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 |
27 | 31 | ||
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 | |||
@@ -1,112 +1,112 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
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 |
11 | */ | 13 | */ |
12 | WLANModule::WLANModule() : Module() { | 14 | WLANModule::WLANModule() : Module() { |
13 | } | 15 | } |
14 | 16 | ||
15 | /** | 17 | /** |
16 | * Delete any interfaces that we own. | 18 | * Delete any interfaces that we own. |
17 | */ | 19 | */ |
18 | WLANModule::~WLANModule(){ | 20 | WLANModule::~WLANModule(){ |
19 | Interface *i; | 21 | Interface *i; |
20 | for ( i=list.first(); i != 0; i=list.next() ) | 22 | for ( i=list.first(); i != 0; i=list.next() ) |
21 | delete i; | 23 | delete i; |
22 | } | 24 | } |
23 | 25 | ||
24 | /** | 26 | /** |
25 | * Change the current profile | 27 | * Change the current profile |
26 | */ | 28 | */ |
27 | void WLANModule::setProfile(QString newProfile){ | 29 | void WLANModule::setProfile(QString newProfile){ |
28 | profile = newProfile; | 30 | profile = newProfile; |
29 | } | 31 | } |
30 | 32 | ||
31 | /** | 33 | /** |
32 | * get the icon name for this device. | 34 | * get the icon name for this device. |
33 | * @param Interface* can be used in determining the icon. | 35 | * @param Interface* can be used in determining the icon. |
34 | * @return QString the icon name (minus .png, .gif etc) | 36 | * @return QString the icon name (minus .png, .gif etc) |
35 | */ | 37 | */ |
36 | QString WLANModule::getPixmapName(Interface* ){ | 38 | QString WLANModule::getPixmapName(Interface* ){ |
37 | return "wlan"; | 39 | return "wlan"; |
38 | } | 40 | } |
39 | 41 | ||
40 | /** | 42 | /** |
41 | * Check to see if the interface i is owned by this module. | 43 | * Check to see if the interface i is owned by this module. |
42 | * @param Interface* interface to check against | 44 | * @param Interface* interface to check against |
43 | * @return bool true if i is owned by this module, false otherwise. | 45 | * @return bool true if i is owned by this module, false otherwise. |
44 | */ | 46 | */ |
45 | bool WLANModule::isOwner(Interface *i){ | 47 | bool WLANModule::isOwner(Interface *i){ |
46 | WExtensions we(i->getInterfaceName()); | 48 | WExtensions we(i->getInterfaceName()); |
47 | if(!we.doesHaveWirelessExtensions()) | 49 | if(!we.doesHaveWirelessExtensions()) |
48 | return false; | 50 | return false; |
49 | 51 | ||
50 | i->setHardwareName("802.11b"); | 52 | i->setHardwareName("802.11b"); |
51 | list.append(i); | 53 | list.append(i); |
52 | return true; | 54 | return true; |
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 | */ |
60 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ | 61 | QWidget *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 | */ |
71 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 70 | QWidget *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 | ||
81 | /** | 81 | /** |
82 | * Get all active (up or down) interfaces | 82 | * Get all active (up or down) interfaces |
83 | * @return QList<Interface> A list of interfaces that exsist that havn't | 83 | * @return QList<Interface> A list of interfaces that exsist that havn't |
84 | * been called by isOwner() | 84 | * been called by isOwner() |
85 | */ | 85 | */ |
86 | QList<Interface> WLANModule::getInterfaces(){ | 86 | QList<Interface> WLANModule::getInterfaces(){ |
87 | return list; | 87 | return list; |
88 | } | 88 | } |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Attempt to add a new interface as defined by name | 91 | * Attempt to add a new interface as defined by name |
92 | * @param name the name of the type of interface that should be created given | 92 | * @param name the name of the type of interface that should be created given |
93 | * by possibleNewInterfaces(); | 93 | * by possibleNewInterfaces(); |
94 | * @return Interface* NULL if it was unable to be created. | 94 | * @return Interface* NULL if it was unable to be created. |
95 | */ | 95 | */ |
96 | Interface *WLANModule::addNewInterface(QString ){ | 96 | Interface *WLANModule::addNewInterface(QString ){ |
97 | // We can't add a 802.11 interface, either the hardware will be there | 97 | // We can't add a 802.11 interface, either the hardware will be there |
98 | // or it wont. | 98 | // or it wont. |
99 | return NULL; | 99 | return NULL; |
100 | } | 100 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Attempts to remove the interface, doesn't delete i | 103 | * Attempts to remove the interface, doesn't delete i |
104 | * @return bool true if successfull, false otherwise. | 104 | * @return bool true if successfull, false otherwise. |
105 | */ | 105 | */ |
106 | bool WLANModule::remove(Interface*){ | 106 | bool WLANModule::remove(Interface*){ |
107 | // Can't remove a hardware device, you can stop it though. | 107 | // Can't remove a hardware device, you can stop it though. |
108 | return false; | 108 | return false; |
109 | } | 109 | } |
110 | 110 | ||
111 | // wlanmodule.cpp | 111 | // wlanmodule.cpp |
112 | 112 | ||
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 | |||
@@ -1,41 +1,41 @@ | |||
1 | #ifndef WLAN_MODULE_H | 1 | #ifndef WLAN_MODULE_H |
2 | #define WLAN_MODULE_H | 2 | #define WLAN_MODULE_H |
3 | 3 | ||
4 | #include "module.h" | 4 | #include "module.h" |
5 | 5 | ||
6 | class WLANModule : Module{ | 6 | class WLANModule : Module{ |
7 | 7 | ||
8 | signals: | 8 | signals: |
9 | void updateInterface(Interface *i); | 9 | void updateInterface(Interface *i); |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WLANModule(); | 12 | WLANModule(); |
13 | ~WLANModule(); | 13 | ~WLANModule(); |
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); |
22 | virtual bool remove(Interface* i); | 22 | virtual bool remove(Interface* i); |
23 | virtual QString getPixmapName(Interface* i); | 23 | virtual QString getPixmapName(Interface* i); |
24 | 24 | ||
25 | private: | 25 | private: |
26 | QList<Interface> list; | 26 | QList<Interface> list; |
27 | QString profile; | 27 | QString profile; |
28 | 28 | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | extern "C" | 31 | extern "C" |
32 | { | 32 | { |
33 | void* create_plugin() { | 33 | void* create_plugin() { |
34 | return new WLANModule(); | 34 | return new WLANModule(); |
35 | } | 35 | } |
36 | }; | 36 | }; |
37 | 37 | ||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | // wlanmodule.h | 40 | // wlanmodule.h |
41 | 41 | ||