author | zecke <zecke> | 2004-01-05 14:39:29 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-01-05 14:39:29 (UTC) |
commit | c127e5d582b1ae4033eca1c8454bee75d510b9e8 (patch) (unidiff) | |
tree | e4f6e610969f35e1e0954f762f317c0e9ccf76b3 /noncore/settings/networksettings/interfaces | |
parent | 7fb9bc93eae8007a6eb298fc743bbf70dc50fbc5 (diff) | |
download | opie-c127e5d582b1ae4033eca1c8454bee75d510b9e8.zip opie-c127e5d582b1ae4033eca1c8454bee75d510b9e8.tar.gz opie-c127e5d582b1ae4033eca1c8454bee75d510b9e8.tar.bz2 |
Spelling fixes by Michael Opdenacker <zumbi2@netcourrier.com>
Diffstat (limited to 'noncore/settings/networksettings/interfaces') (more/less context) (ignore whitespace changes)
3 files changed, 27 insertions, 27 deletions
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp index 69b55d1..b00b899 100644 --- a/noncore/settings/networksettings/interfaces/interface.cpp +++ b/noncore/settings/networksettings/interfaces/interface.cpp | |||
@@ -1,302 +1,302 @@ | |||
1 | /** | 1 | /** |
2 | * $Author$ | 2 | * $Author$ |
3 | * $Date$ | 3 | * $Date$ |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "interface.h" | 6 | #include "interface.h" |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qfileinfo.h> | 10 | #include <qfileinfo.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | 12 | ||
13 | #define IFCONFIG "/sbin/ifconfig" | 13 | #define IFCONFIG "/sbin/ifconfig" |
14 | #define DHCP_INFO_DIR "/etc/dhcpc" | 14 | #define DHCP_INFO_DIR "/etc/dhcpc" |
15 | 15 | ||
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | #include <stdlib.h> | 17 | #include <stdlib.h> |
18 | 18 | ||
19 | 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"){ | 19 | 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"){ |
20 | refresh(); | 20 | refresh(); |
21 | } | 21 | } |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Set status | 24 | * Set status |
25 | * @param newStatus - the new status | 25 | * @param newStatus - the new status |
26 | * emit updateInterface | 26 | * emit updateInterface |
27 | */ | 27 | */ |
28 | void Interface::setStatus(bool newStatus){ | 28 | void Interface::setStatus(bool newStatus){ |
29 | if(status != newStatus){ | 29 | if(status != newStatus){ |
30 | status = newStatus; | 30 | status = newStatus; |
31 | refresh(); | 31 | refresh(); |
32 | } | 32 | } |
33 | }; | 33 | }; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Set if attached or not (802.11 card pulled out for example) | 36 | * Set if attached or not (802.11 card pulled out for example) |
37 | * @param isAttached - if attached | 37 | * @param isAttached - if attached |
38 | * emit updateInterface | 38 | * emit updateInterface |
39 | */ | 39 | */ |
40 | void Interface::setAttached(bool isAttached){ | 40 | void Interface::setAttached(bool isAttached){ |
41 | attached = isAttached; | 41 | attached = isAttached; |
42 | emit(updateInterface(this)); | 42 | emit(updateInterface(this)); |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Set Hardware name | 46 | * Set Hardware name |
47 | * @param name - the new name | 47 | * @param name - the new name |
48 | * emit updateInterface | 48 | * emit updateInterface |
49 | */ | 49 | */ |
50 | void Interface::setHardwareName(const QString &name){ | 50 | void Interface::setHardwareName(const QString &name){ |
51 | hardwareName = name; | 51 | hardwareName = name; |
52 | emit(updateInterface(this)); | 52 | emit(updateInterface(this)); |
53 | }; | 53 | }; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Set Module owner | 56 | * Set Module owner |
57 | * @param owner - the new owner | 57 | * @param owner - the new owner |
58 | * emit updateInterface | 58 | * emit updateInterface |
59 | */ | 59 | */ |
60 | void Interface::setModuleOwner(Module *owner){ | 60 | void Interface::setModuleOwner(Module *owner){ |
61 | moduleOwner = owner; | 61 | moduleOwner = owner; |
62 | emit(updateInterface(this)); | 62 | emit(updateInterface(this)); |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Try to start the interface. | 67 | * Try to start the interface. |
68 | */ | 68 | */ |
69 | void Interface::start(){ | 69 | void Interface::start(){ |
70 | // check to see if we are already running. | 70 | // check to see if we are already running. |
71 | if(true == status){ | 71 | if(true == status){ |
72 | emit (updateMessage("Unable to start interface,\n already started")); | 72 | emit (updateMessage("Unable to start interface,\n already started")); |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | 75 | ||
76 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); | 76 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); |
77 | // See if it was successfull... | 77 | // See if it was successful... |
78 | if(ret != 0){ | 78 | if(ret != 0){ |
79 | emit (updateMessage("Starting interface failed")); | 79 | emit (updateMessage("Starting interface failed")); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | status = true; | 83 | status = true; |
84 | refresh(); | 84 | refresh(); |
85 | emit (updateMessage("Start successfull")); | 85 | emit (updateMessage("Start successful")); |
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Try to stop the interface. | 89 | * Try to stop the interface. |
90 | */ | 90 | */ |
91 | void Interface::stop(){ | 91 | void Interface::stop(){ |
92 | // check to see if we are already stopped. | 92 | // check to see if we are already stopped. |
93 | if(false == status){ | 93 | if(false == status){ |
94 | emit (updateMessage("Unable to stop interface,\n already stopped")); | 94 | emit (updateMessage("Unable to stop interface,\n already stopped")); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | 97 | ||
98 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); | 98 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); |
99 | if(ret != 0){ | 99 | if(ret != 0){ |
100 | emit (updateMessage("Stopping interface failed")); | 100 | emit (updateMessage("Stopping interface failed")); |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | 103 | ||
104 | status = false; | 104 | status = false; |
105 | refresh(); | 105 | refresh(); |
106 | emit (updateMessage("Stop successfull")); | 106 | emit (updateMessage("Stop successful")); |
107 | } | 107 | } |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Try to restart the interface. | 110 | * Try to restart the interface. |
111 | */ | 111 | */ |
112 | void Interface::restart(){ | 112 | void Interface::restart(){ |
113 | stop(); | 113 | stop(); |
114 | start(); | 114 | start(); |
115 | } | 115 | } |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * Try to refresh the information about the interface. | 118 | * Try to refresh the information about the interface. |
119 | * First call ifconfig, then check the dhcp-info file | 119 | * First call ifconfig, then check the dhcp-info file |
120 | * @return bool true if successfull. | 120 | * @return bool true if successful. |
121 | */ | 121 | */ |
122 | bool Interface::refresh(){ | 122 | bool Interface::refresh(){ |
123 | // See if we are up. | 123 | // See if we are up. |
124 | if(status == false){ | 124 | if(status == false){ |
125 | macAddress = ""; | 125 | macAddress = ""; |
126 | ip = "0.0.0.0"; | 126 | ip = "0.0.0.0"; |
127 | subnetMask = "0.0.0.0"; | 127 | subnetMask = "0.0.0.0"; |
128 | broadcast = ""; | 128 | broadcast = ""; |
129 | dhcp = false; | 129 | dhcp = false; |
130 | dhcpServerIp = ""; | 130 | dhcpServerIp = ""; |
131 | leaseObtained = ""; | 131 | leaseObtained = ""; |
132 | leaseExpires = ""; | 132 | leaseExpires = ""; |
133 | emit(updateInterface(this)); | 133 | emit(updateInterface(this)); |
134 | return true; | 134 | return true; |
135 | } | 135 | } |
136 | 136 | ||
137 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); | 137 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); |
138 | int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); | 138 | int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); |
139 | if(ret != 0){ | 139 | if(ret != 0){ |
140 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); | 140 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); |
141 | return false; | 141 | return false; |
142 | } | 142 | } |
143 | 143 | ||
144 | QFile file(fileName); | 144 | QFile file(fileName); |
145 | if (!file.open(IO_ReadOnly)){ | 145 | if (!file.open(IO_ReadOnly)){ |
146 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | 146 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); |
147 | return false; | 147 | return false; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Set to the defaults | 150 | // Set to the defaults |
151 | macAddress = ""; | 151 | macAddress = ""; |
152 | ip = "0.0.0.0"; | 152 | ip = "0.0.0.0"; |
153 | subnetMask = "0.0.0.0"; | 153 | subnetMask = "0.0.0.0"; |
154 | broadcast = ""; | 154 | broadcast = ""; |
155 | 155 | ||
156 | QTextStream stream( &file ); | 156 | QTextStream stream( &file ); |
157 | QString line; | 157 | QString line; |
158 | while ( !stream.eof() ) { | 158 | while ( !stream.eof() ) { |
159 | line = stream.readLine(); | 159 | line = stream.readLine(); |
160 | if(line.contains("HWaddr")){ | 160 | if(line.contains("HWaddr")){ |
161 | int mac = line.find("HWaddr"); | 161 | int mac = line.find("HWaddr"); |
162 | macAddress = line.mid(mac+7, line.length()); | 162 | macAddress = line.mid(mac+7, line.length()); |
163 | } | 163 | } |
164 | if(line.contains("inet addr")){ | 164 | if(line.contains("inet addr")){ |
165 | int ipl = line.find("inet addr"); | 165 | int ipl = line.find("inet addr"); |
166 | int space = line.find(" ", ipl+10); | 166 | int space = line.find(" ", ipl+10); |
167 | ip = line.mid(ipl+10, space-ipl-10); | 167 | ip = line.mid(ipl+10, space-ipl-10); |
168 | } | 168 | } |
169 | if(line.contains("Mask")){ | 169 | if(line.contains("Mask")){ |
170 | int mask = line.find("Mask"); | 170 | int mask = line.find("Mask"); |
171 | subnetMask = line.mid(mask+5, line.length()); | 171 | subnetMask = line.mid(mask+5, line.length()); |
172 | } | 172 | } |
173 | if(line.contains("Bcast")){ | 173 | if(line.contains("Bcast")){ |
174 | int mask = line.find("Bcast"); | 174 | int mask = line.find("Bcast"); |
175 | int space = line.find(" ", mask+6); | 175 | int space = line.find(" ", mask+6); |
176 | broadcast = line.mid(mask+6, space-mask-6); | 176 | broadcast = line.mid(mask+6, space-mask-6); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | file.close(); | 179 | file.close(); |
180 | QFile::remove(fileName); | 180 | QFile::remove(fileName); |
181 | 181 | ||
182 | // DHCP TESTING | 182 | // DHCP TESTING |
183 | // reset DHCP info | 183 | // reset DHCP info |
184 | dhcpServerIp = ""; | 184 | dhcpServerIp = ""; |
185 | leaseObtained = ""; | 185 | leaseObtained = ""; |
186 | leaseExpires = ""; | 186 | leaseExpires = ""; |
187 | dhcp = false; | 187 | dhcp = false; |
188 | 188 | ||
189 | QString dhcpDirectory(DHCP_INFO_DIR); | 189 | QString dhcpDirectory(DHCP_INFO_DIR); |
190 | QDir d(dhcpDirectory); | 190 | QDir d(dhcpDirectory); |
191 | if(!d.exists(dhcpDirectory)) | 191 | if(!d.exists(dhcpDirectory)) |
192 | dhcpDirectory = "/var/run"; | 192 | dhcpDirectory = "/var/run"; |
193 | 193 | ||
194 | // See if we have | 194 | // See if we have |
195 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); | 195 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); |
196 | // If there is no DHCP information then exit now with no errors. | 196 | // If there is no DHCP information then exit now with no errors. |
197 | if(!QFile::exists(dhcpFile)){ | 197 | if(!QFile::exists(dhcpFile)){ |
198 | emit(updateInterface(this)); | 198 | emit(updateInterface(this)); |
199 | return true; | 199 | return true; |
200 | } | 200 | } |
201 | 201 | ||
202 | file.setName(dhcpFile); | 202 | file.setName(dhcpFile); |
203 | if (!file.open(IO_ReadOnly)){ | 203 | if (!file.open(IO_ReadOnly)){ |
204 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 204 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
205 | return false; | 205 | return false; |
206 | } | 206 | } |
207 | 207 | ||
208 | // leaseTime and renewalTime and used if pid and deamon exe can be accessed. | 208 | // leaseTime and renewalTime and used if pid and deamon exe can be accessed. |
209 | int leaseTime = 0; | 209 | int leaseTime = 0; |
210 | int renewalTime = 0; | 210 | int renewalTime = 0; |
211 | 211 | ||
212 | stream.setDevice( &file ); | 212 | stream.setDevice( &file ); |
213 | while ( !stream.eof() ) { | 213 | while ( !stream.eof() ) { |
214 | line = stream.readLine(); | 214 | line = stream.readLine(); |
215 | if(line.contains("DHCPSIADDR=")) | 215 | if(line.contains("DHCPSIADDR=")) |
216 | dhcpServerIp = line.mid(11, line.length()); | 216 | dhcpServerIp = line.mid(11, line.length()); |
217 | if(line.contains("LEASETIME=")) | 217 | if(line.contains("LEASETIME=")) |
218 | leaseTime = line.mid(10, line.length()).toInt(); | 218 | leaseTime = line.mid(10, line.length()).toInt(); |
219 | if(line.contains("RENEWALTIME=")) | 219 | if(line.contains("RENEWALTIME=")) |
220 | renewalTime = line.mid(12, line.length()).toInt(); | 220 | renewalTime = line.mid(12, line.length()).toInt(); |
221 | } | 221 | } |
222 | file.close(); | 222 | file.close(); |
223 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); | 223 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); |
224 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); | 224 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); |
225 | 225 | ||
226 | // Get the pid of the deamond | 226 | // Get the pid of the deamond |
227 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); | 227 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); |
228 | file.setName(dhcpFile); | 228 | file.setName(dhcpFile); |
229 | if (!file.open(IO_ReadOnly)){ | 229 | if (!file.open(IO_ReadOnly)){ |
230 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 230 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
231 | return false; | 231 | return false; |
232 | } | 232 | } |
233 | 233 | ||
234 | int pid = -1; | 234 | int pid = -1; |
235 | stream.setDevice( &file ); | 235 | stream.setDevice( &file ); |
236 | while ( !stream.eof() ) { | 236 | while ( !stream.eof() ) { |
237 | line = stream.readLine(); | 237 | line = stream.readLine(); |
238 | pid = line.toInt(); | 238 | pid = line.toInt(); |
239 | } | 239 | } |
240 | file.close(); | 240 | file.close(); |
241 | 241 | ||
242 | if( pid == -1){ | 242 | if( pid == -1){ |
243 | qDebug("Interface: Could not get pid of dhcpc deamon."); | 243 | qDebug("Interface: Could not get pid of dhcpc deamon."); |
244 | return false; | 244 | return false; |
245 | } | 245 | } |
246 | 246 | ||
247 | // Get the start running time of the deamon | 247 | // Get the start running time of the deamon |
248 | fileName = (QString("/proc/%1/stat").arg(pid)); | 248 | fileName = (QString("/proc/%1/stat").arg(pid)); |
249 | file.setName(fileName); | 249 | file.setName(fileName); |
250 | stream.setDevice( &file ); | 250 | stream.setDevice( &file ); |
251 | if (!file.open(IO_ReadOnly)){ | 251 | if (!file.open(IO_ReadOnly)){ |
252 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | 252 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); |
253 | return false; | 253 | return false; |
254 | } | 254 | } |
255 | while ( !stream.eof() ) { | 255 | while ( !stream.eof() ) { |
256 | line = stream.readLine(); | 256 | line = stream.readLine(); |
257 | } | 257 | } |
258 | file.close(); | 258 | file.close(); |
259 | long time = 0; | 259 | long time = 0; |
260 | // Grab the start time | 260 | // Grab the start time |
261 | // pid com state ppid pgrp session tty_nr tpgid flags | 261 | // pid com state ppid pgrp session tty_nr tpgid flags |
262 | sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " | 262 | sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " |
263 | // minflt cminflt majflt cmajflt utime stime cutime cstime priority | 263 | // minflt cminflt majflt cmajflt utime stime cutime cstime priority |
264 | "%*u %*u %*u %*u %*u %*u %*d %*d %*d " | 264 | "%*u %*u %*u %*u %*u %*u %*d %*d %*d " |
265 | // nice 0 itrealvalue starttime | 265 | // nice 0 itrealvalue starttime |
266 | "%*d %*d %*d %lu", (long*) &time); | 266 | "%*d %*d %*d %lu", (long*) &time); |
267 | time = time/100; | 267 | time = time/100; |
268 | 268 | ||
269 | QDateTime datetime(QDateTime::currentDateTime()); | 269 | QDateTime datetime(QDateTime::currentDateTime()); |
270 | 270 | ||
271 | // Get the uptime of the computer. | 271 | // Get the uptime of the computer. |
272 | QFile f("/proc/uptime"); | 272 | QFile f("/proc/uptime"); |
273 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 273 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
274 | QTextStream t( &f ); // use a text stream | 274 | QTextStream t( &f ); // use a text stream |
275 | int sec = 0; | 275 | int sec = 0; |
276 | t >> sec; | 276 | t >> sec; |
277 | datetime = datetime.addSecs((-1*sec)); | 277 | datetime = datetime.addSecs((-1*sec)); |
278 | f.close(); | 278 | f.close(); |
279 | } | 279 | } |
280 | else{ | 280 | else{ |
281 | qDebug("Interface: Can't open /proc/uptime to retrive uptime."); | 281 | qDebug("Interface: Can't open /proc/uptime to retrive uptime."); |
282 | return false; | 282 | return false; |
283 | } | 283 | } |
284 | 284 | ||
285 | datetime = datetime.addSecs(time); | 285 | datetime = datetime.addSecs(time); |
286 | //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); | 286 | //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); |
287 | 287 | ||
288 | // Calculate the start and renew times | 288 | // Calculate the start and renew times |
289 | leaseObtained= datetime.toString(); | 289 | leaseObtained= datetime.toString(); |
290 | 290 | ||
291 | // Calculate the start and renew times | 291 | // Calculate the start and renew times |
292 | datetime = datetime.addSecs(leaseTime); | 292 | datetime = datetime.addSecs(leaseTime); |
293 | leaseExpires = datetime.toString(); | 293 | leaseExpires = datetime.toString(); |
294 | 294 | ||
295 | dhcp = true; | 295 | dhcp = true; |
296 | 296 | ||
297 | emit(updateInterface(this)); | 297 | emit(updateInterface(this)); |
298 | return true; | 298 | return true; |
299 | } | 299 | } |
300 | 300 | ||
301 | // interface.cpp | 301 | // interface.cpp |
302 | 302 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index 436e449..6b161ae 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp | |||
@@ -1,712 +1,712 @@ | |||
1 | #include "interfaces.h" | 1 | #include "interfaces.h" |
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qtextstream.h> | 5 | #include <qtextstream.h> |
6 | #include <qregexp.h> | 6 | #include <qregexp.h> |
7 | 7 | ||
8 | // The three stanza's | 8 | // The three stanza's |
9 | #define AUTO "auto" | 9 | #define AUTO "auto" |
10 | #define IFACE "iface" | 10 | #define IFACE "iface" |
11 | #define MAPPING "mapping" | 11 | #define MAPPING "mapping" |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Constructor. Reads in the interfaces file and then split the file up by | 14 | * Constructor. Reads in the interfaces file and then split the file up by |
15 | * the \n for interfaces variable. | 15 | * the \n for interfaces variable. |
16 | * @param useInterfacesFile if an interface file other then the default is | 16 | * @param useInterfacesFile if an interface file other then the default is |
17 | * desired to be used it should be passed in. | 17 | * desired to be used it should be passed in. |
18 | */ | 18 | */ |
19 | Interfaces::Interfaces(QString useInterfacesFile){ | 19 | Interfaces::Interfaces(QString useInterfacesFile){ |
20 | acceptedFamily.append(INTERFACES_FAMILY_INET); | 20 | acceptedFamily.append(INTERFACES_FAMILY_INET); |
21 | acceptedFamily.append(INTERFACES_FAMILY_IPX); | 21 | acceptedFamily.append(INTERFACES_FAMILY_IPX); |
22 | acceptedFamily.append(INTERFACES_FAMILY_INET6); | 22 | acceptedFamily.append(INTERFACES_FAMILY_INET6); |
23 | 23 | ||
24 | interfacesFile = useInterfacesFile; | 24 | interfacesFile = useInterfacesFile; |
25 | QFile file(interfacesFile); | 25 | QFile file(interfacesFile); |
26 | if (!file.open(IO_ReadOnly)){ | 26 | if (!file.open(IO_ReadOnly)){ |
27 | qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); | 27 | qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); |
28 | currentIface = interfaces.end(); | 28 | currentIface = interfaces.end(); |
29 | currentMapping = interfaces.end(); | 29 | currentMapping = interfaces.end(); |
30 | return; | 30 | return; |
31 | } | 31 | } |
32 | QTextStream stream( &file ); | 32 | QTextStream stream( &file ); |
33 | QString line; | 33 | QString line; |
34 | while ( !stream.eof() ) { | 34 | while ( !stream.eof() ) { |
35 | line += stream.readLine(); | 35 | line += stream.readLine(); |
36 | line += "\n"; | 36 | line += "\n"; |
37 | } | 37 | } |
38 | file.close(); | 38 | file.close(); |
39 | interfaces = QStringList::split("\n", line, true); | 39 | interfaces = QStringList::split("\n", line, true); |
40 | 40 | ||
41 | currentIface = interfaces.end(); | 41 | currentIface = interfaces.end(); |
42 | currentMapping = interfaces.end(); | 42 | currentMapping = interfaces.end(); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Get a list of all interfaces in the interface file. Usefull for | 47 | * Get a list of all interfaces in the interface file. Useful for |
48 | * hardware that is not currently connected such as an 802.11b card | 48 | * hardware that is not currently connected such as an 802.11b card |
49 | * not plugged in, but configured for when it is plugged in. | 49 | * not plugged in, but configured for when it is plugged in. |
50 | * @return Return string list of interfaces. | 50 | * @return Return string list of interfaces. |
51 | **/ | 51 | **/ |
52 | QStringList Interfaces::getInterfaceList(){ | 52 | QStringList Interfaces::getInterfaceList(){ |
53 | QStringList list; | 53 | QStringList list; |
54 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 54 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
55 | QString line = (*it).simplifyWhiteSpace(); | 55 | QString line = (*it).simplifyWhiteSpace(); |
56 | if(line.contains(IFACE) && line.at(0) != '#'){ | 56 | if(line.contains(IFACE) && line.at(0) != '#'){ |
57 | line = line.mid(QString(IFACE).length() +1, line.length()); | 57 | line = line.mid(QString(IFACE).length() +1, line.length()); |
58 | line = line.simplifyWhiteSpace(); | 58 | line = line.simplifyWhiteSpace(); |
59 | int findSpace = line.find(" "); | 59 | int findSpace = line.find(" "); |
60 | if( findSpace >= 0){ | 60 | if( findSpace >= 0){ |
61 | line = line.mid(0, findSpace); | 61 | line = line.mid(0, findSpace); |
62 | list.append(line); | 62 | list.append(line); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | } | 65 | } |
66 | return list; | 66 | return list; |
67 | } | 67 | } |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Find out if interface is in an "auto" group or not. | 70 | * Find out if interface is in an "auto" group or not. |
71 | * Report any duplicates such as eth0 being in two differnt auto's | 71 | * Report any duplicates such as eth0 being in two differnt auto's |
72 | * @param interface interface to check to see if it is on or not. | 72 | * @param interface interface to check to see if it is on or not. |
73 | * @return true is interface is in auto | 73 | * @return true is interface is in auto |
74 | */ | 74 | */ |
75 | bool Interfaces::isAuto(const QString &interface) const { | 75 | bool Interfaces::isAuto(const QString &interface) const { |
76 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | 76 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); |
77 | QStringList awi = autoLines.grep(QRegExp(interface)); | 77 | QStringList awi = autoLines.grep(QRegExp(interface)); |
78 | if(awi.count() > 1) | 78 | if(awi.count() > 1) |
79 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); | 79 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); |
80 | return awi.count() > 0; | 80 | return awi.count() > 0; |
81 | } | 81 | } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Attempt to set the auto option for interface to setAuto. | 84 | * Attempt to set the auto option for interface to setAuto. |
85 | * @param interface the interface to set | 85 | * @param interface the interface to set |
86 | * @param setAuto the value to set interface to. | 86 | * @param setAuto the value to set interface to. |
87 | * @return false if already set to setAuto. | 87 | * @return false if already set to setAuto. |
88 | * */ | 88 | * */ |
89 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ | 89 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ |
90 | // Don't need to set it if it is already set. | 90 | // Don't need to set it if it is already set. |
91 | if(isAuto(interface) == setAuto) | 91 | if(isAuto(interface) == setAuto) |
92 | return false; | 92 | return false; |
93 | 93 | ||
94 | bool changed = false; | 94 | bool changed = false; |
95 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 95 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
96 | if((*it).contains(AUTO)){ | 96 | if((*it).contains(AUTO)){ |
97 | //We know that they are not in any group so let add to this auto. | 97 | //We know that they are not in any group so let add to this auto. |
98 | if(setAuto){ | 98 | if(setAuto){ |
99 | (*it) = (*it) += " " + interface; | 99 | (*it) = (*it) += " " + interface; |
100 | // Don't care to have such thins as: auto eth0 lo usb0 | 100 | // Don't care to have such thins as: auto eth0 lo usb0 |
101 | (*it) = (*it).simplifyWhiteSpace(); | 101 | (*it) = (*it).simplifyWhiteSpace(); |
102 | changed = true; | 102 | changed = true; |
103 | break; | 103 | break; |
104 | } | 104 | } |
105 | // else see if we need to remove from this one | 105 | // else see if we need to remove from this one |
106 | else{ | 106 | else{ |
107 | if((*it).contains(interface)){ | 107 | if((*it).contains(interface)){ |
108 | (*it) = (*it).replace(QRegExp(interface), ""); | 108 | (*it) = (*it).replace(QRegExp(interface), ""); |
109 | // if AUTO is the only thing left clear the line | 109 | // if AUTO is the only thing left clear the line |
110 | if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) | 110 | if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) |
111 | (*it) = ""; | 111 | (*it) = ""; |
112 | changed = true; | 112 | changed = true; |
113 | // Don't break because we want to make sure we remove all cases. | 113 | // Don't break because we want to make sure we remove all cases. |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | // In the case where there is no AUTO field add one. | 118 | // In the case where there is no AUTO field add one. |
119 | if(!changed && setAuto) | 119 | if(!changed && setAuto) |
120 | interfaces.append(QString(AUTO" %1").arg(interface)); | 120 | interfaces.append(QString(AUTO" %1").arg(interface)); |
121 | return true; | 121 | return true; |
122 | } | 122 | } |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * Set the current interface to interface. This needs to be done before you | 125 | * Set the current interface to interface. This needs to be done before you |
126 | * can call getFamily(), getMethod, and get/setOption(). | 126 | * can call getFamily(), getMethod, and get/setOption(). |
127 | * @param interface the name of the interface to set. All whitespace is | 127 | * @param interface the name of the interface to set. All whitespace is |
128 | * removed from the interface name. | 128 | * removed from the interface name. |
129 | * @return bool true if it is successfull. | 129 | * @return bool true if it is successful. |
130 | */ | 130 | */ |
131 | bool Interfaces::setInterface(QString interface){ | 131 | bool Interfaces::setInterface(QString interface){ |
132 | interface = interface.simplifyWhiteSpace(); | 132 | interface = interface.simplifyWhiteSpace(); |
133 | interface = interface.replace(QRegExp(" "), ""); | 133 | interface = interface.replace(QRegExp(" "), ""); |
134 | return setStanza(IFACE, interface, currentIface); | 134 | return setStanza(IFACE, interface, currentIface); |
135 | } | 135 | } |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * A quick helper funtion to see if the current interface is set. | 138 | * A quick helper funtion to see if the current interface is set. |
139 | * @return bool true if set, false otherwise. | 139 | * @return bool true if set, false otherwise. |
140 | */ | 140 | */ |
141 | bool Interfaces::isInterfaceSet() const { | 141 | bool Interfaces::isInterfaceSet() const { |
142 | return (interfaces.end() != currentIface); | 142 | return (interfaces.end() != currentIface); |
143 | } | 143 | } |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * Add a new interface of with the settings - family and method | 146 | * Add a new interface of with the settings - family and method |
147 | * @param interface the name of the interface to set. All whitespace is | 147 | * @param interface the name of the interface to set. All whitespace is |
148 | * removed from the interface name. | 148 | * removed from the interface name. |
149 | * @param family the family of this interface inet or inet, ipx or inet6 | 149 | * @param family the family of this interface inet or inet, ipx or inet6 |
150 | * Must of one of the families defined in interfaces.h | 150 | * Must of one of the families defined in interfaces.h |
151 | * @param method for the family. see interfaces man page for family methods. | 151 | * @param method for the family. see interfaces man page for family methods. |
152 | * @return true if successfull. | 152 | * @return true if successful. |
153 | */ | 153 | */ |
154 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ | 154 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ |
155 | qDebug("Interfaces::addInterface(%s)",interface.latin1()); | 155 | qDebug("Interfaces::addInterface(%s)",interface.latin1()); |
156 | if(0 == acceptedFamily.contains(family)) | 156 | if(0 == acceptedFamily.contains(family)) |
157 | return false; | 157 | return false; |
158 | QString newInterface = interface.simplifyWhiteSpace(); | 158 | QString newInterface = interface.simplifyWhiteSpace(); |
159 | newInterface = newInterface.replace(QRegExp(" "), ""); | 159 | newInterface = newInterface.replace(QRegExp(" "), ""); |
160 | interfaces.append(""); | 160 | interfaces.append(""); |
161 | interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); | 161 | interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); |
162 | return true; | 162 | return true; |
163 | } | 163 | } |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * Copies interface with name interface to name newInterface | 166 | * Copies interface with name interface to name newInterface |
167 | * @param newInterface name of the new interface. | 167 | * @param newInterface name of the new interface. |
168 | * @return bool true if successfull | 168 | * @return bool true if successful |
169 | */ | 169 | */ |
170 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ | 170 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ |
171 | qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1()); | 171 | qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1()); |
172 | if(!setInterface(interface)) | 172 | if(!setInterface(interface)) |
173 | return false; | 173 | return false; |
174 | 174 | ||
175 | // Store the old interface and bump past the stanza line. | 175 | // Store the old interface and bump past the stanza line. |
176 | QStringList::Iterator it = currentIface; | 176 | QStringList::Iterator it = currentIface; |
177 | it++; | 177 | it++; |
178 | 178 | ||
179 | // Add the new interface | 179 | // Add the new interface |
180 | bool error; | 180 | bool error; |
181 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); | 181 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); |
182 | if(!setInterface(newInterface)) | 182 | if(!setInterface(newInterface)) |
183 | return false; | 183 | return false; |
184 | 184 | ||
185 | QStringList::Iterator newIface = currentIface; | 185 | QStringList::Iterator newIface = currentIface; |
186 | newIface++; | 186 | newIface++; |
187 | 187 | ||
188 | // Copy all of the lines | 188 | // Copy all of the lines |
189 | for ( ; it != interfaces.end(); ++it ){ | 189 | for ( ; it != interfaces.end(); ++it ){ |
190 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) | 190 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) |
191 | break; | 191 | break; |
192 | newIface = interfaces.insert(newIface, *it); | 192 | newIface = interfaces.insert(newIface, *it); |
193 | } | 193 | } |
194 | 194 | ||
195 | return true; | 195 | return true; |
196 | } | 196 | } |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Remove the currently selected interface and all of its options. | 199 | * Remove the currently selected interface and all of its options. |
200 | * @return bool if successfull or not. | 200 | * @return bool if successful or not. |
201 | */ | 201 | */ |
202 | bool Interfaces::removeInterface(){ | 202 | bool Interfaces::removeInterface(){ |
203 | return removeStanza(currentIface); | 203 | return removeStanza(currentIface); |
204 | } | 204 | } |
205 | 205 | ||
206 | /** | 206 | /** |
207 | * Gets the hardware name of the interface that is currently selected. | 207 | * Gets the hardware name of the interface that is currently selected. |
208 | * @return QString name of the hardware interface (eth0, usb2, wlan1...). | 208 | * @return QString name of the hardware interface (eth0, usb2, wlan1...). |
209 | * @param error set to true if any error occurs, false otherwise. | 209 | * @param error set to true if any error occurs, false otherwise. |
210 | */ | 210 | */ |
211 | QString Interfaces::getInterfaceName(bool &error){ | 211 | QString Interfaces::getInterfaceName(bool &error){ |
212 | if(currentIface == interfaces.end()){ | 212 | if(currentIface == interfaces.end()){ |
213 | error = true; | 213 | error = true; |
214 | return QString(); | 214 | return QString(); |
215 | } | 215 | } |
216 | QString line = (*currentIface); | 216 | QString line = (*currentIface); |
217 | line = line.mid(QString(IFACE).length() +1, line.length()); | 217 | line = line.mid(QString(IFACE).length() +1, line.length()); |
218 | line = line.simplifyWhiteSpace(); | 218 | line = line.simplifyWhiteSpace(); |
219 | int findSpace = line.find(" "); | 219 | int findSpace = line.find(" "); |
220 | if( findSpace < 0){ | 220 | if( findSpace < 0){ |
221 | error = true; | 221 | error = true; |
222 | return QString(); | 222 | return QString(); |
223 | } | 223 | } |
224 | error = false; | 224 | error = false; |
225 | return line.mid(0, findSpace); | 225 | return line.mid(0, findSpace); |
226 | } | 226 | } |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * Gets the family name of the interface that is currently selected. | 229 | * Gets the family name of the interface that is currently selected. |
230 | * @return QString name of the family (inet, inet6, ipx). | 230 | * @return QString name of the family (inet, inet6, ipx). |
231 | * @param error set to true if any error occurs, false otherwise. | 231 | * @param error set to true if any error occurs, false otherwise. |
232 | */ | 232 | */ |
233 | QString Interfaces::getInterfaceFamily(bool &error){ | 233 | QString Interfaces::getInterfaceFamily(bool &error){ |
234 | QString name = getInterfaceName(error); | 234 | QString name = getInterfaceName(error); |
235 | if(error) | 235 | if(error) |
236 | return QString(); | 236 | return QString(); |
237 | QString line = (*currentIface); | 237 | QString line = (*currentIface); |
238 | line = line.mid(QString(IFACE).length() +1, line.length()); | 238 | line = line.mid(QString(IFACE).length() +1, line.length()); |
239 | line = line.mid(name.length()+1, line.length()); | 239 | line = line.mid(name.length()+1, line.length()); |
240 | line = line.simplifyWhiteSpace(); | 240 | line = line.simplifyWhiteSpace(); |
241 | int findSpace = line.find(" "); | 241 | int findSpace = line.find(" "); |
242 | if( findSpace < 0){ | 242 | if( findSpace < 0){ |
243 | error = true; | 243 | error = true; |
244 | return QString(); | 244 | return QString(); |
245 | } | 245 | } |
246 | error = false; | 246 | error = false; |
247 | return line.mid(0, findSpace); | 247 | return line.mid(0, findSpace); |
248 | } | 248 | } |
249 | 249 | ||
250 | /** | 250 | /** |
251 | * Gets the method of the interface that is currently selected. | 251 | * Gets the method of the interface that is currently selected. |
252 | * @return QString name of the method such as staic or dhcp. | 252 | * @return QString name of the method such as staic or dhcp. |
253 | * See the man page of interfaces for possible methods depending on the family. | 253 | * See the man page of interfaces for possible methods depending on the family. |
254 | * @param error set to true if any error occurs, false otherwise. | 254 | * @param error set to true if any error occurs, false otherwise. |
255 | */ | 255 | */ |
256 | QString Interfaces::getInterfaceMethod(bool &error){ | 256 | QString Interfaces::getInterfaceMethod(bool &error){ |
257 | QString name = getInterfaceName(error); | 257 | QString name = getInterfaceName(error); |
258 | if(error) | 258 | if(error) |
259 | return QString(); | 259 | return QString(); |
260 | QString family = getInterfaceFamily(error); | 260 | QString family = getInterfaceFamily(error); |
261 | if(error) | 261 | if(error) |
262 | return QString(); | 262 | return QString(); |
263 | QString line = (*currentIface); | 263 | QString line = (*currentIface); |
264 | line = line.mid(QString(IFACE).length()+1, line.length()); | 264 | line = line.mid(QString(IFACE).length()+1, line.length()); |
265 | line = line.mid(name.length()+1, line.length()); | 265 | line = line.mid(name.length()+1, line.length()); |
266 | line = line.mid(family.length()+1, line.length()); | 266 | line = line.mid(family.length()+1, line.length()); |
267 | line = line.simplifyWhiteSpace(); | 267 | line = line.simplifyWhiteSpace(); |
268 | error = false; | 268 | error = false; |
269 | return line; | 269 | return line; |
270 | } | 270 | } |
271 | 271 | ||
272 | /** | 272 | /** |
273 | * Sets the interface name to newName. | 273 | * Sets the interface name to newName. |
274 | * @param newName the new name of the interface. All whitespace is removed. | 274 | * @param newName the new name of the interface. All whitespace is removed. |
275 | * @return bool true if successfull. | 275 | * @return bool true if successful. |
276 | */ | 276 | */ |
277 | bool Interfaces::setInterfaceName(const QString &newName){ | 277 | bool Interfaces::setInterfaceName(const QString &newName){ |
278 | qDebug("setInterfaceName %s", newName.latin1()); | 278 | qDebug("setInterfaceName %s", newName.latin1()); |
279 | if(currentIface == interfaces.end()) | 279 | if(currentIface == interfaces.end()) |
280 | return false; | 280 | return false; |
281 | QString name = newName.simplifyWhiteSpace(); | 281 | QString name = newName.simplifyWhiteSpace(); |
282 | name = name.replace(QRegExp(" "), ""); | 282 | name = name.replace(QRegExp(" "), ""); |
283 | bool returnValue = false; | 283 | bool returnValue = false; |
284 | QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); | 284 | QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); |
285 | qDebug("setting %s",tmp.latin1()); | 285 | qDebug("setting %s",tmp.latin1()); |
286 | 286 | ||
287 | (*currentIface) = tmp; | 287 | (*currentIface) = tmp; |
288 | return !returnValue; | 288 | return !returnValue; |
289 | } | 289 | } |
290 | 290 | ||
291 | /** | 291 | /** |
292 | * Sets the interface family to newName. | 292 | * Sets the interface family to newName. |
293 | * @param newName the new name of the interface. Must be one of the families | 293 | * @param newName the new name of the interface. Must be one of the families |
294 | * defined in the interfaces.h file. | 294 | * defined in the interfaces.h file. |
295 | * @return bool true if successfull. | 295 | * @return bool true if successful. |
296 | */ | 296 | */ |
297 | bool Interfaces::setInterfaceFamily(const QString &newName){ | 297 | bool Interfaces::setInterfaceFamily(const QString &newName){ |
298 | if(currentIface == interfaces.end()) | 298 | if(currentIface == interfaces.end()) |
299 | return false; | 299 | return false; |
300 | if(acceptedFamily.contains(newName)==0) | 300 | if(acceptedFamily.contains(newName)==0) |
301 | return false; | 301 | return false; |
302 | bool returnValue = false; | 302 | bool returnValue = false; |
303 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); | 303 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); |
304 | return !returnValue; | 304 | return !returnValue; |
305 | } | 305 | } |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * Sets the interface method to newName | 308 | * Sets the interface method to newName |
309 | * @param newName the new name of the interface | 309 | * @param newName the new name of the interface |
310 | * @return bool true if successfull. | 310 | * @return bool true if successful. |
311 | */ | 311 | */ |
312 | bool Interfaces::setInterfaceMethod(const QString &newName){ | 312 | bool Interfaces::setInterfaceMethod(const QString &newName){ |
313 | if(currentIface == interfaces.end()) | 313 | if(currentIface == interfaces.end()) |
314 | return false; | 314 | return false; |
315 | bool returnValue = false; | 315 | bool returnValue = false; |
316 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); | 316 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); |
317 | return !returnValue; | 317 | return !returnValue; |
318 | } | 318 | } |
319 | 319 | ||
320 | /** | 320 | /** |
321 | * Get a value for an option in the currently selected interface. For example | 321 | * Get a value for an option in the currently selected interface. For example |
322 | * calling getInterfaceOption("address") on the following stanza would | 322 | * calling getInterfaceOption("address") on the following stanza would |
323 | * return 192.168.1.1. | 323 | * return 192.168.1.1. |
324 | * iface eth0 static | 324 | * iface eth0 static |
325 | * address 192.168.1.1 | 325 | * address 192.168.1.1 |
326 | * @param option the options to get the value. | 326 | * @param option the options to get the value. |
327 | * @param error set to true if any error occurs, false otherwise. | 327 | * @param error set to true if any error occurs, false otherwise. |
328 | * @return QString the options value. QString::null if error == true | 328 | * @return QString the options value. QString::null if error == true |
329 | */ | 329 | */ |
330 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ | 330 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ |
331 | return getOption(currentIface, option, error); | 331 | return getOption(currentIface, option, error); |
332 | } | 332 | } |
333 | 333 | ||
334 | /** | 334 | /** |
335 | * Set a value for an option in the currently selected interface. If option | 335 | * Set a value for an option in the currently selected interface. If option |
336 | * doesn't exist then it is added along with the value. | 336 | * doesn't exist then it is added along with the value. |
337 | * If value isEmpty() then we will remove the option | 337 | * If value isEmpty() then we will remove the option |
338 | * | 338 | * |
339 | * @param option the options to set the value. | 339 | * @param option the options to set the value. |
340 | * @param value the value that option should be set to. | 340 | * @param value the value that option should be set to. |
341 | * @param error set to true if any error occurs, false otherwise. | 341 | * @param error set to true if any error occurs, false otherwise. |
342 | * @return QString the options value. QString::null if error == true | 342 | * @return QString the options value. QString::null if error == true |
343 | */ | 343 | */ |
344 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ | 344 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ |
345 | if( value.stripWhiteSpace().isEmpty() ) | 345 | if( value.stripWhiteSpace().isEmpty() ) |
346 | return removeInterfaceOption( option ); | 346 | return removeInterfaceOption( option ); |
347 | 347 | ||
348 | qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1()); | 348 | qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1()); |
349 | return setOption(currentIface, option, value); | 349 | return setOption(currentIface, option, value); |
350 | } | 350 | } |
351 | 351 | ||
352 | /** | 352 | /** |
353 | * Removes a value for an option in the currently selected interface. | 353 | * Removes a value for an option in the currently selected interface. |
354 | * @param option the options to set the value. | 354 | * @param option the options to set the value. |
355 | * @param error set to true if any error occurs, false otherwise. | 355 | * @param error set to true if any error occurs, false otherwise. |
356 | * @return QString the options value. QString::null if error == true | 356 | * @return QString the options value. QString::null if error == true |
357 | */ | 357 | */ |
358 | bool Interfaces::removeInterfaceOption(const QString &option){ | 358 | bool Interfaces::removeInterfaceOption(const QString &option){ |
359 | return removeOption(currentIface, option); | 359 | return removeOption(currentIface, option); |
360 | } | 360 | } |
361 | 361 | ||
362 | /** | 362 | /** |
363 | * Removes a value for an option in the currently selected interface. | 363 | * Removes a value for an option in the currently selected interface. |
364 | * @param option the options to set the value. | 364 | * @param option the options to set the value. |
365 | * @param value the value that option should be set to. | 365 | * @param value the value that option should be set to. |
366 | * @param error set to true if any error occurs, false otherwise. | 366 | * @param error set to true if any error occurs, false otherwise. |
367 | * @return QString the options value. QString::null if error == true | 367 | * @return QString the options value. QString::null if error == true |
368 | */ | 368 | */ |
369 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ | 369 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ |
370 | return removeOption(currentIface, option, value); | 370 | return removeOption(currentIface, option, value); |
371 | } | 371 | } |
372 | 372 | ||
373 | /** | 373 | /** |
374 | * Removes all of the options from the currently selected interface. | 374 | * Removes all of the options from the currently selected interface. |
375 | * @return bool error if if successfull | 375 | * @return bool error if if successful |
376 | */ | 376 | */ |
377 | bool Interfaces::removeAllInterfaceOptions(){ | 377 | bool Interfaces::removeAllInterfaceOptions(){ |
378 | return removeAllOptions(currentIface); | 378 | return removeAllOptions(currentIface); |
379 | } | 379 | } |
380 | 380 | ||
381 | /** | 381 | /** |
382 | * Set the current map to interface's map. This needs to be done before you | 382 | * Set the current map to interface's map. This needs to be done before you |
383 | * can call addMapping(), set/getMap(), and get/setScript(). | 383 | * can call addMapping(), set/getMap(), and get/setScript(). |
384 | * @param interface the name of the interface to set. All whitespace is | 384 | * @param interface the name of the interface to set. All whitespace is |
385 | * removed from the interface name. | 385 | * removed from the interface name. |
386 | * @return bool true if it is successfull. | 386 | * @return bool true if it is successful. |
387 | */ | 387 | */ |
388 | bool Interfaces::setMapping(const QString &interface){ | 388 | bool Interfaces::setMapping(const QString &interface){ |
389 | QString interfaceName = interface.simplifyWhiteSpace(); | 389 | QString interfaceName = interface.simplifyWhiteSpace(); |
390 | interfaceName = interfaceName.replace(QRegExp(" "), ""); | 390 | interfaceName = interfaceName.replace(QRegExp(" "), ""); |
391 | return setStanza(MAPPING, interfaceName, currentMapping); | 391 | return setStanza(MAPPING, interfaceName, currentMapping); |
392 | } | 392 | } |
393 | 393 | ||
394 | /** | 394 | /** |
395 | * Adds a new Mapping to the interfaces file with interfaces. | 395 | * Adds a new Mapping to the interfaces file with interfaces. |
396 | * @param interface the name(s) of the interfaces to set to this mapping | 396 | * @param interface the name(s) of the interfaces to set to this mapping |
397 | */ | 397 | */ |
398 | void Interfaces::addMapping(const QString &option){ | 398 | void Interfaces::addMapping(const QString &option){ |
399 | interfaces.append(""); | 399 | interfaces.append(""); |
400 | interfaces.append(QString(MAPPING " %1").arg(option)); | 400 | interfaces.append(QString(MAPPING " %1").arg(option)); |
401 | } | 401 | } |
402 | 402 | ||
403 | /** | 403 | /** |
404 | * Remove the currently selected map and all of its options. | 404 | * Remove the currently selected map and all of its options. |
405 | * @return bool if successfull or not. | 405 | * @return bool if successful or not. |
406 | */ | 406 | */ |
407 | bool Interfaces::removeMapping(){ | 407 | bool Interfaces::removeMapping(){ |
408 | return removeStanza(currentMapping); | 408 | return removeStanza(currentMapping); |
409 | } | 409 | } |
410 | 410 | ||
411 | /** | 411 | /** |
412 | * Set a map option within a mapping. | 412 | * Set a map option within a mapping. |
413 | * @param map map to use | 413 | * @param map map to use |
414 | * @param value value to go with map | 414 | * @param value value to go with map |
415 | * @return bool true if it is successfull. | 415 | * @return bool true if it is successful. |
416 | */ | 416 | */ |
417 | bool Interfaces::setMap(const QString &map, const QString &value){ | 417 | bool Interfaces::setMap(const QString &map, const QString &value){ |
418 | return setOption(currentMapping, map, value); | 418 | return setOption(currentMapping, map, value); |
419 | } | 419 | } |
420 | 420 | ||
421 | /** | 421 | /** |
422 | * Removes a map option within a mapping. | 422 | * Removes a map option within a mapping. |
423 | * @param map map to use | 423 | * @param map map to use |
424 | * @param value value to go with map | 424 | * @param value value to go with map |
425 | * @return bool true if it is successfull. | 425 | * @return bool true if it is successful. |
426 | */ | 426 | */ |
427 | bool Interfaces::removeMap(const QString &map, const QString &value){ | 427 | bool Interfaces::removeMap(const QString &map, const QString &value){ |
428 | return removeOption(currentMapping, map, value); | 428 | return removeOption(currentMapping, map, value); |
429 | } | 429 | } |
430 | 430 | ||
431 | /** | 431 | /** |
432 | * Get a map value within a mapping. | 432 | * Get a map value within a mapping. |
433 | * @param map map to get value of | 433 | * @param map map to get value of |
434 | * @param bool true if it is successfull. | 434 | * @param bool true if it is successful. |
435 | * @return value that goes to the map | 435 | * @return value that goes to the map |
436 | */ | 436 | */ |
437 | QString Interfaces::getMap(const QString &map, bool &error){ | 437 | QString Interfaces::getMap(const QString &map, bool &error){ |
438 | return getOption(currentMapping, map, error); | 438 | return getOption(currentMapping, map, error); |
439 | } | 439 | } |
440 | 440 | ||
441 | /** | 441 | /** |
442 | * Sets a script value of the current mapping to argument. | 442 | * Sets a script value of the current mapping to argument. |
443 | * @param argument the script name. | 443 | * @param argument the script name. |
444 | * @return true if successfull. | 444 | * @return true if successful. |
445 | */ | 445 | */ |
446 | bool Interfaces::setScript(const QString &argument){ | 446 | bool Interfaces::setScript(const QString &argument){ |
447 | return setOption(currentMapping, "script", argument); | 447 | return setOption(currentMapping, "script", argument); |
448 | } | 448 | } |
449 | 449 | ||
450 | /** | 450 | /** |
451 | * @param error true if could not retrieve the current script argument. | 451 | * @param error true if could not retrieve the current script argument. |
452 | * @return QString the argument of the script for the current mapping. | 452 | * @return QString the argument of the script for the current mapping. |
453 | */ | 453 | */ |
454 | QString Interfaces::getScript(bool &error){ | 454 | QString Interfaces::getScript(bool &error){ |
455 | return getOption(currentMapping, "script", error); | 455 | return getOption(currentMapping, "script", error); |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | 459 | ||
460 | /** | 460 | /** |
461 | * Helper function used to parse through the QStringList and put pointers in | 461 | * Helper function used to parse through the QStringList and put pointers in |
462 | * the correct place. | 462 | * the correct place. |
463 | * @param stanza The stanza (auto, iface, mapping) to look for. | 463 | * @param stanza The stanza (auto, iface, mapping) to look for. |
464 | * @param option string that must be in the stanza's main line. | 464 | * @param option string that must be in the stanza's main line. |
465 | * @param interator interator to place at location of stanza if successfull. | 465 | * @param interator interator to place at location of stanza if successful. |
466 | * @return bool true if the stanza is found. | 466 | * @return bool true if the stanza is found. |
467 | */ | 467 | */ |
468 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ | 468 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ |
469 | bool found = false; | 469 | bool found = false; |
470 | iterator = interfaces.end(); | 470 | iterator = interfaces.end(); |
471 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 471 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
472 | QString line = (*it).simplifyWhiteSpace(); | 472 | QString line = (*it).simplifyWhiteSpace(); |
473 | if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ | 473 | if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ |
474 | uint point = line.find(option); | 474 | uint point = line.find(option); |
475 | bool valid = true; | 475 | bool valid = true; |
476 | if(point > 0){ | 476 | if(point > 0){ |
477 | // There are more chars in the line. check +1 | 477 | // There are more chars in the line. check +1 |
478 | if(line.at(point-1) != ' ') | 478 | if(line.at(point-1) != ' ') |
479 | valid = false; | 479 | valid = false; |
480 | } | 480 | } |
481 | point += option.length(); | 481 | point += option.length(); |
482 | if(point < line.length()-1){ | 482 | if(point < line.length()-1){ |
483 | // There are more chars in the line. check -1 | 483 | // There are more chars in the line. check -1 |
484 | if(line.at(point) != ' ') | 484 | if(line.at(point) != ' ') |
485 | valid = false; | 485 | valid = false; |
486 | } | 486 | } |
487 | if(valid){ | 487 | if(valid){ |
488 | if(found == true){ | 488 | if(found == true){ |
489 | qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); | 489 | qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); |
490 | } | 490 | } |
491 | found = true; | 491 | found = true; |
492 | iterator = it; | 492 | iterator = it; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | return found; | 496 | return found; |
497 | } | 497 | } |
498 | 498 | ||
499 | /** | 499 | /** |
500 | * Sets a value of an option in a stanza | 500 | * Sets a value of an option in a stanza |
501 | * @param start the start of the stanza | 501 | * @param start the start of the stanza |
502 | * @param option the option to use when setting value. | 502 | * @param option the option to use when setting value. |
503 | * @return bool true if successfull, false otherwise. | 503 | * @return bool true if successful, false otherwise. |
504 | */ | 504 | */ |
505 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 505 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
506 | if(start == interfaces.end()) | 506 | if(start == interfaces.end()) |
507 | return false; | 507 | return false; |
508 | qDebug("setting option"); | 508 | qDebug("setting option"); |
509 | bool found = false; | 509 | bool found = false; |
510 | bool replaced = false; | 510 | bool replaced = false; |
511 | QStringList::Iterator insertAt = NULL; | 511 | QStringList::Iterator insertAt = NULL; |
512 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 512 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
513 | qDebug(" Interfaces::setOption got line >%s<",(*it).latin1()); | 513 | qDebug(" Interfaces::setOption got line >%s<",(*it).latin1()); |
514 | // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line | 514 | // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line |
515 | // but since it works with an empty interfaces file I (tille) will not do anything more | 515 | // but since it works with an empty interfaces file I (tille) will not do anything more |
516 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){ | 516 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){ |
517 | if (found) break; | 517 | if (found) break; |
518 | // && it != start){ | 518 | // && it != start){ |
519 | // if(!found && value != ""){ | 519 | // if(!found && value != ""){ |
520 | // // Got to the end of the stanza without finding it, so append it. | 520 | // // Got to the end of the stanza without finding it, so append it. |
521 | // qDebug(" Got to the end of the stanza without finding it, so append it."); | 521 | // qDebug(" Got to the end of the stanza without finding it, so append it."); |
522 | // interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); | 522 | // interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); |
523 | // } | 523 | // } |
524 | qDebug("found 1"); | 524 | qDebug("found 1"); |
525 | // interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value)); | 525 | // interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value)); |
526 | found = true; | 526 | found = true; |
527 | insertAt = it; | 527 | insertAt = it; |
528 | 528 | ||
529 | } | 529 | } |
530 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ | 530 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ |
531 | // Found it in stanza so replace it. | 531 | // Found it in stanza so replace it. |
532 | qDebug("found 2"); | 532 | qDebug("found 2"); |
533 | if(found) | 533 | if(found) |
534 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 534 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
535 | found = true; | 535 | found = true; |
536 | replaced = true; | 536 | replaced = true; |
537 | (*it) = QString("\t%1 %2").arg(option).arg(value); | 537 | (*it) = QString("\t%1 %2").arg(option).arg(value); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | if(!found){ | 540 | if(!found){ |
541 | qDebug("! found insert anyway"); | 541 | qDebug("! found insert anyway"); |
542 | QStringList::Iterator p = start; | 542 | QStringList::Iterator p = start; |
543 | interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); | 543 | interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); |
544 | found = true; | 544 | found = true; |
545 | } | 545 | } |
546 | 546 | ||
547 | if(found && !replaced){ | 547 | if(found && !replaced){ |
548 | qDebug("found iface but not the option so insert it here..."); | 548 | qDebug("found iface but not the option so insert it here..."); |
549 | interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value)); | 549 | interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value)); |
550 | } | 550 | } |
551 | return found; | 551 | return found; |
552 | } | 552 | } |
553 | 553 | ||
554 | /** | 554 | /** |
555 | * Removes a stanza and all of its options | 555 | * Removes a stanza and all of its options |
556 | * @param stanza the stanza to remove | 556 | * @param stanza the stanza to remove |
557 | * @return bool true if successfull. | 557 | * @return bool true if successful. |
558 | */ | 558 | */ |
559 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ | 559 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ |
560 | if(stanza == interfaces.end()) | 560 | if(stanza == interfaces.end()) |
561 | return false; | 561 | return false; |
562 | (*stanza) = ""; | 562 | (*stanza) = ""; |
563 | return removeAllOptions(stanza); | 563 | return removeAllOptions(stanza); |
564 | } | 564 | } |
565 | 565 | ||
566 | /** | 566 | /** |
567 | * Removes a option in a stanza | 567 | * Removes a option in a stanza |
568 | * @param start the start of the stanza | 568 | * @param start the start of the stanza |
569 | * @param option the option to remove | 569 | * @param option the option to remove |
570 | * @return bool true if successfull, false otherwise. | 570 | * @return bool true if successful, false otherwise. |
571 | */ | 571 | */ |
572 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ | 572 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ |
573 | if(start == interfaces.end()) | 573 | if(start == interfaces.end()) |
574 | return false; | 574 | return false; |
575 | 575 | ||
576 | bool found = false; | 576 | bool found = false; |
577 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 577 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
578 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 578 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
579 | // got to the end without finding it | 579 | // got to the end without finding it |
580 | break; | 580 | break; |
581 | } | 581 | } |
582 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ | 582 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ |
583 | // Found it in stanza so replace it. | 583 | // Found it in stanza so replace it. |
584 | if(found) | 584 | if(found) |
585 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 585 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
586 | found = true; | 586 | found = true; |
587 | it = interfaces.remove( it ); // we really want to remove the line | 587 | it = interfaces.remove( it ); // we really want to remove the line |
588 | --it; // we do ++it later in the head of the for loop | 588 | --it; // we do ++it later in the head of the for loop |
589 | } | 589 | } |
590 | } | 590 | } |
591 | return found; | 591 | return found; |
592 | } | 592 | } |
593 | 593 | ||
594 | /** | 594 | /** |
595 | * Removes a option in a stanza | 595 | * Removes a option in a stanza |
596 | * @param start the start of the stanza | 596 | * @param start the start of the stanza |
597 | * @param option the option to use when setting value. | 597 | * @param option the option to use when setting value. |
598 | * @return bool true if successfull, false otherwise. | 598 | * @return bool true if successful, false otherwise. |
599 | */ | 599 | */ |
600 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 600 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
601 | if(start == interfaces.end()) | 601 | if(start == interfaces.end()) |
602 | return false; | 602 | return false; |
603 | 603 | ||
604 | bool found = false; | 604 | bool found = false; |
605 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 605 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
606 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 606 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
607 | // got to the end without finding it | 607 | // got to the end without finding it |
608 | break; | 608 | break; |
609 | } | 609 | } |
610 | if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ | 610 | if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ |
611 | // Found it in stanza so replace it. | 611 | // Found it in stanza so replace it. |
612 | if(found) | 612 | if(found) |
613 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 613 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
614 | found = true; | 614 | found = true; |
615 | it = interfaces.remove( it ); // we really want to remove the line | 615 | it = interfaces.remove( it ); // we really want to remove the line |
616 | --it; // we do ++it later in the head of the for loop | 616 | --it; // we do ++it later in the head of the for loop |
617 | } | 617 | } |
618 | } | 618 | } |
619 | return found; | 619 | return found; |
620 | } | 620 | } |
621 | 621 | ||
622 | /** | 622 | /** |
623 | * Removes all options in a stanza | 623 | * Removes all options in a stanza |
624 | * @param start the start of the stanza | 624 | * @param start the start of the stanza |
625 | * @return bool true if successfull, false otherwise. | 625 | * @return bool true if successful, false otherwise. |
626 | */ | 626 | */ |
627 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ | 627 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ |
628 | if(start == interfaces.end()) | 628 | if(start == interfaces.end()) |
629 | return false; | 629 | return false; |
630 | 630 | ||
631 | QStringList::Iterator it = start; | 631 | QStringList::Iterator it = start; |
632 | it = ++it; | 632 | it = ++it; |
633 | for (; it != interfaces.end(); ++it ) { | 633 | for (; it != interfaces.end(); ++it ) { |
634 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 634 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
635 | break; | 635 | break; |
636 | } | 636 | } |
637 | it = interfaces.remove(it); | 637 | it = interfaces.remove(it); |
638 | it = --it; | 638 | it = --it; |
639 | } | 639 | } |
640 | // Leave a space between this interface and the next. | 640 | // Leave a space between this interface and the next. |
641 | interfaces.insert(it, QString("")); | 641 | interfaces.insert(it, QString("")); |
642 | return true; | 642 | return true; |
643 | } | 643 | } |
644 | 644 | ||
645 | /** | 645 | /** |
646 | * Gets a value of an option in a stanza | 646 | * Gets a value of an option in a stanza |
647 | * @param start the start of the stanza | 647 | * @param start the start of the stanza |
648 | * @param option the option to use when getting the value. | 648 | * @param option the option to use when getting the value. |
649 | * @param bool true if errors false otherwise. | 649 | * @param bool true if errors false otherwise. |
650 | * @return QString the value of option QString::null() if error == true. | 650 | * @return QString the value of option QString::null() if error == true. |
651 | */ | 651 | */ |
652 | QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ | 652 | QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ |
653 | if(start == interfaces.end()){ | 653 | if(start == interfaces.end()){ |
654 | error = false; | 654 | error = false; |
655 | return QString(); | 655 | return QString(); |
656 | } | 656 | } |
657 | 657 | ||
658 | QString value; | 658 | QString value; |
659 | bool found = false; | 659 | bool found = false; |
660 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 660 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
661 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 661 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
662 | break; | 662 | break; |
663 | } | 663 | } |
664 | if((*it).contains(option) && (*it).at(0) != '#'){ | 664 | if((*it).contains(option) && (*it).at(0) != '#'){ |
665 | if(found) | 665 | if(found) |
666 | qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); | 666 | qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); |
667 | found = true; | 667 | found = true; |
668 | QString line = (*it).simplifyWhiteSpace(); | 668 | QString line = (*it).simplifyWhiteSpace(); |
669 | int space = line.find(" ", option.length()); | 669 | int space = line.find(" ", option.length()); |
670 | if(space != -1){ | 670 | if(space != -1){ |
671 | value = line.mid(space+1, line.length()); | 671 | value = line.mid(space+1, line.length()); |
672 | break; | 672 | break; |
673 | } | 673 | } |
674 | } | 674 | } |
675 | } | 675 | } |
676 | error = !found; | 676 | error = !found; |
677 | return value; | 677 | return value; |
678 | } | 678 | } |
679 | 679 | ||
680 | /** | 680 | /** |
681 | * Write out the interfaces file to the file passed into the constructor. | 681 | * Write out the interfaces file to the file passed into the constructor. |
682 | * Removes any excess blank lines over 1 line long. | 682 | * Removes any excess blank lines over 1 line long. |
683 | * @return bool true if successfull, false if not. | 683 | * @return bool true if successful, false if not. |
684 | */ | 684 | */ |
685 | bool Interfaces::write(){ | 685 | bool Interfaces::write(){ |
686 | QFile::remove(interfacesFile); | 686 | QFile::remove(interfacesFile); |
687 | QFile file(interfacesFile); | 687 | QFile file(interfacesFile); |
688 | 688 | ||
689 | if (!file.open(IO_ReadWrite)){ | 689 | if (!file.open(IO_ReadWrite)){ |
690 | qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); | 690 | qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); |
691 | return false; | 691 | return false; |
692 | } | 692 | } |
693 | QTextStream stream( &file ); | 693 | QTextStream stream( &file ); |
694 | int whiteSpaceCount = 0; | 694 | int whiteSpaceCount = 0; |
695 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 695 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
696 | QString line = (*it).simplifyWhiteSpace(); | 696 | QString line = (*it).simplifyWhiteSpace(); |
697 | line = line.replace(QRegExp(" "),""); | 697 | line = line.replace(QRegExp(" "),""); |
698 | if(line.length() == 0) | 698 | if(line.length() == 0) |
699 | whiteSpaceCount++; | 699 | whiteSpaceCount++; |
700 | else | 700 | else |
701 | whiteSpaceCount = 0; | 701 | whiteSpaceCount = 0; |
702 | if(whiteSpaceCount < 2){ | 702 | if(whiteSpaceCount < 2){ |
703 | qDebug((*it).latin1()); | 703 | qDebug((*it).latin1()); |
704 | stream << (*it) << '\n'; | 704 | stream << (*it) << '\n'; |
705 | } | 705 | } |
706 | } | 706 | } |
707 | file.close(); | 707 | file.close(); |
708 | return true; | 708 | return true; |
709 | } | 709 | } |
710 | 710 | ||
711 | // interfaces.cpp | 711 | // interfaces.cpp |
712 | 712 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index e844d8a..78466d0 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -1,206 +1,206 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | 3 | ||
4 | #include <qcheckbox.h> | 4 | #include <qcheckbox.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qspinbox.h> | 6 | #include <qspinbox.h> |
7 | #include <qgroupbox.h> | 7 | #include <qgroupbox.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | 9 | ||
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | 11 | ||
12 | #include <opie/oprocess.h> | 12 | #include <opie/oprocess.h> |
13 | 13 | ||
14 | #ifdef QWS | 14 | #ifdef QWS |
15 | #include <opie/owait.h> | 15 | #include <opie/owait.h> |
16 | #include <qpe/global.h> | 16 | #include <qpe/global.h> |
17 | #include <qapplication.h> | 17 | #include <qapplication.h> |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | #define DNSSCRIPT "changedns" | 20 | #define DNSSCRIPT "changedns" |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Constuctor. Set up the connection. A profile must be set. | 23 | * Constuctor. Set up the connection. A profile must be set. |
24 | */ | 24 | */ |
25 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ | 25 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ |
26 | if (j == 0) { | 26 | if (j == 0) { |
27 | delInterfaces = true; | 27 | delInterfaces = true; |
28 | interfaces = new Interfaces; | 28 | interfaces = new Interfaces; |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Destructor | 33 | * Destructor |
34 | */ | 34 | */ |
35 | InterfaceSetupImp::~InterfaceSetupImp(){ | 35 | InterfaceSetupImp::~InterfaceSetupImp(){ |
36 | if(delInterfaces) { | 36 | if(delInterfaces) { |
37 | delete interfaces; | 37 | delete interfaces; |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Save the current settings, then write out the interfaces file and close. | 42 | * Save the current settings, then write out the interfaces file and close. |
43 | */ | 43 | */ |
44 | bool InterfaceSetupImp::saveChanges(){ | 44 | bool InterfaceSetupImp::saveChanges(){ |
45 | bool error; | 45 | bool error; |
46 | QString iface = interfaces->getInterfaceName(error); | 46 | QString iface = interfaces->getInterfaceName(error); |
47 | qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); | 47 | qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); |
48 | if(!saveSettings()) | 48 | if(!saveSettings()) |
49 | return false; | 49 | return false; |
50 | 50 | ||
51 | interfaces->write(); | 51 | interfaces->write(); |
52 | 52 | ||
53 | if (interface->getStatus()) { | 53 | if (interface->getStatus()) { |
54 | QString ifup; | 54 | QString ifup; |
55 | ifup += "ifdown "; | 55 | ifup += "ifdown "; |
56 | ifup += iface; | 56 | ifup += iface; |
57 | ifup += "; ifup "; | 57 | ifup += "; ifup "; |
58 | ifup += iface; | 58 | ifup += iface; |
59 | ifup += ";"; | 59 | ifup += ";"; |
60 | 60 | ||
61 | OProcess restart; | 61 | OProcess restart; |
62 | restart << "sh"; | 62 | restart << "sh"; |
63 | restart << "-c"; | 63 | restart << "-c"; |
64 | restart << ifup; | 64 | restart << ifup; |
65 | 65 | ||
66 | OWait *owait = new OWait(); | 66 | OWait *owait = new OWait(); |
67 | Global::statusMessage( tr( "Restarting interface" ) ); | 67 | Global::statusMessage( tr( "Restarting interface" ) ); |
68 | 68 | ||
69 | owait->show(); | 69 | owait->show(); |
70 | qApp->processEvents(); | 70 | qApp->processEvents(); |
71 | 71 | ||
72 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { | 72 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { |
73 | qWarning("unstable to spawn ifdown/ifup"); | 73 | qWarning("unstable to spawn ifdown/ifup"); |
74 | } | 74 | } |
75 | 75 | ||
76 | owait->hide(); | 76 | owait->hide(); |
77 | delete owait; | 77 | delete owait; |
78 | 78 | ||
79 | interface->refresh(); | 79 | interface->refresh(); |
80 | } | 80 | } |
81 | return true; | 81 | return true; |
82 | } | 82 | } |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Save the settings for the current Interface. | 85 | * Save the settings for the current Interface. |
86 | * @return bool true if successfull, false otherwise | 86 | * @return bool true if successful, false otherwise |
87 | */ | 87 | */ |
88 | bool InterfaceSetupImp::saveSettings(){ | 88 | bool InterfaceSetupImp::saveSettings(){ |
89 | // eh can't really do anything about it other then return. :-D | 89 | // eh can't really do anything about it other then return. :-D |
90 | if(!interfaces->isInterfaceSet()) | 90 | if(!interfaces->isInterfaceSet()) |
91 | return true; | 91 | return true; |
92 | 92 | ||
93 | bool error = false; | 93 | bool error = false; |
94 | // Loopback case | 94 | // Loopback case |
95 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 95 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
96 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 96 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
97 | return true; | 97 | return true; |
98 | } | 98 | } |
99 | 99 | ||
100 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 100 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
101 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); | 101 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); |
102 | return false; | 102 | return false; |
103 | } | 103 | } |
104 | // DHCP | 104 | // DHCP |
105 | if(dhcpCheckBox->isChecked()) { | 105 | if(dhcpCheckBox->isChecked()) { |
106 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 106 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
107 | interfaces->removeInterfaceOption("address"); | 107 | interfaces->removeInterfaceOption("address"); |
108 | interfaces->removeInterfaceOption("netmask"); | 108 | interfaces->removeInterfaceOption("netmask"); |
109 | interfaces->removeInterfaceOption("gateway"); | 109 | interfaces->removeInterfaceOption("gateway"); |
110 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | 110 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); |
111 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); | 111 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); |
112 | } else{ | 112 | } else{ |
113 | interfaces->setInterfaceMethod("static"); | 113 | interfaces->setInterfaceMethod("static"); |
114 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 114 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
115 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 115 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
116 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 116 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
117 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 117 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
118 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 118 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
119 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 119 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
120 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 120 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
121 | }else{ | 121 | }else{ |
122 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | 122 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); |
123 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); | 123 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | // IP Information | 127 | // IP Information |
128 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 128 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
129 | return true; | 129 | return true; |
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * The Profile has changed. | 133 | * The Profile has changed. |
134 | * @param QString profile the new profile. | 134 | * @param QString profile the new profile. |
135 | */ | 135 | */ |
136 | void InterfaceSetupImp::setProfile(const QString &profile){ | 136 | void InterfaceSetupImp::setProfile(const QString &profile){ |
137 | /* | 137 | /* |
138 | bool error = false; | 138 | bool error = false; |
139 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 139 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
140 | staticGroupBox->hide(); | 140 | staticGroupBox->hide(); |
141 | dhcpCheckBox->hide(); | 141 | dhcpCheckBox->hide(); |
142 | leaseTime->hide(); | 142 | leaseTime->hide(); |
143 | leaseHoursLabel->hide(); | 143 | leaseHoursLabel->hide(); |
144 | } | 144 | } |
145 | */ | 145 | */ |
146 | 146 | ||
147 | QString newInterfaceName = interface->getInterfaceName(); | 147 | QString newInterfaceName = interface->getInterfaceName(); |
148 | if(profile.length() > 0) | 148 | if(profile.length() > 0) |
149 | newInterfaceName += "_" + profile; | 149 | newInterfaceName += "_" + profile; |
150 | // See if we have to make a interface. | 150 | // See if we have to make a interface. |
151 | if(!interfaces->setInterface(newInterfaceName)){ | 151 | if(!interfaces->setInterface(newInterfaceName)){ |
152 | // Add making for this new interface if need too | 152 | // Add making for this new interface if need too |
153 | if(profile != ""){ | 153 | if(profile != ""){ |
154 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 154 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
155 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 155 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
156 | interfaces->addMapping(interface->getInterfaceName()); | 156 | interfaces->addMapping(interface->getInterfaceName()); |
157 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 157 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
158 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); | 158 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); |
159 | return; | 159 | return; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | interfaces->setMap("map", newInterfaceName); | 162 | interfaces->setMap("map", newInterfaceName); |
163 | interfaces->setScript("getprofile.sh"); | 163 | interfaces->setScript("getprofile.sh"); |
164 | } | 164 | } |
165 | else{ | 165 | else{ |
166 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 166 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
167 | if(!interfaces->setInterface(newInterfaceName)){ | 167 | if(!interfaces->setInterface(newInterfaceName)){ |
168 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); | 168 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); |
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | // We must have a valid interface to get this far so read some settings. | 174 | // We must have a valid interface to get this far so read some settings. |
175 | 175 | ||
176 | // DHCP | 176 | // DHCP |
177 | bool error = false; | 177 | bool error = false; |
178 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 178 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
179 | dhcpCheckBox->setChecked(true); | 179 | dhcpCheckBox->setChecked(true); |
180 | else | 180 | else |
181 | dhcpCheckBox->setChecked(false); | 181 | dhcpCheckBox->setChecked(false); |
182 | 182 | ||
183 | // IP Information | 183 | // IP Information |
184 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 184 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
185 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 185 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
186 | qDebug("dns >%s<",dns.latin1()); | 186 | qDebug("dns >%s<",dns.latin1()); |
187 | if(dns.contains(" ")){ | 187 | if(dns.contains(" ")){ |
188 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 188 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
189 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 189 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
190 | }else firstDNSLineEdit->setText(dns); | 190 | }else firstDNSLineEdit->setText(dns); |
191 | 191 | ||
192 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 192 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
193 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 193 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
194 | if (subnetMaskEdit->text().isEmpty()) | 194 | if (subnetMaskEdit->text().isEmpty()) |
195 | subnetMaskEdit->setText( "255.255.255.0" ); | 195 | subnetMaskEdit->setText( "255.255.255.0" ); |
196 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 196 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
197 | 197 | ||
198 | 198 | ||
199 | 199 | ||
200 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); | 200 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); |
201 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); | 201 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); |
202 | 202 | ||
203 | } | 203 | } |
204 | 204 | ||
205 | // interfacesetup.cpp | 205 | // interfacesetup.cpp |
206 | 206 | ||