summaryrefslogtreecommitdiff
authortille <tille>2003-06-21 15:34:55 (UTC)
committer tille <tille>2003-06-21 15:34:55 (UTC)
commit5f5accf337a109371296c6a78175734454165406 (patch) (unidiff)
tree7c4334febdedcd8c0b42a2296af6875f6f990762
parentfde32755685bec14851f943be337e94675caf0c4 (diff)
downloadopie-5f5accf337a109371296c6a78175734454165406.zip
opie-5f5accf337a109371296c6a78175734454165406.tar.gz
opie-5f5accf337a109371296c6a78175734454165406.tar.bz2
channel count for wellenreiter
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp114
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp36
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
@@ -1,678 +1,678 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qregexp.h> 5#include <qregexp.h>
6 6
7// The three stanza's 7// The three stanza's
8#define AUTO "auto" 8#define AUTO "auto"
9#define IFACE "iface" 9#define IFACE "iface"
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 */
18Interfaces::Interfaces(QString useInterfacesFile){ 18Interfaces::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() );
27 currentIface = interfaces.end(); 27 currentIface = interfaces.end();
28 currentMapping = interfaces.end(); 28 currentMapping = interfaces.end();
29 return; 29 return;
30 } 30 }
31 QTextStream stream( &file ); 31 QTextStream stream( &file );
32 QString line; 32 QString line;
33 while ( !stream.eof() ) { 33 while ( !stream.eof() ) {
34 line += stream.readLine(); 34 line += stream.readLine();
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 **/
51QStringList Interfaces::getInterfaceList(){ 51QStringList 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();
55 if(line.contains(IFACE) && line.at(0) != '#'){ 55 if(line.contains(IFACE) && line.at(0) != '#'){
56 line = line.mid(QString(IFACE).length() +1, line.length()); 56 line = line.mid(QString(IFACE).length() +1, line.length());
57 line = line.simplifyWhiteSpace(); 57 line = line.simplifyWhiteSpace();
58 int findSpace = line.find(" "); 58 int findSpace = line.find(" ");
59 if( findSpace >= 0){ 59 if( findSpace >= 0){
60 line = line.mid(0, findSpace); 60 line = line.mid(0, findSpace);
61 list.append(line); 61 list.append(line);
62 } 62 }
63 } 63 }
64 } 64 }
65 return list; 65 return list;
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 */
74bool Interfaces::isAuto(const QString &interface) const { 74bool 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)
78 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 78 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
79 return awi.count() > 0; 79 return awi.count() > 0;
80} 80}
81 81
82/** 82/**
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 * */
88bool Interfaces::setAuto(const QString &interface, bool setAuto){ 88bool 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.
97 if(setAuto){ 97 if(setAuto){
98 (*it) = (*it) += " " + interface; 98 (*it) = (*it) += " " + interface;
99 // Don't care to have such thins as: auto eth0 lo usb0 99 // Don't care to have such thins as: auto eth0 lo usb0
100 (*it) = (*it).simplifyWhiteSpace(); 100 (*it) = (*it).simplifyWhiteSpace();
101 changed = true; 101 changed = true;
102 break; 102 break;
103 } 103 }
104 // else see if we need to remove from this one 104 // else see if we need to remove from this one
105 else{ 105 else{
106 if((*it).contains(interface)){ 106 if((*it).contains(interface)){
107 (*it) = (*it).replace(QRegExp(interface), ""); 107 (*it) = (*it).replace(QRegExp(interface), "");
108 // if AUTO is the only thing left clear the line 108 // if AUTO is the only thing left clear the line
109 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) 109 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO)
110 (*it) = ""; 110 (*it) = "";
111 changed = true; 111 changed = true;
112 // Don't break because we want to make sure we remove all cases. 112 // Don't break because we want to make sure we remove all cases.
113 } 113 }
114 } 114 }
115 } 115 }
116 } 116 }
117 // In the case where there is no AUTO field add one. 117 // In the case where there is no AUTO field add one.
118 if(!changed && setAuto) 118 if(!changed && setAuto)
119 interfaces.append(QString(AUTO" %1").arg(interface)); 119 interfaces.append(QString(AUTO" %1").arg(interface));
120 return true; 120 return true;
121} 121}
122 122
123/** 123/**
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 */
130bool Interfaces::setInterface(QString interface){ 130bool 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);
134} 134}
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 */
140bool Interfaces::isInterfaceSet() const { 140bool Interfaces::isInterfaceSet() const {
141 return (interfaces.end() != currentIface); 141 return (interfaces.end() != currentIface);
142} 142}
143 143
144/** 144/**
145 * Add a new interface of with the settings - family and method 145 * Add a new interface of with the settings - family and method
146 * @param interface the name of the interface to set. All whitespace is 146 * @param interface the name of the interface to set. All whitespace is
147 * removed from the interface name. 147 * removed from the interface name.
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 */
153bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ 153bool 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();
157 newInterface = newInterface.replace(QRegExp(" "), ""); 157 newInterface = newInterface.replace(QRegExp(" "), "");
158 interfaces.append(""); 158 interfaces.append("");
159 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); 159 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
160 return true; 160 return true;
161} 161}
162 162
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 */
168bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ 168bool 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 */
199bool Interfaces::removeInterface(){ 199bool 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 */
208QString Interfaces::getInterfaceName(bool &error){ 208QString 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();
212 } 212 }
213 QString line = (*currentIface); 213 QString line = (*currentIface);
214 line = line.mid(QString(IFACE).length() +1, line.length()); 214 line = line.mid(QString(IFACE).length() +1, line.length());
215 line = line.simplifyWhiteSpace(); 215 line = line.simplifyWhiteSpace();
216 int findSpace = line.find(" "); 216 int findSpace = line.find(" ");
217 if( findSpace < 0){ 217 if( findSpace < 0){
218 error = true; 218 error = true;
219 return QString(); 219 return QString();
220 } 220 }
221 error = false; 221 error = false;
222 return line.mid(0, findSpace); 222 return line.mid(0, findSpace);
223} 223}
224 224
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 */
230QString Interfaces::getInterfaceFamily(bool &error){ 230QString 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();
234 QString line = (*currentIface); 234 QString line = (*currentIface);
235 line = line.mid(QString(IFACE).length() +1, line.length()); 235 line = line.mid(QString(IFACE).length() +1, line.length());
236 line = line.mid(name.length()+1, line.length()); 236 line = line.mid(name.length()+1, line.length());
237 line = line.simplifyWhiteSpace(); 237 line = line.simplifyWhiteSpace();
238 int findSpace = line.find(" "); 238 int findSpace = line.find(" ");
239 if( findSpace < 0){ 239 if( findSpace < 0){
240 error = true; 240 error = true;
241 return QString(); 241 return QString();
242 } 242 }
243 error = false; 243 error = false;
244 return line.mid(0, findSpace); 244 return line.mid(0, findSpace);
245} 245}
246 246
247/** 247/**
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 */
253QString Interfaces::getInterfaceMethod(bool &error){ 253QString 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();
257 QString family = getInterfaceFamily(error); 257 QString family = getInterfaceFamily(error);
258 if(error) 258 if(error)
259 return QString(); 259 return QString();
260 QString line = (*currentIface); 260 QString line = (*currentIface);
261 line = line.mid(QString(IFACE).length()+1, line.length()); 261 line = line.mid(QString(IFACE).length()+1, line.length());
262 line = line.mid(name.length()+1, line.length()); 262 line = line.mid(name.length()+1, line.length());
263 line = line.mid(family.length()+1, line.length()); 263 line = line.mid(family.length()+1, line.length());
264 line = line.simplifyWhiteSpace(); 264 line = line.simplifyWhiteSpace();
265 error = false; 265 error = false;
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 */
274bool Interfaces::setInterfaceName(const QString &newName){ 274bool 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 */
290bool Interfaces::setInterfaceFamily(const QString &newName){ 290bool 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 */
305bool Interfaces::setInterfaceMethod(const QString &newName){ 305bool 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
315 * calling getInterfaceOption("address") on the following stanza would 315 * calling getInterfaceOption("address") on the following stanza would
316 * return 192.168.1.1. 316 * return 192.168.1.1.
317 * iface eth0 static 317 * iface eth0 static
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 */
323QString Interfaces::getInterfaceOption(const QString &option, bool &error){ 323QString Interfaces::getInterfaceOption(const QString &option, bool &error){
324 return getOption(currentIface, option, error); 324 return getOption(currentIface, option, error);
325} 325}
326 326
327/** 327/**
328 * Set a value for an option in the currently selected interface. If option 328 * Set a value for an option in the currently selected interface. If option
329 * doesn't exist then it is added along with the value. 329 * doesn't exist then it is added along with the value.
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 */
335bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ 335bool 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 */
345bool Interfaces::removeInterfaceOption(const QString &option){ 345bool 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 */
356bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ 356bool 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 */
364bool Interfaces::removeAllInterfaceOptions(){ 364bool Interfaces::removeAllInterfaceOptions(){
365 return removeAllOptions(currentIface); 365 return removeAllOptions(currentIface);
366} 366}
367 367
368/** 368/**
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 */
375bool Interfaces::setMapping(const QString &interface){ 375bool 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);
379} 379}
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 */
385void Interfaces::addMapping(const QString &option){ 385void 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}
389 389
390/** 390/**
391 * Remove the currently selected map and all of its options. 391 * Remove the currently selected map and all of its options.
392 * @return bool if successfull or not. 392 * @return bool if successfull or not.
393 */ 393 */
394bool Interfaces::removeMapping(){ 394bool 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 */
404bool Interfaces::setMap(const QString &map, const QString &value){ 404bool Interfaces::setMap(const QString &map, const QString &value){
405 return setOption(currentMapping, map, value); 405 return setOption(currentMapping, map, value);
406} 406}
407 407
408/** 408/**
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 */
414bool Interfaces::removeMap(const QString &map, const QString &value){ 414bool Interfaces::removeMap(const QString &map, const QString &value){
415 return removeOption(currentMapping, map, value); 415 return removeOption(currentMapping, map, value);
416} 416}
417 417
418/** 418/**
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 */
424QString Interfaces::getMap(const QString &map, bool &error){ 424QString 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 */
433bool Interfaces::setScript(const QString &argument){ 433bool 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 */
441QString Interfaces::getScript(bool &error){ 441QString 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 */
455bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ 455bool 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 ) {
459 QString line = (*it).simplifyWhiteSpace(); 459 QString line = (*it).simplifyWhiteSpace();
460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ 460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
461 uint point = line.find(option); 461 uint point = line.find(option);
462 bool valid = true; 462 bool valid = true;
463 if(point > 0){ 463 if(point > 0){
464 // There are more chars in the line. check +1 464 // There are more chars in the line. check +1
465 if(line.at(point-1) != ' ') 465 if(line.at(point-1) != ' ')
466 valid = false; 466 valid = false;
467 } 467 }
468 point += option.length(); 468 point += option.length();
469 if(point < line.length()-1){ 469 if(point < line.length()-1){
470 // There are more chars in the line. check -1 470 // There are more chars in the line. check -1
471 if(line.at(point) != ' ') 471 if(line.at(point) != ' ')
472 valid = false; 472 valid = false;
473 } 473 }
474 if(valid){ 474 if(valid){
475 if(found == true){ 475 if(found == true){
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 } 477 }
478 found = true; 478 found = true;
479 iterator = it; 479 iterator = it;
480 } 480 }
481 } 481 }
482 } 482 }
483 return found; 483 return found;
484} 484}
485 485
486/** 486/**
487 * Sets a value of an option in a stanza 487 * Sets a value of an option in a stanza
488 * @param start the start of the stanza 488 * @param start the start of the stanza
489 * @param option the option to use when setting value. 489 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise. 490 * @return bool true if successfull, false otherwise.
491 */ 491 */
492bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 492bool 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 != ""){
500 // Got to the end of the stanza without finding it, so append it. 500 // Got to the end of the stanza without finding it, so append it.
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
502 } 502 }
503 found = true; 503 found = true;
504 break; 504 break;
505 } 505 }
506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it. 507 // Found it in stanza so replace it.
508 if(found) 508 if(found)
509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
510 found = true; 510 found = true;
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 511 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 512 }
513 } 513 }
514 if(!found){ 514 if(!found){
515 QStringList::Iterator p = start; 515 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 517 found = true;
518 } 518 }
519 return found; 519 return found;
520} 520}
521 521
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 */
527bool Interfaces::removeStanza(QStringList::Iterator &stanza){ 527bool 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) = "";
531 return removeAllOptions(stanza); 531 return removeAllOptions(stanza);
532} 532}
533 533
534/** 534/**
535 * Removes a option in a stanza 535 * Removes a option in a stanza
536 * @param start the start of the stanza 536 * @param start the start of the stanza
537 * @param option the option to remove 537 * @param option the option to remove
538 * @return bool true if successfull, false otherwise. 538 * @return bool true if successfull, false otherwise.
539 */ 539 */
540bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ 540bool 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
548 break; 548 break;
549 } 549 }
550 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 550 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
551 // Found it in stanza so replace it. 551 // Found it in stanza so replace it.
552 if(found) 552 if(found)
553 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 553 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
554 found = true; 554 found = true;
555 (*it) = ""; 555 (*it) = "";
556 } 556 }
557 } 557 }
558 return found; 558 return found;
559} 559}
560 560
561/** 561/**
562 * Removes a option in a stanza 562 * Removes a option in a stanza
563 * @param start the start of the stanza 563 * @param start the start of the stanza
564 * @param option the option to use when setting value. 564 * @param option the option to use when setting value.
565 * @return bool true if successfull, false otherwise. 565 * @return bool true if successfull, false otherwise.
566 */ 566 */
567bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 567bool 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
575 break; 575 break;
576 } 576 }
577 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ 577 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
578 // Found it in stanza so replace it. 578 // Found it in stanza so replace it.
579 if(found) 579 if(found)
580 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 580 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
581 found = true; 581 found = true;
582 (*it) = ""; 582 (*it) = "";
583 } 583 }
584 } 584 }
585 return found; 585 return found;
586} 586}
587 587
588/** 588/**
589 * Removes all options in a stanza 589 * Removes all options in a stanza
590 * @param start the start of the stanza 590 * @param start the start of the stanza
591 * @return bool true if successfull, false otherwise. 591 * @return bool true if successfull, false otherwise.
592 */ 592 */
593bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ 593bool 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){
601 break; 601 break;
602 } 602 }
603 it = interfaces.remove(it); 603 it = interfaces.remove(it);
604 it = --it; 604 it = --it;
605 } 605 }
606 // Leave a space between this interface and the next. 606 // Leave a space between this interface and the next.
607 interfaces.insert(it, QString("")); 607 interfaces.insert(it, QString(""));
608 return true; 608 return true;
609} 609}
610 610
611/** 611/**
612 * Gets a value of an option in a stanza 612 * Gets a value of an option in a stanza
613 * @param start the start of the stanza 613 * @param start the start of the stanza
614 * @param option the option to use when getting the value. 614 * @param option the option to use when getting the value.
615 * @param bool true if errors false otherwise. 615 * @param bool true if errors false otherwise.
616 * @return QString the value of option QString::null() if error == true. 616 * @return QString the value of option QString::null() if error == true.
617 */ 617 */
618QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ 618QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
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){
628 break; 628 break;
629 } 629 }
630 if((*it).contains(option) && (*it).at(0) != '#'){ 630 if((*it).contains(option) && (*it).at(0) != '#'){
631 if(found) 631 if(found)
632 qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 632 qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
633 found = true; 633 found = true;
634 QString line = (*it).simplifyWhiteSpace(); 634 QString line = (*it).simplifyWhiteSpace();
635 int space = line.find(" ", option.length()); 635 int space = line.find(" ", option.length());
636 if(space != -1){ 636 if(space != -1){
637 value = line.mid(space+1, line.length()); 637 value = line.mid(space+1, line.length());
638 break; 638 break;
639 } 639 }
640 } 640 }
641 } 641 }
642 error = !found; 642 error = !found;
643 return value; 643 return value;
644} 644}
645 645
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 */
651bool Interfaces::write(){ 651bool Interfaces::write(){
652 QFile::remove(interfacesFile); 652 QFile::remove(interfacesFile);
653 QFile file(interfacesFile); 653 QFile file(interfacesFile);
654 654
655 if (!file.open(IO_ReadWrite)){ 655 if (!file.open(IO_ReadWrite)){
656 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); 656 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
657 return false; 657 return false;
658 } 658 }
659 QTextStream stream( &file ); 659 QTextStream stream( &file );
660 int whiteSpaceCount = 0; 660 int whiteSpaceCount = 0;
661 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 661 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
662 QString line = (*it).simplifyWhiteSpace(); 662 QString line = (*it).simplifyWhiteSpace();
663 line = line.replace(QRegExp(" "),""); 663 line = line.replace(QRegExp(" "),"");
664 if(line.length() == 0) 664 if(line.length() == 0)
665 whiteSpaceCount++; 665 whiteSpaceCount++;
666 else 666 else
667 whiteSpaceCount = 0; 667 whiteSpaceCount = 0;
668 if(whiteSpaceCount < 2){ 668 if(whiteSpaceCount < 2){
669 qDebug((*it).latin1()); 669 qDebug((*it).latin1());
670 stream << (*it) << '\n'; 670 stream << (*it) << '\n';
671 } 671 }
672 } 672 }
673 file.close(); 673 file.close();
674 return true; 674 return true;
675} 675}
676 676
677// interfaces.cpp 677// interfaces.cpp
678 678
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
@@ -1,200 +1,202 @@
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 */
25InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ 25InterfaceSetupImp::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 */
35InterfaceSetupImp::~InterfaceSetupImp(){ 35InterfaceSetupImp::~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 */
44bool InterfaceSetupImp::saveChanges(){ 44bool InterfaceSetupImp::saveChanges(){
45 bool error; 45 bool error;
46 QString iface = interfaces->getInterfaceName(error); 46 QString iface = interfaces->getInterfaceName(error);
47 if(!saveSettings()) 47 if(!saveSettings())
48 return false; 48 return false;
49 49
50 interfaces->write(); 50 interfaces->write();
51 51
52 if (interface->getStatus()) { 52 if (interface->getStatus()) {
53 QString ifup; 53 QString ifup;
54 ifup += "ifdown "; 54 ifup += "ifdown ";
55 ifup += iface; 55 ifup += iface;
56 ifup += "; ifup "; 56 ifup += "; ifup ";
57 ifup += iface; 57 ifup += iface;
58 ifup += ";"; 58 ifup += ";";
59 59
60 OProcess restart; 60 OProcess restart;
61 restart << "sh"; 61 restart << "sh";
62 restart << "-c"; 62 restart << "-c";
63 restart << ifup; 63 restart << ifup;
64 64
65 OWait *owait = new OWait(); 65 OWait *owait = new OWait();
66 Global::statusMessage( tr( "Restarting interface" ) ); 66 Global::statusMessage( tr( "Restarting interface" ) );
67 67
68 owait->show(); 68 owait->show();
69 qApp->processEvents(); 69 qApp->processEvents();
70 70
71 if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { 71 if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) {
72 qWarning("unstable to spawn ifdown/ifup"); 72 qWarning("unstable to spawn ifdown/ifup");
73 } 73 }
74 74
75 owait->hide(); 75 owait->hide();
76 delete owait; 76 delete owait;
77 77
78 interface->refresh(); 78 interface->refresh();
79 } 79 }
80 return true; 80 return true;
81} 81}
82 82
83/** 83/**
84 * Save the settings for the current Interface. 84 * Save the settings for the current Interface.
85 * @return bool true if successfull, false otherwise 85 * @return bool true if successfull, false otherwise
86 */ 86 */
87bool InterfaceSetupImp::saveSettings(){ 87bool InterfaceSetupImp::saveSettings(){
88 // eh can't really do anything about it other then return. :-D 88 // eh can't really do anything about it other then return. :-D
89 if(!interfaces->isInterfaceSet()) 89 if(!interfaces->isInterfaceSet())
90 return true; 90 return true;
91 91
92 bool error = false; 92 bool error = false;
93 // Loopback case 93 // Loopback case
94 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 94 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
95 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 95 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
96 return true; 96 return true;
97 } 97 }
98 98
99 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ 99 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
100 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); 100 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
101 return false; 101 return false;
102 } 102 }
103 // DHCP 103 // DHCP
104 if(dhcpCheckBox->isChecked()) { 104 if(dhcpCheckBox->isChecked()) {
105 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); 105 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
106 interfaces->removeInterfaceOption("address"); 106 interfaces->removeInterfaceOption("address");
107 interfaces->removeInterfaceOption("netmask"); 107 interfaces->removeInterfaceOption("netmask");
108 interfaces->removeInterfaceOption("gateway"); 108 interfaces->removeInterfaceOption("gateway");
109 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 109 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
110 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); 110 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r ");
111 } else{ 111 } else{
112 interfaces->setInterfaceMethod("static"); 112 interfaces->setInterfaceMethod("static");
113 interfaces->setInterfaceOption("address", ipAddressEdit->text()); 113 interfaces->setInterfaceOption("address", ipAddressEdit->text());
114 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); 114 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
115 interfaces->setInterfaceOption("gateway", gatewayEdit->text()); 115 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
116 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 116 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
117 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 117 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
118 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); 118 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
119 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); 119 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
120 } 120 }
121 } 121 }
122 122
123 // IP Information 123 // IP Information
124 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 124 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
125 return true; 125 return true;
126} 126}
127 127
128/** 128/**
129 * The Profile has changed. 129 * The Profile has changed.
130 * @param QString profile the new profile. 130 * @param QString profile the new profile.
131 */ 131 */
132void InterfaceSetupImp::setProfile(const QString &profile){ 132void InterfaceSetupImp::setProfile(const QString &profile){
133 /* 133 /*
134 bool error = false; 134 bool error = false;
135 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 135 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
136 staticGroupBox->hide(); 136 staticGroupBox->hide();
137 dhcpCheckBox->hide(); 137 dhcpCheckBox->hide();
138 leaseTime->hide(); 138 leaseTime->hide();
139 leaseHoursLabel->hide(); 139 leaseHoursLabel->hide();
140 } 140 }
141 */ 141 */
142 142
143 QString newInterfaceName = interface->getInterfaceName(); 143 QString newInterfaceName = interface->getInterfaceName();
144 if(profile.length() > 0) 144 if(profile.length() > 0)
145 newInterfaceName += "_" + profile; 145 newInterfaceName += "_" + profile;
146 // See if we have to make a interface. 146 // See if we have to make a interface.
147 if(!interfaces->setInterface(newInterfaceName)){ 147 if(!interfaces->setInterface(newInterfaceName)){
148 // Add making for this new interface if need too 148 // Add making for this new interface if need too
149 if(profile != ""){ 149 if(profile != ""){
150 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); 150 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
151 if(!interfaces->setMapping(interface->getInterfaceName())){ 151 if(!interfaces->setMapping(interface->getInterfaceName())){
152 interfaces->addMapping(interface->getInterfaceName()); 152 interfaces->addMapping(interface->getInterfaceName());
153 if(!interfaces->setMapping(interface->getInterfaceName())){ 153 if(!interfaces->setMapping(interface->getInterfaceName())){
154 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); 154 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface.");
155 return; 155 return;
156 } 156 }
157 } 157 }
158 interfaces->setMap("map", newInterfaceName); 158 interfaces->setMap("map", newInterfaceName);
159 interfaces->setScript("getprofile.sh"); 159 interfaces->setScript("getprofile.sh");
160 } 160 }
161 else{ 161 else{
162 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); 162 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
163 if(!interfaces->setInterface(newInterfaceName)){ 163 if(!interfaces->setInterface(newInterfaceName)){
164 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); 164 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface.");
165 return; 165 return;
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 // We must have a valid interface to get this far so read some settings. 170 // We must have a valid interface to get this far so read some settings.
171 171
172 // DHCP 172 // DHCP
173 bool error = false; 173 bool error = false;
174 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 174 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
175 dhcpCheckBox->setChecked(true); 175 dhcpCheckBox->setChecked(true);
176 else 176 else
177 dhcpCheckBox->setChecked(false); 177 dhcpCheckBox->setChecked(false);
178 178
179 // IP Information 179 // IP Information
180 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); 180 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
181 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); 181 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error);
182 qDebug("dns >%s<",dns.latin1()); 182 qDebug("dns >%s<",dns.latin1());
183 if(dns.contains(" ")){ 183 if(dns.contains(" ")){
184 firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); 184 firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
185 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); 185 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
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
194 qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); 196 qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1());
195 qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); 197 qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1());
196 198
197} 199}
198 200
199// interfacesetup.cpp 201// interfacesetup.cpp
200 202
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
@@ -1,222 +1,252 @@
1#include "wlanmodule.h" 1#include "wlanmodule.h"
2#include "wlanimp.h" 2#include "wlanimp.h"
3#include "infoimp.h" 3#include "infoimp.h"
4#include "wextensions.h" 4#include "wextensions.h"
5#include "interfaceinformationimp.h" 5#include "interfaceinformationimp.h"
6 6
7#include <qcheckbox.h> 7#include <qcheckbox.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qlabel.h> 9#include <qlabel.h>
10#include <qlineedit.h> 10#include <qlineedit.h>
11#include <qprogressbar.h> 11#include <qprogressbar.h>
12#include <qspinbox.h> 12#include <qspinbox.h>
13#include <qtabwidget.h> 13#include <qtabwidget.h>
14 14
15 15
16 16
17 17
18/** 18/**
19 * Constructor, find all of the possible interfaces 19 * Constructor, find all of the possible interfaces
20 */ 20 */
21WLANModule::WLANModule() 21WLANModule::WLANModule()
22 : Module(), 22 : Module(),
23 wlanconfigWiget(0) 23 wlanconfigWiget(0)
24{ 24{
25} 25}
26 26
27/** 27/**
28 * Delete any interfaces that we own. 28 * Delete any interfaces that we own.
29 */ 29 */
30WLANModule::~WLANModule(){ 30WLANModule::~WLANModule(){
31 Interface *i; 31 Interface *i;
32 for ( i=list.first(); i != 0; i=list.next() ) 32 for ( i=list.first(); i != 0; i=list.next() )
33 delete i; 33 delete i;
34 34
35} 35}
36 36
37/** 37/**
38 * Change the current profile 38 * Change the current profile
39 */ 39 */
40void WLANModule::setProfile(const QString &newProfile){ 40void WLANModule::setProfile(const QString &newProfile){
41 profile = newProfile; 41 profile = newProfile;
42} 42}
43 43
44/** 44/**
45 * get the icon name for this device. 45 * get the icon name for this device.
46 * @param Interface* can be used in determining the icon. 46 * @param Interface* can be used in determining the icon.
47 * @return QString the icon name (minus .png, .gif etc) 47 * @return QString the icon name (minus .png, .gif etc)
48 */ 48 */
49QString WLANModule::getPixmapName(Interface* ){ 49QString WLANModule::getPixmapName(Interface* ){
50 return "wlan"; 50 return "wlan";
51} 51}
52 52
53/** 53/**
54 * Check to see if the interface i is owned by this module. 54 * Check to see if the interface i is owned by this module.
55 * @param Interface* interface to check against 55 * @param Interface* interface to check against
56 * @return bool true if i is owned by this module, false otherwise. 56 * @return bool true if i is owned by this module, false otherwise.
57 */ 57 */
58bool WLANModule::isOwner(Interface *i){ 58bool WLANModule::isOwner(Interface *i){
59 WExtensions we(i->getInterfaceName()); 59 WExtensions we(i->getInterfaceName());
60 if(!we.doesHaveWirelessExtensions()) 60 if(!we.doesHaveWirelessExtensions())
61 return false; 61 return false;
62 62
63 i->setHardwareName("802.11b"); 63 i->setHardwareName("802.11b");
64 list.append(i); 64 list.append(i);
65 return true; 65 return true;
66} 66}
67 67
68/** 68/**
69 * Create, and return the WLANConfigure Module 69 * Create, and return the WLANConfigure Module
70 * @return QWidget* pointer to this modules configure. 70 * @return QWidget* pointer to this modules configure.
71 */ 71 */
72QWidget *WLANModule::configure(Interface *i){ 72QWidget *WLANModule::configure(Interface *i){
73 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); 73 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose);
74 wlanconfig->setProfile(profile); 74 wlanconfig->setProfile(profile);
75 return wlanconfig; 75 return wlanconfig;
76} 76}
77 77
78/** 78/**
79 * Create, and return the Information Module 79 * Create, and return the Information Module
80 * @return QWidget* pointer to this modules info. 80 * @return QWidget* pointer to this modules info.
81 */ 81 */
82QWidget *WLANModule::information(Interface *i){ 82QWidget *WLANModule::information(Interface *i){
83 WExtensions we(i->getInterfaceName()); 83 WExtensions we(i->getInterfaceName());
84 if(!we.doesHaveWirelessExtensions()) 84 if(!we.doesHaveWirelessExtensions())
85 return NULL; 85 return NULL;
86 86
87 return getInfo( i ); 87 return getInfo( i );
88} 88}
89 89
90/** 90/**
91 * Get all active (up or down) interfaces 91 * Get all active (up or down) interfaces
92 * @return QList<Interface> A list of interfaces that exsist that havn't 92 * @return QList<Interface> A list of interfaces that exsist that havn't
93 * been called by isOwner() 93 * been called by isOwner()
94 */ 94 */
95QList<Interface> WLANModule::getInterfaces(){ 95QList<Interface> WLANModule::getInterfaces(){
96 return list; 96 return list;
97} 97}
98 98
99/** 99/**
100 * Attempt to add a new interface as defined by name 100 * Attempt to add a new interface as defined by name
101 * @param name the name of the type of interface that should be created given 101 * @param name the name of the type of interface that should be created given
102 * by possibleNewInterfaces(); 102 * by possibleNewInterfaces();
103 * @return Interface* NULL if it was unable to be created. 103 * @return Interface* NULL if it was unable to be created.
104 */ 104 */
105Interface *WLANModule::addNewInterface(const QString &){ 105Interface *WLANModule::addNewInterface(const QString &){
106 // We can't add a 802.11 interface, either the hardware will be there 106 // We can't add a 802.11 interface, either the hardware will be there
107 // or it wont. 107 // or it wont.
108 return NULL; 108 return NULL;
109} 109}
110 110
111/** 111/**
112 * Attempts to remove the interface, doesn't delete i 112 * Attempts to remove the interface, doesn't delete i
113 * @return bool true if successfull, false otherwise. 113 * @return bool true if successfull, false otherwise.
114 */ 114 */
115bool WLANModule::remove(Interface*){ 115bool WLANModule::remove(Interface*){
116 // Can't remove a hardware device, you can stop it though. 116 // Can't remove a hardware device, you can stop it though.
117 return false; 117 return false;
118} 118}
119 119
120void WLANModule::receive(const QCString &param, const QByteArray &arg) 120void WLANModule::receive(const QCString &param, const QByteArray &arg)
121{ 121{
122 qDebug("WLANModule::receive "+param); 122 qDebug("WLANModule::receive "+param);
123 QStringList params = QStringList::split(",",param); 123 QStringList params = QStringList::split(",",param);
124 int count = params.count(); 124 int count = params.count();
125 qDebug("WLANModule got %i params", count ); 125 qDebug("WLANModule got %i params", count );
126 if (count < 2){ 126 if (count < 2){
127 qDebug("Erorr less than 2 parameter"); 127 qDebug("Erorr less than 2 parameter");
128 qDebug("RETURNING"); 128 qDebug("RETURNING");
129 return; 129 return;
130 } 130 }
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;
142 for ( Interface *i=list.first(); i != 0; i=list.next() ){ 159 for ( Interface *i=list.first(); i != 0; i=list.next() ){
143 if (i->getInterfaceName() == interface){ 160 if (i->getInterfaceName() == interface){
144 qDebug("WLANModule found interface %s",interface.latin1()); 161 qDebug("WLANModule found interface %s",interface.latin1());
145 ifa = i; 162 ifa = i;
146 } 163 }
147 } 164 }
148 165
149 if (ifa == 0){ 166 if (ifa == 0){
150 qDebug("WLANModule Did not find %s",interface.latin1()); 167 qDebug("WLANModule Did not find %s",interface.latin1());
151 qDebug("skipping"); 168 qDebug("skipping");
152 count = 0; 169 count = 0;
153 } 170 }
154 171
155 if (count == 2){ 172 if (count == 2){
156 // those should call the interface directly 173 // those should call the interface directly
157 QWidget *info = getInfo( ifa ); 174 QWidget *info = getInfo( ifa );
158 info->showMaximized(); 175 info->showMaximized();
159 176
160 if ( action.contains("start" ) ){ 177 if ( action.contains("start" ) ){
161 ifa->start(); 178 ifa->start();
162 } else if ( action.contains("restart" ) ){ 179 } else if ( action.contains("restart" ) ){
163 ifa->restart(); 180 ifa->restart();
164 } else if ( action.contains("stop" ) ){ 181 } else if ( action.contains("stop" ) ){
165 ifa->stop(); 182 ifa->stop();
166 }else if ( action.contains("refresh" ) ){ 183 }else if ( action.contains("refresh" ) ){
167 ifa->refresh(); 184 ifa->refresh();
168 } 185 }
169 }else if (count == 3){ 186 }else if (count == 3){
170 QString value; 187 QString value;
171 if (!wlanconfigWiget){ 188 if (!wlanconfigWiget){
172 //FIXME: what if it got closed meanwhile? 189 //FIXME: what if it got closed meanwhile?
173 wlanconfigWiget = (WLANImp*) configure(ifa); 190 wlanconfigWiget = (WLANImp*) configure(ifa);
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++)
183 if ( combo->text( i ) == value ){ 204 if ( combo->text( i ) == value ){
184 combo->setCurrentItem( i ); 205 combo->setCurrentItem( i );
185 found = true; 206 found = true;
186 } 207 }
187 if (!found) combo->insertItem( value, 0 ); 208 if (!found) combo->insertItem( value, 0 );
188 }else if ( action.contains("Mode") ){ 209 }else if ( action.contains("Mode") ){
189 QComboBox *combo = wlanconfigWiget->mode; 210 QComboBox *combo = wlanconfigWiget->mode;
190 for ( int i = 0; i < combo->count(); i++) 211 for ( int i = 0; i < combo->count(); i++)
191 if ( combo->text( i ) == value ){ 212 if ( combo->text( i ) == value ){
192 combo->setCurrentItem( i ); 213 combo->setCurrentItem( i );
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")){
203 wlanconfigWiget->specifyAp->setChecked( true ); 226 wlanconfigWiget->specifyAp->setChecked( true );
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
212QWidget *WLANModule::getInfo( Interface *i) 238QWidget *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