Diffstat (limited to 'noncore/net/networksetup/interfaces') (more/less context) (ignore whitespace changes)
13 files changed, 0 insertions, 2329 deletions
diff --git a/noncore/net/networksetup/interfaces/config.in b/noncore/net/networksetup/interfaces/config.in deleted file mode 100644 index 6c21aeb..0000000 --- a/noncore/net/networksetup/interfaces/config.in +++ b/dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | config INTERFACES | ||
2 | boolean | ||
3 | default "y" if NETWORKSETUP | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | ||
diff --git a/noncore/net/networksetup/interfaces/interface.cpp b/noncore/net/networksetup/interfaces/interface.cpp deleted file mode 100644 index d964961..0000000 --- a/noncore/net/networksetup/interfaces/interface.cpp +++ b/dev/null | |||
@@ -1,297 +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), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){ | ||
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(const 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 | emit (updateMessage("Unable to start interface,\n already started")); | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); | ||
72 | // See if it was successfull... | ||
73 | if(ret != 0){ | ||
74 | emit (updateMessage("Starting interface failed")); | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | status = true; | ||
79 | refresh(); | ||
80 | emit (updateMessage("Start successfull")); | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * Try to stop the interface. | ||
85 | */ | ||
86 | void Interface::stop(){ | ||
87 | // check to see if we are already stopped. | ||
88 | if(false == status){ | ||
89 | emit (updateMessage("Unable to stop interface,\n already stopped")); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); | ||
94 | if(ret != 0){ | ||
95 | emit (updateMessage("Stopping interface failed")); | ||
96 | return; | ||
97 | } | ||
98 | |||
99 | status = false; | ||
100 | refresh(); | ||
101 | emit (updateMessage("Stop successfull")); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * Try to restart the interface. | ||
106 | */ | ||
107 | void Interface::restart(){ | ||
108 | stop(); | ||
109 | start(); | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * Try to refresh the information about the interface. | ||
114 | * First call ifconfig, then check the dhcp-info file | ||
115 | * @return bool true if successfull. | ||
116 | */ | ||
117 | bool Interface::refresh(){ | ||
118 | // See if we are up. | ||
119 | if(status == false){ | ||
120 | macAddress = ""; | ||
121 | ip = "0.0.0.0"; | ||
122 | subnetMask = "0.0.0.0"; | ||
123 | broadcast = ""; | ||
124 | dhcp = false; | ||
125 | dhcpServerIp = ""; | ||
126 | leaseObtained = ""; | ||
127 | leaseExpires = ""; | ||
128 | emit(updateInterface(this)); | ||
129 | return true; | ||
130 | } | ||
131 | |||
132 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); | ||
133 | int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); | ||
134 | if(ret != 0){ | ||
135 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); | ||
136 | return false; | ||
137 | } | ||
138 | |||
139 | QFile file(fileName); | ||
140 | if (!file.open(IO_ReadOnly)){ | ||
141 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | ||
142 | return false; | ||
143 | } | ||
144 | |||
145 | // Set to the defaults | ||
146 | macAddress = ""; | ||
147 | ip = "0.0.0.0"; | ||
148 | subnetMask = "0.0.0.0"; | ||
149 | broadcast = ""; | ||
150 | |||
151 | QTextStream stream( &file ); | ||
152 | QString line; | ||
153 | while ( !stream.eof() ) { | ||
154 | line = stream.readLine(); | ||
155 | if(line.contains("HWaddr")){ | ||
156 | int mac = line.find("HWaddr"); | ||
157 | macAddress = line.mid(mac+7, line.length()); | ||
158 | } | ||
159 | if(line.contains("inet addr")){ | ||
160 | int ipl = line.find("inet addr"); | ||
161 | int space = line.find(" ", ipl+10); | ||
162 | ip = line.mid(ipl+10, space-ipl-10); | ||
163 | } | ||
164 | if(line.contains("Mask")){ | ||
165 | int mask = line.find("Mask"); | ||
166 | subnetMask = line.mid(mask+5, line.length()); | ||
167 | } | ||
168 | if(line.contains("Bcast")){ | ||
169 | int mask = line.find("Bcast"); | ||
170 | int space = line.find(" ", mask+6); | ||
171 | broadcast = line.mid(mask+6, space-mask-6); | ||
172 | } | ||
173 | } | ||
174 | file.close(); | ||
175 | QFile::remove(fileName); | ||
176 | |||
177 | // DHCP TESTING | ||
178 | // reset DHCP info | ||
179 | dhcpServerIp = ""; | ||
180 | leaseObtained = ""; | ||
181 | leaseExpires = ""; | ||
182 | dhcp = false; | ||
183 | |||
184 | QString dhcpDirectory(DHCP_INFO_DIR); | ||
185 | QDir d(dhcpDirectory); | ||
186 | if(!d.exists(dhcpDirectory)) | ||
187 | dhcpDirectory = "/var/run"; | ||
188 | |||
189 | // See if we have | ||
190 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); | ||
191 | // If there is no DHCP information then exit now with no errors. | ||
192 | if(!QFile::exists(dhcpFile)){ | ||
193 | emit(updateInterface(this)); | ||
194 | return true; | ||
195 | } | ||
196 | |||
197 | file.setName(dhcpFile); | ||
198 | if (!file.open(IO_ReadOnly)){ | ||
199 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | ||
200 | return false; | ||
201 | } | ||
202 | |||
203 | // leaseTime and renewalTime and used if pid and deamon exe can be accessed. | ||
204 | int leaseTime = 0; | ||
205 | int renewalTime = 0; | ||
206 | |||
207 | stream.setDevice( &file ); | ||
208 | while ( !stream.eof() ) { | ||
209 | line = stream.readLine(); | ||
210 | if(line.contains("DHCPSIADDR=")) | ||
211 | dhcpServerIp = line.mid(11, line.length()); | ||
212 | if(line.contains("LEASETIME=")) | ||
213 | leaseTime = line.mid(10, line.length()).toInt(); | ||
214 | if(line.contains("RENEWALTIME=")) | ||
215 | renewalTime = line.mid(12, line.length()).toInt(); | ||
216 | } | ||
217 | file.close(); | ||
218 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); | ||
219 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); | ||
220 | |||
221 | // Get the pid of the deamond | ||
222 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); | ||
223 | file.setName(dhcpFile); | ||
224 | if (!file.open(IO_ReadOnly)){ | ||
225 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | ||
226 | return false; | ||
227 | } | ||
228 | |||
229 | int pid = -1; | ||
230 | stream.setDevice( &file ); | ||
231 | while ( !stream.eof() ) { | ||
232 | line = stream.readLine(); | ||
233 | pid = line.toInt(); | ||
234 | } | ||
235 | file.close(); | ||
236 | |||
237 | if( pid == -1){ | ||
238 | qDebug("Interface: Could not get pid of dhcpc deamon."); | ||
239 | return false; | ||
240 | } | ||
241 | |||
242 | // Get the start running time of the deamon | ||
243 | fileName = (QString("/proc/%1/stat").arg(pid)); | ||
244 | file.setName(fileName); | ||
245 | stream.setDevice( &file ); | ||
246 | if (!file.open(IO_ReadOnly)){ | ||
247 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | ||
248 | return false; | ||
249 | } | ||
250 | while ( !stream.eof() ) { | ||
251 | line = stream.readLine(); | ||
252 | } | ||
253 | file.close(); | ||
254 | long time = 0; | ||
255 | // Grab the start time | ||
256 | // pid com state ppid pgrp session tty_nr tpgid flags | ||
257 | sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " | ||
258 | // minflt cminflt majflt cmajflt utime stime cutime cstime priority | ||
259 | "%*u %*u %*u %*u %*u %*u %*d %*d %*d " | ||
260 | // nice 0 itrealvalue starttime | ||
261 | "%*d %*d %*d %lu", (long*) &time); | ||
262 | time = time/100; | ||
263 | |||
264 | QDateTime datetime(QDateTime::currentDateTime()); | ||
265 | |||
266 | // Get the uptime of the computer. | ||
267 | QFile f("/proc/uptime"); | ||
268 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | ||
269 | QTextStream t( &f ); // use a text stream | ||
270 | int sec = 0; | ||
271 | t >> sec; | ||
272 | datetime = datetime.addSecs((-1*sec)); | ||
273 | f.close(); | ||
274 | } | ||
275 | else{ | ||
276 | qDebug("Interface: Can't open /proc/uptime to retrive uptime."); | ||
277 | return false; | ||
278 | } | ||
279 | |||
280 | datetime = datetime.addSecs(time); | ||
281 | //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); | ||
282 | |||
283 | // Calculate the start and renew times | ||
284 | leaseObtained= datetime.toString(); | ||
285 | |||
286 | // Calculate the start and renew times | ||
287 | datetime = datetime.addSecs(leaseTime); | ||
288 | leaseExpires = datetime.toString(); | ||
289 | |||
290 | dhcp = true; | ||
291 | |||
292 | emit(updateInterface(this)); | ||
293 | return true; | ||
294 | } | ||
295 | |||
296 | // interface.cpp | ||
297 | |||
diff --git a/noncore/net/networksetup/interfaces/interface.h b/noncore/net/networksetup/interfaces/interface.h deleted file mode 100644 index d37834a..0000000 --- a/noncore/net/networksetup/interfaces/interface.h +++ b/dev/null | |||
@@ -1,72 +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 | void updateMessage(const QString &message); | ||
15 | |||
16 | public: | ||
17 | Interface(QObject * parent=0, const char * name= "unknown", bool status = false); | ||
18 | |||
19 | QString getInterfaceName() const { QString n(this->name()); return n; }; | ||
20 | |||
21 | bool getStatus() const { return status; }; | ||
22 | void setStatus(bool newStatus); | ||
23 | |||
24 | bool isAttached() const { return attached; }; | ||
25 | void setAttached(bool isAttached=false); | ||
26 | |||
27 | QString getHardwareName() const { return hardwareName; }; | ||
28 | void setHardwareName(const QString &name="Unknown"); | ||
29 | |||
30 | Module* getModuleOwner() const { return moduleOwner; }; | ||
31 | void setModuleOwner(Module *owner=NULL); | ||
32 | |||
33 | // inet information. | ||
34 | QString getMacAddress() const { return macAddress; }; | ||
35 | QString getIp() const { return ip; }; | ||
36 | QString getSubnetMask() const { return subnetMask; }; | ||
37 | QString getBroadcast() const { return broadcast; }; | ||
38 | bool isDhcp() const { return dhcp; }; | ||
39 | QString getDhcpServerIp() const { return dhcpServerIp; }; | ||
40 | QString getLeaseObtained() const { return leaseObtained; }; | ||
41 | QString getLeaseExpires() const { 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 | QString hardwareName; | ||
52 | Module *moduleOwner; | ||
53 | bool status; | ||
54 | bool attached; | ||
55 | |||
56 | // Network information | ||
57 | bool dhcp; | ||
58 | QString dhcpServerIp; | ||
59 | QString leaseObtained; | ||
60 | QString leaseExpires; | ||
61 | |||
62 | QString macAddress; | ||
63 | QString ip; | ||
64 | QString broadcast; | ||
65 | QString subnetMask; | ||
66 | |||
67 | }; | ||
68 | |||
69 | #endif | ||
70 | |||
71 | // interface.h | ||
72 | |||
diff --git a/noncore/net/networksetup/interfaces/interfaceadvanced.ui b/noncore/net/networksetup/interfaces/interfaceadvanced.ui deleted file mode 100644 index 9d9f98e..0000000 --- a/noncore/net/networksetup/interfaces/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>290</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="0" column="1" > | ||
39 | <class>QLabel</class> | ||
40 | <property stdset="1"> | ||
41 | <name>name</name> | ||
42 | <cstring>interfaceName</cstring> | ||
43 | </property> | ||
44 | <property stdset="1"> | ||
45 | <name>frameShape</name> | ||
46 | <enum>Panel</enum> | ||
47 | </property> | ||
48 | <property stdset="1"> | ||
49 | <name>frameShadow</name> | ||
50 | <enum>Sunken</enum> | ||
51 | </property> | ||
52 | <property stdset="1"> | ||
53 | <name>text</name> | ||
54 | <string>eth0</string> | ||
55 | </property> | ||
56 | </widget> | ||
57 | <widget row="1" column="0" > | ||
58 | <class>QLabel</class> | ||
59 | <property stdset="1"> | ||
60 | <name>name</name> | ||
61 | <cstring>TextLabel3</cstring> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>text</name> | ||
65 | <string>IP Address</string> | ||
66 | </property> | ||
67 | </widget> | ||
68 | <widget row="0" column="0" > | ||
69 | <class>QLabel</class> | ||
70 | <property stdset="1"> | ||
71 | <name>name</name> | ||
72 | <cstring>TextLabel7</cstring> | ||
73 | </property> | ||
74 | <property stdset="1"> | ||
75 | <name>text</name> | ||
76 | <string>Interface</string> | ||
77 | </property> | ||
78 | </widget> | ||
79 | <widget row="2" column="0" > | ||
80 | <class>QLabel</class> | ||
81 | <property stdset="1"> | ||
82 | <name>name</name> | ||
83 | <cstring>TextLabel4</cstring> | ||
84 | </property> | ||
85 | <property stdset="1"> | ||
86 | <name>enabled</name> | ||
87 | <bool>true</bool> | ||
88 | </property> | ||
89 | <property stdset="1"> | ||
90 | <name>text</name> | ||
91 | <string>Subnet Mask</string> | ||
92 | </property> | ||
93 | </widget> | ||
94 | <widget row="1" column="1" > | ||
95 | <class>QLabel</class> | ||
96 | <property stdset="1"> | ||
97 | <name>name</name> | ||
98 | <cstring>ipAddressLabel</cstring> | ||
99 | </property> | ||
100 | <property stdset="1"> | ||
101 | <name>frameShape</name> | ||
102 | <enum>Panel</enum> | ||
103 | </property> | ||
104 | <property stdset="1"> | ||
105 | <name>frameShadow</name> | ||
106 | <enum>Sunken</enum> | ||
107 | </property> | ||
108 | <property stdset="1"> | ||
109 | <name>text</name> | ||
110 | <string>0.0.0.0</string> | ||
111 | </property> | ||
112 | </widget> | ||
113 | <widget row="2" column="1" > | ||
114 | <class>QLabel</class> | ||
115 | <property stdset="1"> | ||
116 | <name>name</name> | ||
117 | <cstring>subnetMaskLabel</cstring> | ||
118 | </property> | ||
119 | <property stdset="1"> | ||
120 | <name>frameShape</name> | ||
121 | <enum>Panel</enum> | ||
122 | </property> | ||
123 | <property stdset="1"> | ||
124 | <name>frameShadow</name> | ||
125 | <enum>Sunken</enum> | ||
126 | </property> | ||
127 | <property stdset="1"> | ||
128 | <name>text</name> | ||
129 | <string>0.0.0.0</string> | ||
130 | </property> | ||
131 | </widget> | ||
132 | <spacer row="6" column="1" > | ||
133 | <property> | ||
134 | <name>name</name> | ||
135 | <cstring>Spacer2</cstring> | ||
136 | </property> | ||
137 | <property stdset="1"> | ||
138 | <name>orientation</name> | ||
139 | <enum>Vertical</enum> | ||
140 | </property> | ||
141 | <property stdset="1"> | ||
142 | <name>sizeType</name> | ||
143 | <enum>Expanding</enum> | ||
144 | </property> | ||
145 | <property> | ||
146 | <name>sizeHint</name> | ||
147 | <size> | ||
148 | <width>20</width> | ||
149 | <height>20</height> | ||
150 | </size> | ||
151 | </property> | ||
152 | </spacer> | ||
153 | <widget row="5" column="0" rowspan="1" colspan="2" > | ||
154 | <class>QGroupBox</class> | ||
155 | <property stdset="1"> | ||
156 | <name>name</name> | ||
157 | <cstring>dhcpInformation</cstring> | ||
158 | </property> | ||
159 | <property stdset="1"> | ||
160 | <name>title</name> | ||
161 | <string>DHCP Information</string> | ||
162 | </property> | ||
163 | <grid> | ||
164 | <property stdset="1"> | ||
165 | <name>margin</name> | ||
166 | <number>11</number> | ||
167 | </property> | ||
168 | <property stdset="1"> | ||
169 | <name>spacing</name> | ||
170 | <number>6</number> | ||
171 | </property> | ||
172 | <widget row="0" column="0" > | ||
173 | <class>QLabel</class> | ||
174 | <property stdset="1"> | ||
175 | <name>name</name> | ||
176 | <cstring>TextLabel6</cstring> | ||
177 | </property> | ||
178 | <property stdset="1"> | ||
179 | <name>text</name> | ||
180 | <string>DHCP Server</string> | ||
181 | </property> | ||
182 | </widget> | ||
183 | <widget row="2" column="1" > | ||
184 | <class>QLabel</class> | ||
185 | <property stdset="1"> | ||
186 | <name>name</name> | ||
187 | <cstring>leaseExpiresLabel</cstring> | ||
188 | </property> | ||
189 | <property stdset="1"> | ||
190 | <name>frameShape</name> | ||
191 | <enum>Panel</enum> | ||
192 | </property> | ||
193 | <property stdset="1"> | ||
194 | <name>frameShadow</name> | ||
195 | <enum>Sunken</enum> | ||
196 | </property> | ||
197 | <property stdset="1"> | ||
198 | <name>text</name> | ||
199 | <string></string> | ||
200 | </property> | ||
201 | </widget> | ||
202 | <widget row="1" column="1" > | ||
203 | <class>QLabel</class> | ||
204 | <property stdset="1"> | ||
205 | <name>name</name> | ||
206 | <cstring>leaseObtainedLabel</cstring> | ||
207 | </property> | ||
208 | <property stdset="1"> | ||
209 | <name>frameShape</name> | ||
210 | <enum>Panel</enum> | ||
211 | </property> | ||
212 | <property stdset="1"> | ||
213 | <name>frameShadow</name> | ||
214 | <enum>Sunken</enum> | ||
215 | </property> | ||
216 | <property stdset="1"> | ||
217 | <name>text</name> | ||
218 | <string></string> | ||
219 | </property> | ||
220 | </widget> | ||
221 | <widget row="2" column="0" > | ||
222 | <class>QLabel</class> | ||
223 | <property stdset="1"> | ||
224 | <name>name</name> | ||
225 | <cstring>TextLabel9</cstring> | ||
226 | </property> | ||
227 | <property stdset="1"> | ||
228 | <name>text</name> | ||
229 | <string>Lease Expires</string> | ||
230 | </property> | ||
231 | </widget> | ||
232 | <widget row="1" column="0" > | ||
233 | <class>QLabel</class> | ||
234 | <property stdset="1"> | ||
235 | <name>name</name> | ||
236 | <cstring>TextLabel8</cstring> | ||
237 | </property> | ||
238 | <property stdset="1"> | ||
239 | <name>text</name> | ||
240 | <string>Lease Obtained</string> | ||
241 | </property> | ||
242 | </widget> | ||
243 | <widget row="0" column="1" > | ||
244 | <class>QLabel</class> | ||
245 | <property stdset="1"> | ||
246 | <name>name</name> | ||
247 | <cstring>dhcpServerLabel</cstring> | ||
248 | </property> | ||
249 | <property stdset="1"> | ||
250 | <name>frameShape</name> | ||
251 | <enum>Panel</enum> | ||
252 | </property> | ||
253 | <property stdset="1"> | ||
254 | <name>frameShadow</name> | ||
255 | <enum>Sunken</enum> | ||
256 | </property> | ||
257 | <property stdset="1"> | ||
258 | <name>text</name> | ||
259 | <string></string> | ||
260 | </property> | ||
261 | </widget> | ||
262 | </grid> | ||
263 | </widget> | ||
264 | <widget row="4" column="0" > | ||
265 | <class>QLabel</class> | ||
266 | <property stdset="1"> | ||
267 | <name>name</name> | ||
268 | <cstring>TextLabel2</cstring> | ||
269 | </property> | ||
270 | <property stdset="1"> | ||
271 | <name>text</name> | ||
272 | <string>Broadcast</string> | ||
273 | </property> | ||
274 | </widget> | ||
275 | <widget row="4" column="1" > | ||
276 | <class>QLabel</class> | ||
277 | <property stdset="1"> | ||
278 | <name>name</name> | ||
279 | <cstring>broadcastLabel</cstring> | ||
280 | </property> | ||
281 | <property stdset="1"> | ||
282 | <name>frameShape</name> | ||
283 | <enum>Panel</enum> | ||
284 | </property> | ||
285 | <property stdset="1"> | ||
286 | <name>frameShadow</name> | ||
287 | <enum>Sunken</enum> | ||
288 | </property> | ||
289 | </widget> | ||
290 | <widget row="3" column="0" > | ||
291 | <class>QLabel</class> | ||
292 | <property stdset="1"> | ||
293 | <name>name</name> | ||
294 | <cstring>TextLabel1</cstring> | ||
295 | </property> | ||
296 | <property stdset="1"> | ||
297 | <name>text</name> | ||
298 | <string>MAC Address</string> | ||
299 | </property> | ||
300 | </widget> | ||
301 | <widget row="3" column="1" > | ||
302 | <class>QLabel</class> | ||
303 | <property stdset="1"> | ||
304 | <name>name</name> | ||
305 | <cstring>macAddressLabel</cstring> | ||
306 | </property> | ||
307 | <property stdset="1"> | ||
308 | <name>frameShape</name> | ||
309 | <enum>Panel</enum> | ||
310 | </property> | ||
311 | <property stdset="1"> | ||
312 | <name>frameShadow</name> | ||
313 | <enum>Sunken</enum> | ||
314 | </property> | ||
315 | <property stdset="1"> | ||
316 | <name>text</name> | ||
317 | <string>00:00:00:00:00:00</string> | ||
318 | </property> | ||
319 | </widget> | ||
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/interfaces/interfaceinformation.ui b/noncore/net/networksetup/interfaces/interfaceinformation.ui deleted file mode 100644 index e49e09f..0000000 --- a/noncore/net/networksetup/interfaces/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/interfaces/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp deleted file mode 100644 index 1fa5d38..0000000 --- a/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp +++ b/dev/null | |||
@@ -1,76 +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 <qmessagebox.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), interface(i){ | ||
14 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | ||
15 | connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); | ||
16 | updateInterface(interface); | ||
17 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); | ||
18 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); | ||
19 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); | ||
20 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); | ||
21 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * Update the interface information and buttons. | ||
26 | * @param Intarface *i the interface to update (should be the one we already | ||
27 | * know about). | ||
28 | */ | ||
29 | void InterfaceInformationImp::updateInterface(Interface *){ | ||
30 | if(interface->getStatus()){ | ||
31 | startButton->setEnabled(false); | ||
32 | stopButton->setEnabled(true); | ||
33 | restartButton->setEnabled(true); | ||
34 | } | ||
35 | else{ | ||
36 | startButton->setEnabled(true); | ||
37 | stopButton->setEnabled(false); | ||
38 | restartButton->setEnabled(false); | ||
39 | } | ||
40 | macAddressLabel->setText(interface->getMacAddress()); | ||
41 | ipAddressLabel->setText(interface->getIp()); | ||
42 | subnetMaskLabel->setText(interface->getSubnetMask()); | ||
43 | broadcastLabel->setText(interface->getBroadcast()); | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * Create the advanced widget. Fill it with the current interface's information. | ||
48 | * Display it. | ||
49 | */ | ||
50 | void InterfaceInformationImp::advanced(){ | ||
51 | InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); | ||
52 | a->interfaceName->setText(interface->getInterfaceName()); | ||
53 | a->macAddressLabel->setText(interface->getMacAddress()); | ||
54 | a->ipAddressLabel->setText(interface->getIp()); | ||
55 | a->subnetMaskLabel->setText(interface->getSubnetMask()); | ||
56 | a->broadcastLabel->setText(interface->getBroadcast()); | ||
57 | a->dhcpServerLabel->setText(interface->getDhcpServerIp()); | ||
58 | a->leaseObtainedLabel->setText(interface->getLeaseObtained()); | ||
59 | a->leaseExpiresLabel->setText(interface->getLeaseExpires()); | ||
60 | a->dhcpInformation->setEnabled(interface->isDhcp()); | ||
61 | |||
62 | a->showMaximized(); | ||
63 | a->show(); | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Messages from the interface if start/stop went as planned. | ||
68 | * Purly for user feedback. | ||
69 | * @param message the message to display. | ||
70 | */ | ||
71 | void InterfaceInformationImp::showMessage(const QString &message){ | ||
72 | QMessageBox::information(this, "Message", message, QMessageBox::Ok); | ||
73 | } | ||
74 | |||
75 | // infoimp.cpp | ||
76 | |||
diff --git a/noncore/net/networksetup/interfaces/interfaceinformationimp.h b/noncore/net/networksetup/interfaces/interfaceinformationimp.h deleted file mode 100644 index 65cdfe0..0000000 --- a/noncore/net/networksetup/interfaces/interfaceinformationimp.h +++ b/dev/null | |||
@@ -1,28 +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 | void showMessage(const QString &message); | ||
19 | |||
20 | private: | ||
21 | Interface *interface; | ||
22 | |||
23 | }; | ||
24 | |||
25 | #endif | ||
26 | |||
27 | // addserviceimp.h | ||
28 | |||
diff --git a/noncore/net/networksetup/interfaces/interfaces.cpp b/noncore/net/networksetup/interfaces/interfaces.cpp deleted file mode 100644 index 8f685fe..0000000 --- a/noncore/net/networksetup/interfaces/interfaces.cpp +++ b/dev/null | |||
@@ -1,643 +0,0 @@ | |||
1 | #include "interfaces.h" | ||
2 | |||
3 | #include <qfile.h> | ||
4 | #include <qtextstream.h> | ||
5 | #include <qregexp.h> | ||
6 | |||
7 | // The three stanza's | ||
8 | #define AUTO "auto" | ||
9 | #define IFACE "iface" | ||
10 | #define MAPPING "mapping" | ||
11 | |||
12 | /** | ||
13 | * Constructor. Reads in the interfaces file and then split the file up by | ||
14 | * the \n for interfaces variable. | ||
15 | * @param useInterfacesFile if an interface file other then the default is | ||
16 | * desired to be used it should be passed in. | ||
17 | */ | ||
18 | Interfaces::Interfaces(QString useInterfacesFile){ | ||
19 | acceptedFamily.append(INTERFACES_FAMILY_INET); | ||
20 | acceptedFamily.append(INTERFACES_FAMILY_IPX); | ||
21 | acceptedFamily.append(INTERFACES_FAMILY_INET6); | ||
22 | |||
23 | interfacesFile = useInterfacesFile; | ||
24 | QFile file(interfacesFile); | ||
25 | if (!file.open(IO_ReadOnly)){ | ||
26 | qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); | ||
27 | currentIface = interfaces.end(); | ||
28 | currentMapping = interfaces.end(); | ||
29 | return; | ||
30 | } | ||
31 | QTextStream stream( &file ); | ||
32 | QString line; | ||
33 | while ( !stream.eof() ) { | ||
34 | line += stream.readLine(); | ||
35 | line += "\n"; | ||
36 | } | ||
37 | file.close(); | ||
38 | interfaces = QStringList::split("\n", line, true); | ||
39 | |||
40 | currentIface = interfaces.end(); | ||
41 | currentMapping = interfaces.end(); | ||
42 | } | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Get a list of all interfaces in the interface file. Usefull for | ||
47 | * hardware that is not currently connected such as an 802.11b card | ||
48 | * not plugged in, but configured for when it is plugged in. | ||
49 | * @return Return string list of interfaces. | ||
50 | **/ | ||
51 | QStringList Interfaces::getInterfaceList(){ | ||
52 | QStringList list; | ||
53 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | ||
54 | QString line = (*it).simplifyWhiteSpace(); | ||
55 | if(line.contains(IFACE) && line.at(0) != '#'){ | ||
56 | line = line.mid(QString(IFACE).length() +1, line.length()); | ||
57 | line = line.simplifyWhiteSpace(); | ||
58 | int findSpace = line.find(" "); | ||
59 | if( findSpace >= 0){ | ||
60 | line = line.mid(0, findSpace); | ||
61 | list.append(line); | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | return list; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Find out if interface is in an "auto" group or not. | ||
70 | * Report any duplicates such as eth0 being in two differnt auto's | ||
71 | * @param interface interface to check to see if it is on or not. | ||
72 | * @return true is interface is in auto | ||
73 | */ | ||
74 | bool Interfaces::isAuto(const QString &interface) const { | ||
75 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | ||
76 | QStringList awi = autoLines.grep(QRegExp(interface)); | ||
77 | if(awi.count() > 1) | ||
78 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); | ||
79 | if(awi.count() < 1) | ||
80 | return false; | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * Attempt to set the auto option for interface to setAuto. | ||
86 | * @param interface the interface to set | ||
87 | * @param setAuto the value to set interface to. | ||
88 | * @return false if already set to setAuto. | ||
89 | * */ | ||
90 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ | ||
91 | // Don't need to set it if it is already set. | ||
92 | if(isAuto(interface) == setAuto) | ||
93 | return false; | ||
94 | |||
95 | bool changed = false; | ||
96 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | ||
97 | if((*it).contains(AUTO)){ | ||
98 | //We know that they are not in any group so let add to this auto. | ||
99 | if(setAuto){ | ||
100 | (*it) = (*it) += " " + interface; | ||
101 | // Don't care to have such thins as: auto eth0 lo usb0 | ||
102 | (*it) = (*it).simplifyWhiteSpace(); | ||
103 | changed = true; | ||
104 | break; | ||
105 | } | ||
106 | // else see if we need to remove from this one | ||
107 | else{ | ||
108 | if((*it).contains(interface)){ | ||
109 | (*it) = (*it).replace(QRegExp(interface), ""); | ||
110 | // if AUTO is the only thing left clear the line | ||
111 | if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == 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 | // In the case where there is no AUTO field add one. | ||
120 | if(!changed && setAuto) | ||
121 | interfaces.append(QString(AUTO" %1").arg(interface)); | ||
122 | return true; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * Set the current interface to interface. This needs to be done before you | ||
127 | * can call getFamily(), getMethod, and get/setOption(). | ||
128 | * @param interface the name of the interface to set. All whitespace is | ||
129 | * removed from the interface name. | ||
130 | * @return bool true if it is successfull. | ||
131 | */ | ||
132 | bool Interfaces::setInterface(QString interface){ | ||
133 | interface = interface.simplifyWhiteSpace(); | ||
134 | interface = interface.replace(QRegExp(" "), ""); | ||
135 | return setStanza(IFACE, interface, currentIface); | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * A quick helper funtion to see if the current interface is set. | ||
140 | * @return bool true if set, false otherwise. | ||
141 | */ | ||
142 | bool Interfaces::isInterfaceSet() const { | ||
143 | return (interfaces.end() != currentIface); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * Add a new interface of with the settings - family and method | ||
148 | * @param interface the name of the interface to set. All whitespace is | ||
149 | * removed from the interface name. | ||
150 | * @param family the family of this interface inet or inet, ipx or inet6 | ||
151 | * Must of one of the families defined in interfaces.h | ||
152 | * @param method for the family. see interfaces man page for family methods. | ||
153 | * @return true if successfull. | ||
154 | */ | ||
155 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ | ||
156 | if(0 == acceptedFamily.contains(family)) | ||
157 | return false; | ||
158 | QString newInterface = interface.simplifyWhiteSpace(); | ||
159 | newInterface = newInterface.replace(QRegExp(" "), ""); | ||
160 | interfaces.append(""); | ||
161 | interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); | ||
162 | return true; | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * Copies interface with name interface to name newInterface | ||
167 | * @param newInterface name of the new interface. | ||
168 | * @return bool true if successfull | ||
169 | */ | ||
170 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ | ||
171 | if(!setInterface(interface)) | ||
172 | return false; | ||
173 | |||
174 | // Store the old interface and bump past the stanza line. | ||
175 | QStringList::Iterator it = currentIface; | ||
176 | it++; | ||
177 | |||
178 | // Add the new interface | ||
179 | bool error; | ||
180 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); | ||
181 | if(!setInterface(newInterface)) | ||
182 | return false; | ||
183 | |||
184 | QStringList::Iterator newIface = currentIface; | ||
185 | newIface++; | ||
186 | |||
187 | // Copy all of the lines | ||
188 | for ( ; it != interfaces.end(); ++it ){ | ||
189 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) | ||
190 | break; | ||
191 | newIface = interfaces.insert(newIface, *it); | ||
192 | } | ||
193 | |||
194 | return true; | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * Remove the currently selected interface and all of its options. | ||
199 | * @return bool if successfull or not. | ||
200 | */ | ||
201 | bool Interfaces::removeInterface(){ | ||
202 | return removeStanza(currentIface); | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * Gets the hardware name of the interface that is currently selected. | ||
207 | * @return QString name of the hardware interface (eth0, usb2, wlan1...). | ||
208 | * @param error set to true if any error occurs, false otherwise. | ||
209 | */ | ||
210 | QString Interfaces::getInterfaceName(bool &error){ | ||
211 | if(currentIface == interfaces.end()){ | ||
212 | error = true; | ||
213 | return QString(); | ||
214 | } | ||
215 | QString line = (*currentIface); | ||
216 | line = line.mid(QString(IFACE).length() +1, line.length()); | ||
217 | line = line.simplifyWhiteSpace(); | ||
218 | int findSpace = line.find(" "); | ||
219 | if( findSpace < 0){ | ||
220 | error = true; | ||
221 | return QString(); | ||
222 | } | ||
223 | error = false; | ||
224 | return line.mid(0, findSpace); | ||
225 | } | ||
226 | |||
227 | /** | ||
228 | * Gets the family name of the interface that is currently selected. | ||
229 | * @return QString name of the family (inet, inet6, ipx). | ||
230 | * @param error set to true if any error occurs, false otherwise. | ||
231 | */ | ||
232 | QString Interfaces::getInterfaceFamily(bool &error){ | ||
233 | QString name = getInterfaceName(error); | ||
234 | if(error) | ||
235 | return QString(); | ||
236 | QString line = (*currentIface); | ||
237 | line = line.mid(QString(IFACE).length() +1, line.length()); | ||
238 | line = line.mid(name.length()+1, line.length()); | ||
239 | line = line.simplifyWhiteSpace(); | ||
240 | int findSpace = line.find(" "); | ||
241 | if( findSpace < 0){ | ||
242 | error = true; | ||
243 | return QString(); | ||
244 | } | ||
245 | error = false; | ||
246 | return line.mid(0, findSpace); | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * Gets the method of the interface that is currently selected. | ||
251 | * @return QString name of the method such as staic or dhcp. | ||
252 | * See the man page of interfaces for possible methods depending on the family. | ||
253 | * @param error set to true if any error occurs, false otherwise. | ||
254 | */ | ||
255 | QString Interfaces::getInterfaceMethod(bool &error){ | ||
256 | QString name = getInterfaceName(error); | ||
257 | if(error) | ||
258 | return QString(); | ||
259 | QString family = getInterfaceFamily(error); | ||
260 | if(error) | ||
261 | return QString(); | ||
262 | QString line = (*currentIface); | ||
263 | line = line.mid(QString(IFACE).length()+1, line.length()); | ||
264 | line = line.mid(name.length()+1, line.length()); | ||
265 | line = line.mid(family.length()+1, line.length()); | ||
266 | line = line.simplifyWhiteSpace(); | ||
267 | error = false; | ||
268 | return line; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * Sets the interface name to newName. | ||
273 | * @param newName the new name of the interface. All whitespace is removed. | ||
274 | * @return bool true if successfull. | ||
275 | */ | ||
276 | bool Interfaces::setInterfaceName(const QString &newName){ | ||
277 | if(currentIface == interfaces.end()) | ||
278 | return false; | ||
279 | QString name = newName.simplifyWhiteSpace(); | ||
280 | name = name.replace(QRegExp(" "), ""); | ||
281 | bool returnValue = false; | ||
282 | (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); | ||
283 | return !returnValue; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * Sets the interface family to newName. | ||
288 | * @param newName the new name of the interface. Must be one of the families | ||
289 | * defined in the interfaces.h file. | ||
290 | * @return bool true if successfull. | ||
291 | */ | ||
292 | bool Interfaces::setInterfaceFamily(const QString &newName){ | ||
293 | if(currentIface == interfaces.end()) | ||
294 | return false; | ||
295 | if(acceptedFamily.contains(newName)==0) | ||
296 | return false; | ||
297 | bool returnValue = false; | ||
298 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); | ||
299 | return !returnValue; | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * Sets the interface method to newName | ||
304 | * @param newName the new name of the interface | ||
305 | * @return bool true if successfull. | ||
306 | */ | ||
307 | bool Interfaces::setInterfaceMethod(const QString &newName){ | ||
308 | if(currentIface == interfaces.end()) | ||
309 | return false; | ||
310 | bool returnValue = false; | ||
311 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); | ||
312 | return !returnValue; | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Get a value for an option in the currently selected interface. For example | ||
317 | * calling getInterfaceOption("address") on the following stanza would | ||
318 | * return 192.168.1.1. | ||
319 | * iface eth0 static | ||
320 | * address 192.168.1.1 | ||
321 | * @param option the options to get the value. | ||
322 | * @param error set to true if any error occurs, false otherwise. | ||
323 | * @return QString the options value. QString::null if error == true | ||
324 | */ | ||
325 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ | ||
326 | return getOption(currentIface, option, error); | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * Set a value for an option in the currently selected interface. If option | ||
331 | * doesn't exist then it is added along with the value. | ||
332 | * @param option the options to set the value. | ||
333 | * @param value the value that option should be set to. | ||
334 | * @param error set to true if any error occurs, false otherwise. | ||
335 | * @return QString the options value. QString::null if error == true | ||
336 | */ | ||
337 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ | ||
338 | return setOption(currentIface, option, value); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Removes a value for an option in the currently selected interface. | ||
343 | * @param option the options to set the value. | ||
344 | * @param value the value that option should be set to. | ||
345 | * @param error set to true if any error occurs, false otherwise. | ||
346 | * @return QString the options value. QString::null if error == true | ||
347 | */ | ||
348 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ | ||
349 | return removeOption(currentIface, option, value); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Removes all of the options from the currently selected interface. | ||
354 | * @return bool error if if successfull | ||
355 | */ | ||
356 | bool Interfaces::removeAllInterfaceOptions(){ | ||
357 | return removeAllOptions(currentIface); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Set the current map to interface's map. This needs to be done before you | ||
362 | * can call addMapping(), set/getMap(), and get/setScript(). | ||
363 | * @param interface the name of the interface to set. All whitespace is | ||
364 | * removed from the interface name. | ||
365 | * @return bool true if it is successfull. | ||
366 | */ | ||
367 | bool Interfaces::setMapping(const QString &interface){ | ||
368 | QString interfaceName = interface.simplifyWhiteSpace(); | ||
369 | interfaceName = interfaceName.replace(QRegExp(" "), ""); | ||
370 | return setStanza(MAPPING, interfaceName, currentMapping); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * Adds a new Mapping to the interfaces file with interfaces. | ||
375 | * @param interface the name(s) of the interfaces to set to this mapping | ||
376 | */ | ||
377 | void Interfaces::addMapping(const QString &option){ | ||
378 | interfaces.append(""); | ||
379 | interfaces.append(QString(MAPPING " %1").arg(option)); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Remove the currently selected map and all of its options. | ||
384 | * @return bool if successfull or not. | ||
385 | */ | ||
386 | bool Interfaces::removeMapping(){ | ||
387 | return removeStanza(currentMapping); | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * Set a map option within a mapping. | ||
392 | * @param map map to use | ||
393 | * @param value value to go with map | ||
394 | * @return bool true if it is successfull. | ||
395 | */ | ||
396 | bool Interfaces::setMap(const QString &map, const QString &value){ | ||
397 | return setOption(currentMapping, map, value); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Removes 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::removeMap(const QString &map, const QString &value){ | ||
407 | return removeOption(currentMapping, map, value); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * Get a map value within a mapping. | ||
412 | * @param map map to get value of | ||
413 | * @param bool true if it is successfull. | ||
414 | * @return value that goes to the map | ||
415 | */ | ||
416 | QString Interfaces::getMap(const QString &map, bool &error){ | ||
417 | return getOption(currentMapping, map, error); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * Sets a script value of the current mapping to argument. | ||
422 | * @param argument the script name. | ||
423 | * @return true if successfull. | ||
424 | */ | ||
425 | bool Interfaces::setScript(const QString &argument){ | ||
426 | return setOption(currentMapping, "script", argument); | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * @param error true if could not retrieve the current script argument. | ||
431 | * @return QString the argument of the script for the current mapping. | ||
432 | */ | ||
433 | QString Interfaces::getScript(bool &error){ | ||
434 | return getOption(currentMapping, "script", error); | ||
435 | } | ||
436 | |||
437 | |||
438 | |||
439 | /** | ||
440 | * Helper function used to parse through the QStringList and put pointers in | ||
441 | * the correct place. | ||
442 | * @param stanza The stanza (auto, iface, mapping) to look for. | ||
443 | * @param option string that must be in the stanza's main line. | ||
444 | * @param interator interator to place at location of stanza if successfull. | ||
445 | * @return bool true if the stanza is found. | ||
446 | */ | ||
447 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ | ||
448 | bool found = false; | ||
449 | iterator = interfaces.end(); | ||
450 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | ||
451 | QString line = (*it).simplifyWhiteSpace(); | ||
452 | if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ | ||
453 | uint point = line.find(option); | ||
454 | bool valid = true; | ||
455 | if(point > 0){ | ||
456 | // There are more chars in the line. check +1 | ||
457 | if(line.at(point-1) != ' ') | ||
458 | valid = false; | ||
459 | } | ||
460 | point += option.length(); | ||
461 | if(point < line.length()-1){ | ||
462 | // There are more chars in the line. check -1 | ||
463 | if(line.at(point) != ' ') | ||
464 | valid = false; | ||
465 | } | ||
466 | if(valid){ | ||
467 | if(found == true){ | ||
468 | qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); | ||
469 | } | ||
470 | found = true; | ||
471 | iterator = it; | ||
472 | } | ||
473 | } | ||
474 | } | ||
475 | return found; | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Sets a value of an option in a stanza | ||
480 | * @param start the start of the stanza | ||
481 | * @param option the option to use when setting value. | ||
482 | * @return bool true if successfull, false otherwise. | ||
483 | */ | ||
484 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | ||
485 | if(start == interfaces.end()) | ||
486 | return false; | ||
487 | |||
488 | bool found = false; | ||
489 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | ||
490 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | ||
491 | if(!found && value != ""){ | ||
492 | // Got to the end of the stanza without finding it, so append it. | ||
493 | interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); | ||
494 | } | ||
495 | found = true; | ||
496 | break; | ||
497 | } | ||
498 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ | ||
499 | // Found it in stanza so replace it. | ||
500 | if(found) | ||
501 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | ||
502 | found = true; | ||
503 | (*it) = QString("\t%1 %2").arg(option).arg(value); | ||
504 | } | ||
505 | } | ||
506 | if(!found){ | ||
507 | QStringList::Iterator p = start; | ||
508 | interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); | ||
509 | found = true; | ||
510 | } | ||
511 | return found; | ||
512 | } | ||
513 | |||
514 | /** | ||
515 | * Removes a stanza and all of its options | ||
516 | * @param stanza the stanza to remove | ||
517 | * @return bool true if successfull. | ||
518 | */ | ||
519 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ | ||
520 | if(stanza == interfaces.end()) | ||
521 | return false; | ||
522 | (*stanza) = ""; | ||
523 | return removeAllOptions(stanza); | ||
524 | } | ||
525 | |||
526 | /** | ||
527 | * Removes a option in a stanza | ||
528 | * @param start the start of the stanza | ||
529 | * @param option the option to use when setting value. | ||
530 | * @return bool true if successfull, false otherwise. | ||
531 | */ | ||
532 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | ||
533 | if(start == interfaces.end()) | ||
534 | return false; | ||
535 | |||
536 | bool found = false; | ||
537 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | ||
538 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | ||
539 | // got to the end without finding it | ||
540 | break; | ||
541 | } | ||
542 | if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ | ||
543 | // Found it in stanza so replace it. | ||
544 | if(found) | ||
545 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | ||
546 | found = true; | ||
547 | (*it) = ""; | ||
548 | } | ||
549 | } | ||
550 | return found; | ||
551 | } | ||
552 | |||
553 | /** | ||
554 | * Removes all options in a stanza | ||
555 | * @param start the start of the stanza | ||
556 | * @return bool true if successfull, false otherwise. | ||
557 | */ | ||
558 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ | ||
559 | if(start == interfaces.end()) | ||
560 | return false; | ||
561 | |||
562 | QStringList::Iterator it = start; | ||
563 | it = ++it; | ||
564 | for (; it != interfaces.end(); ++it ) { | ||
565 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | ||
566 | break; | ||
567 | } | ||
568 | it = interfaces.remove(it); | ||
569 | it = --it; | ||
570 | } | ||
571 | // Leave a space between this interface and the next. | ||
572 | interfaces.insert(it, QString("")); | ||
573 | return true; | ||
574 | } | ||
575 | |||
576 | /** | ||
577 | * Gets a value of an option in a stanza | ||
578 | * @param start the start of the stanza | ||
579 | * @param option the option to use when getting the value. | ||
580 | * @param bool true if errors false otherwise. | ||
581 | * @return QString the value of option QString::null() if error == true. | ||
582 | */ | ||
583 | QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ | ||
584 | if(start == interfaces.end()){ | ||
585 | error = false; | ||
586 | return QString(); | ||
587 | } | ||
588 | |||
589 | QString value; | ||
590 | bool found = false; | ||
591 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | ||
592 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | ||
593 | break; | ||
594 | } | ||
595 | if((*it).contains(option) && (*it).at(0) != '#'){ | ||
596 | if(found) | ||
597 | qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); | ||
598 | found = true; | ||
599 | QString line = (*it).simplifyWhiteSpace(); | ||
600 | int space = line.find(" ", option.length()); | ||
601 | if(space != -1){ | ||
602 | value = line.mid(space+1, line.length()); | ||
603 | break; | ||
604 | } | ||
605 | } | ||
606 | } | ||
607 | error = !found; | ||
608 | return value; | ||
609 | } | ||
610 | |||
611 | /** | ||
612 | * Write out the interfaces file to the file passed into the constructor. | ||
613 | * Removes any excess blank lines over 1 line long. | ||
614 | * @return bool true if successfull, false if not. | ||
615 | */ | ||
616 | bool Interfaces::write(){ | ||
617 | QFile::remove(interfacesFile); | ||
618 | QFile file(interfacesFile); | ||
619 | |||
620 | if (!file.open(IO_ReadWrite)){ | ||
621 | qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); | ||
622 | return false; | ||
623 | } | ||
624 | QTextStream stream( &file ); | ||
625 | int whiteSpaceCount = 0; | ||
626 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | ||
627 | QString line = (*it).simplifyWhiteSpace(); | ||
628 | line = line.replace(QRegExp(" "),""); | ||
629 | if(line.length() == 0) | ||
630 | whiteSpaceCount++; | ||
631 | else | ||
632 | whiteSpaceCount = 0; | ||
633 | if(whiteSpaceCount < 2){ | ||
634 | qDebug((*it).latin1()); | ||
635 | stream << (*it) << '\n'; | ||
636 | } | ||
637 | } | ||
638 | file.close(); | ||
639 | return true; | ||
640 | } | ||
641 | |||
642 | // interfaces.cpp | ||
643 | |||
diff --git a/noncore/net/networksetup/interfaces/interfaces.h b/noncore/net/networksetup/interfaces/interfaces.h deleted file mode 100644 index bac2a7e..0000000 --- a/noncore/net/networksetup/interfaces/interfaces.h +++ b/dev/null | |||
@@ -1,77 +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(const QString &interface) const ; | ||
29 | bool setAuto(const QString &interface, bool setAuto); | ||
30 | |||
31 | bool removeInterface(); | ||
32 | bool addInterface(const QString &interface, const QString &family, const QString &method); | ||
33 | bool copyInterface(const QString &oldInterface, const QString &newInterface); | ||
34 | bool setInterface(QString interface); | ||
35 | bool isInterfaceSet() const ; | ||
36 | QString getInterfaceName(bool &error); | ||
37 | bool setInterfaceName(const QString &newName); | ||
38 | QString getInterfaceFamily(bool &error); | ||
39 | bool setInterfaceFamily(const QString &newName); | ||
40 | QString getInterfaceMethod(bool &error); | ||
41 | bool setInterfaceMethod(const QString &newName); | ||
42 | QString getInterfaceOption(const QString &option, bool &error); | ||
43 | bool setInterfaceOption(const QString &option, const QString &value); | ||
44 | bool removeInterfaceOption(const QString &option, const QString &value); | ||
45 | bool removeAllInterfaceOptions(); | ||
46 | |||
47 | bool setMapping(const QString &interface); | ||
48 | bool removeMapping(); | ||
49 | void addMapping(const QString &options); | ||
50 | bool setMap(const QString &map, const QString &value); | ||
51 | bool removeMap(const QString &map, const QString &value); | ||
52 | QString getMap(const QString &map, bool &error); | ||
53 | bool setScript(const QString &argument); | ||
54 | QString getScript(bool &error); | ||
55 | |||
56 | bool write(); | ||
57 | |||
58 | private: | ||
59 | bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator); | ||
60 | bool removeStanza(QStringList::Iterator &stanza); | ||
61 | bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value); | ||
62 | bool removeAllOptions(const QStringList::Iterator &start); | ||
63 | bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value); | ||
64 | QString getOption(const QStringList::Iterator &start, const QString &option, bool &error); | ||
65 | |||
66 | QString interfacesFile; | ||
67 | QStringList interfaces; | ||
68 | QStringList::Iterator currentIface; | ||
69 | QStringList::Iterator currentMapping; | ||
70 | |||
71 | QStringList acceptedFamily; | ||
72 | }; | ||
73 | |||
74 | #endif | ||
75 | |||
76 | // interfaces | ||
77 | |||
diff --git a/noncore/net/networksetup/interfaces/interfaces.pro b/noncore/net/networksetup/interfaces/interfaces.pro deleted file mode 100644 index 9a024f6..0000000 --- a/noncore/net/networksetup/interfaces/interfaces.pro +++ b/dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on release | ||
3 | #CONFIG += qt warn_on debug | ||
4 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | ||
5 | HEADERS = interface.h interfaceinformationimp.h interfaces.h interfacesetupimp.h | ||
6 | SOURCES = interface.cpp interfaces.cpp interfaceinformationimp.cpp interfacesetupimp.cpp | ||
7 | INCLUDEPATH+= $(OPIEDIR)/include ../ | ||
8 | DEPENDPATH+= $(OPIEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | INTERFACES= interfaceadvanced.ui interfaceinformation.ui interfacesetup.ui | ||
11 | TARGET = interfaces | ||
12 | VERSION = 1.0.0 | ||
diff --git a/noncore/net/networksetup/interfaces/interfacesetup.ui b/noncore/net/networksetup/interfaces/interfacesetup.ui deleted file mode 100644 index 2b45d49..0000000 --- a/noncore/net/networksetup/interfaces/interfacesetup.ui +++ b/dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>InterfaceSetup</class> | ||
3 | <widget> | ||
4 | <class>QWidget</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>286</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>QCheckBox</class> | ||
44 | <property stdset="1"> | ||
45 | <name>name</name> | ||
46 | <cstring>dhcpCheckBox</cstring> | ||
47 | </property> | ||
48 | <property stdset="1"> | ||
49 | <name>text</name> | ||
50 | <string>DHCP</string> | ||
51 | </property> | ||
52 | <property stdset="1"> | ||
53 | <name>checked</name> | ||
54 | <bool>true</bool> | ||
55 | </property> | ||
56 | </widget> | ||
57 | <widget> | ||
58 | <class>QGroupBox</class> | ||
59 | <property stdset="1"> | ||
60 | <name>name</name> | ||
61 | <cstring>staticGroupBox</cstring> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>enabled</name> | ||
65 | <bool>false</bool> | ||
66 | </property> | ||
67 | <property stdset="1"> | ||
68 | <name>frameShape</name> | ||
69 | <enum>Box</enum> | ||
70 | </property> | ||
71 | <property stdset="1"> | ||
72 | <name>frameShadow</name> | ||
73 | <enum>Sunken</enum> | ||
74 | </property> | ||
75 | <property stdset="1"> | ||
76 | <name>title</name> | ||
77 | <string>Static Ip Configuration</string> | ||
78 | </property> | ||
79 | <grid> | ||
80 | <property stdset="1"> | ||
81 | <name>margin</name> | ||
82 | <number>11</number> | ||
83 | </property> | ||
84 | <property stdset="1"> | ||
85 | <name>spacing</name> | ||
86 | <number>6</number> | ||
87 | </property> | ||
88 | <widget row="1" column="0" > | ||
89 | <class>QLabel</class> | ||
90 | <property stdset="1"> | ||
91 | <name>name</name> | ||
92 | <cstring>TextLabel5</cstring> | ||
93 | </property> | ||
94 | <property stdset="1"> | ||
95 | <name>text</name> | ||
96 | <string>Subnet Mask</string> | ||
97 | </property> | ||
98 | </widget> | ||
99 | <widget row="2" column="1" > | ||
100 | <class>QLineEdit</class> | ||
101 | <property stdset="1"> | ||
102 | <name>name</name> | ||
103 | <cstring>gatewayEdit</cstring> | ||
104 | </property> | ||
105 | </widget> | ||
106 | <widget row="1" column="1" > | ||
107 | <class>QLineEdit</class> | ||
108 | <property stdset="1"> | ||
109 | <name>name</name> | ||
110 | <cstring>subnetMaskEdit</cstring> | ||
111 | </property> | ||
112 | </widget> | ||
113 | <widget row="0" column="1" > | ||
114 | <class>QLineEdit</class> | ||
115 | <property stdset="1"> | ||
116 | <name>name</name> | ||
117 | <cstring>ipAddressEdit</cstring> | ||
118 | </property> | ||
119 | </widget> | ||
120 | <widget row="3" column="0" > | ||
121 | <class>QLabel</class> | ||
122 | <property stdset="1"> | ||
123 | <name>name</name> | ||
124 | <cstring>TextLabel2</cstring> | ||
125 | </property> | ||
126 | <property stdset="1"> | ||
127 | <name>text</name> | ||
128 | <string>First DNS</string> | ||
129 | </property> | ||
130 | </widget> | ||
131 | <widget row="0" column="0" > | ||
132 | <class>QLabel</class> | ||
133 | <property stdset="1"> | ||
134 | <name>name</name> | ||
135 | <cstring>TextLabel4</cstring> | ||
136 | </property> | ||
137 | <property stdset="1"> | ||
138 | <name>text</name> | ||
139 | <string>IP Address</string> | ||
140 | </property> | ||
141 | </widget> | ||
142 | <widget row="2" column="0" > | ||
143 | <class>QLabel</class> | ||
144 | <property stdset="1"> | ||
145 | <name>name</name> | ||
146 | <cstring>TextLabel1_2</cstring> | ||
147 | </property> | ||
148 | <property stdset="1"> | ||
149 | <name>text</name> | ||
150 | <string>Gateway</string> | ||
151 | </property> | ||
152 | </widget> | ||
153 | <widget row="4" column="0" > | ||
154 | <class>QLabel</class> | ||
155 | <property stdset="1"> | ||
156 | <name>name</name> | ||
157 | <cstring>TextLabel3</cstring> | ||
158 | </property> | ||
159 | <property stdset="1"> | ||
160 | <name>text</name> | ||
161 | <string>Second DNS</string> | ||
162 | </property> | ||
163 | </widget> | ||
164 | <widget row="3" column="1" > | ||
165 | <class>QLineEdit</class> | ||
166 | <property stdset="1"> | ||
167 | <name>name</name> | ||
168 | <cstring>firstDNSLineEdit</cstring> | ||
169 | </property> | ||
170 | </widget> | ||
171 | <widget row="4" column="1" > | ||
172 | <class>QLineEdit</class> | ||
173 | <property stdset="1"> | ||
174 | <name>name</name> | ||
175 | <cstring>secondDNSLineEdit</cstring> | ||
176 | </property> | ||
177 | </widget> | ||
178 | </grid> | ||
179 | </widget> | ||
180 | <spacer> | ||
181 | <property> | ||
182 | <name>name</name> | ||
183 | <cstring>Spacer9</cstring> | ||
184 | </property> | ||
185 | <property stdset="1"> | ||
186 | <name>orientation</name> | ||
187 | <enum>Vertical</enum> | ||
188 | </property> | ||
189 | <property stdset="1"> | ||
190 | <name>sizeType</name> | ||
191 | <enum>Expanding</enum> | ||
192 | </property> | ||
193 | <property> | ||
194 | <name>sizeHint</name> | ||
195 | <size> | ||
196 | <width>20</width> | ||
197 | <height>20</height> | ||
198 | </size> | ||
199 | </property> | ||
200 | </spacer> | ||
201 | </vbox> | ||
202 | </widget> | ||
203 | <customwidgets> | ||
204 | <customwidget> | ||
205 | <class>QWidget</class> | ||
206 | <header location="local">qwidget.h</header> | ||
207 | <sizehint> | ||
208 | <width>100</width> | ||
209 | <height>100</height> | ||
210 | </sizehint> | ||
211 | <container>0</container> | ||
212 | <sizepolicy> | ||
213 | <hordata>7</hordata> | ||
214 | <verdata>7</verdata> | ||
215 | </sizepolicy> | ||
216 | <pixmap>image0</pixmap> | ||
217 | </customwidget> | ||
218 | </customwidgets> | ||
219 | <images> | ||
220 | <image> | ||
221 | <name>image0</name> | ||
222 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | ||
223 | </image> | ||
224 | </images> | ||
225 | <connections> | ||
226 | <connection> | ||
227 | <sender>dhcpCheckBox</sender> | ||
228 | <signal>toggled(bool)</signal> | ||
229 | <receiver>staticGroupBox</receiver> | ||
230 | <slot>setDisabled(bool)</slot> | ||
231 | </connection> | ||
232 | </connections> | ||
233 | <tabstops> | ||
234 | <tabstop>autoStart</tabstop> | ||
235 | <tabstop>dhcpCheckBox</tabstop> | ||
236 | <tabstop>ipAddressEdit</tabstop> | ||
237 | <tabstop>subnetMaskEdit</tabstop> | ||
238 | <tabstop>gatewayEdit</tabstop> | ||
239 | <tabstop>firstDNSLineEdit</tabstop> | ||
240 | <tabstop>secondDNSLineEdit</tabstop> | ||
241 | </tabstops> | ||
242 | </UI> | ||
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp deleted file mode 100644 index 56bbe93..0000000 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp +++ b/dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | #include "interfacesetupimp.h" | ||
2 | #include "interface.h" | ||
3 | |||
4 | #include <qcheckbox.h> | ||
5 | #include <qlineedit.h> | ||
6 | #include <qspinbox.h> | ||
7 | #include <qgroupbox.h> | ||
8 | #include <qlabel.h> | ||
9 | |||
10 | #include <qmessagebox.h> | ||
11 | |||
12 | #define DNSSCRIPT "changedns" | ||
13 | |||
14 | /** | ||
15 | * Constuctor. Set up the connection. A profile must be set. | ||
16 | */ | ||
17 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){ | ||
18 | } | ||
19 | |||
20 | /** | ||
21 | * Save the current settings, then write out the interfaces file and close. | ||
22 | */ | ||
23 | bool InterfaceSetupImp::saveChanges(){ | ||
24 | if(!saveSettings()) | ||
25 | return false; | ||
26 | interfaces.write(); | ||
27 | return true; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * Save the settings for the current Interface. | ||
32 | * @return bool true if successfull, false otherwise | ||
33 | */ | ||
34 | bool InterfaceSetupImp::saveSettings(){ | ||
35 | // eh can't really do anything about it other then return. :-D | ||
36 | if(!interfaces.isInterfaceSet()) | ||
37 | return true; | ||
38 | |||
39 | bool error = false; | ||
40 | // Loopback case | ||
41 | if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | ||
42 | interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | ||
47 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); | ||
48 | return false; | ||
49 | } | ||
50 | interfaces.removeAllInterfaceOptions(); | ||
51 | |||
52 | // DHCP | ||
53 | if(dhcpCheckBox->isChecked()) | ||
54 | interfaces.setInterfaceMethod(INTERFACES_METHOD_DHCP); | ||
55 | else{ | ||
56 | interfaces.setInterfaceMethod("static"); | ||
57 | interfaces.setInterfaceOption("address", ipAddressEdit->text()); | ||
58 | interfaces.setInterfaceOption("netmask", subnetMaskEdit->text()); | ||
59 | interfaces.setInterfaceOption("gateway", gatewayEdit->text()); | ||
60 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | ||
61 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | ||
62 | interfaces.setInterfaceOption("up "DNSSCRIPT" -a ", dns); | ||
63 | interfaces.setInterfaceOption("down "DNSSCRIPT" -r ", dns); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | // IP Information | ||
68 | interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); | ||
69 | return true; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * The Profile has changed. | ||
74 | * @param QString profile the new profile. | ||
75 | */ | ||
76 | void InterfaceSetupImp::setProfile(const QString &profile){ | ||
77 | /* | ||
78 | bool error = false; | ||
79 | if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | ||
80 | staticGroupBox->hide(); | ||
81 | dhcpCheckBox->hide(); | ||
82 | leaseTime->hide(); | ||
83 | leaseHoursLabel->hide(); | ||
84 | } | ||
85 | */ | ||
86 | |||
87 | QString newInterfaceName = interface->getInterfaceName(); | ||
88 | if(profile.length() > 0) | ||
89 | newInterfaceName += "_" + profile; | ||
90 | // See if we have to make a interface. | ||
91 | if(!interfaces.setInterface(newInterfaceName)){ | ||
92 | // Add making for this new interface if need too | ||
93 | if(profile != ""){ | ||
94 | interfaces.copyInterface(interface->getInterfaceName(), newInterfaceName); | ||
95 | if(!interfaces.setMapping(interface->getInterfaceName())){ | ||
96 | interfaces.addMapping(interface->getInterfaceName()); | ||
97 | if(!interfaces.setMapping(interface->getInterfaceName())){ | ||
98 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); | ||
99 | return; | ||
100 | } | ||
101 | } | ||
102 | interfaces.setMap("map", newInterfaceName); | ||
103 | interfaces.setScript("getprofile.sh"); | ||
104 | } | ||
105 | else{ | ||
106 | interfaces.addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | ||
107 | if(!interfaces.setInterface(newInterfaceName)){ | ||
108 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); | ||
109 | return; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | |||
114 | // We must have a valid interface to get this far so read some settings. | ||
115 | |||
116 | // DHCP | ||
117 | bool error = false; | ||
118 | if(interfaces.getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | ||
119 | dhcpCheckBox->setChecked(true); | ||
120 | else | ||
121 | dhcpCheckBox->setChecked(false); | ||
122 | |||
123 | // IP Information | ||
124 | autoStart->setChecked(interfaces.isAuto(interface->getInterfaceName())); | ||
125 | QString dns = interfaces.getInterfaceOption("up "DNSSCRIPT" -a", error); | ||
126 | if(dns.contains(" ")){ | ||
127 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | ||
128 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | ||
129 | } | ||
130 | ipAddressEdit->setText(interfaces.getInterfaceOption("address", error)); | ||
131 | subnetMaskEdit->setText(interfaces.getInterfaceOption("netmask", error)); | ||
132 | gatewayEdit->setText(interfaces.getInterfaceOption("gateway", error)); | ||
133 | } | ||
134 | |||
135 | // interfacesetup.cpp | ||
136 | |||
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.h b/noncore/net/networksetup/interfaces/interfacesetupimp.h deleted file mode 100644 index 9ec526c..0000000 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.h +++ b/dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | #ifndef INTERFACESETUPIMP_H | ||
2 | #define INTERFACESETUPIMP_H | ||
3 | |||
4 | #include "interfacesetup.h" | ||
5 | #include "interfaces.h" | ||
6 | #include <qdialog.h> | ||
7 | |||
8 | class Interface; | ||
9 | |||
10 | class InterfaceSetupImp : public InterfaceSetup { | ||
11 | Q_OBJECT | ||
12 | |||
13 | public: | ||
14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); | ||
15 | bool saveChanges(); | ||
16 | |||
17 | public slots: | ||
18 | void setProfile(const QString &profile); | ||
19 | bool saveSettings(); | ||
20 | |||
21 | private: | ||
22 | Interfaces interfaces; | ||
23 | Interface *interface; | ||
24 | }; | ||
25 | |||
26 | |||
27 | #include <qlayout.h> | ||
28 | |||
29 | class InterfaceSetupImpDialog : public QDialog { | ||
30 | Q_OBJECT | ||
31 | |||
32 | public: | ||
33 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ | ||
34 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); | ||
35 | setCaption("Interface Setup"); | ||
36 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); | ||
37 | InterfaceSetupLayout->addWidget( interfaceSetup ); | ||
38 | }; | ||
39 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; | ||
40 | |||
41 | private: | ||
42 | InterfaceSetupImp *interfaceSetup; | ||
43 | |||
44 | protected slots: | ||
45 | void accept(){ | ||
46 | if(interfaceSetup->saveChanges()) | ||
47 | QDialog::accept(); | ||
48 | }; | ||
49 | |||
50 | }; | ||
51 | |||
52 | #endif | ||
53 | |||
54 | // interfacesetupimp.h | ||
55 | |||