author | benmeyer <benmeyer> | 2002-10-18 18:12:53 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-18 18:12:53 (UTC) |
commit | a63b3b36cf4d665b67733e069bfaad8f96388276 (patch) (unidiff) | |
tree | 0089ca8d5bacd31982d8bec367d091b4f58cace1 | |
parent | 5ec0d959ca9d3ade0c7271885028fd4309cf2b4c (diff) | |
download | opie-a63b3b36cf4d665b67733e069bfaad8f96388276.zip opie-a63b3b36cf4d665b67733e069bfaad8f96388276.tar.gz opie-a63b3b36cf4d665b67733e069bfaad8f96388276.tar.bz2 |
interfaces now watches for # in most cases
-rw-r--r-- | noncore/net/networksetup/interfaceinformation.ui | 12 | ||||
-rw-r--r-- | noncore/net/networksetup/interfaces.cpp | 10 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 4 | ||||
-rw-r--r-- | noncore/net/networksetup/module.h | 8 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaceinformation.ui | 12 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaces.cpp | 10 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/module.h | 8 |
8 files changed, 34 insertions, 34 deletions
diff --git a/noncore/net/networksetup/interfaceinformation.ui b/noncore/net/networksetup/interfaceinformation.ui index fc99fce..2838d19 100644 --- a/noncore/net/networksetup/interfaceinformation.ui +++ b/noncore/net/networksetup/interfaceinformation.ui | |||
@@ -30,82 +30,82 @@ | |||
30 | </property> | 30 | </property> |
31 | <widget row="4" column="0" rowspan="1" colspan="2" > | 31 | <widget row="4" column="0" rowspan="1" colspan="2" > |
32 | <class>QLayoutWidget</class> | 32 | <class>QLayoutWidget</class> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>name</name> | 34 | <name>name</name> |
35 | <cstring>Layout1</cstring> | 35 | <cstring>Layout1</cstring> |
36 | </property> | 36 | </property> |
37 | <grid> | 37 | <grid> |
38 | <property stdset="1"> | 38 | <property stdset="1"> |
39 | <name>margin</name> | 39 | <name>margin</name> |
40 | <number>0</number> | 40 | <number>0</number> |
41 | </property> | 41 | </property> |
42 | <property stdset="1"> | 42 | <property stdset="1"> |
43 | <name>spacing</name> | 43 | <name>spacing</name> |
44 | <number>6</number> | 44 | <number>6</number> |
45 | </property> | 45 | </property> |
46 | <widget row="1" column="0" > | 46 | <widget row="1" column="0" > |
47 | <class>QPushButton</class> | 47 | <class>QPushButton</class> |
48 | <property stdset="1"> | 48 | <property stdset="1"> |
49 | <name>name</name> | 49 | <name>name</name> |
50 | <cstring>refreshButton</cstring> | 50 | <cstring>refreshButton</cstring> |
51 | </property> | 51 | </property> |
52 | <property stdset="1"> | 52 | <property stdset="1"> |
53 | <name>text</name> | 53 | <name>text</name> |
54 | <string>Refresh</string> | 54 | <string>&Refresh</string> |
55 | </property> | 55 | </property> |
56 | </widget> | 56 | </widget> |
57 | <widget row="0" column="1" > | 57 | <widget row="0" column="1" > |
58 | <class>QPushButton</class> | 58 | <class>QPushButton</class> |
59 | <property stdset="1"> | 59 | <property stdset="1"> |
60 | <name>name</name> | 60 | <name>name</name> |
61 | <cstring>stopButton</cstring> | 61 | <cstring>stopButton</cstring> |
62 | </property> | 62 | </property> |
63 | <property stdset="1"> | 63 | <property stdset="1"> |
64 | <name>text</name> | 64 | <name>text</name> |
65 | <string>Stop</string> | 65 | <string>S&top</string> |
66 | </property> | 66 | </property> |
67 | </widget> | 67 | </widget> |
68 | <widget row="1" column="1" > | 68 | <widget row="1" column="1" > |
69 | <class>QPushButton</class> | 69 | <class>QPushButton</class> |
70 | <property stdset="1"> | 70 | <property stdset="1"> |
71 | <name>name</name> | 71 | <name>name</name> |
72 | <cstring>restartButton</cstring> | 72 | <cstring>restartButton</cstring> |
73 | </property> | 73 | </property> |
74 | <property stdset="1"> | 74 | <property stdset="1"> |
75 | <name>text</name> | 75 | <name>text</name> |
76 | <string>Restart</string> | 76 | <string>R&estart</string> |
77 | </property> | 77 | </property> |
78 | </widget> | 78 | </widget> |
79 | <widget row="0" column="0" > | 79 | <widget row="0" column="0" > |
80 | <class>QPushButton</class> | 80 | <class>QPushButton</class> |
81 | <property stdset="1"> | 81 | <property stdset="1"> |
82 | <name>name</name> | 82 | <name>name</name> |
83 | <cstring>startButton</cstring> | 83 | <cstring>startButton</cstring> |
84 | </property> | 84 | </property> |
85 | <property stdset="1"> | 85 | <property stdset="1"> |
86 | <name>text</name> | 86 | <name>text</name> |
87 | <string>Start</string> | 87 | <string>&Start</string> |
88 | </property> | 88 | </property> |
89 | </widget> | 89 | </widget> |
90 | </grid> | 90 | </grid> |
91 | </widget> | 91 | </widget> |
92 | <widget row="0" column="0" > | 92 | <widget row="0" column="0" > |
93 | <class>Line</class> | 93 | <class>Line</class> |
94 | <property stdset="1"> | 94 | <property stdset="1"> |
95 | <name>name</name> | 95 | <name>name</name> |
96 | <cstring>Line1</cstring> | 96 | <cstring>Line1</cstring> |
97 | </property> | 97 | </property> |
98 | <property stdset="1"> | 98 | <property stdset="1"> |
99 | <name>orientation</name> | 99 | <name>orientation</name> |
100 | <enum>Horizontal</enum> | 100 | <enum>Horizontal</enum> |
101 | </property> | 101 | </property> |
102 | </widget> | 102 | </widget> |
103 | <widget row="0" column="0" > | 103 | <widget row="0" column="0" > |
104 | <class>QLabel</class> | 104 | <class>QLabel</class> |
105 | <property stdset="1"> | 105 | <property stdset="1"> |
106 | <name>name</name> | 106 | <name>name</name> |
107 | <cstring>TextLabel22</cstring> | 107 | <cstring>TextLabel22</cstring> |
108 | </property> | 108 | </property> |
109 | <property stdset="1"> | 109 | <property stdset="1"> |
110 | <name>text</name> | 110 | <name>text</name> |
111 | <string>IP Address</string> | 111 | <string>IP Address</string> |
@@ -272,74 +272,72 @@ | |||
272 | <property stdset="1"> | 272 | <property stdset="1"> |
273 | <name>orientation</name> | 273 | <name>orientation</name> |
274 | <enum>Horizontal</enum> | 274 | <enum>Horizontal</enum> |
275 | </property> | 275 | </property> |
276 | <property stdset="1"> | 276 | <property stdset="1"> |
277 | <name>sizeType</name> | 277 | <name>sizeType</name> |
278 | <enum>Expanding</enum> | 278 | <enum>Expanding</enum> |
279 | </property> | 279 | </property> |
280 | <property> | 280 | <property> |
281 | <name>sizeHint</name> | 281 | <name>sizeHint</name> |
282 | <size> | 282 | <size> |
283 | <width>20</width> | 283 | <width>20</width> |
284 | <height>20</height> | 284 | <height>20</height> |
285 | </size> | 285 | </size> |
286 | </property> | 286 | </property> |
287 | </spacer> | 287 | </spacer> |
288 | <widget> | 288 | <widget> |
289 | <class>QPushButton</class> | 289 | <class>QPushButton</class> |
290 | <property stdset="1"> | 290 | <property stdset="1"> |
291 | <name>name</name> | 291 | <name>name</name> |
292 | <cstring>advancedButton</cstring> | 292 | <cstring>advancedButton</cstring> |
293 | </property> | 293 | </property> |
294 | <property stdset="1"> | 294 | <property stdset="1"> |
295 | <name>text</name> | 295 | <name>text</name> |
296 | <string>View Advanced Information</string> | 296 | <string>View &Advanced Information</string> |
297 | </property> | 297 | </property> |
298 | </widget> | 298 | </widget> |
299 | </hbox> | 299 | </hbox> |
300 | </widget> | 300 | </widget> |
301 | <widget row="5" column="0" rowspan="1" colspan="2" > | 301 | <widget row="5" column="0" rowspan="1" colspan="2" > |
302 | <class>Line</class> | 302 | <class>Line</class> |
303 | <property stdset="1"> | 303 | <property stdset="1"> |
304 | <name>name</name> | 304 | <name>name</name> |
305 | <cstring>Line5</cstring> | 305 | <cstring>Line5</cstring> |
306 | </property> | 306 | </property> |
307 | <property stdset="1"> | 307 | <property stdset="1"> |
308 | <name>orientation</name> | 308 | <name>orientation</name> |
309 | <enum>Horizontal</enum> | 309 | <enum>Horizontal</enum> |
310 | </property> | 310 | </property> |
311 | </widget> | 311 | </widget> |
312 | </grid> | 312 | </grid> |
313 | </widget> | 313 | </widget> |
314 | <customwidgets> | 314 | <customwidgets> |
315 | <customwidget> | 315 | <customwidget> |
316 | <class>QWidget</class> | 316 | <class>QWidget</class> |
317 | <header location="local">qwidget.h</header> | 317 | <header location="local">qwidget.h</header> |
318 | <sizehint> | 318 | <sizehint> |
319 | <width>100</width> | 319 | <width>100</width> |
320 | <height>100</height> | 320 | <height>100</height> |
321 | </sizehint> | 321 | </sizehint> |
322 | <container>0</container> | 322 | <container>0</container> |
323 | <sizepolicy> | 323 | <sizepolicy> |
324 | <hordata>7</hordata> | 324 | <hordata>7</hordata> |
325 | <verdata>7</verdata> | 325 | <verdata>7</verdata> |
326 | </sizepolicy> | 326 | </sizepolicy> |
327 | <pixmap>image0</pixmap> | 327 | <pixmap>image0</pixmap> |
328 | </customwidget> | 328 | </customwidget> |
329 | </customwidgets> | 329 | </customwidgets> |
330 | <images> | 330 | <images> |
331 | <image> | 331 | <image> |
332 | <name>image0</name> | 332 | <name>image0</name> |
333 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | 333 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> |
334 | </image> | 334 | </image> |
335 | </images> | 335 | </images> |
336 | <connections> | ||
337 | </connections> | ||
338 | <tabstops> | 336 | <tabstops> |
339 | <tabstop>startButton</tabstop> | 337 | <tabstop>startButton</tabstop> |
340 | <tabstop>stopButton</tabstop> | 338 | <tabstop>stopButton</tabstop> |
341 | <tabstop>refreshButton</tabstop> | 339 | <tabstop>refreshButton</tabstop> |
342 | <tabstop>restartButton</tabstop> | 340 | <tabstop>restartButton</tabstop> |
343 | <tabstop>advancedButton</tabstop> | 341 | <tabstop>advancedButton</tabstop> |
344 | </tabstops> | 342 | </tabstops> |
345 | </UI> | 343 | </UI> |
diff --git a/noncore/net/networksetup/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp index 9155890..377a6db 100644 --- a/noncore/net/networksetup/interfaces.cpp +++ b/noncore/net/networksetup/interfaces.cpp | |||
@@ -30,49 +30,49 @@ Interfaces::Interfaces(QString useInterfacesFile){ | |||
30 | QTextStream stream( &file ); | 30 | QTextStream stream( &file ); |
31 | QString line; | 31 | QString line; |
32 | while ( !stream.eof() ) { | 32 | while ( !stream.eof() ) { |
33 | line += stream.readLine(); | 33 | line += stream.readLine(); |
34 | line += "\n"; | 34 | line += "\n"; |
35 | } | 35 | } |
36 | file.close(); | 36 | file.close(); |
37 | interfaces = QStringList::split("\n", line, true); | 37 | interfaces = QStringList::split("\n", line, true); |
38 | 38 | ||
39 | currentIface = interfaces.end(); | 39 | currentIface = interfaces.end(); |
40 | currentMapping = interfaces.end(); | 40 | currentMapping = interfaces.end(); |
41 | } | 41 | } |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Get a list of all interfaces in the interface file. Usefull for | 45 | * Get a list of all interfaces in the interface file. Usefull for |
46 | * hardware that is not currently connected such as an 802.11b card | 46 | * hardware that is not currently connected such as an 802.11b card |
47 | * not plugged in, but configured for when it is plugged in. | 47 | * not plugged in, but configured for when it is plugged in. |
48 | * @return Return string list of interfaces. | 48 | * @return Return string list of interfaces. |
49 | **/ | 49 | **/ |
50 | QStringList Interfaces::getInterfaceList(){ | 50 | QStringList Interfaces::getInterfaceList(){ |
51 | QStringList list; | 51 | QStringList list; |
52 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 52 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
53 | QString line = (*it).simplifyWhiteSpace(); | 53 | QString line = (*it).simplifyWhiteSpace(); |
54 | if(line.contains(IFACE)){ | 54 | if(line.contains(IFACE) && line.at(0) != '#'){ |
55 | line = line.mid(QString(IFACE).length() +1, line.length()); | 55 | line = line.mid(QString(IFACE).length() +1, line.length()); |
56 | line = line.simplifyWhiteSpace(); | 56 | line = line.simplifyWhiteSpace(); |
57 | int findSpace = line.find(" "); | 57 | int findSpace = line.find(" "); |
58 | if( findSpace >= 0){ | 58 | if( findSpace >= 0){ |
59 | line = line.mid(0, findSpace); | 59 | line = line.mid(0, findSpace); |
60 | list.append(line); | 60 | list.append(line); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | return list; | 64 | return list; |
65 | } | 65 | } |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Find out if interface is in an "auto" group or not. | 68 | * Find out if interface is in an "auto" group or not. |
69 | * Report any duplicates such as eth0 being in two differnt auto's | 69 | * Report any duplicates such as eth0 being in two differnt auto's |
70 | * @param interface interface to check to see if it is on or not. | 70 | * @param interface interface to check to see if it is on or not. |
71 | * @return true is interface is in auto | 71 | * @return true is interface is in auto |
72 | */ | 72 | */ |
73 | bool Interfaces::isAuto(QString interface){ | 73 | bool Interfaces::isAuto(QString interface){ |
74 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | 74 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); |
75 | QStringList awi = autoLines.grep(QRegExp(interface)); | 75 | QStringList awi = autoLines.grep(QRegExp(interface)); |
76 | if(awi.count() > 1) | 76 | if(awi.count() > 1) |
77 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); | 77 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); |
78 | if(awi.count() < 1) | 78 | if(awi.count() < 1) |
@@ -436,126 +436,126 @@ bool Interfaces::setScript(QString argument){ | |||
436 | return setOption(currentMapping, "script", argument); | 436 | return setOption(currentMapping, "script", argument); |
437 | } | 437 | } |
438 | 438 | ||
439 | /** | 439 | /** |
440 | * @param error true if could not retrieve the current script argument. | 440 | * @param error true if could not retrieve the current script argument. |
441 | * @return QString the argument of the script for the current mapping. | 441 | * @return QString the argument of the script for the current mapping. |
442 | */ | 442 | */ |
443 | QString Interfaces::getScript(bool &error){ | 443 | QString Interfaces::getScript(bool &error){ |
444 | return getOption(currentMapping, "script", error); | 444 | return getOption(currentMapping, "script", error); |
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(QString stanza, QString option, QStringList::Iterator &iterator){ | 455 | bool Interfaces::setStanza(QString stanza, 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)){ | 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 | */ |
492 | bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ | 492 | bool Interfaces::setOption(QStringList::Iterator start, QString option, 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){ | 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 | * Removes a option in a stanza | 522 | * Removes a option in a stanza |
523 | * @param start the start of the stanza | 523 | * @param start the start of the stanza |
524 | * @param option the option to use when setting value. | 524 | * @param option the option to use when setting value. |
525 | * @return bool true if successfull, false otherwise. | 525 | * @return bool true if successfull, false otherwise. |
526 | */ | 526 | */ |
527 | bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ | 527 | bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ |
528 | if(start == interfaces.end()) | 528 | if(start == interfaces.end()) |
529 | return false; | 529 | return false; |
530 | 530 | ||
531 | bool found = false; | 531 | bool found = false; |
532 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 532 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
533 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 533 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
534 | // got to the end without finding it | 534 | // got to the end without finding it |
535 | break; | 535 | break; |
536 | } | 536 | } |
537 | if((*it).contains(option) && (*it).contains(value) &&it != start){ | 537 | if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ |
538 | // Found it in stanza so replace it. | 538 | // Found it in stanza so replace it. |
539 | if(found) | 539 | if(found) |
540 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 540 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
541 | found = true; | 541 | found = true; |
542 | (*it) = ""; | 542 | (*it) = ""; |
543 | } | 543 | } |
544 | } | 544 | } |
545 | return found; | 545 | return found; |
546 | } | 546 | } |
547 | 547 | ||
548 | /** | 548 | /** |
549 | * Removes all options in a stanza | 549 | * Removes all options in a stanza |
550 | * @param start the start of the stanza | 550 | * @param start the start of the stanza |
551 | * @return bool true if successfull, false otherwise. | 551 | * @return bool true if successfull, false otherwise. |
552 | */ | 552 | */ |
553 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ | 553 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ |
554 | if(start == interfaces.end()) | 554 | if(start == interfaces.end()) |
555 | return false; | 555 | return false; |
556 | 556 | ||
557 | QStringList::Iterator it = start; | 557 | QStringList::Iterator it = start; |
558 | it = ++it; | 558 | it = ++it; |
559 | for (it; it != interfaces.end(); ++it ) { | 559 | for (it; it != interfaces.end(); ++it ) { |
560 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 560 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
561 | break; | 561 | break; |
@@ -566,49 +566,49 @@ bool Interfaces::removeAllOptions(QStringList::Iterator start){ | |||
566 | // Leave a space between this interface and the next. | 566 | // Leave a space between this interface and the next. |
567 | interfaces.insert(it, QString("")); | 567 | interfaces.insert(it, QString("")); |
568 | return true; | 568 | return true; |
569 | } | 569 | } |
570 | 570 | ||
571 | /** | 571 | /** |
572 | * Gets a value of an option in a stanza | 572 | * Gets a value of an option in a stanza |
573 | * @param start the start of the stanza | 573 | * @param start the start of the stanza |
574 | * @param option the option to use when getting the value. | 574 | * @param option the option to use when getting the value. |
575 | * @param bool true if errors false otherwise. | 575 | * @param bool true if errors false otherwise. |
576 | * @return QString the value of option QString::null() if error == true. | 576 | * @return QString the value of option QString::null() if error == true. |
577 | */ | 577 | */ |
578 | QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ | 578 | QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ |
579 | if(start == interfaces.end()){ | 579 | if(start == interfaces.end()){ |
580 | error = false; | 580 | error = false; |
581 | return QString(); | 581 | return QString(); |
582 | } | 582 | } |
583 | 583 | ||
584 | QString value; | 584 | QString value; |
585 | bool found = false; | 585 | bool found = false; |
586 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 586 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
587 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 587 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
588 | break; | 588 | break; |
589 | } | 589 | } |
590 | if((*it).contains(option)){ | 590 | if((*it).contains(option) && (*it).at(0) != '#'){ |
591 | if(found) | 591 | if(found) |
592 | qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); | 592 | qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); |
593 | found = true; | 593 | found = true; |
594 | QString line = (*it).simplifyWhiteSpace(); | 594 | QString line = (*it).simplifyWhiteSpace(); |
595 | int space = line.find(" ", option.length()); | 595 | int space = line.find(" ", option.length()); |
596 | if(space != -1) | 596 | if(space != -1) |
597 | value = line.mid(space+1, line.length()); | 597 | value = line.mid(space+1, line.length()); |
598 | else | 598 | else |
599 | qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); | 599 | qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | error = !found; | 602 | error = !found; |
603 | return value; | 603 | return value; |
604 | } | 604 | } |
605 | 605 | ||
606 | /** | 606 | /** |
607 | * Write out the interfaces file to the file passed into the constructor. | 607 | * Write out the interfaces file to the file passed into the constructor. |
608 | * Removes any excess blank lines over 1 line long. | 608 | * Removes any excess blank lines over 1 line long. |
609 | * @return bool true if successfull, false if not. | 609 | * @return bool true if successfull, false if not. |
610 | */ | 610 | */ |
611 | bool Interfaces::write(){ | 611 | bool Interfaces::write(){ |
612 | QFile::remove(interfacesFile); | 612 | QFile::remove(interfacesFile); |
613 | QFile file(interfacesFile); | 613 | QFile file(interfacesFile); |
614 | 614 | ||
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 01063c2..8e4e898 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -211,95 +211,95 @@ void MainWindowImp::removeClicked(){ | |||
211 | } | 211 | } |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Pull up the configure about the currently selected interface. | 214 | * Pull up the configure about the currently selected interface. |
215 | * Report an error if no interface is selected. | 215 | * Report an error if no interface is selected. |
216 | * If the interface has a module owner then request its configure with a empty | 216 | * If the interface has a module owner then request its configure with a empty |
217 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 217 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
218 | */ | 218 | */ |
219 | void MainWindowImp::configureClicked(){ | 219 | void MainWindowImp::configureClicked(){ |
220 | QListViewItem *item = connectionList->currentItem(); | 220 | QListViewItem *item = connectionList->currentItem(); |
221 | if(!item){ | 221 | if(!item){ |
222 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 222 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | 225 | ||
226 | QString currentProfile = currentProfileLabel->text(); | 226 | QString currentProfile = currentProfileLabel->text(); |
227 | if(profilesList->count() <= 1 || currentProfile == "All"){ | 227 | if(profilesList->count() <= 1 || currentProfile == "All"){ |
228 | currentProfile = ""; | 228 | currentProfile = ""; |
229 | } | 229 | } |
230 | 230 | ||
231 | Interface *i = interfaceItems[item]; | 231 | Interface *i = interfaceItems[item]; |
232 | if(i->getModuleOwner()){ | 232 | if(i->getModuleOwner()){ |
233 | i->getModuleOwner()->setProfile(currentProfile); | 233 | i->getModuleOwner()->setProfile(currentProfile); |
234 | QTabWidget *tabWidget = NULL; | 234 | QTabWidget *tabWidget = NULL; |
235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); |
236 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
237 | if(tabWidget != NULL){ | 237 | if(tabWidget != NULL){ |
238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
239 | configure->setProfile(currentProfile); | 239 | configure->setProfile(currentProfile); |
240 | tabWidget->insertTab(configure, "TCP/IP"); | 240 | tabWidget->insertTab(configure, "TCP/IP"); |
241 | 241 | ||
242 | } | 242 | } |
243 | moduleConfigure->showMaximized(); | 243 | moduleConfigure->showMaximized(); |
244 | moduleConfigure->show(); | 244 | moduleConfigure->show(); |
245 | return; | 245 | return; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); | 249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); |
250 | configure->setProfile(currentProfile); | 250 | configure->setProfile(currentProfile); |
251 | configure->showMaximized(); | 251 | configure->showMaximized(); |
252 | configure->show(); | 252 | configure->show(); |
253 | } | 253 | } |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * Pull up the information about the currently selected interface. | 256 | * Pull up the information about the currently selected interface. |
257 | * Report an error if no interface is selected. | 257 | * Report an error if no interface is selected. |
258 | * If the interface has a module owner then request its configure with a empty | 258 | * If the interface has a module owner then request its configure with a empty |
259 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 259 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
260 | */ | 260 | */ |
261 | void MainWindowImp::informationClicked(){ | 261 | void MainWindowImp::informationClicked(){ |
262 | QListViewItem *item = connectionList->currentItem(); | 262 | QListViewItem *item = connectionList->currentItem(); |
263 | if(!item){ | 263 | if(!item){ |
264 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 264 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | Interface *i = interfaceItems[item]; | 268 | Interface *i = interfaceItems[item]; |
269 | if(!i->isAttached()){ | 269 | if(!i->isAttached()){ |
270 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); | 270 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | QStringList list; | 274 | QStringList list; |
275 | for(uint i = 0; i < profilesList->count(); i++){ | 275 | for(uint i = 0; i < profilesList->count(); i++){ |
276 | list.append(profilesList->text(i)); | 276 | list.append(profilesList->text(i)); |
277 | } | 277 | } |
278 | 278 | ||
279 | if(i->getModuleOwner()){ | 279 | if(i->getModuleOwner()){ |
280 | QTabWidget *tabWidget = NULL; | 280 | QTabWidget *tabWidget = NULL; |
281 | QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); | 281 | QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); |
282 | if(moduleInformation != NULL){ | 282 | if(moduleInformation != NULL){ |
283 | if(tabWidget != NULL){ | 283 | if(tabWidget != NULL){ |
284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); | 284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); |
285 | tabWidget->insertTab(information, "TCP/IP"); | 285 | tabWidget->insertTab(information, "TCP/IP"); |
286 | } | 286 | } |
287 | moduleInformation->showMaximized(); | 287 | moduleInformation->showMaximized(); |
288 | moduleInformation->show(); | 288 | moduleInformation->show(); |
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); | 293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); |
294 | information->showMaximized(); | 294 | information->showMaximized(); |
295 | information->show(); | 295 | information->show(); |
296 | } | 296 | } |
297 | 297 | ||
298 | /** | 298 | /** |
299 | * Aquire the list of active interfaces from ifconfig | 299 | * Aquire the list of active interfaces from ifconfig |
300 | * Call ifconfig and ifconfig -a | 300 | * Call ifconfig and ifconfig -a |
301 | */ | 301 | */ |
302 | void MainWindowImp::getInterfaceList(){ | 302 | void MainWindowImp::getInterfaceList(){ |
303 | KShellProcess *processAll = new KShellProcess(); | 303 | KShellProcess *processAll = new KShellProcess(); |
304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
305 | connect(processAll, SIGNAL(processExited(KProcess *)), | 305 | connect(processAll, SIGNAL(processExited(KProcess *)), |
diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h index a30f492..96db5b3 100644 --- a/noncore/net/networksetup/module.h +++ b/noncore/net/networksetup/module.h | |||
@@ -8,70 +8,72 @@ | |||
8 | 8 | ||
9 | class QWidget; | 9 | class QWidget; |
10 | class QTabWidget; | 10 | class QTabWidget; |
11 | 11 | ||
12 | class Module : QObject{ | 12 | class Module : QObject{ |
13 | 13 | ||
14 | signals: | 14 | signals: |
15 | void updateInterface(Interface *i); | 15 | void updateInterface(Interface *i); |
16 | 16 | ||
17 | public: | 17 | public: |
18 | Module(){}; | 18 | Module(){}; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * The current profile has been changed and the module should do any | 21 | * The current profile has been changed and the module should do any |
22 | * neccesary changes also. | 22 | * neccesary changes also. |
23 | * @param newProfile what the profile should be changed to. | 23 | * @param newProfile what the profile should be changed to. |
24 | */ | 24 | */ |
25 | virtual void setProfile(QString newProfile) = 0; | 25 | virtual void setProfile(QString newProfile) = 0; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * get the icon name for this device. | 28 | * get the icon name for this device. |
29 | * @param Interface* can be used in determining the icon. | 29 | * @param Interface* can be used in determining the icon. |
30 | * @return QString the icon name (minus .png, .gif etc) | 30 | * @return QString the icon name (minus .png, .gif etc) |
31 | */ | 31 | */ |
32 | virtual QString getPixmapName(Interface* i) = 0; | 32 | virtual QString getPixmapName(Interface *) = 0; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Check to see if the interface i is owned by this module. | 35 | * Check to see if the interface i is owned by this module. |
36 | * @param Interface* interface to check against | 36 | * @param Interface* interface to check against |
37 | * @return bool true if i is owned by this module, false otherwise. | 37 | * @return bool true if i is owned by this module, false otherwise. |
38 | */ | 38 | */ |
39 | virtual bool isOwner(Interface *){ return false; }; | 39 | virtual bool isOwner(Interface *){ return false; }; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Create, set tabWiget and return the WLANConfigure Module | 42 | * Create, set tabWiget and return the WLANConfigure Module |
43 | * @param Interface *i the interface to configure. | ||
43 | * @param tabWidget a pointer to the tab widget that this configure has. | 44 | * @param tabWidget a pointer to the tab widget that this configure has. |
44 | * @return QWidget* pointer to the tab widget in this modules configure. | 45 | * @return QWidget* pointer to the tab widget in this modules configure. |
45 | */ | 46 | */ |
46 | virtual QWidget *configure(QTabWidget **){ return NULL; } ; | 47 | virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ; |
47 | 48 | ||
48 | /** | 49 | /** |
49 | * Create, set tabWiget and return the Information Module | 50 | * Create, set tabWiget and return the Information Module |
51 | * @param Interface *i the interface to get info on. | ||
50 | * @param tabWidget a pointer to the tab widget that this information has. | 52 | * @param tabWidget a pointer to the tab widget that this information has. |
51 | * @return QWidget* pointer to the tab widget in this modules info. | 53 | * @return QWidget* pointer to the tab widget in this modules info. |
52 | */ | 54 | */ |
53 | virtual QWidget *information(QTabWidget **){ return NULL; }; | 55 | virtual QWidget *information(Interface *, QTabWidget **){ return NULL; }; |
54 | 56 | ||
55 | /** | 57 | /** |
56 | * Get all active (up or down) interfaces | 58 | * Get all active (up or down) interfaces |
57 | * @return QList<Interface> A list of interfaces that exsist that havn't | 59 | * @return QList<Interface> A list of interfaces that exsist that havn't |
58 | * been called by isOwner() | 60 | * been called by isOwner() |
59 | */ | 61 | */ |
60 | virtual QList<Interface> getInterfaces() = 0; | 62 | virtual QList<Interface> getInterfaces() = 0; |
61 | 63 | ||
62 | /** | 64 | /** |
63 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), | 65 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), |
64 | * modem ppp) | 66 | * modem ppp) |
65 | */ | 67 | */ |
66 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; | 68 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; |
67 | 69 | ||
68 | /** | 70 | /** |
69 | * Attempts to create a new interface from name | 71 | * Attempts to create a new interface from name |
70 | * @return Interface* NULL if it was unable to be created. | 72 | * @return Interface* NULL if it was unable to be created. |
71 | * @param name the type of interface to create | 73 | * @param name the type of interface to create |
72 | */ | 74 | */ |
73 | virtual Interface *addNewInterface(QString name) = 0; | 75 | virtual Interface *addNewInterface(QString name) = 0; |
74 | 76 | ||
75 | /** | 77 | /** |
76 | * Attempts to remove the interface, doesn't delete i | 78 | * Attempts to remove the interface, doesn't delete i |
77 | * @return bool true if successfull, false otherwise. | 79 | * @return bool true if successfull, false otherwise. |
diff --git a/noncore/settings/networksettings/interfaceinformation.ui b/noncore/settings/networksettings/interfaceinformation.ui index fc99fce..2838d19 100644 --- a/noncore/settings/networksettings/interfaceinformation.ui +++ b/noncore/settings/networksettings/interfaceinformation.ui | |||
@@ -30,82 +30,82 @@ | |||
30 | </property> | 30 | </property> |
31 | <widget row="4" column="0" rowspan="1" colspan="2" > | 31 | <widget row="4" column="0" rowspan="1" colspan="2" > |
32 | <class>QLayoutWidget</class> | 32 | <class>QLayoutWidget</class> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>name</name> | 34 | <name>name</name> |
35 | <cstring>Layout1</cstring> | 35 | <cstring>Layout1</cstring> |
36 | </property> | 36 | </property> |
37 | <grid> | 37 | <grid> |
38 | <property stdset="1"> | 38 | <property stdset="1"> |
39 | <name>margin</name> | 39 | <name>margin</name> |
40 | <number>0</number> | 40 | <number>0</number> |
41 | </property> | 41 | </property> |
42 | <property stdset="1"> | 42 | <property stdset="1"> |
43 | <name>spacing</name> | 43 | <name>spacing</name> |
44 | <number>6</number> | 44 | <number>6</number> |
45 | </property> | 45 | </property> |
46 | <widget row="1" column="0" > | 46 | <widget row="1" column="0" > |
47 | <class>QPushButton</class> | 47 | <class>QPushButton</class> |
48 | <property stdset="1"> | 48 | <property stdset="1"> |
49 | <name>name</name> | 49 | <name>name</name> |
50 | <cstring>refreshButton</cstring> | 50 | <cstring>refreshButton</cstring> |
51 | </property> | 51 | </property> |
52 | <property stdset="1"> | 52 | <property stdset="1"> |
53 | <name>text</name> | 53 | <name>text</name> |
54 | <string>Refresh</string> | 54 | <string>&Refresh</string> |
55 | </property> | 55 | </property> |
56 | </widget> | 56 | </widget> |
57 | <widget row="0" column="1" > | 57 | <widget row="0" column="1" > |
58 | <class>QPushButton</class> | 58 | <class>QPushButton</class> |
59 | <property stdset="1"> | 59 | <property stdset="1"> |
60 | <name>name</name> | 60 | <name>name</name> |
61 | <cstring>stopButton</cstring> | 61 | <cstring>stopButton</cstring> |
62 | </property> | 62 | </property> |
63 | <property stdset="1"> | 63 | <property stdset="1"> |
64 | <name>text</name> | 64 | <name>text</name> |
65 | <string>Stop</string> | 65 | <string>S&top</string> |
66 | </property> | 66 | </property> |
67 | </widget> | 67 | </widget> |
68 | <widget row="1" column="1" > | 68 | <widget row="1" column="1" > |
69 | <class>QPushButton</class> | 69 | <class>QPushButton</class> |
70 | <property stdset="1"> | 70 | <property stdset="1"> |
71 | <name>name</name> | 71 | <name>name</name> |
72 | <cstring>restartButton</cstring> | 72 | <cstring>restartButton</cstring> |
73 | </property> | 73 | </property> |
74 | <property stdset="1"> | 74 | <property stdset="1"> |
75 | <name>text</name> | 75 | <name>text</name> |
76 | <string>Restart</string> | 76 | <string>R&estart</string> |
77 | </property> | 77 | </property> |
78 | </widget> | 78 | </widget> |
79 | <widget row="0" column="0" > | 79 | <widget row="0" column="0" > |
80 | <class>QPushButton</class> | 80 | <class>QPushButton</class> |
81 | <property stdset="1"> | 81 | <property stdset="1"> |
82 | <name>name</name> | 82 | <name>name</name> |
83 | <cstring>startButton</cstring> | 83 | <cstring>startButton</cstring> |
84 | </property> | 84 | </property> |
85 | <property stdset="1"> | 85 | <property stdset="1"> |
86 | <name>text</name> | 86 | <name>text</name> |
87 | <string>Start</string> | 87 | <string>&Start</string> |
88 | </property> | 88 | </property> |
89 | </widget> | 89 | </widget> |
90 | </grid> | 90 | </grid> |
91 | </widget> | 91 | </widget> |
92 | <widget row="0" column="0" > | 92 | <widget row="0" column="0" > |
93 | <class>Line</class> | 93 | <class>Line</class> |
94 | <property stdset="1"> | 94 | <property stdset="1"> |
95 | <name>name</name> | 95 | <name>name</name> |
96 | <cstring>Line1</cstring> | 96 | <cstring>Line1</cstring> |
97 | </property> | 97 | </property> |
98 | <property stdset="1"> | 98 | <property stdset="1"> |
99 | <name>orientation</name> | 99 | <name>orientation</name> |
100 | <enum>Horizontal</enum> | 100 | <enum>Horizontal</enum> |
101 | </property> | 101 | </property> |
102 | </widget> | 102 | </widget> |
103 | <widget row="0" column="0" > | 103 | <widget row="0" column="0" > |
104 | <class>QLabel</class> | 104 | <class>QLabel</class> |
105 | <property stdset="1"> | 105 | <property stdset="1"> |
106 | <name>name</name> | 106 | <name>name</name> |
107 | <cstring>TextLabel22</cstring> | 107 | <cstring>TextLabel22</cstring> |
108 | </property> | 108 | </property> |
109 | <property stdset="1"> | 109 | <property stdset="1"> |
110 | <name>text</name> | 110 | <name>text</name> |
111 | <string>IP Address</string> | 111 | <string>IP Address</string> |
@@ -272,74 +272,72 @@ | |||
272 | <property stdset="1"> | 272 | <property stdset="1"> |
273 | <name>orientation</name> | 273 | <name>orientation</name> |
274 | <enum>Horizontal</enum> | 274 | <enum>Horizontal</enum> |
275 | </property> | 275 | </property> |
276 | <property stdset="1"> | 276 | <property stdset="1"> |
277 | <name>sizeType</name> | 277 | <name>sizeType</name> |
278 | <enum>Expanding</enum> | 278 | <enum>Expanding</enum> |
279 | </property> | 279 | </property> |
280 | <property> | 280 | <property> |
281 | <name>sizeHint</name> | 281 | <name>sizeHint</name> |
282 | <size> | 282 | <size> |
283 | <width>20</width> | 283 | <width>20</width> |
284 | <height>20</height> | 284 | <height>20</height> |
285 | </size> | 285 | </size> |
286 | </property> | 286 | </property> |
287 | </spacer> | 287 | </spacer> |
288 | <widget> | 288 | <widget> |
289 | <class>QPushButton</class> | 289 | <class>QPushButton</class> |
290 | <property stdset="1"> | 290 | <property stdset="1"> |
291 | <name>name</name> | 291 | <name>name</name> |
292 | <cstring>advancedButton</cstring> | 292 | <cstring>advancedButton</cstring> |
293 | </property> | 293 | </property> |
294 | <property stdset="1"> | 294 | <property stdset="1"> |
295 | <name>text</name> | 295 | <name>text</name> |
296 | <string>View Advanced Information</string> | 296 | <string>View &Advanced Information</string> |
297 | </property> | 297 | </property> |
298 | </widget> | 298 | </widget> |
299 | </hbox> | 299 | </hbox> |
300 | </widget> | 300 | </widget> |
301 | <widget row="5" column="0" rowspan="1" colspan="2" > | 301 | <widget row="5" column="0" rowspan="1" colspan="2" > |
302 | <class>Line</class> | 302 | <class>Line</class> |
303 | <property stdset="1"> | 303 | <property stdset="1"> |
304 | <name>name</name> | 304 | <name>name</name> |
305 | <cstring>Line5</cstring> | 305 | <cstring>Line5</cstring> |
306 | </property> | 306 | </property> |
307 | <property stdset="1"> | 307 | <property stdset="1"> |
308 | <name>orientation</name> | 308 | <name>orientation</name> |
309 | <enum>Horizontal</enum> | 309 | <enum>Horizontal</enum> |
310 | </property> | 310 | </property> |
311 | </widget> | 311 | </widget> |
312 | </grid> | 312 | </grid> |
313 | </widget> | 313 | </widget> |
314 | <customwidgets> | 314 | <customwidgets> |
315 | <customwidget> | 315 | <customwidget> |
316 | <class>QWidget</class> | 316 | <class>QWidget</class> |
317 | <header location="local">qwidget.h</header> | 317 | <header location="local">qwidget.h</header> |
318 | <sizehint> | 318 | <sizehint> |
319 | <width>100</width> | 319 | <width>100</width> |
320 | <height>100</height> | 320 | <height>100</height> |
321 | </sizehint> | 321 | </sizehint> |
322 | <container>0</container> | 322 | <container>0</container> |
323 | <sizepolicy> | 323 | <sizepolicy> |
324 | <hordata>7</hordata> | 324 | <hordata>7</hordata> |
325 | <verdata>7</verdata> | 325 | <verdata>7</verdata> |
326 | </sizepolicy> | 326 | </sizepolicy> |
327 | <pixmap>image0</pixmap> | 327 | <pixmap>image0</pixmap> |
328 | </customwidget> | 328 | </customwidget> |
329 | </customwidgets> | 329 | </customwidgets> |
330 | <images> | 330 | <images> |
331 | <image> | 331 | <image> |
332 | <name>image0</name> | 332 | <name>image0</name> |
333 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | 333 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> |
334 | </image> | 334 | </image> |
335 | </images> | 335 | </images> |
336 | <connections> | ||
337 | </connections> | ||
338 | <tabstops> | 336 | <tabstops> |
339 | <tabstop>startButton</tabstop> | 337 | <tabstop>startButton</tabstop> |
340 | <tabstop>stopButton</tabstop> | 338 | <tabstop>stopButton</tabstop> |
341 | <tabstop>refreshButton</tabstop> | 339 | <tabstop>refreshButton</tabstop> |
342 | <tabstop>restartButton</tabstop> | 340 | <tabstop>restartButton</tabstop> |
343 | <tabstop>advancedButton</tabstop> | 341 | <tabstop>advancedButton</tabstop> |
344 | </tabstops> | 342 | </tabstops> |
345 | </UI> | 343 | </UI> |
diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp index 9155890..377a6db 100644 --- a/noncore/settings/networksettings/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces.cpp | |||
@@ -30,49 +30,49 @@ Interfaces::Interfaces(QString useInterfacesFile){ | |||
30 | QTextStream stream( &file ); | 30 | QTextStream stream( &file ); |
31 | QString line; | 31 | QString line; |
32 | while ( !stream.eof() ) { | 32 | while ( !stream.eof() ) { |
33 | line += stream.readLine(); | 33 | line += stream.readLine(); |
34 | line += "\n"; | 34 | line += "\n"; |
35 | } | 35 | } |
36 | file.close(); | 36 | file.close(); |
37 | interfaces = QStringList::split("\n", line, true); | 37 | interfaces = QStringList::split("\n", line, true); |
38 | 38 | ||
39 | currentIface = interfaces.end(); | 39 | currentIface = interfaces.end(); |
40 | currentMapping = interfaces.end(); | 40 | currentMapping = interfaces.end(); |
41 | } | 41 | } |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Get a list of all interfaces in the interface file. Usefull for | 45 | * Get a list of all interfaces in the interface file. Usefull for |
46 | * hardware that is not currently connected such as an 802.11b card | 46 | * hardware that is not currently connected such as an 802.11b card |
47 | * not plugged in, but configured for when it is plugged in. | 47 | * not plugged in, but configured for when it is plugged in. |
48 | * @return Return string list of interfaces. | 48 | * @return Return string list of interfaces. |
49 | **/ | 49 | **/ |
50 | QStringList Interfaces::getInterfaceList(){ | 50 | QStringList Interfaces::getInterfaceList(){ |
51 | QStringList list; | 51 | QStringList list; |
52 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 52 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
53 | QString line = (*it).simplifyWhiteSpace(); | 53 | QString line = (*it).simplifyWhiteSpace(); |
54 | if(line.contains(IFACE)){ | 54 | if(line.contains(IFACE) && line.at(0) != '#'){ |
55 | line = line.mid(QString(IFACE).length() +1, line.length()); | 55 | line = line.mid(QString(IFACE).length() +1, line.length()); |
56 | line = line.simplifyWhiteSpace(); | 56 | line = line.simplifyWhiteSpace(); |
57 | int findSpace = line.find(" "); | 57 | int findSpace = line.find(" "); |
58 | if( findSpace >= 0){ | 58 | if( findSpace >= 0){ |
59 | line = line.mid(0, findSpace); | 59 | line = line.mid(0, findSpace); |
60 | list.append(line); | 60 | list.append(line); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | return list; | 64 | return list; |
65 | } | 65 | } |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Find out if interface is in an "auto" group or not. | 68 | * Find out if interface is in an "auto" group or not. |
69 | * Report any duplicates such as eth0 being in two differnt auto's | 69 | * Report any duplicates such as eth0 being in two differnt auto's |
70 | * @param interface interface to check to see if it is on or not. | 70 | * @param interface interface to check to see if it is on or not. |
71 | * @return true is interface is in auto | 71 | * @return true is interface is in auto |
72 | */ | 72 | */ |
73 | bool Interfaces::isAuto(QString interface){ | 73 | bool Interfaces::isAuto(QString interface){ |
74 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | 74 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); |
75 | QStringList awi = autoLines.grep(QRegExp(interface)); | 75 | QStringList awi = autoLines.grep(QRegExp(interface)); |
76 | if(awi.count() > 1) | 76 | if(awi.count() > 1) |
77 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); | 77 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); |
78 | if(awi.count() < 1) | 78 | if(awi.count() < 1) |
@@ -436,126 +436,126 @@ bool Interfaces::setScript(QString argument){ | |||
436 | return setOption(currentMapping, "script", argument); | 436 | return setOption(currentMapping, "script", argument); |
437 | } | 437 | } |
438 | 438 | ||
439 | /** | 439 | /** |
440 | * @param error true if could not retrieve the current script argument. | 440 | * @param error true if could not retrieve the current script argument. |
441 | * @return QString the argument of the script for the current mapping. | 441 | * @return QString the argument of the script for the current mapping. |
442 | */ | 442 | */ |
443 | QString Interfaces::getScript(bool &error){ | 443 | QString Interfaces::getScript(bool &error){ |
444 | return getOption(currentMapping, "script", error); | 444 | return getOption(currentMapping, "script", error); |
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(QString stanza, QString option, QStringList::Iterator &iterator){ | 455 | bool Interfaces::setStanza(QString stanza, 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)){ | 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 | */ |
492 | bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ | 492 | bool Interfaces::setOption(QStringList::Iterator start, QString option, 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){ | 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 | * Removes a option in a stanza | 522 | * Removes a option in a stanza |
523 | * @param start the start of the stanza | 523 | * @param start the start of the stanza |
524 | * @param option the option to use when setting value. | 524 | * @param option the option to use when setting value. |
525 | * @return bool true if successfull, false otherwise. | 525 | * @return bool true if successfull, false otherwise. |
526 | */ | 526 | */ |
527 | bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ | 527 | bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ |
528 | if(start == interfaces.end()) | 528 | if(start == interfaces.end()) |
529 | return false; | 529 | return false; |
530 | 530 | ||
531 | bool found = false; | 531 | bool found = false; |
532 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 532 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
533 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 533 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
534 | // got to the end without finding it | 534 | // got to the end without finding it |
535 | break; | 535 | break; |
536 | } | 536 | } |
537 | if((*it).contains(option) && (*it).contains(value) &&it != start){ | 537 | if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ |
538 | // Found it in stanza so replace it. | 538 | // Found it in stanza so replace it. |
539 | if(found) | 539 | if(found) |
540 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 540 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
541 | found = true; | 541 | found = true; |
542 | (*it) = ""; | 542 | (*it) = ""; |
543 | } | 543 | } |
544 | } | 544 | } |
545 | return found; | 545 | return found; |
546 | } | 546 | } |
547 | 547 | ||
548 | /** | 548 | /** |
549 | * Removes all options in a stanza | 549 | * Removes all options in a stanza |
550 | * @param start the start of the stanza | 550 | * @param start the start of the stanza |
551 | * @return bool true if successfull, false otherwise. | 551 | * @return bool true if successfull, false otherwise. |
552 | */ | 552 | */ |
553 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ | 553 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ |
554 | if(start == interfaces.end()) | 554 | if(start == interfaces.end()) |
555 | return false; | 555 | return false; |
556 | 556 | ||
557 | QStringList::Iterator it = start; | 557 | QStringList::Iterator it = start; |
558 | it = ++it; | 558 | it = ++it; |
559 | for (it; it != interfaces.end(); ++it ) { | 559 | for (it; it != interfaces.end(); ++it ) { |
560 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 560 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
561 | break; | 561 | break; |
@@ -566,49 +566,49 @@ bool Interfaces::removeAllOptions(QStringList::Iterator start){ | |||
566 | // Leave a space between this interface and the next. | 566 | // Leave a space between this interface and the next. |
567 | interfaces.insert(it, QString("")); | 567 | interfaces.insert(it, QString("")); |
568 | return true; | 568 | return true; |
569 | } | 569 | } |
570 | 570 | ||
571 | /** | 571 | /** |
572 | * Gets a value of an option in a stanza | 572 | * Gets a value of an option in a stanza |
573 | * @param start the start of the stanza | 573 | * @param start the start of the stanza |
574 | * @param option the option to use when getting the value. | 574 | * @param option the option to use when getting the value. |
575 | * @param bool true if errors false otherwise. | 575 | * @param bool true if errors false otherwise. |
576 | * @return QString the value of option QString::null() if error == true. | 576 | * @return QString the value of option QString::null() if error == true. |
577 | */ | 577 | */ |
578 | QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ | 578 | QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ |
579 | if(start == interfaces.end()){ | 579 | if(start == interfaces.end()){ |
580 | error = false; | 580 | error = false; |
581 | return QString(); | 581 | return QString(); |
582 | } | 582 | } |
583 | 583 | ||
584 | QString value; | 584 | QString value; |
585 | bool found = false; | 585 | bool found = false; |
586 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 586 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
587 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 587 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
588 | break; | 588 | break; |
589 | } | 589 | } |
590 | if((*it).contains(option)){ | 590 | if((*it).contains(option) && (*it).at(0) != '#'){ |
591 | if(found) | 591 | if(found) |
592 | qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); | 592 | qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); |
593 | found = true; | 593 | found = true; |
594 | QString line = (*it).simplifyWhiteSpace(); | 594 | QString line = (*it).simplifyWhiteSpace(); |
595 | int space = line.find(" ", option.length()); | 595 | int space = line.find(" ", option.length()); |
596 | if(space != -1) | 596 | if(space != -1) |
597 | value = line.mid(space+1, line.length()); | 597 | value = line.mid(space+1, line.length()); |
598 | else | 598 | else |
599 | qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); | 599 | qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | error = !found; | 602 | error = !found; |
603 | return value; | 603 | return value; |
604 | } | 604 | } |
605 | 605 | ||
606 | /** | 606 | /** |
607 | * Write out the interfaces file to the file passed into the constructor. | 607 | * Write out the interfaces file to the file passed into the constructor. |
608 | * Removes any excess blank lines over 1 line long. | 608 | * Removes any excess blank lines over 1 line long. |
609 | * @return bool true if successfull, false if not. | 609 | * @return bool true if successfull, false if not. |
610 | */ | 610 | */ |
611 | bool Interfaces::write(){ | 611 | bool Interfaces::write(){ |
612 | QFile::remove(interfacesFile); | 612 | QFile::remove(interfacesFile); |
613 | QFile file(interfacesFile); | 613 | QFile file(interfacesFile); |
614 | 614 | ||
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 01063c2..8e4e898 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -211,95 +211,95 @@ void MainWindowImp::removeClicked(){ | |||
211 | } | 211 | } |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Pull up the configure about the currently selected interface. | 214 | * Pull up the configure about the currently selected interface. |
215 | * Report an error if no interface is selected. | 215 | * Report an error if no interface is selected. |
216 | * If the interface has a module owner then request its configure with a empty | 216 | * If the interface has a module owner then request its configure with a empty |
217 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 217 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
218 | */ | 218 | */ |
219 | void MainWindowImp::configureClicked(){ | 219 | void MainWindowImp::configureClicked(){ |
220 | QListViewItem *item = connectionList->currentItem(); | 220 | QListViewItem *item = connectionList->currentItem(); |
221 | if(!item){ | 221 | if(!item){ |
222 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 222 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | 225 | ||
226 | QString currentProfile = currentProfileLabel->text(); | 226 | QString currentProfile = currentProfileLabel->text(); |
227 | if(profilesList->count() <= 1 || currentProfile == "All"){ | 227 | if(profilesList->count() <= 1 || currentProfile == "All"){ |
228 | currentProfile = ""; | 228 | currentProfile = ""; |
229 | } | 229 | } |
230 | 230 | ||
231 | Interface *i = interfaceItems[item]; | 231 | Interface *i = interfaceItems[item]; |
232 | if(i->getModuleOwner()){ | 232 | if(i->getModuleOwner()){ |
233 | i->getModuleOwner()->setProfile(currentProfile); | 233 | i->getModuleOwner()->setProfile(currentProfile); |
234 | QTabWidget *tabWidget = NULL; | 234 | QTabWidget *tabWidget = NULL; |
235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); |
236 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
237 | if(tabWidget != NULL){ | 237 | if(tabWidget != NULL){ |
238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
239 | configure->setProfile(currentProfile); | 239 | configure->setProfile(currentProfile); |
240 | tabWidget->insertTab(configure, "TCP/IP"); | 240 | tabWidget->insertTab(configure, "TCP/IP"); |
241 | 241 | ||
242 | } | 242 | } |
243 | moduleConfigure->showMaximized(); | 243 | moduleConfigure->showMaximized(); |
244 | moduleConfigure->show(); | 244 | moduleConfigure->show(); |
245 | return; | 245 | return; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); | 249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); |
250 | configure->setProfile(currentProfile); | 250 | configure->setProfile(currentProfile); |
251 | configure->showMaximized(); | 251 | configure->showMaximized(); |
252 | configure->show(); | 252 | configure->show(); |
253 | } | 253 | } |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * Pull up the information about the currently selected interface. | 256 | * Pull up the information about the currently selected interface. |
257 | * Report an error if no interface is selected. | 257 | * Report an error if no interface is selected. |
258 | * If the interface has a module owner then request its configure with a empty | 258 | * If the interface has a module owner then request its configure with a empty |
259 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 259 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
260 | */ | 260 | */ |
261 | void MainWindowImp::informationClicked(){ | 261 | void MainWindowImp::informationClicked(){ |
262 | QListViewItem *item = connectionList->currentItem(); | 262 | QListViewItem *item = connectionList->currentItem(); |
263 | if(!item){ | 263 | if(!item){ |
264 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 264 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | Interface *i = interfaceItems[item]; | 268 | Interface *i = interfaceItems[item]; |
269 | if(!i->isAttached()){ | 269 | if(!i->isAttached()){ |
270 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); | 270 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | QStringList list; | 274 | QStringList list; |
275 | for(uint i = 0; i < profilesList->count(); i++){ | 275 | for(uint i = 0; i < profilesList->count(); i++){ |
276 | list.append(profilesList->text(i)); | 276 | list.append(profilesList->text(i)); |
277 | } | 277 | } |
278 | 278 | ||
279 | if(i->getModuleOwner()){ | 279 | if(i->getModuleOwner()){ |
280 | QTabWidget *tabWidget = NULL; | 280 | QTabWidget *tabWidget = NULL; |
281 | QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); | 281 | QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); |
282 | if(moduleInformation != NULL){ | 282 | if(moduleInformation != NULL){ |
283 | if(tabWidget != NULL){ | 283 | if(tabWidget != NULL){ |
284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); | 284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); |
285 | tabWidget->insertTab(information, "TCP/IP"); | 285 | tabWidget->insertTab(information, "TCP/IP"); |
286 | } | 286 | } |
287 | moduleInformation->showMaximized(); | 287 | moduleInformation->showMaximized(); |
288 | moduleInformation->show(); | 288 | moduleInformation->show(); |
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); | 293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); |
294 | information->showMaximized(); | 294 | information->showMaximized(); |
295 | information->show(); | 295 | information->show(); |
296 | } | 296 | } |
297 | 297 | ||
298 | /** | 298 | /** |
299 | * Aquire the list of active interfaces from ifconfig | 299 | * Aquire the list of active interfaces from ifconfig |
300 | * Call ifconfig and ifconfig -a | 300 | * Call ifconfig and ifconfig -a |
301 | */ | 301 | */ |
302 | void MainWindowImp::getInterfaceList(){ | 302 | void MainWindowImp::getInterfaceList(){ |
303 | KShellProcess *processAll = new KShellProcess(); | 303 | KShellProcess *processAll = new KShellProcess(); |
304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
305 | connect(processAll, SIGNAL(processExited(KProcess *)), | 305 | connect(processAll, SIGNAL(processExited(KProcess *)), |
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h index a30f492..96db5b3 100644 --- a/noncore/settings/networksettings/module.h +++ b/noncore/settings/networksettings/module.h | |||
@@ -8,70 +8,72 @@ | |||
8 | 8 | ||
9 | class QWidget; | 9 | class QWidget; |
10 | class QTabWidget; | 10 | class QTabWidget; |
11 | 11 | ||
12 | class Module : QObject{ | 12 | class Module : QObject{ |
13 | 13 | ||
14 | signals: | 14 | signals: |
15 | void updateInterface(Interface *i); | 15 | void updateInterface(Interface *i); |
16 | 16 | ||
17 | public: | 17 | public: |
18 | Module(){}; | 18 | Module(){}; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * The current profile has been changed and the module should do any | 21 | * The current profile has been changed and the module should do any |
22 | * neccesary changes also. | 22 | * neccesary changes also. |
23 | * @param newProfile what the profile should be changed to. | 23 | * @param newProfile what the profile should be changed to. |
24 | */ | 24 | */ |
25 | virtual void setProfile(QString newProfile) = 0; | 25 | virtual void setProfile(QString newProfile) = 0; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * get the icon name for this device. | 28 | * get the icon name for this device. |
29 | * @param Interface* can be used in determining the icon. | 29 | * @param Interface* can be used in determining the icon. |
30 | * @return QString the icon name (minus .png, .gif etc) | 30 | * @return QString the icon name (minus .png, .gif etc) |
31 | */ | 31 | */ |
32 | virtual QString getPixmapName(Interface* i) = 0; | 32 | virtual QString getPixmapName(Interface *) = 0; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Check to see if the interface i is owned by this module. | 35 | * Check to see if the interface i is owned by this module. |
36 | * @param Interface* interface to check against | 36 | * @param Interface* interface to check against |
37 | * @return bool true if i is owned by this module, false otherwise. | 37 | * @return bool true if i is owned by this module, false otherwise. |
38 | */ | 38 | */ |
39 | virtual bool isOwner(Interface *){ return false; }; | 39 | virtual bool isOwner(Interface *){ return false; }; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Create, set tabWiget and return the WLANConfigure Module | 42 | * Create, set tabWiget and return the WLANConfigure Module |
43 | * @param Interface *i the interface to configure. | ||
43 | * @param tabWidget a pointer to the tab widget that this configure has. | 44 | * @param tabWidget a pointer to the tab widget that this configure has. |
44 | * @return QWidget* pointer to the tab widget in this modules configure. | 45 | * @return QWidget* pointer to the tab widget in this modules configure. |
45 | */ | 46 | */ |
46 | virtual QWidget *configure(QTabWidget **){ return NULL; } ; | 47 | virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ; |
47 | 48 | ||
48 | /** | 49 | /** |
49 | * Create, set tabWiget and return the Information Module | 50 | * Create, set tabWiget and return the Information Module |
51 | * @param Interface *i the interface to get info on. | ||
50 | * @param tabWidget a pointer to the tab widget that this information has. | 52 | * @param tabWidget a pointer to the tab widget that this information has. |
51 | * @return QWidget* pointer to the tab widget in this modules info. | 53 | * @return QWidget* pointer to the tab widget in this modules info. |
52 | */ | 54 | */ |
53 | virtual QWidget *information(QTabWidget **){ return NULL; }; | 55 | virtual QWidget *information(Interface *, QTabWidget **){ return NULL; }; |
54 | 56 | ||
55 | /** | 57 | /** |
56 | * Get all active (up or down) interfaces | 58 | * Get all active (up or down) interfaces |
57 | * @return QList<Interface> A list of interfaces that exsist that havn't | 59 | * @return QList<Interface> A list of interfaces that exsist that havn't |
58 | * been called by isOwner() | 60 | * been called by isOwner() |
59 | */ | 61 | */ |
60 | virtual QList<Interface> getInterfaces() = 0; | 62 | virtual QList<Interface> getInterfaces() = 0; |
61 | 63 | ||
62 | /** | 64 | /** |
63 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), | 65 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), |
64 | * modem ppp) | 66 | * modem ppp) |
65 | */ | 67 | */ |
66 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; | 68 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; |
67 | 69 | ||
68 | /** | 70 | /** |
69 | * Attempts to create a new interface from name | 71 | * Attempts to create a new interface from name |
70 | * @return Interface* NULL if it was unable to be created. | 72 | * @return Interface* NULL if it was unable to be created. |
71 | * @param name the type of interface to create | 73 | * @param name the type of interface to create |
72 | */ | 74 | */ |
73 | virtual Interface *addNewInterface(QString name) = 0; | 75 | virtual Interface *addNewInterface(QString name) = 0; |
74 | 76 | ||
75 | /** | 77 | /** |
76 | * Attempts to remove the interface, doesn't delete i | 78 | * Attempts to remove the interface, doesn't delete i |
77 | * @return bool true if successfull, false otherwise. | 79 | * @return bool true if successfull, false otherwise. |