author | tille <tille> | 2003-06-21 15:34:55 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-21 15:34:55 (UTC) |
commit | 5f5accf337a109371296c6a78175734454165406 (patch) (unidiff) | |
tree | 7c4334febdedcd8c0b42a2296af6875f6f990762 | |
parent | fde32755685bec14851f943be337e94675caf0c4 (diff) | |
download | opie-5f5accf337a109371296c6a78175734454165406.zip opie-5f5accf337a109371296c6a78175734454165406.tar.gz opie-5f5accf337a109371296c6a78175734454165406.tar.bz2 |
channel count for wellenreiter
3 files changed, 92 insertions, 60 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index a62a90c..71d0cf5 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp | |||
@@ -10,17 +10,17 @@ | |||
10 | #define MAPPING "mapping" | 10 | #define MAPPING "mapping" |
11 | 11 | ||
12 | /** | 12 | /** |
13 | * Constructor. Reads in the interfaces file and then split the file up by | 13 | * Constructor. Reads in the interfaces file and then split the file up by |
14 | * the \n for interfaces variable. | 14 | * the \n for interfaces variable. |
15 | * @param useInterfacesFile if an interface file other then the default is | 15 | * @param useInterfacesFile if an interface file other then the default is |
16 | * desired to be used it should be passed in. | 16 | * desired to be used it should be passed in. |
17 | */ | 17 | */ |
18 | Interfaces::Interfaces(QString useInterfacesFile){ | 18 | Interfaces::Interfaces(QString useInterfacesFile){ |
19 | acceptedFamily.append(INTERFACES_FAMILY_INET); | 19 | acceptedFamily.append(INTERFACES_FAMILY_INET); |
20 | acceptedFamily.append(INTERFACES_FAMILY_IPX); | 20 | acceptedFamily.append(INTERFACES_FAMILY_IPX); |
21 | acceptedFamily.append(INTERFACES_FAMILY_INET6); | 21 | acceptedFamily.append(INTERFACES_FAMILY_INET6); |
22 | 22 | ||
23 | interfacesFile = useInterfacesFile; | 23 | interfacesFile = useInterfacesFile; |
24 | QFile file(interfacesFile); | 24 | QFile file(interfacesFile); |
25 | if (!file.open(IO_ReadOnly)){ | 25 | if (!file.open(IO_ReadOnly)){ |
26 | qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); | 26 | qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); |
@@ -35,20 +35,20 @@ Interfaces::Interfaces(QString useInterfacesFile){ | |||
35 | line += "\n"; | 35 | line += "\n"; |
36 | } | 36 | } |
37 | file.close(); | 37 | file.close(); |
38 | interfaces = QStringList::split("\n", line, true); | 38 | interfaces = QStringList::split("\n", line, true); |
39 | 39 | ||
40 | currentIface = interfaces.end(); | 40 | currentIface = interfaces.end(); |
41 | currentMapping = interfaces.end(); | 41 | currentMapping = interfaces.end(); |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Get a list of all interfaces in the interface file. Usefull for | 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 | 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. | 48 | * not plugged in, but configured for when it is plugged in. |
49 | * @return Return string list of interfaces. | 49 | * @return Return string list of interfaces. |
50 | **/ | 50 | **/ |
51 | QStringList Interfaces::getInterfaceList(){ | 51 | QStringList Interfaces::getInterfaceList(){ |
52 | QStringList list; | 52 | QStringList list; |
53 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 53 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
54 | QString line = (*it).simplifyWhiteSpace(); | 54 | QString line = (*it).simplifyWhiteSpace(); |
@@ -66,12 +66,12 @@ QStringList Interfaces::getInterfaceList(){ | |||
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Find out if interface is in an "auto" group or not. | 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 | 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. | 71 | * @param interface interface to check to see if it is on or not. |
72 | * @return true is interface is in auto | 72 | * @return true is interface is in auto |
73 | */ | 73 | */ |
74 | bool Interfaces::isAuto(const QString &interface) const { | 74 | bool Interfaces::isAuto(const QString &interface) const { |
75 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | 75 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); |
76 | QStringList awi = autoLines.grep(QRegExp(interface)); | 76 | QStringList awi = autoLines.grep(QRegExp(interface)); |
77 | if(awi.count() > 1) | 77 | if(awi.count() > 1) |
@@ -83,14 +83,14 @@ bool Interfaces::isAuto(const QString &interface) const { | |||
83 | * Attempt to set the auto option for interface to setAuto. | 83 | * Attempt to set the auto option for interface to setAuto. |
84 | * @param interface the interface to set | 84 | * @param interface the interface to set |
85 | * @param setAuto the value to set interface to. | 85 | * @param setAuto the value to set interface to. |
86 | * @return false if already set to setAuto. | 86 | * @return false if already set to setAuto. |
87 | * */ | 87 | * */ |
88 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ | 88 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ |
89 | // Don't need to set it if it is already set. | 89 | // Don't need to set it if it is already set. |
90 | if(isAuto(interface) == setAuto) | 90 | if(isAuto(interface) == setAuto) |
91 | return false; | 91 | return false; |
92 | 92 | ||
93 | bool changed = false; | 93 | bool changed = false; |
94 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 94 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
95 | if((*it).contains(AUTO)){ | 95 | if((*it).contains(AUTO)){ |
96 | //We know that they are not in any group so let add to this auto. | 96 | //We know that they are not in any group so let add to this auto. |
@@ -124,10 +124,10 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ | |||
124 | * Set the current interface to interface. This needs to be done before you | 124 | * Set the current interface to interface. This needs to be done before you |
125 | * can call getFamily(), getMethod, and get/setOption(). | 125 | * can call getFamily(), getMethod, and get/setOption(). |
126 | * @param interface the name of the interface to set. All whitespace is | 126 | * @param interface the name of the interface to set. All whitespace is |
127 | * removed from the interface name. | 127 | * removed from the interface name. |
128 | * @return bool true if it is successfull. | 128 | * @return bool true if it is successfull. |
129 | */ | 129 | */ |
130 | bool Interfaces::setInterface(QString interface){ | 130 | bool Interfaces::setInterface(QString interface){ |
131 | interface = interface.simplifyWhiteSpace(); | 131 | interface = interface.simplifyWhiteSpace(); |
132 | interface = interface.replace(QRegExp(" "), ""); | 132 | interface = interface.replace(QRegExp(" "), ""); |
133 | return setStanza(IFACE, interface, currentIface); | 133 | return setStanza(IFACE, interface, currentIface); |
@@ -135,9 +135,9 @@ bool Interfaces::setInterface(QString interface){ | |||
135 | 135 | ||
136 | /** | 136 | /** |
137 | * A quick helper funtion to see if the current interface is set. | 137 | * A quick helper funtion to see if the current interface is set. |
138 | * @return bool true if set, false otherwise. | 138 | * @return bool true if set, false otherwise. |
139 | */ | 139 | */ |
140 | bool Interfaces::isInterfaceSet() const { | 140 | bool Interfaces::isInterfaceSet() const { |
141 | return (interfaces.end() != currentIface); | 141 | return (interfaces.end() != currentIface); |
142 | } | 142 | } |
143 | 143 | ||
@@ -148,9 +148,9 @@ bool Interfaces::isInterfaceSet() const { | |||
148 | * @param family the family of this interface inet or inet, ipx or inet6 | 148 | * @param family the family of this interface inet or inet, ipx or inet6 |
149 | * Must of one of the families defined in interfaces.h | 149 | * Must of one of the families defined in interfaces.h |
150 | * @param method for the family. see interfaces man page for family methods. | 150 | * @param method for the family. see interfaces man page for family methods. |
151 | * @return true if successfull. | 151 | * @return true if successfull. |
152 | */ | 152 | */ |
153 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ | 153 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ |
154 | if(0 == acceptedFamily.contains(family)) | 154 | if(0 == acceptedFamily.contains(family)) |
155 | return false; | 155 | return false; |
156 | QString newInterface = interface.simplifyWhiteSpace(); | 156 | QString newInterface = interface.simplifyWhiteSpace(); |
@@ -163,49 +163,49 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c | |||
163 | /** | 163 | /** |
164 | * Copies interface with name interface to name newInterface | 164 | * Copies interface with name interface to name newInterface |
165 | * @param newInterface name of the new interface. | 165 | * @param newInterface name of the new interface. |
166 | * @return bool true if successfull | 166 | * @return bool true if successfull |
167 | */ | 167 | */ |
168 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ | 168 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ |
169 | if(!setInterface(interface)) | 169 | if(!setInterface(interface)) |
170 | return false; | 170 | return false; |
171 | 171 | ||
172 | // Store the old interface and bump past the stanza line. | 172 | // Store the old interface and bump past the stanza line. |
173 | QStringList::Iterator it = currentIface; | 173 | QStringList::Iterator it = currentIface; |
174 | it++; | 174 | it++; |
175 | 175 | ||
176 | // Add the new interface | 176 | // Add the new interface |
177 | bool error; | 177 | bool error; |
178 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); | 178 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); |
179 | if(!setInterface(newInterface)) | 179 | if(!setInterface(newInterface)) |
180 | return false; | 180 | return false; |
181 | 181 | ||
182 | QStringList::Iterator newIface = currentIface; | 182 | QStringList::Iterator newIface = currentIface; |
183 | newIface++; | 183 | newIface++; |
184 | 184 | ||
185 | // Copy all of the lines | 185 | // Copy all of the lines |
186 | for ( ; it != interfaces.end(); ++it ){ | 186 | for ( ; it != interfaces.end(); ++it ){ |
187 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) | 187 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) |
188 | break; | 188 | break; |
189 | newIface = interfaces.insert(newIface, *it); | 189 | newIface = interfaces.insert(newIface, *it); |
190 | } | 190 | } |
191 | 191 | ||
192 | return true; | 192 | return true; |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Remove the currently selected interface and all of its options. | 196 | * Remove the currently selected interface and all of its options. |
197 | * @return bool if successfull or not. | 197 | * @return bool if successfull or not. |
198 | */ | 198 | */ |
199 | bool Interfaces::removeInterface(){ | 199 | bool Interfaces::removeInterface(){ |
200 | return removeStanza(currentIface); | 200 | return removeStanza(currentIface); |
201 | } | 201 | } |
202 | 202 | ||
203 | /** | 203 | /** |
204 | * Gets the hardware name of the interface that is currently selected. | 204 | * Gets the hardware name of the interface that is currently selected. |
205 | * @return QString name of the hardware interface (eth0, usb2, wlan1...). | 205 | * @return QString name of the hardware interface (eth0, usb2, wlan1...). |
206 | * @param error set to true if any error occurs, false otherwise. | 206 | * @param error set to true if any error occurs, false otherwise. |
207 | */ | 207 | */ |
208 | QString Interfaces::getInterfaceName(bool &error){ | 208 | QString Interfaces::getInterfaceName(bool &error){ |
209 | if(currentIface == interfaces.end()){ | 209 | if(currentIface == interfaces.end()){ |
210 | error = true; | 210 | error = true; |
211 | return QString(); | 211 | return QString(); |
@@ -225,9 +225,9 @@ QString Interfaces::getInterfaceName(bool &error){ | |||
225 | /** | 225 | /** |
226 | * Gets the family name of the interface that is currently selected. | 226 | * Gets the family name of the interface that is currently selected. |
227 | * @return QString name of the family (inet, inet6, ipx). | 227 | * @return QString name of the family (inet, inet6, ipx). |
228 | * @param error set to true if any error occurs, false otherwise. | 228 | * @param error set to true if any error occurs, false otherwise. |
229 | */ | 229 | */ |
230 | QString Interfaces::getInterfaceFamily(bool &error){ | 230 | QString Interfaces::getInterfaceFamily(bool &error){ |
231 | QString name = getInterfaceName(error); | 231 | QString name = getInterfaceName(error); |
232 | if(error) | 232 | if(error) |
233 | return QString(); | 233 | return QString(); |
@@ -248,9 +248,9 @@ QString Interfaces::getInterfaceFamily(bool &error){ | |||
248 | * Gets the method of the interface that is currently selected. | 248 | * Gets the method of the interface that is currently selected. |
249 | * @return QString name of the method such as staic or dhcp. | 249 | * @return QString name of the method such as staic or dhcp. |
250 | * See the man page of interfaces for possible methods depending on the family. | 250 | * See the man page of interfaces for possible methods depending on the family. |
251 | * @param error set to true if any error occurs, false otherwise. | 251 | * @param error set to true if any error occurs, false otherwise. |
252 | */ | 252 | */ |
253 | QString Interfaces::getInterfaceMethod(bool &error){ | 253 | QString Interfaces::getInterfaceMethod(bool &error){ |
254 | QString name = getInterfaceName(error); | 254 | QString name = getInterfaceName(error); |
255 | if(error) | 255 | if(error) |
256 | return QString(); | 256 | return QString(); |
@@ -266,49 +266,49 @@ QString Interfaces::getInterfaceMethod(bool &error){ | |||
266 | return line; | 266 | return line; |
267 | } | 267 | } |
268 | 268 | ||
269 | /** | 269 | /** |
270 | * Sets the interface name to newName. | 270 | * Sets the interface name to newName. |
271 | * @param newName the new name of the interface. All whitespace is removed. | 271 | * @param newName the new name of the interface. All whitespace is removed. |
272 | * @return bool true if successfull. | 272 | * @return bool true if successfull. |
273 | */ | 273 | */ |
274 | bool Interfaces::setInterfaceName(const QString &newName){ | 274 | bool Interfaces::setInterfaceName(const QString &newName){ |
275 | if(currentIface == interfaces.end()) | 275 | if(currentIface == interfaces.end()) |
276 | return false; | 276 | return false; |
277 | QString name = newName.simplifyWhiteSpace(); | 277 | QString name = newName.simplifyWhiteSpace(); |
278 | name = name.replace(QRegExp(" "), ""); | 278 | name = name.replace(QRegExp(" "), ""); |
279 | bool returnValue = false; | 279 | bool returnValue = false; |
280 | (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); | 280 | (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); |
281 | return !returnValue; | 281 | return !returnValue; |
282 | } | 282 | } |
283 | 283 | ||
284 | /** | 284 | /** |
285 | * Sets the interface family to newName. | 285 | * Sets the interface family to newName. |
286 | * @param newName the new name of the interface. Must be one of the families | 286 | * @param newName the new name of the interface. Must be one of the families |
287 | * defined in the interfaces.h file. | 287 | * defined in the interfaces.h file. |
288 | * @return bool true if successfull. | 288 | * @return bool true if successfull. |
289 | */ | 289 | */ |
290 | bool Interfaces::setInterfaceFamily(const QString &newName){ | 290 | bool Interfaces::setInterfaceFamily(const QString &newName){ |
291 | if(currentIface == interfaces.end()) | 291 | if(currentIface == interfaces.end()) |
292 | return false; | 292 | return false; |
293 | if(acceptedFamily.contains(newName)==0) | 293 | if(acceptedFamily.contains(newName)==0) |
294 | return false; | 294 | return false; |
295 | bool returnValue = false; | 295 | bool returnValue = false; |
296 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); | 296 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); |
297 | return !returnValue; | 297 | return !returnValue; |
298 | } | 298 | } |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * Sets the interface method to newName | 301 | * Sets the interface method to newName |
302 | * @param newName the new name of the interface | 302 | * @param newName the new name of the interface |
303 | * @return bool true if successfull. | 303 | * @return bool true if successfull. |
304 | */ | 304 | */ |
305 | bool Interfaces::setInterfaceMethod(const QString &newName){ | 305 | bool Interfaces::setInterfaceMethod(const QString &newName){ |
306 | if(currentIface == interfaces.end()) | 306 | if(currentIface == interfaces.end()) |
307 | return false; | 307 | return false; |
308 | bool returnValue = false; | 308 | bool returnValue = false; |
309 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); | 309 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); |
310 | return !returnValue; | 310 | return !returnValue; |
311 | } | 311 | } |
312 | 312 | ||
313 | /** | 313 | /** |
314 | * Get a value for an option in the currently selected interface. For example | 314 | * Get a value for an option in the currently selected interface. For example |
@@ -318,9 +318,9 @@ bool Interfaces::setInterfaceMethod(const QString &newName){ | |||
318 | * address 192.168.1.1 | 318 | * address 192.168.1.1 |
319 | * @param option the options to get the value. | 319 | * @param option the options to get the value. |
320 | * @param error set to true if any error occurs, false otherwise. | 320 | * @param error set to true if any error occurs, false otherwise. |
321 | * @return QString the options value. QString::null if error == true | 321 | * @return QString the options value. QString::null if error == true |
322 | */ | 322 | */ |
323 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ | 323 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ |
324 | return getOption(currentIface, option, error); | 324 | return getOption(currentIface, option, error); |
325 | } | 325 | } |
326 | 326 | ||
@@ -330,38 +330,38 @@ QString Interfaces::getInterfaceOption(const QString &option, bool &error){ | |||
330 | * @param option the options to set the value. | 330 | * @param option the options to set the value. |
331 | * @param value the value that option should be set to. | 331 | * @param value the value that option should be set to. |
332 | * @param error set to true if any error occurs, false otherwise. | 332 | * @param error set to true if any error occurs, false otherwise. |
333 | * @return QString the options value. QString::null if error == true | 333 | * @return QString the options value. QString::null if error == true |
334 | */ | 334 | */ |
335 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ | 335 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ |
336 | return setOption(currentIface, option, value); | 336 | return setOption(currentIface, option, value); |
337 | } | 337 | } |
338 | 338 | ||
339 | /** | 339 | /** |
340 | * Removes a value for an option in the currently selected interface. | 340 | * Removes a value for an option in the currently selected interface. |
341 | * @param option the options to set the value. | 341 | * @param option the options to set the value. |
342 | * @param error set to true if any error occurs, false otherwise. | 342 | * @param error set to true if any error occurs, false otherwise. |
343 | * @return QString the options value. QString::null if error == true | 343 | * @return QString the options value. QString::null if error == true |
344 | */ | 344 | */ |
345 | bool Interfaces::removeInterfaceOption(const QString &option){ | 345 | bool Interfaces::removeInterfaceOption(const QString &option){ |
346 | return removeOption(currentIface, option); | 346 | return removeOption(currentIface, option); |
347 | } | 347 | } |
348 | 348 | ||
349 | /** | 349 | /** |
350 | * Removes a value for an option in the currently selected interface. | 350 | * Removes a value for an option in the currently selected interface. |
351 | * @param option the options to set the value. | 351 | * @param option the options to set the value. |
352 | * @param value the value that option should be set to. | 352 | * @param value the value that option should be set to. |
353 | * @param error set to true if any error occurs, false otherwise. | 353 | * @param error set to true if any error occurs, false otherwise. |
354 | * @return QString the options value. QString::null if error == true | 354 | * @return QString the options value. QString::null if error == true |
355 | */ | 355 | */ |
356 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ | 356 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ |
357 | return removeOption(currentIface, option, value); | 357 | return removeOption(currentIface, option, value); |
358 | } | 358 | } |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * Removes all of the options from the currently selected interface. | 361 | * Removes all of the options from the currently selected interface. |
362 | * @return bool error if if successfull | 362 | * @return bool error if if successfull |
363 | */ | 363 | */ |
364 | bool Interfaces::removeAllInterfaceOptions(){ | 364 | bool Interfaces::removeAllInterfaceOptions(){ |
365 | return removeAllOptions(currentIface); | 365 | return removeAllOptions(currentIface); |
366 | } | 366 | } |
367 | 367 | ||
@@ -369,10 +369,10 @@ bool Interfaces::removeAllInterfaceOptions(){ | |||
369 | * Set the current map to interface's map. This needs to be done before you | 369 | * Set the current map to interface's map. This needs to be done before you |
370 | * can call addMapping(), set/getMap(), and get/setScript(). | 370 | * can call addMapping(), set/getMap(), and get/setScript(). |
371 | * @param interface the name of the interface to set. All whitespace is | 371 | * @param interface the name of the interface to set. All whitespace is |
372 | * removed from the interface name. | 372 | * removed from the interface name. |
373 | * @return bool true if it is successfull. | 373 | * @return bool true if it is successfull. |
374 | */ | 374 | */ |
375 | bool Interfaces::setMapping(const QString &interface){ | 375 | bool Interfaces::setMapping(const QString &interface){ |
376 | QString interfaceName = interface.simplifyWhiteSpace(); | 376 | QString interfaceName = interface.simplifyWhiteSpace(); |
377 | interfaceName = interfaceName.replace(QRegExp(" "), ""); | 377 | interfaceName = interfaceName.replace(QRegExp(" "), ""); |
378 | return setStanza(MAPPING, interfaceName, currentMapping); | 378 | return setStanza(MAPPING, interfaceName, currentMapping); |
@@ -380,9 +380,9 @@ bool Interfaces::setMapping(const QString &interface){ | |||
380 | 380 | ||
381 | /** | 381 | /** |
382 | * Adds a new Mapping to the interfaces file with interfaces. | 382 | * Adds a new Mapping to the interfaces file with interfaces. |
383 | * @param interface the name(s) of the interfaces to set to this mapping | 383 | * @param interface the name(s) of the interfaces to set to this mapping |
384 | */ | 384 | */ |
385 | void Interfaces::addMapping(const QString &option){ | 385 | void Interfaces::addMapping(const QString &option){ |
386 | interfaces.append(""); | 386 | interfaces.append(""); |
387 | interfaces.append(QString(MAPPING " %1").arg(option)); | 387 | interfaces.append(QString(MAPPING " %1").arg(option)); |
388 | } | 388 | } |
@@ -392,16 +392,16 @@ void Interfaces::addMapping(const QString &option){ | |||
392 | * @return bool if successfull or not. | 392 | * @return bool if successfull or not. |
393 | */ | 393 | */ |
394 | bool Interfaces::removeMapping(){ | 394 | bool Interfaces::removeMapping(){ |
395 | return removeStanza(currentMapping); | 395 | return removeStanza(currentMapping); |
396 | } | 396 | } |
397 | 397 | ||
398 | /** | 398 | /** |
399 | * Set a map option within a mapping. | 399 | * Set a map option within a mapping. |
400 | * @param map map to use | 400 | * @param map map to use |
401 | * @param value value to go with map | 401 | * @param value value to go with map |
402 | * @return bool true if it is successfull. | 402 | * @return bool true if it is successfull. |
403 | */ | 403 | */ |
404 | bool Interfaces::setMap(const QString &map, const QString &value){ | 404 | bool Interfaces::setMap(const QString &map, const QString &value){ |
405 | return setOption(currentMapping, map, value); | 405 | return setOption(currentMapping, map, value); |
406 | } | 406 | } |
407 | 407 | ||
@@ -409,9 +409,9 @@ bool Interfaces::setMap(const QString &map, const QString &value){ | |||
409 | * Removes a map option within a mapping. | 409 | * Removes a map option within a mapping. |
410 | * @param map map to use | 410 | * @param map map to use |
411 | * @param value value to go with map | 411 | * @param value value to go with map |
412 | * @return bool true if it is successfull. | 412 | * @return bool true if it is successfull. |
413 | */ | 413 | */ |
414 | bool Interfaces::removeMap(const QString &map, const QString &value){ | 414 | bool Interfaces::removeMap(const QString &map, const QString &value){ |
415 | return removeOption(currentMapping, map, value); | 415 | return removeOption(currentMapping, map, value); |
416 | } | 416 | } |
417 | 417 | ||
@@ -419,40 +419,40 @@ bool Interfaces::removeMap(const QString &map, const QString &value){ | |||
419 | * Get a map value within a mapping. | 419 | * Get a map value within a mapping. |
420 | * @param map map to get value of | 420 | * @param map map to get value of |
421 | * @param bool true if it is successfull. | 421 | * @param bool true if it is successfull. |
422 | * @return value that goes to the map | 422 | * @return value that goes to the map |
423 | */ | 423 | */ |
424 | QString Interfaces::getMap(const QString &map, bool &error){ | 424 | QString Interfaces::getMap(const QString &map, bool &error){ |
425 | return getOption(currentMapping, map, error); | 425 | return getOption(currentMapping, map, error); |
426 | } | 426 | } |
427 | 427 | ||
428 | /** | 428 | /** |
429 | * Sets a script value of the current mapping to argument. | 429 | * Sets a script value of the current mapping to argument. |
430 | * @param argument the script name. | 430 | * @param argument the script name. |
431 | * @return true if successfull. | 431 | * @return true if successfull. |
432 | */ | 432 | */ |
433 | bool Interfaces::setScript(const QString &argument){ | 433 | bool Interfaces::setScript(const QString &argument){ |
434 | return setOption(currentMapping, "script", argument); | 434 | return setOption(currentMapping, "script", argument); |
435 | } | 435 | } |
436 | 436 | ||
437 | /** | 437 | /** |
438 | * @param error true if could not retrieve the current script argument. | 438 | * @param error true if could not retrieve the current script argument. |
439 | * @return QString the argument of the script for the current mapping. | 439 | * @return QString the argument of the script for the current mapping. |
440 | */ | 440 | */ |
441 | QString Interfaces::getScript(bool &error){ | 441 | QString Interfaces::getScript(bool &error){ |
442 | return getOption(currentMapping, "script", error); | 442 | return getOption(currentMapping, "script", error); |
443 | } | 443 | } |
444 | 444 | ||
445 | 445 | ||
446 | 446 | ||
447 | /** | 447 | /** |
448 | * Helper function used to parse through the QStringList and put pointers in | 448 | * Helper function used to parse through the QStringList and put pointers in |
449 | * the correct place. | 449 | * the correct place. |
450 | * @param stanza The stanza (auto, iface, mapping) to look for. | 450 | * @param stanza The stanza (auto, iface, mapping) to look for. |
451 | * @param option string that must be in the stanza's main line. | 451 | * @param option string that must be in the stanza's main line. |
452 | * @param interator interator to place at location of stanza if successfull. | 452 | * @param interator interator to place at location of stanza if successfull. |
453 | * @return bool true if the stanza is found. | 453 | * @return bool true if the stanza is found. |
454 | */ | 454 | */ |
455 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ | 455 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ |
456 | bool found = false; | 456 | bool found = false; |
457 | iterator = interfaces.end(); | 457 | iterator = interfaces.end(); |
458 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 458 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
@@ -491,9 +491,9 @@ bool Interfaces::setStanza(const QString &stanza, const QString &option, QString | |||
491 | */ | 491 | */ |
492 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 492 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
493 | if(start == interfaces.end()) | 493 | if(start == interfaces.end()) |
494 | return false; | 494 | return false; |
495 | 495 | ||
496 | bool found = false; | 496 | bool found = false; |
497 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 497 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
498 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 498 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
499 | if(!found && value != ""){ | 499 | if(!found && value != ""){ |
@@ -522,9 +522,9 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op | |||
522 | /** | 522 | /** |
523 | * Removes a stanza and all of its options | 523 | * Removes a stanza and all of its options |
524 | * @param stanza the stanza to remove | 524 | * @param stanza the stanza to remove |
525 | * @return bool true if successfull. | 525 | * @return bool true if successfull. |
526 | */ | 526 | */ |
527 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ | 527 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ |
528 | if(stanza == interfaces.end()) | 528 | if(stanza == interfaces.end()) |
529 | return false; | 529 | return false; |
530 | (*stanza) = ""; | 530 | (*stanza) = ""; |
@@ -539,9 +539,9 @@ bool Interfaces::removeStanza(QStringList::Iterator &stanza){ | |||
539 | */ | 539 | */ |
540 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ | 540 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ |
541 | if(start == interfaces.end()) | 541 | if(start == interfaces.end()) |
542 | return false; | 542 | return false; |
543 | 543 | ||
544 | bool found = false; | 544 | bool found = false; |
545 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 545 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
546 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 546 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
547 | // got to the end without finding it | 547 | // got to the end without finding it |
@@ -566,9 +566,9 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString | |||
566 | */ | 566 | */ |
567 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 567 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
568 | if(start == interfaces.end()) | 568 | if(start == interfaces.end()) |
569 | return false; | 569 | return false; |
570 | 570 | ||
571 | bool found = false; | 571 | bool found = false; |
572 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 572 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
573 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 573 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
574 | // got to the end without finding it | 574 | // got to the end without finding it |
@@ -592,9 +592,9 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString | |||
592 | */ | 592 | */ |
593 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ | 593 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ |
594 | if(start == interfaces.end()) | 594 | if(start == interfaces.end()) |
595 | return false; | 595 | return false; |
596 | 596 | ||
597 | QStringList::Iterator it = start; | 597 | QStringList::Iterator it = start; |
598 | it = ++it; | 598 | it = ++it; |
599 | for (; it != interfaces.end(); ++it ) { | 599 | for (; it != interfaces.end(); ++it ) { |
600 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 600 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
@@ -619,9 +619,9 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString | |||
619 | if(start == interfaces.end()){ | 619 | if(start == interfaces.end()){ |
620 | error = false; | 620 | error = false; |
621 | return QString(); | 621 | return QString(); |
622 | } | 622 | } |
623 | 623 | ||
624 | QString value; | 624 | QString value; |
625 | bool found = false; | 625 | bool found = false; |
626 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 626 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
627 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 627 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
@@ -646,9 +646,9 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString | |||
646 | /** | 646 | /** |
647 | * Write out the interfaces file to the file passed into the constructor. | 647 | * Write out the interfaces file to the file passed into the constructor. |
648 | * Removes any excess blank lines over 1 line long. | 648 | * Removes any excess blank lines over 1 line long. |
649 | * @return bool true if successfull, false if not. | 649 | * @return bool true if successfull, false if not. |
650 | */ | 650 | */ |
651 | bool Interfaces::write(){ | 651 | bool Interfaces::write(){ |
652 | QFile::remove(interfacesFile); | 652 | QFile::remove(interfacesFile); |
653 | QFile file(interfacesFile); | 653 | QFile file(interfacesFile); |
654 | 654 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index f19cbdd..b40d101 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -186,8 +186,10 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
186 | }else firstDNSLineEdit->setText(dns); | 186 | }else firstDNSLineEdit->setText(dns); |
187 | 187 | ||
188 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 188 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
189 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 189 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
190 | if (subnetMaskEdit->text().isEmpty()) | ||
191 | subnetMaskEdit->setText( "255.255.255.0" ); | ||
190 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 192 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
191 | 193 | ||
192 | 194 | ||
193 | 195 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index 7bded85..a4488f9 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -131,11 +131,28 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) | |||
131 | 131 | ||
132 | QDataStream stream(arg,IO_ReadOnly); | 132 | QDataStream stream(arg,IO_ReadOnly); |
133 | QString interface; | 133 | QString interface; |
134 | QString action; | 134 | QString action; |
135 | int countMsgs = 0; | ||
136 | stream >> interface; | ||
137 | qDebug("got count? >%s<",interface.latin1()); | ||
138 | if (interface == "count"){ | ||
139 | qDebug("got count"); | ||
140 | stream >> action; | ||
141 | qDebug("Got count num >%s<", action.latin1()); | ||
142 | countMsgs = action.toInt(); | ||
143 | } | ||
144 | |||
135 | QDialog *toShow; | 145 | QDialog *toShow; |
136 | while (! stream.atEnd() ){ | 146 | //while (! stream.atEnd() ){ |
147 | for (int i = 0; i < countMsgs; i++){ | ||
148 | qDebug("start stream %d/%d",i,countMsgs); | ||
149 | if (stream.atEnd()){ | ||
150 | qDebug("end of stream"); | ||
151 | return; | ||
152 | } | ||
137 | stream >> interface; | 153 | stream >> interface; |
154 | qDebug("got iface"); | ||
138 | stream >> action; | 155 | stream >> action; |
139 | qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); | 156 | qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); |
140 | // find interfaces | 157 | // find interfaces |
141 | Interface *ifa=0; | 158 | Interface *ifa=0; |
@@ -174,9 +191,13 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) | |||
174 | toShow = (QDialog*) wlanconfigWiget; | 191 | toShow = (QDialog*) wlanconfigWiget; |
175 | } | 192 | } |
176 | wlanconfigWiget->showMaximized(); | 193 | wlanconfigWiget->showMaximized(); |
177 | stream >> value; | 194 | stream >> value; |
178 | qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); | 195 | qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); |
196 | if (value.isEmpty()){ | ||
197 | qDebug("value is empty!!!\nreturning"); | ||
198 | return; | ||
199 | } | ||
179 | if ( action.contains("ESSID") ){ | 200 | if ( action.contains("ESSID") ){ |
180 | QComboBox *combo = wlanconfigWiget->essid; | 201 | QComboBox *combo = wlanconfigWiget->essid; |
181 | bool found = false; | 202 | bool found = false; |
182 | for ( int i = 0; i < combo->count(); i++) | 203 | for ( int i = 0; i < combo->count(); i++) |
@@ -193,10 +214,12 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) | |||
193 | } | 214 | } |
194 | 215 | ||
195 | }else if (action.contains("Channel")){ | 216 | }else if (action.contains("Channel")){ |
196 | bool ok; | 217 | bool ok; |
218 | qDebug("converting channel"); | ||
197 | int chan = value.toInt( &ok ); | 219 | int chan = value.toInt( &ok ); |
198 | if (ok){ | 220 | if (ok){ |
221 | qDebug("ok setting channel"); | ||
199 | wlanconfigWiget->specifyChan->setChecked( true ); | 222 | wlanconfigWiget->specifyChan->setChecked( true ); |
200 | wlanconfigWiget->networkChannel->setValue( chan ); | 223 | wlanconfigWiget->networkChannel->setValue( chan ); |
201 | } | 224 | } |
202 | }else if (action.contains("MacAddr")){ | 225 | }else if (action.contains("MacAddr")){ |
@@ -204,19 +227,26 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) | |||
204 | wlanconfigWiget->macEdit->setText( value ); | 227 | wlanconfigWiget->macEdit->setText( value ); |
205 | }else | 228 | }else |
206 | qDebug("wlan plugin has no clue"); | 229 | qDebug("wlan plugin has no clue"); |
207 | } | 230 | } |
231 | qDebug("next stream"); | ||
208 | }// while stream | 232 | }// while stream |
233 | qDebug("end of stream"); | ||
209 | if (toShow) toShow->exec(); | 234 | if (toShow) toShow->exec(); |
235 | qDebug("returning"); | ||
210 | } | 236 | } |
211 | 237 | ||
212 | QWidget *WLANModule::getInfo( Interface *i) | 238 | QWidget *WLANModule::getInfo( Interface *i) |
213 | { | 239 | { |
214 | qDebug("WLANModule::getInfo start"); | 240 | qDebug("WLANModule::getInfo start"); |
215 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); | 241 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); |
216 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); | 242 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); |
217 | info->tabWidget->insertTab(information, "TCP/IP", 0); | 243 | info->tabWidget->insertTab(information, "TCP/IP", 0); |
218 | 244 | info->tabWidget->setCurrentPage( 0 ); | |
245 | info->tabWidget->showPage( information ); | ||
246 | if (info->tabWidget->currentPage() == information ) qDebug("infotab OK"); | ||
247 | else qDebug("infotab NOT OK"); | ||
248 | qDebug("current idx %d", info->tabWidget->currentPageIndex()); | ||
219 | qDebug("WLANModule::getInfo return"); | 249 | qDebug("WLANModule::getInfo return"); |
220 | return info; | 250 | return info; |
221 | } | 251 | } |
222 | 252 | ||