summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO8
-rw-r--r--noncore/net/networksetup/interfaceadvanced.ui4
-rw-r--r--noncore/net/networksetup/interfaceinformation.ui6
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.cpp3
-rw-r--r--noncore/net/networksetup/interfaces.cpp17
-rw-r--r--noncore/net/networksetup/interfaces.h2
-rw-r--r--noncore/net/networksetup/interfacesetup.ui97
-rw-r--r--noncore/net/networksetup/interfacesetupimp.cpp39
-rw-r--r--noncore/net/networksetup/interfacesetupimp.h5
-rw-r--r--noncore/net/networksetup/mainwindow.ui18
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp89
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.cpp1
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp2
-rw-r--r--noncore/settings/networksettings/TODO8
-rw-r--r--noncore/settings/networksettings/interfaceadvanced.ui4
-rw-r--r--noncore/settings/networksettings/interfaceinformation.ui6
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.cpp3
-rw-r--r--noncore/settings/networksettings/interfaces.cpp17
-rw-r--r--noncore/settings/networksettings/interfaces.h2
-rw-r--r--noncore/settings/networksettings/interfacesetup.ui97
-rw-r--r--noncore/settings/networksettings/interfacesetupimp.cpp39
-rw-r--r--noncore/settings/networksettings/interfacesetupimp.h5
-rw-r--r--noncore/settings/networksettings/mainwindow.ui18
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp89
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp1
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp2
26 files changed, 310 insertions, 272 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index c8e2989..c587f58 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,10 +1,6 @@
1Write a class that parses /proc and not ifconfig 1Write a class that parses /proc and not ifconfig
2WLAN needs to be re-written to not use Config
3remove WLAN Config item
2 4
3[ ] Wlanmodule needs to check if an interface supports wireless 5[ ] Wlanmodule needs to check if an interface supports wireless
4 extensions. 6 extensions.
5[x] When you set options in wlanmodule, hit OK, it exits all of
6 networksetup, doesnt bring you back to the main screen.
7[x] Wlanmodule isnt writing out wireless.opts
8[ ] Need a means of bringing an interface up and down (calling
9 out ifup/ifdown) from the gui.
10 -Ben- Click information, then click up or down... :-D
diff --git a/noncore/net/networksetup/interfaceadvanced.ui b/noncore/net/networksetup/interfaceadvanced.ui
index efe67b0..0ec67c2 100644
--- a/noncore/net/networksetup/interfaceadvanced.ui
+++ b/noncore/net/networksetup/interfaceadvanced.ui
@@ -15,13 +15,13 @@
15 <height>286</height> 15 <height>286</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>maximumSize</name> 19 <name>maximumSize</name>
20 <size> 20 <size>
21 <width>320</width> 21 <width>240</width>
22 <height>32767</height> 22 <height>32767</height>
23 </size> 23 </size>
24 </property> 24 </property>
25 <property stdset="1"> 25 <property stdset="1">
26 <name>caption</name> 26 <name>caption</name>
27 <string>Advanced Interface Information</string> 27 <string>Advanced Interface Information</string>
@@ -186,13 +186,13 @@
186 </property> 186 </property>
187 </widget> 187 </widget>
188 <widget row="5" column="0" rowspan="1" colspan="2" > 188 <widget row="5" column="0" rowspan="1" colspan="2" >
189 <class>QGroupBox</class> 189 <class>QGroupBox</class>
190 <property stdset="1"> 190 <property stdset="1">
191 <name>name</name> 191 <name>name</name>
192 <cstring>GroupBox2</cstring> 192 <cstring>dhcpInformation</cstring>
193 </property> 193 </property>
194 <property stdset="1"> 194 <property stdset="1">
195 <name>title</name> 195 <name>title</name>
196 <string>DHCP Information</string> 196 <string>DHCP Information</string>
197 </property> 197 </property>
198 <grid> 198 <grid>
diff --git a/noncore/net/networksetup/interfaceinformation.ui b/noncore/net/networksetup/interfaceinformation.ui
index 76af19c..fc99fce 100644
--- a/noncore/net/networksetup/interfaceinformation.ui
+++ b/noncore/net/networksetup/interfaceinformation.ui
@@ -8,14 +8,14 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>199</width> 14 <width>219</width>
15 <height>244</height> 15 <height>255</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Interface Information</string> 20 <string>Interface Information</string>
21 </property> 21 </property>
@@ -330,12 +330,14 @@
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>
336<tabstops> 338<tabstops>
337 <tabstop>startButton</tabstop> 339 <tabstop>startButton</tabstop>
338 <tabstop>stopButton</tabstop> 340 <tabstop>stopButton</tabstop>
339 <tabstop>refreshButton</tabstop> 341 <tabstop>refreshButton</tabstop>
340 <tabstop>restartButton</tabstop> 342 <tabstop>restartButton</tabstop>
341 <tabstop>advancedButton</tabstop> 343 <tabstop>advancedButton</tabstop>
diff --git a/noncore/net/networksetup/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaceinformationimp.cpp
index 59a6400..43483fb 100644
--- a/noncore/net/networksetup/interfaceinformationimp.cpp
+++ b/noncore/net/networksetup/interfaceinformationimp.cpp
@@ -1,11 +1,12 @@
1#include "interfaceinformationimp.h" 1#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h" 2#include "interfaceadvanced.h"
3 3
4#include <qpushbutton.h> 4#include <qpushbutton.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qgroupbox.h>
6#include <assert.h> 7#include <assert.h>
7 8
8/** 9/**
9 * Constructor for the InterfaceInformationImp class. This class pretty much 10 * Constructor for the InterfaceInformationImp class. This class pretty much
10 * just display's information about the interface that is passed to it. 11 * just display's information about the interface that is passed to it.
11 */ 12 */
@@ -56,12 +57,14 @@ void InterfaceInformationImp::advanced(){
56 a->ipAddressLabel->setText(interface->getIp()); 57 a->ipAddressLabel->setText(interface->getIp());
57 a->subnetMaskLabel->setText(interface->getSubnetMask()); 58 a->subnetMaskLabel->setText(interface->getSubnetMask());
58 a->broadcastLabel->setText(interface->getBroadcast()); 59 a->broadcastLabel->setText(interface->getBroadcast());
59 a->dhcpServerLabel->setText(interface->getDhcpServerIp()); 60 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
60 a->leaseObtainedLabel->setText(interface->getLeaseObtained()); 61 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
61 a->leaseExpiresLabel->setText(interface->getLeaseExpires()); 62 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
63 a->dhcpInformation->setEnabled(interface->isDhcp());
64
62 a->showMaximized(); 65 a->showMaximized();
63 a->show(); 66 a->show();
64} 67}
65 68
66// infoimp.cpp 69// infoimp.cpp
67 70
diff --git a/noncore/net/networksetup/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp
index 1287d90..eef42df 100644
--- a/noncore/net/networksetup/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces.cpp
@@ -342,15 +342,15 @@ bool Interfaces::setMapping(QString interface){
342} 342}
343 343
344/** 344/**
345 * Adds a new Mapping to the interfaces file with interfaces. 345 * Adds a new Mapping to the interfaces file with interfaces.
346 * @param interface the name(s) of the interfaces to set to this mapping 346 * @param interface the name(s) of the interfaces to set to this mapping
347 */ 347 */
348void Interfaces::addMapping(QString interfaces){ 348void Interfaces::addMapping(QString option){
349 interfaces.append(""); 349 interfaces.append("");
350 interfaces.append(QString(MAPPING " %1").arg(interfaces)); 350 interfaces.append(QString(MAPPING " %1").arg(option));
351} 351}
352 352
353/** 353/**
354 * Set a map option within a mapping. 354 * Set a map option within a mapping.
355 * @param map map to use 355 * @param map map to use
356 * @param value value to go with map 356 * @param value value to go with map
@@ -401,17 +401,18 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator
401 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 401 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
402 QString line = (*it).simplifyWhiteSpace(); 402 QString line = (*it).simplifyWhiteSpace();
403 if(line.contains(stanza) && line.contains(option)){ 403 if(line.contains(stanza) && line.contains(option)){
404 if(found == true){ 404 if(found == true){
405 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 405 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
406 } 406 }
407 qDebug("Found");
407 found = true; 408 found = true;
408 iterator = it; 409 iterator = it;
409 } 410 }
410 } 411 }
411 return !found; 412 return found;
412} 413}
413 414
414/** 415/**
415 * Sets a value of an option in a stanza 416 * Sets a value of an option in a stanza
416 * @param start the start of the stanza 417 * @param start the start of the stanza
417 * @param option the option to use when setting value. 418 * @param option the option to use when setting value.
@@ -425,26 +426,32 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString
425 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 426 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
426 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 427 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
427 if(!found && value != ""){ 428 if(!found && value != ""){
428 // Got to the end of the stanza without finding it, so append it. 429 // Got to the end of the stanza without finding it, so append it.
429 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 430 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
430 } 431 }
432 found = true;
431 break; 433 break;
432 } 434 }
433 if((*it).contains(option)){ 435 if((*it).contains(option) && it != start){
434 // Found it in stanza so replace it. 436 // Found it in stanza so replace it.
435 if(found) 437 if(found)
436 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 438 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
437 found = true; 439 found = true;
438 if(value == "") 440 if(value == "")
439 (*it) = ""; 441 (*it) = "";
440 else 442 else
441 (*it) = QString("\t%1 %2").arg(option).arg(value); 443 (*it) = QString("\t%1 %2").arg(option).arg(value);
442 } 444 }
443 } 445 }
444 return true; 446 if(!found){
447 QStringList::Iterator p = start;
448 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
449 found = true;
450 }
451 return found;
445} 452}
446 453
447/** 454/**
448 * Removes all options in a stanza 455 * Removes all options in a stanza
449 * @param start the start of the stanza 456 * @param start the start of the stanza
450 * @return bool true if successfull, false otherwise. 457 * @return bool true if successfull, false otherwise.
diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h
index 8b4788c..e617c17 100644
--- a/noncore/net/networksetup/interfaces.h
+++ b/noncore/net/networksetup/interfaces.h
@@ -40,13 +40,13 @@ public:
40 bool setInterfaceMethod(QString newName); 40 bool setInterfaceMethod(QString newName);
41 QString getInterfaceOption(QString option, bool &error); 41 QString getInterfaceOption(QString option, bool &error);
42 bool setInterfaceOption(QString option, QString value); 42 bool setInterfaceOption(QString option, QString value);
43 bool removeAllInterfaceOptions(); 43 bool removeAllInterfaceOptions();
44 44
45 bool setMapping(QString interface); 45 bool setMapping(QString interface);
46 void addMapping(QString interfaces); 46 void addMapping(QString options);
47 bool setMap(QString map, QString value); 47 bool setMap(QString map, QString value);
48 QString getMap(QString map, bool &error); 48 QString getMap(QString map, bool &error);
49 bool setScript(QString); 49 bool setScript(QString);
50 QString getScript(bool &error); 50 QString getScript(bool &error);
51 51
52 bool write(); 52 bool write();
diff --git a/noncore/net/networksetup/interfacesetup.ui b/noncore/net/networksetup/interfacesetup.ui
index 3db9a0b..c94b1be 100644
--- a/noncore/net/networksetup/interfacesetup.ui
+++ b/noncore/net/networksetup/interfacesetup.ui
@@ -8,13 +8,13 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>267</width> 14 <width>276</width>
15 <height>280</height> 15 <height>280</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Interface Configuration</string> 20 <string>Interface Configuration</string>
@@ -40,74 +40,12 @@
40 </property> 40 </property>
41 </widget> 41 </widget>
42 <widget> 42 <widget>
43 <class>QLayoutWidget</class> 43 <class>QLayoutWidget</class>
44 <property stdset="1"> 44 <property stdset="1">
45 <name>name</name> 45 <name>name</name>
46 <cstring>Layout8</cstring>
47 </property>
48 <hbox>
49 <property stdset="1">
50 <name>margin</name>
51 <number>0</number>
52 </property>
53 <property stdset="1">
54 <name>spacing</name>
55 <number>6</number>
56 </property>
57 <widget>
58 <class>QLabel</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>TextLabel1</cstring>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>Profile</string>
66 </property>
67 </widget>
68 <widget>
69 <class>QComboBox</class>
70 <item>
71 <property>
72 <name>text</name>
73 <string>All</string>
74 </property>
75 </item>
76 <property stdset="1">
77 <name>name</name>
78 <cstring>profileCombo</cstring>
79 </property>
80 </widget>
81 <spacer>
82 <property>
83 <name>name</name>
84 <cstring>Spacer20</cstring>
85 </property>
86 <property stdset="1">
87 <name>orientation</name>
88 <enum>Horizontal</enum>
89 </property>
90 <property stdset="1">
91 <name>sizeType</name>
92 <enum>Expanding</enum>
93 </property>
94 <property>
95 <name>sizeHint</name>
96 <size>
97 <width>20</width>
98 <height>20</height>
99 </size>
100 </property>
101 </spacer>
102 </hbox>
103 </widget>
104 <widget>
105 <class>QLayoutWidget</class>
106 <property stdset="1">
107 <name>name</name>
108 <cstring>Layout9</cstring> 46 <cstring>Layout9</cstring>
109 </property> 47 </property>
110 <hbox> 48 <hbox>
111 <property stdset="1"> 49 <property stdset="1">
112 <name>margin</name> 50 <name>margin</name>
113 <number>0</number> 51 <number>0</number>
@@ -151,21 +89,21 @@
151 <property stdset="1"> 89 <property stdset="1">
152 <name>suffix</name> 90 <name>suffix</name>
153 <string> hours</string> 91 <string> hours</string>
154 </property> 92 </property>
155 <property stdset="1"> 93 <property stdset="1">
156 <name>maxValue</name> 94 <name>maxValue</name>
157 <number>336</number> 95 <number>87600</number>
158 </property> 96 </property>
159 <property stdset="1"> 97 <property stdset="1">
160 <name>minValue</name> 98 <name>minValue</name>
161 <number>1</number> 99 <number>1</number>
162 </property> 100 </property>
163 <property stdset="1"> 101 <property stdset="1">
164 <name>value</name> 102 <name>value</name>
165 <number>24</number> 103 <number>168</number>
166 </property> 104 </property>
167 </widget> 105 </widget>
168 </hbox> 106 </hbox>
169 </widget> 107 </widget>
170 <widget> 108 <widget>
171 <class>QGroupBox</class> 109 <class>QGroupBox</class>
@@ -195,19 +133,12 @@
195 <number>11</number> 133 <number>11</number>
196 </property> 134 </property>
197 <property stdset="1"> 135 <property stdset="1">
198 <name>spacing</name> 136 <name>spacing</name>
199 <number>6</number> 137 <number>6</number>
200 </property> 138 </property>
201 <widget row="3" column="1" >
202 <class>QLineEdit</class>
203 <property stdset="1">
204 <name>name</name>
205 <cstring>firstDNSLineEdit</cstring>
206 </property>
207 </widget>
208 <widget row="1" column="0" > 139 <widget row="1" column="0" >
209 <class>QLabel</class> 140 <class>QLabel</class>
210 <property stdset="1"> 141 <property stdset="1">
211 <name>name</name> 142 <name>name</name>
212 <cstring>TextLabel5</cstring> 143 <cstring>TextLabel5</cstring>
213 </property> 144 </property>
@@ -245,19 +176,12 @@
245 </property> 176 </property>
246 <property stdset="1"> 177 <property stdset="1">
247 <name>text</name> 178 <name>text</name>
248 <string>First DNS</string> 179 <string>First DNS</string>
249 </property> 180 </property>
250 </widget> 181 </widget>
251 <widget row="4" column="1" >
252 <class>QLineEdit</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>secondDNSLineEdit</cstring>
256 </property>
257 </widget>
258 <widget row="0" column="0" > 182 <widget row="0" column="0" >
259 <class>QLabel</class> 183 <class>QLabel</class>
260 <property stdset="1"> 184 <property stdset="1">
261 <name>name</name> 185 <name>name</name>
262 <cstring>TextLabel4</cstring> 186 <cstring>TextLabel4</cstring>
263 </property> 187 </property>
@@ -285,12 +209,26 @@
285 </property> 209 </property>
286 <property stdset="1"> 210 <property stdset="1">
287 <name>text</name> 211 <name>text</name>
288 <string>Second DNS</string> 212 <string>Second DNS</string>
289 </property> 213 </property>
290 </widget> 214 </widget>
215 <widget row="3" column="1" >
216 <class>QLineEdit</class>
217 <property stdset="1">
218 <name>name</name>
219 <cstring>firstDNSLineEdit</cstring>
220 </property>
221 </widget>
222 <widget row="4" column="1" >
223 <class>QLineEdit</class>
224 <property stdset="1">
225 <name>name</name>
226 <cstring>secondDNSLineEdit</cstring>
227 </property>
228 </widget>
291 </grid> 229 </grid>
292 </widget> 230 </widget>
293 <spacer> 231 <spacer>
294 <property> 232 <property>
295 <name>name</name> 233 <name>name</name>
296 <cstring>Spacer9</cstring> 234 <cstring>Spacer9</cstring>
@@ -332,13 +270,12 @@
332 <receiver>staticGroupBox</receiver> 270 <receiver>staticGroupBox</receiver>
333 <slot>setDisabled(bool)</slot> 271 <slot>setDisabled(bool)</slot>
334 </connection> 272 </connection>
335</connections> 273</connections>
336<tabstops> 274<tabstops>
337 <tabstop>autoStart</tabstop> 275 <tabstop>autoStart</tabstop>
338 <tabstop>profileCombo</tabstop>
339 <tabstop>dhcpCheckBox</tabstop> 276 <tabstop>dhcpCheckBox</tabstop>
340 <tabstop>leaseTime</tabstop> 277 <tabstop>leaseTime</tabstop>
341 <tabstop>ipAddressEdit</tabstop> 278 <tabstop>ipAddressEdit</tabstop>
342 <tabstop>subnetMaskEdit</tabstop> 279 <tabstop>subnetMaskEdit</tabstop>
343 <tabstop>gatewayEdit</tabstop> 280 <tabstop>gatewayEdit</tabstop>
344 <tabstop>firstDNSLineEdit</tabstop> 281 <tabstop>firstDNSLineEdit</tabstop>
diff --git a/noncore/net/networksetup/interfacesetupimp.cpp b/noncore/net/networksetup/interfacesetupimp.cpp
index 951aeee..c16d821 100644
--- a/noncore/net/networksetup/interfacesetupimp.cpp
+++ b/noncore/net/networksetup/interfacesetupimp.cpp
@@ -19,21 +19,19 @@
19 * Constuctor. Set up the connection and load the first profile. 19 * Constuctor. Set up the connection and load the first profile.
20 */ 20 */
21InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ 21InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){
22 assert(i); 22 assert(i);
23 interface = i; 23 interface = i;
24 interfaces = new Interfaces(); 24 interfaces = new Interfaces();
25 changeProfile(profileCombo->currentText());
26 bool error = false; 25 bool error = false;
27 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 26 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
28 staticGroupBox->hide(); 27 staticGroupBox->hide();
29 dhcpCheckBox->hide(); 28 dhcpCheckBox->hide();
30 leaseTime->hide(); 29 leaseTime->hide();
31 leaseHoursLabel->hide(); 30 leaseHoursLabel->hide();
32 } 31 }
33 connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &)));
34} 32}
35 33
36/** 34/**
37 * Save the current settings, then write out the interfaces file and close. 35 * Save the current settings, then write out the interfaces file and close.
38 */ 36 */
39void InterfaceSetupImp::accept(){ 37void InterfaceSetupImp::accept(){
@@ -87,41 +85,40 @@ bool InterfaceSetupImp::saveSettings(){
87} 85}
88 86
89/** 87/**
90 * The Profile has changed. 88 * The Profile has changed.
91 * @profile the new profile. 89 * @profile the new profile.
92 */ 90 */
93void InterfaceSetupImp::changeProfile(const QString &profile){ 91void InterfaceSetupImp::setProfile(const QString &profile){
94 QString newInterfaceName; 92 QString newInterfaceName = interface->getInterfaceName() + profile;
95 if(profile.lower() == "all")
96 newInterfaceName = interface->getInterfaceName();
97 else
98 newInterfaceName = interface->getInterfaceName() + "_" + profile;
99 if(newInterfaceName == currentInterfaceName)
100 return;
101 else{
102 saveSettings();
103 currentInterfaceName = newInterfaceName;
104 }
105 bool error = interfaces->setInterface(currentInterfaceName);
106 93
107 // See if we have to make a interface. 94 // See if we have to make a interface.
108 if(error){ 95 if(!interfaces->setInterface(newInterfaceName)){
109 qDebug("InterfaceSetupImp: Adding a new interface from profile change."); 96 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
110 interfaces->addInterface(currentInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); 97 if(!interfaces->setInterface(newInterfaceName)){
111 error = interfaces->setInterface(currentInterfaceName);
112 if(error){
113 qDebug("InterfaceSetupImp: Added interface, but still can't set."); 98 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
114 return; 99 return;
115 } 100 }
101 // Add making for this new interface if need too
102 if(profile != ""){
103 if(!interfaces->setMapping(interface->getInterfaceName())){
104 interfaces->addMapping(interface->getInterfaceName());
105 if(!interfaces->setMapping(interface->getInterfaceName())){
106 qDebug("InterfaceSetupImp: Added Mapping, but still can't set.");
107 return;
108 }
109 }
110 interfaces->setScript("getprofile.sh");
111 interfaces->setMap("map", newInterfaceName);
112 }
116 } 113 }
117 114
118 //qDebug( currentInterfaceName.latin1() );
119 // We must have a valid interface to get this far so read some settings. 115 // We must have a valid interface to get this far so read some settings.
120 116
121 // DHCP 117 // DHCP
118 bool error = false;
122 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 119 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
123 dhcpCheckBox->setChecked(true); 120 dhcpCheckBox->setChecked(true);
124 else 121 else
125 dhcpCheckBox->setChecked(false); 122 dhcpCheckBox->setChecked(false);
126 leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); 123 leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt());
127 if(error) 124 if(error)
diff --git a/noncore/net/networksetup/interfacesetupimp.h b/noncore/net/networksetup/interfacesetupimp.h
index 6c34718..7df0d46 100644
--- a/noncore/net/networksetup/interfacesetupimp.h
+++ b/noncore/net/networksetup/interfacesetupimp.h
@@ -11,19 +11,20 @@ class InterfaceSetupImp : public InterfaceSetup {
11 11
12public: 12public:
13 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0); 13 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0);
14 14
15protected slots: 15protected slots:
16 void accept(); 16 void accept();
17 void changeProfile(const QString &profile); 17
18public slots:
19 void setProfile(const QString &profile);
18 20
19private: 21private:
20 bool saveSettings(); 22 bool saveSettings();
21 Interfaces *interfaces; 23 Interfaces *interfaces;
22 Interface *interface; 24 Interface *interface;
23 QString currentInterfaceName;
24 25
25}; 26};
26 27
27#endif 28#endif
28 29
29// interfacesetupimp.h 30// interfacesetupimp.h
diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui
index bea999b..3d30994 100644
--- a/noncore/net/networksetup/mainwindow.ui
+++ b/noncore/net/networksetup/mainwindow.ui
@@ -8,13 +8,13 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>230</width> 14 <width>240</width>
15 <height>289</height> 15 <height>289</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Network Setup</string> 20 <string>Network Setup</string>
@@ -58,13 +58,13 @@
58 </property> 58 </property>
59 <widget> 59 <widget>
60 <class>QListView</class> 60 <class>QListView</class>
61 <column> 61 <column>
62 <property> 62 <property>
63 <name>text</name> 63 <name>text</name>
64 <string>i</string> 64 <string>s</string>
65 </property> 65 </property>
66 <property> 66 <property>
67 <name>clickable</name> 67 <name>clickable</name>
68 <bool>true</bool> 68 <bool>true</bool>
69 </property> 69 </property>
70 <property> 70 <property>
@@ -100,12 +100,26 @@
100 <bool>true</bool> 100 <bool>true</bool>
101 </property> 101 </property>
102 </column> 102 </column>
103 <column> 103 <column>
104 <property> 104 <property>
105 <name>text</name> 105 <name>text</name>
106 <string>in</string>
107 </property>
108 <property>
109 <name>clickable</name>
110 <bool>true</bool>
111 </property>
112 <property>
113 <name>resizeable</name>
114 <bool>true</bool>
115 </property>
116 </column>
117 <column>
118 <property>
119 <name>text</name>
106 <string>IP</string> 120 <string>IP</string>
107 </property> 121 </property>
108 <property> 122 <property>
109 <name>clickable</name> 123 <name>clickable</name>
110 <bool>true</bool> 124 <bool>true</bool>
111 </property> 125 </property>
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index a446d29..3c0af6a 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -29,12 +29,13 @@
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
32#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
33#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
34 34
35#define SCHEME "/var/lib/pcmcia/scheme"
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 36MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 37 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 38 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 39 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 40 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
40 41
@@ -50,25 +51,39 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
50 51
51 52
52 Config cfg("NetworkSetup"); 53 Config cfg("NetworkSetup");
53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 54 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 55 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
55 profilesList->insertItem((*it)); 56 profilesList->insertItem((*it));
57 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 58 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
59
60 QFile file(SCHEME);
61 if ( file.open(IO_ReadOnly) ) { // file opened successfully
62 QTextStream stream( &file ); // use a text stream
63 while ( !stream.eof() ) { // until end of file...
64 QString line = stream.readLine(); // line of text excluding '\n'
65 if(line.contains("SCHEME")){
66 line = line.mid(7, line.length());
67 currentProfileLabel->setText(line);
68 break;
69 }
70 }
71 file.close();
72 }
57} 73}
58 74
59/** 75/**
60 * Deconstructor. Save profiles. Delete loaded libraries. 76 * Deconstructor. Save profiles. Delete loaded libraries.
61 */ 77 */
62MainWindowImp::~MainWindowImp(){ 78MainWindowImp::~MainWindowImp(){
63 // Save profiles. 79 // Save profiles.
64 if(profiles.count() > 1){ 80 Config cfg("NetworkSetup");
65 Config cfg("NetworkSetup"); 81 cfg.setGroup("General");
66 cfg.setGroup("General"); 82 cfg.writeEntry("Profiles", profiles.join(" "));
67 cfg.writeEntry("Profiles", profiles.join(" ")); 83
68 }
69 // Delete Modules and Libraries 84 // Delete Modules and Libraries
70 QMap<Module*, QLibrary*>::Iterator it; 85 QMap<Module*, QLibrary*>::Iterator it;
71 for( it = libraries.begin(); it != libraries.end(); ++it ){ 86 for( it = libraries.begin(); it != libraries.end(); ++it ){
72 delete it.key(); 87 delete it.key();
73 delete it.data(); 88 delete it.data();
74 } 89 }
@@ -202,29 +217,38 @@ void MainWindowImp::removeClicked(){
202void MainWindowImp::configureClicked(){ 217void MainWindowImp::configureClicked(){
203 QListViewItem *item = connectionList->currentItem(); 218 QListViewItem *item = connectionList->currentItem();
204 if(!item){ 219 if(!item){
205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 220 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
206 return; 221 return;
207 } 222 }
208 223
224 QString currentProfile = currentProfileLabel->text();
225 if(profilesList->count() <= 1 || currentProfile == "All"){
226 currentProfile = "";
227 }
228
209 Interface *i = interfaceItems[item]; 229 Interface *i = interfaceItems[item];
210 if(i->getModuleOwner()){ 230 if(i->getModuleOwner()){
231 i->getModuleOwner()->setProfile(currentProfileLabel->text());
211 QTabWidget *tabWidget = NULL; 232 QTabWidget *tabWidget = NULL;
212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 233 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
213 if(moduleConfigure != NULL){ 234 if(moduleConfigure != NULL){
214 if(tabWidget != NULL){ 235 if(tabWidget != NULL){
215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 236 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
216 tabWidget->insertTab(configure, "TCP/IP"); 237 configure->setProfile(currentProfileLabel->text());
238 tabWidget->insertTab(configure, "TCP/IP");
239
217 } 240 }
218 moduleConfigure->showMaximized(); 241 moduleConfigure->showMaximized();
219 moduleConfigure->show(); 242 moduleConfigure->show();
220 return; 243 return;
221 } 244 }
222 } 245 }
223 246
224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 247 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
248 configure->setProfile(currentProfileLabel->text());
225 configure->showMaximized(); 249 configure->showMaximized();
226 configure->show(); 250 configure->show();
227} 251}
228 252
229/** 253/**
230 * Pull up the information about the currently selected interface. 254 * Pull up the information about the currently selected interface.
@@ -241,12 +265,18 @@ void MainWindowImp::informationClicked(){
241 265
242 Interface *i = interfaceItems[item]; 266 Interface *i = interfaceItems[item];
243 if(!i->isAttached()){ 267 if(!i->isAttached()){
244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); 268 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
245 return; 269 return;
246 } 270 }
271
272 QStringList list;
273 for(uint i = 0; i < profilesList->count(); i++){
274 list.append(profilesList->text(i));
275 }
276
247 if(i->getModuleOwner()){ 277 if(i->getModuleOwner()){
248 QTabWidget *tabWidget = NULL; 278 QTabWidget *tabWidget = NULL;
249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 279 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
250 if(moduleInformation != NULL){ 280 if(moduleInformation != NULL){
251 if(tabWidget != NULL){ 281 if(tabWidget != NULL){
252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 282 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
@@ -317,13 +347,13 @@ void MainWindowImp::jobDone(KProcess *process){
317 QString hardName = "Ethernet"; 347 QString hardName = "Ethernet";
318 int hardwareName = line.find("Link encap:"); 348 int hardwareName = line.find("Link encap:");
319 int macAddress = line.find("HWaddr"); 349 int macAddress = line.find("HWaddr");
320 if(macAddress == -1) 350 if(macAddress == -1)
321 macAddress = line.length(); 351 macAddress = line.length();
322 if(hardwareName != -1) 352 if(hardwareName != -1)
323 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 353 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
324 354
325 interfaceNames.insert(i->getInterfaceName(), i); 355 interfaceNames.insert(i->getInterfaceName(), i);
326 updateInterface(i); 356 updateInterface(i);
327 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 357 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
328 } 358 }
329 // It was an interface we already had. 359 // It was an interface we already had.
@@ -346,13 +376,13 @@ void MainWindowImp::jobDone(KProcess *process){
346 if(it.key() == (*ni)) 376 if(it.key() == (*ni))
347 found = true; 377 found = true;
348 } 378 }
349 if(!found){ 379 if(!found){
350 Interface *i = new Interface(this, *ni, false); 380 Interface *i = new Interface(this, *ni, false);
351 i->setAttached(false); 381 i->setAttached(false);
352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 382 i->setHardwareName("Disconnected");
353 interfaceNames.insert(i->getInterfaceName(), i); 383 interfaceNames.insert(i->getInterfaceName(), i);
354 updateInterface(i); 384 updateInterface(i);
355 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 385 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
356 } 386 }
357 } 387 }
358 } 388 }
@@ -403,13 +433,14 @@ void MainWindowImp::updateInterface(Interface *i){
403 // Actually try to use the Module 433 // Actually try to use the Module
404 if(i->getModuleOwner() != NULL) 434 if(i->getModuleOwner() != NULL)
405 typeName = i->getModuleOwner()->getPixmapName(i); 435 typeName = i->getModuleOwner()->getPixmapName(i);
406 436
407 item->setPixmap(1, (Resource::loadPixmap(typeName))); 437 item->setPixmap(1, (Resource::loadPixmap(typeName)));
408 item->setText(2, i->getHardwareName()); 438 item->setText(2, i->getHardwareName());
409 item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); 439 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
440 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
410} 441}
411 442
412void MainWindowImp::newProfileChanged(const QString& newText){ 443void MainWindowImp::newProfileChanged(const QString& newText){
413 if(newText.length() > 0) 444 if(newText.length() > 0)
414 newProfileButton->setEnabled(true); 445 newProfileButton->setEnabled(true);
415 else 446 else
@@ -434,29 +465,61 @@ void MainWindowImp::addProfile(){
434/** 465/**
435 * Removes the currently selected profile in the combo. 466 * Removes the currently selected profile in the combo.
436 * Doesn't delete if there are less then 2 profiles. 467 * Doesn't delete if there are less then 2 profiles.
437 */ 468 */
438void MainWindowImp::removeProfile(){ 469void MainWindowImp::removeProfile(){
439 if(profilesList->count() <= 1){ 470 if(profilesList->count() <= 1){
440 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok"); 471 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
441 return; 472 return;
442 } 473 }
443 QString profileToRemove = profilesList->currentText(); 474 QString profileToRemove = profilesList->currentText();
475 if(profileToRemove == "All"){
476 QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok");
477 return;
478 }
479 // Can't remove the curent profile
480 if(profileToRemove == currentProfileLabel->text()){
481 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok");
482 return;
483
484 }
485
444 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 486 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
445 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 487 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
446 profilesList->clear(); 488 profilesList->clear();
447 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 489 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
448 profilesList->insertItem((*it)); 490 profilesList->insertItem((*it));
449 } 491 }
450
451} 492}
452 493
453/** 494/**
454 * A new profile has been selected, change. 495 * A new profile has been selected, change.
455 * @param newProfile the new profile. 496 * @param newProfile the new profile.
456 */ 497 */
457void MainWindowImp::changeProfile(){ 498void MainWindowImp::changeProfile(){
458 currentProfileLabel->setText(profilesList->text(profilesList->currentItem())); 499 if(profilesList->currentItem() == -1){
500 QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok");
501 return;
502 }
503 QString newProfile = profilesList->text(profilesList->currentItem());
504 if(newProfile != currentProfileLabel->text()){
505 currentProfileLabel->setText(newProfile);
506 QFile file(SCHEME);
507 if ( file.open(IO_ReadWrite) ) {
508 QTextStream stream( &file );
509 stream << QString("SCHEME=%1").arg(newProfile);
510 file.close();
511 }
512 // restart all up devices?
513 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
514 // Go through them one by one
515 QMap<Interface*, QListViewItem*>::Iterator it;
516 for( it = items.begin(); it != items.end(); ++it ){
517 if(it.key()->getStatus() == true)
518 it.key()->restart();
519 }
520 }
521 }
459} 522}
460 523
461// mainwindowimp.cpp 524// mainwindowimp.cpp
462 525
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp
index 74eef5f..517604f 100644
--- a/noncore/net/networksetup/wlan/wlanimp.cpp
+++ b/noncore/net/networksetup/wlan/wlanimp.cpp
@@ -94,13 +94,12 @@ bool WLANImp::writeConfig()
94 } 94 }
95 config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); 95 config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() );
96 config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); 96 config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() );
97 config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); 97 config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() );
98 config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); 98 config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() );
99 return writeWirelessOpts( config ); 99 return writeWirelessOpts( config );
100// return true;
101} 100}
102 101
103/** 102/**
104 */ 103 */
105void WLANImp::accept() 104void WLANImp::accept()
106{ 105{
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 9d34d75..53b5857 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -29,13 +29,13 @@ QString WLANModule::getPixmapName(Interface* ){
29 * Check to see if the interface i is owned by this module. 29 * Check to see if the interface i is owned by this module.
30 * @param Interface* interface to check against 30 * @param Interface* interface to check against
31 * @return bool true if i is owned by this module, false otherwise. 31 * @return bool true if i is owned by this module, false otherwise.
32 */ 32 */
33bool WLANModule::isOwner(Interface *i){ 33bool WLANModule::isOwner(Interface *i){
34 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ 34 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
35 i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName())); 35 i->setHardwareName("802.11b");
36 return true; 36 return true;
37 } 37 }
38 return false; 38 return false;
39} 39}
40 40
41/** 41/**
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index c8e2989..c587f58 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,10 +1,6 @@
1Write a class that parses /proc and not ifconfig 1Write a class that parses /proc and not ifconfig
2WLAN needs to be re-written to not use Config
3remove WLAN Config item
2 4
3[ ] Wlanmodule needs to check if an interface supports wireless 5[ ] Wlanmodule needs to check if an interface supports wireless
4 extensions. 6 extensions.
5[x] When you set options in wlanmodule, hit OK, it exits all of
6 networksetup, doesnt bring you back to the main screen.
7[x] Wlanmodule isnt writing out wireless.opts
8[ ] Need a means of bringing an interface up and down (calling
9 out ifup/ifdown) from the gui.
10 -Ben- Click information, then click up or down... :-D
diff --git a/noncore/settings/networksettings/interfaceadvanced.ui b/noncore/settings/networksettings/interfaceadvanced.ui
index efe67b0..0ec67c2 100644
--- a/noncore/settings/networksettings/interfaceadvanced.ui
+++ b/noncore/settings/networksettings/interfaceadvanced.ui
@@ -15,13 +15,13 @@
15 <height>286</height> 15 <height>286</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>maximumSize</name> 19 <name>maximumSize</name>
20 <size> 20 <size>
21 <width>320</width> 21 <width>240</width>
22 <height>32767</height> 22 <height>32767</height>
23 </size> 23 </size>
24 </property> 24 </property>
25 <property stdset="1"> 25 <property stdset="1">
26 <name>caption</name> 26 <name>caption</name>
27 <string>Advanced Interface Information</string> 27 <string>Advanced Interface Information</string>
@@ -186,13 +186,13 @@
186 </property> 186 </property>
187 </widget> 187 </widget>
188 <widget row="5" column="0" rowspan="1" colspan="2" > 188 <widget row="5" column="0" rowspan="1" colspan="2" >
189 <class>QGroupBox</class> 189 <class>QGroupBox</class>
190 <property stdset="1"> 190 <property stdset="1">
191 <name>name</name> 191 <name>name</name>
192 <cstring>GroupBox2</cstring> 192 <cstring>dhcpInformation</cstring>
193 </property> 193 </property>
194 <property stdset="1"> 194 <property stdset="1">
195 <name>title</name> 195 <name>title</name>
196 <string>DHCP Information</string> 196 <string>DHCP Information</string>
197 </property> 197 </property>
198 <grid> 198 <grid>
diff --git a/noncore/settings/networksettings/interfaceinformation.ui b/noncore/settings/networksettings/interfaceinformation.ui
index 76af19c..fc99fce 100644
--- a/noncore/settings/networksettings/interfaceinformation.ui
+++ b/noncore/settings/networksettings/interfaceinformation.ui
@@ -8,14 +8,14 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>199</width> 14 <width>219</width>
15 <height>244</height> 15 <height>255</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Interface Information</string> 20 <string>Interface Information</string>
21 </property> 21 </property>
@@ -330,12 +330,14 @@
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>
336<tabstops> 338<tabstops>
337 <tabstop>startButton</tabstop> 339 <tabstop>startButton</tabstop>
338 <tabstop>stopButton</tabstop> 340 <tabstop>stopButton</tabstop>
339 <tabstop>refreshButton</tabstop> 341 <tabstop>refreshButton</tabstop>
340 <tabstop>restartButton</tabstop> 342 <tabstop>restartButton</tabstop>
341 <tabstop>advancedButton</tabstop> 343 <tabstop>advancedButton</tabstop>
diff --git a/noncore/settings/networksettings/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaceinformationimp.cpp
index 59a6400..43483fb 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaceinformationimp.cpp
@@ -1,11 +1,12 @@
1#include "interfaceinformationimp.h" 1#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h" 2#include "interfaceadvanced.h"
3 3
4#include <qpushbutton.h> 4#include <qpushbutton.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qgroupbox.h>
6#include <assert.h> 7#include <assert.h>
7 8
8/** 9/**
9 * Constructor for the InterfaceInformationImp class. This class pretty much 10 * Constructor for the InterfaceInformationImp class. This class pretty much
10 * just display's information about the interface that is passed to it. 11 * just display's information about the interface that is passed to it.
11 */ 12 */
@@ -56,12 +57,14 @@ void InterfaceInformationImp::advanced(){
56 a->ipAddressLabel->setText(interface->getIp()); 57 a->ipAddressLabel->setText(interface->getIp());
57 a->subnetMaskLabel->setText(interface->getSubnetMask()); 58 a->subnetMaskLabel->setText(interface->getSubnetMask());
58 a->broadcastLabel->setText(interface->getBroadcast()); 59 a->broadcastLabel->setText(interface->getBroadcast());
59 a->dhcpServerLabel->setText(interface->getDhcpServerIp()); 60 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
60 a->leaseObtainedLabel->setText(interface->getLeaseObtained()); 61 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
61 a->leaseExpiresLabel->setText(interface->getLeaseExpires()); 62 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
63 a->dhcpInformation->setEnabled(interface->isDhcp());
64
62 a->showMaximized(); 65 a->showMaximized();
63 a->show(); 66 a->show();
64} 67}
65 68
66// infoimp.cpp 69// infoimp.cpp
67 70
diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp
index 1287d90..eef42df 100644
--- a/noncore/settings/networksettings/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces.cpp
@@ -342,15 +342,15 @@ bool Interfaces::setMapping(QString interface){
342} 342}
343 343
344/** 344/**
345 * Adds a new Mapping to the interfaces file with interfaces. 345 * Adds a new Mapping to the interfaces file with interfaces.
346 * @param interface the name(s) of the interfaces to set to this mapping 346 * @param interface the name(s) of the interfaces to set to this mapping
347 */ 347 */
348void Interfaces::addMapping(QString interfaces){ 348void Interfaces::addMapping(QString option){
349 interfaces.append(""); 349 interfaces.append("");
350 interfaces.append(QString(MAPPING " %1").arg(interfaces)); 350 interfaces.append(QString(MAPPING " %1").arg(option));
351} 351}
352 352
353/** 353/**
354 * Set a map option within a mapping. 354 * Set a map option within a mapping.
355 * @param map map to use 355 * @param map map to use
356 * @param value value to go with map 356 * @param value value to go with map
@@ -401,17 +401,18 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator
401 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 401 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
402 QString line = (*it).simplifyWhiteSpace(); 402 QString line = (*it).simplifyWhiteSpace();
403 if(line.contains(stanza) && line.contains(option)){ 403 if(line.contains(stanza) && line.contains(option)){
404 if(found == true){ 404 if(found == true){
405 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 405 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
406 } 406 }
407 qDebug("Found");
407 found = true; 408 found = true;
408 iterator = it; 409 iterator = it;
409 } 410 }
410 } 411 }
411 return !found; 412 return found;
412} 413}
413 414
414/** 415/**
415 * Sets a value of an option in a stanza 416 * Sets a value of an option in a stanza
416 * @param start the start of the stanza 417 * @param start the start of the stanza
417 * @param option the option to use when setting value. 418 * @param option the option to use when setting value.
@@ -425,26 +426,32 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString
425 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 426 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
426 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 427 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
427 if(!found && value != ""){ 428 if(!found && value != ""){
428 // Got to the end of the stanza without finding it, so append it. 429 // Got to the end of the stanza without finding it, so append it.
429 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 430 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
430 } 431 }
432 found = true;
431 break; 433 break;
432 } 434 }
433 if((*it).contains(option)){ 435 if((*it).contains(option) && it != start){
434 // Found it in stanza so replace it. 436 // Found it in stanza so replace it.
435 if(found) 437 if(found)
436 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 438 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
437 found = true; 439 found = true;
438 if(value == "") 440 if(value == "")
439 (*it) = ""; 441 (*it) = "";
440 else 442 else
441 (*it) = QString("\t%1 %2").arg(option).arg(value); 443 (*it) = QString("\t%1 %2").arg(option).arg(value);
442 } 444 }
443 } 445 }
444 return true; 446 if(!found){
447 QStringList::Iterator p = start;
448 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
449 found = true;
450 }
451 return found;
445} 452}
446 453
447/** 454/**
448 * Removes all options in a stanza 455 * Removes all options in a stanza
449 * @param start the start of the stanza 456 * @param start the start of the stanza
450 * @return bool true if successfull, false otherwise. 457 * @return bool true if successfull, false otherwise.
diff --git a/noncore/settings/networksettings/interfaces.h b/noncore/settings/networksettings/interfaces.h
index 8b4788c..e617c17 100644
--- a/noncore/settings/networksettings/interfaces.h
+++ b/noncore/settings/networksettings/interfaces.h
@@ -40,13 +40,13 @@ public:
40 bool setInterfaceMethod(QString newName); 40 bool setInterfaceMethod(QString newName);
41 QString getInterfaceOption(QString option, bool &error); 41 QString getInterfaceOption(QString option, bool &error);
42 bool setInterfaceOption(QString option, QString value); 42 bool setInterfaceOption(QString option, QString value);
43 bool removeAllInterfaceOptions(); 43 bool removeAllInterfaceOptions();
44 44
45 bool setMapping(QString interface); 45 bool setMapping(QString interface);
46 void addMapping(QString interfaces); 46 void addMapping(QString options);
47 bool setMap(QString map, QString value); 47 bool setMap(QString map, QString value);
48 QString getMap(QString map, bool &error); 48 QString getMap(QString map, bool &error);
49 bool setScript(QString); 49 bool setScript(QString);
50 QString getScript(bool &error); 50 QString getScript(bool &error);
51 51
52 bool write(); 52 bool write();
diff --git a/noncore/settings/networksettings/interfacesetup.ui b/noncore/settings/networksettings/interfacesetup.ui
index 3db9a0b..c94b1be 100644
--- a/noncore/settings/networksettings/interfacesetup.ui
+++ b/noncore/settings/networksettings/interfacesetup.ui
@@ -8,13 +8,13 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>267</width> 14 <width>276</width>
15 <height>280</height> 15 <height>280</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Interface Configuration</string> 20 <string>Interface Configuration</string>
@@ -40,74 +40,12 @@
40 </property> 40 </property>
41 </widget> 41 </widget>
42 <widget> 42 <widget>
43 <class>QLayoutWidget</class> 43 <class>QLayoutWidget</class>
44 <property stdset="1"> 44 <property stdset="1">
45 <name>name</name> 45 <name>name</name>
46 <cstring>Layout8</cstring>
47 </property>
48 <hbox>
49 <property stdset="1">
50 <name>margin</name>
51 <number>0</number>
52 </property>
53 <property stdset="1">
54 <name>spacing</name>
55 <number>6</number>
56 </property>
57 <widget>
58 <class>QLabel</class>
59 <property stdset="1">
60 <name>name</name>
61 <cstring>TextLabel1</cstring>
62 </property>
63 <property stdset="1">
64 <name>text</name>
65 <string>Profile</string>
66 </property>
67 </widget>
68 <widget>
69 <class>QComboBox</class>
70 <item>
71 <property>
72 <name>text</name>
73 <string>All</string>
74 </property>
75 </item>
76 <property stdset="1">
77 <name>name</name>
78 <cstring>profileCombo</cstring>
79 </property>
80 </widget>
81 <spacer>
82 <property>
83 <name>name</name>
84 <cstring>Spacer20</cstring>
85 </property>
86 <property stdset="1">
87 <name>orientation</name>
88 <enum>Horizontal</enum>
89 </property>
90 <property stdset="1">
91 <name>sizeType</name>
92 <enum>Expanding</enum>
93 </property>
94 <property>
95 <name>sizeHint</name>
96 <size>
97 <width>20</width>
98 <height>20</height>
99 </size>
100 </property>
101 </spacer>
102 </hbox>
103 </widget>
104 <widget>
105 <class>QLayoutWidget</class>
106 <property stdset="1">
107 <name>name</name>
108 <cstring>Layout9</cstring> 46 <cstring>Layout9</cstring>
109 </property> 47 </property>
110 <hbox> 48 <hbox>
111 <property stdset="1"> 49 <property stdset="1">
112 <name>margin</name> 50 <name>margin</name>
113 <number>0</number> 51 <number>0</number>
@@ -151,21 +89,21 @@
151 <property stdset="1"> 89 <property stdset="1">
152 <name>suffix</name> 90 <name>suffix</name>
153 <string> hours</string> 91 <string> hours</string>
154 </property> 92 </property>
155 <property stdset="1"> 93 <property stdset="1">
156 <name>maxValue</name> 94 <name>maxValue</name>
157 <number>336</number> 95 <number>87600</number>
158 </property> 96 </property>
159 <property stdset="1"> 97 <property stdset="1">
160 <name>minValue</name> 98 <name>minValue</name>
161 <number>1</number> 99 <number>1</number>
162 </property> 100 </property>
163 <property stdset="1"> 101 <property stdset="1">
164 <name>value</name> 102 <name>value</name>
165 <number>24</number> 103 <number>168</number>
166 </property> 104 </property>
167 </widget> 105 </widget>
168 </hbox> 106 </hbox>
169 </widget> 107 </widget>
170 <widget> 108 <widget>
171 <class>QGroupBox</class> 109 <class>QGroupBox</class>
@@ -195,19 +133,12 @@
195 <number>11</number> 133 <number>11</number>
196 </property> 134 </property>
197 <property stdset="1"> 135 <property stdset="1">
198 <name>spacing</name> 136 <name>spacing</name>
199 <number>6</number> 137 <number>6</number>
200 </property> 138 </property>
201 <widget row="3" column="1" >
202 <class>QLineEdit</class>
203 <property stdset="1">
204 <name>name</name>
205 <cstring>firstDNSLineEdit</cstring>
206 </property>
207 </widget>
208 <widget row="1" column="0" > 139 <widget row="1" column="0" >
209 <class>QLabel</class> 140 <class>QLabel</class>
210 <property stdset="1"> 141 <property stdset="1">
211 <name>name</name> 142 <name>name</name>
212 <cstring>TextLabel5</cstring> 143 <cstring>TextLabel5</cstring>
213 </property> 144 </property>
@@ -245,19 +176,12 @@
245 </property> 176 </property>
246 <property stdset="1"> 177 <property stdset="1">
247 <name>text</name> 178 <name>text</name>
248 <string>First DNS</string> 179 <string>First DNS</string>
249 </property> 180 </property>
250 </widget> 181 </widget>
251 <widget row="4" column="1" >
252 <class>QLineEdit</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>secondDNSLineEdit</cstring>
256 </property>
257 </widget>
258 <widget row="0" column="0" > 182 <widget row="0" column="0" >
259 <class>QLabel</class> 183 <class>QLabel</class>
260 <property stdset="1"> 184 <property stdset="1">
261 <name>name</name> 185 <name>name</name>
262 <cstring>TextLabel4</cstring> 186 <cstring>TextLabel4</cstring>
263 </property> 187 </property>
@@ -285,12 +209,26 @@
285 </property> 209 </property>
286 <property stdset="1"> 210 <property stdset="1">
287 <name>text</name> 211 <name>text</name>
288 <string>Second DNS</string> 212 <string>Second DNS</string>
289 </property> 213 </property>
290 </widget> 214 </widget>
215 <widget row="3" column="1" >
216 <class>QLineEdit</class>
217 <property stdset="1">
218 <name>name</name>
219 <cstring>firstDNSLineEdit</cstring>
220 </property>
221 </widget>
222 <widget row="4" column="1" >
223 <class>QLineEdit</class>
224 <property stdset="1">
225 <name>name</name>
226 <cstring>secondDNSLineEdit</cstring>
227 </property>
228 </widget>
291 </grid> 229 </grid>
292 </widget> 230 </widget>
293 <spacer> 231 <spacer>
294 <property> 232 <property>
295 <name>name</name> 233 <name>name</name>
296 <cstring>Spacer9</cstring> 234 <cstring>Spacer9</cstring>
@@ -332,13 +270,12 @@
332 <receiver>staticGroupBox</receiver> 270 <receiver>staticGroupBox</receiver>
333 <slot>setDisabled(bool)</slot> 271 <slot>setDisabled(bool)</slot>
334 </connection> 272 </connection>
335</connections> 273</connections>
336<tabstops> 274<tabstops>
337 <tabstop>autoStart</tabstop> 275 <tabstop>autoStart</tabstop>
338 <tabstop>profileCombo</tabstop>
339 <tabstop>dhcpCheckBox</tabstop> 276 <tabstop>dhcpCheckBox</tabstop>
340 <tabstop>leaseTime</tabstop> 277 <tabstop>leaseTime</tabstop>
341 <tabstop>ipAddressEdit</tabstop> 278 <tabstop>ipAddressEdit</tabstop>
342 <tabstop>subnetMaskEdit</tabstop> 279 <tabstop>subnetMaskEdit</tabstop>
343 <tabstop>gatewayEdit</tabstop> 280 <tabstop>gatewayEdit</tabstop>
344 <tabstop>firstDNSLineEdit</tabstop> 281 <tabstop>firstDNSLineEdit</tabstop>
diff --git a/noncore/settings/networksettings/interfacesetupimp.cpp b/noncore/settings/networksettings/interfacesetupimp.cpp
index 951aeee..c16d821 100644
--- a/noncore/settings/networksettings/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfacesetupimp.cpp
@@ -19,21 +19,19 @@
19 * Constuctor. Set up the connection and load the first profile. 19 * Constuctor. Set up the connection and load the first profile.
20 */ 20 */
21InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ 21InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){
22 assert(i); 22 assert(i);
23 interface = i; 23 interface = i;
24 interfaces = new Interfaces(); 24 interfaces = new Interfaces();
25 changeProfile(profileCombo->currentText());
26 bool error = false; 25 bool error = false;
27 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 26 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
28 staticGroupBox->hide(); 27 staticGroupBox->hide();
29 dhcpCheckBox->hide(); 28 dhcpCheckBox->hide();
30 leaseTime->hide(); 29 leaseTime->hide();
31 leaseHoursLabel->hide(); 30 leaseHoursLabel->hide();
32 } 31 }
33 connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &)));
34} 32}
35 33
36/** 34/**
37 * Save the current settings, then write out the interfaces file and close. 35 * Save the current settings, then write out the interfaces file and close.
38 */ 36 */
39void InterfaceSetupImp::accept(){ 37void InterfaceSetupImp::accept(){
@@ -87,41 +85,40 @@ bool InterfaceSetupImp::saveSettings(){
87} 85}
88 86
89/** 87/**
90 * The Profile has changed. 88 * The Profile has changed.
91 * @profile the new profile. 89 * @profile the new profile.
92 */ 90 */
93void InterfaceSetupImp::changeProfile(const QString &profile){ 91void InterfaceSetupImp::setProfile(const QString &profile){
94 QString newInterfaceName; 92 QString newInterfaceName = interface->getInterfaceName() + profile;
95 if(profile.lower() == "all")
96 newInterfaceName = interface->getInterfaceName();
97 else
98 newInterfaceName = interface->getInterfaceName() + "_" + profile;
99 if(newInterfaceName == currentInterfaceName)
100 return;
101 else{
102 saveSettings();
103 currentInterfaceName = newInterfaceName;
104 }
105 bool error = interfaces->setInterface(currentInterfaceName);
106 93
107 // See if we have to make a interface. 94 // See if we have to make a interface.
108 if(error){ 95 if(!interfaces->setInterface(newInterfaceName)){
109 qDebug("InterfaceSetupImp: Adding a new interface from profile change."); 96 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
110 interfaces->addInterface(currentInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); 97 if(!interfaces->setInterface(newInterfaceName)){
111 error = interfaces->setInterface(currentInterfaceName);
112 if(error){
113 qDebug("InterfaceSetupImp: Added interface, but still can't set."); 98 qDebug("InterfaceSetupImp: Added interface, but still can't set.");
114 return; 99 return;
115 } 100 }
101 // Add making for this new interface if need too
102 if(profile != ""){
103 if(!interfaces->setMapping(interface->getInterfaceName())){
104 interfaces->addMapping(interface->getInterfaceName());
105 if(!interfaces->setMapping(interface->getInterfaceName())){
106 qDebug("InterfaceSetupImp: Added Mapping, but still can't set.");
107 return;
108 }
109 }
110 interfaces->setScript("getprofile.sh");
111 interfaces->setMap("map", newInterfaceName);
112 }
116 } 113 }
117 114
118 //qDebug( currentInterfaceName.latin1() );
119 // We must have a valid interface to get this far so read some settings. 115 // We must have a valid interface to get this far so read some settings.
120 116
121 // DHCP 117 // DHCP
118 bool error = false;
122 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 119 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
123 dhcpCheckBox->setChecked(true); 120 dhcpCheckBox->setChecked(true);
124 else 121 else
125 dhcpCheckBox->setChecked(false); 122 dhcpCheckBox->setChecked(false);
126 leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); 123 leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt());
127 if(error) 124 if(error)
diff --git a/noncore/settings/networksettings/interfacesetupimp.h b/noncore/settings/networksettings/interfacesetupimp.h
index 6c34718..7df0d46 100644
--- a/noncore/settings/networksettings/interfacesetupimp.h
+++ b/noncore/settings/networksettings/interfacesetupimp.h
@@ -11,19 +11,20 @@ class InterfaceSetupImp : public InterfaceSetup {
11 11
12public: 12public:
13 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0); 13 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0);
14 14
15protected slots: 15protected slots:
16 void accept(); 16 void accept();
17 void changeProfile(const QString &profile); 17
18public slots:
19 void setProfile(const QString &profile);
18 20
19private: 21private:
20 bool saveSettings(); 22 bool saveSettings();
21 Interfaces *interfaces; 23 Interfaces *interfaces;
22 Interface *interface; 24 Interface *interface;
23 QString currentInterfaceName;
24 25
25}; 26};
26 27
27#endif 28#endif
28 29
29// interfacesetupimp.h 30// interfacesetupimp.h
diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui
index bea999b..3d30994 100644
--- a/noncore/settings/networksettings/mainwindow.ui
+++ b/noncore/settings/networksettings/mainwindow.ui
@@ -8,13 +8,13 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>230</width> 14 <width>240</width>
15 <height>289</height> 15 <height>289</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Network Setup</string> 20 <string>Network Setup</string>
@@ -58,13 +58,13 @@
58 </property> 58 </property>
59 <widget> 59 <widget>
60 <class>QListView</class> 60 <class>QListView</class>
61 <column> 61 <column>
62 <property> 62 <property>
63 <name>text</name> 63 <name>text</name>
64 <string>i</string> 64 <string>s</string>
65 </property> 65 </property>
66 <property> 66 <property>
67 <name>clickable</name> 67 <name>clickable</name>
68 <bool>true</bool> 68 <bool>true</bool>
69 </property> 69 </property>
70 <property> 70 <property>
@@ -100,12 +100,26 @@
100 <bool>true</bool> 100 <bool>true</bool>
101 </property> 101 </property>
102 </column> 102 </column>
103 <column> 103 <column>
104 <property> 104 <property>
105 <name>text</name> 105 <name>text</name>
106 <string>in</string>
107 </property>
108 <property>
109 <name>clickable</name>
110 <bool>true</bool>
111 </property>
112 <property>
113 <name>resizeable</name>
114 <bool>true</bool>
115 </property>
116 </column>
117 <column>
118 <property>
119 <name>text</name>
106 <string>IP</string> 120 <string>IP</string>
107 </property> 121 </property>
108 <property> 122 <property>
109 <name>clickable</name> 123 <name>clickable</name>
110 <bool>true</bool> 124 <bool>true</bool>
111 </property> 125 </property>
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index a446d29..3c0af6a 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -29,12 +29,13 @@
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
32#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
33#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
34 34
35#define SCHEME "/var/lib/pcmcia/scheme"
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 36MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 37 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 38 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 39 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 40 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
40 41
@@ -50,25 +51,39 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
50 51
51 52
52 Config cfg("NetworkSetup"); 53 Config cfg("NetworkSetup");
53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 54 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 55 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
55 profilesList->insertItem((*it)); 56 profilesList->insertItem((*it));
57 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 58 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
59
60 QFile file(SCHEME);
61 if ( file.open(IO_ReadOnly) ) { // file opened successfully
62 QTextStream stream( &file ); // use a text stream
63 while ( !stream.eof() ) { // until end of file...
64 QString line = stream.readLine(); // line of text excluding '\n'
65 if(line.contains("SCHEME")){
66 line = line.mid(7, line.length());
67 currentProfileLabel->setText(line);
68 break;
69 }
70 }
71 file.close();
72 }
57} 73}
58 74
59/** 75/**
60 * Deconstructor. Save profiles. Delete loaded libraries. 76 * Deconstructor. Save profiles. Delete loaded libraries.
61 */ 77 */
62MainWindowImp::~MainWindowImp(){ 78MainWindowImp::~MainWindowImp(){
63 // Save profiles. 79 // Save profiles.
64 if(profiles.count() > 1){ 80 Config cfg("NetworkSetup");
65 Config cfg("NetworkSetup"); 81 cfg.setGroup("General");
66 cfg.setGroup("General"); 82 cfg.writeEntry("Profiles", profiles.join(" "));
67 cfg.writeEntry("Profiles", profiles.join(" ")); 83
68 }
69 // Delete Modules and Libraries 84 // Delete Modules and Libraries
70 QMap<Module*, QLibrary*>::Iterator it; 85 QMap<Module*, QLibrary*>::Iterator it;
71 for( it = libraries.begin(); it != libraries.end(); ++it ){ 86 for( it = libraries.begin(); it != libraries.end(); ++it ){
72 delete it.key(); 87 delete it.key();
73 delete it.data(); 88 delete it.data();
74 } 89 }
@@ -202,29 +217,38 @@ void MainWindowImp::removeClicked(){
202void MainWindowImp::configureClicked(){ 217void MainWindowImp::configureClicked(){
203 QListViewItem *item = connectionList->currentItem(); 218 QListViewItem *item = connectionList->currentItem();
204 if(!item){ 219 if(!item){
205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 220 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
206 return; 221 return;
207 } 222 }
208 223
224 QString currentProfile = currentProfileLabel->text();
225 if(profilesList->count() <= 1 || currentProfile == "All"){
226 currentProfile = "";
227 }
228
209 Interface *i = interfaceItems[item]; 229 Interface *i = interfaceItems[item];
210 if(i->getModuleOwner()){ 230 if(i->getModuleOwner()){
231 i->getModuleOwner()->setProfile(currentProfileLabel->text());
211 QTabWidget *tabWidget = NULL; 232 QTabWidget *tabWidget = NULL;
212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 233 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
213 if(moduleConfigure != NULL){ 234 if(moduleConfigure != NULL){
214 if(tabWidget != NULL){ 235 if(tabWidget != NULL){
215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 236 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
216 tabWidget->insertTab(configure, "TCP/IP"); 237 configure->setProfile(currentProfileLabel->text());
238 tabWidget->insertTab(configure, "TCP/IP");
239
217 } 240 }
218 moduleConfigure->showMaximized(); 241 moduleConfigure->showMaximized();
219 moduleConfigure->show(); 242 moduleConfigure->show();
220 return; 243 return;
221 } 244 }
222 } 245 }
223 246
224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 247 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
248 configure->setProfile(currentProfileLabel->text());
225 configure->showMaximized(); 249 configure->showMaximized();
226 configure->show(); 250 configure->show();
227} 251}
228 252
229/** 253/**
230 * Pull up the information about the currently selected interface. 254 * Pull up the information about the currently selected interface.
@@ -241,12 +265,18 @@ void MainWindowImp::informationClicked(){
241 265
242 Interface *i = interfaceItems[item]; 266 Interface *i = interfaceItems[item];
243 if(!i->isAttached()){ 267 if(!i->isAttached()){
244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); 268 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
245 return; 269 return;
246 } 270 }
271
272 QStringList list;
273 for(uint i = 0; i < profilesList->count(); i++){
274 list.append(profilesList->text(i));
275 }
276
247 if(i->getModuleOwner()){ 277 if(i->getModuleOwner()){
248 QTabWidget *tabWidget = NULL; 278 QTabWidget *tabWidget = NULL;
249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 279 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
250 if(moduleInformation != NULL){ 280 if(moduleInformation != NULL){
251 if(tabWidget != NULL){ 281 if(tabWidget != NULL){
252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 282 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
@@ -317,13 +347,13 @@ void MainWindowImp::jobDone(KProcess *process){
317 QString hardName = "Ethernet"; 347 QString hardName = "Ethernet";
318 int hardwareName = line.find("Link encap:"); 348 int hardwareName = line.find("Link encap:");
319 int macAddress = line.find("HWaddr"); 349 int macAddress = line.find("HWaddr");
320 if(macAddress == -1) 350 if(macAddress == -1)
321 macAddress = line.length(); 351 macAddress = line.length();
322 if(hardwareName != -1) 352 if(hardwareName != -1)
323 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 353 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
324 354
325 interfaceNames.insert(i->getInterfaceName(), i); 355 interfaceNames.insert(i->getInterfaceName(), i);
326 updateInterface(i); 356 updateInterface(i);
327 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 357 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
328 } 358 }
329 // It was an interface we already had. 359 // It was an interface we already had.
@@ -346,13 +376,13 @@ void MainWindowImp::jobDone(KProcess *process){
346 if(it.key() == (*ni)) 376 if(it.key() == (*ni))
347 found = true; 377 found = true;
348 } 378 }
349 if(!found){ 379 if(!found){
350 Interface *i = new Interface(this, *ni, false); 380 Interface *i = new Interface(this, *ni, false);
351 i->setAttached(false); 381 i->setAttached(false);
352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 382 i->setHardwareName("Disconnected");
353 interfaceNames.insert(i->getInterfaceName(), i); 383 interfaceNames.insert(i->getInterfaceName(), i);
354 updateInterface(i); 384 updateInterface(i);
355 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 385 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
356 } 386 }
357 } 387 }
358 } 388 }
@@ -403,13 +433,14 @@ void MainWindowImp::updateInterface(Interface *i){
403 // Actually try to use the Module 433 // Actually try to use the Module
404 if(i->getModuleOwner() != NULL) 434 if(i->getModuleOwner() != NULL)
405 typeName = i->getModuleOwner()->getPixmapName(i); 435 typeName = i->getModuleOwner()->getPixmapName(i);
406 436
407 item->setPixmap(1, (Resource::loadPixmap(typeName))); 437 item->setPixmap(1, (Resource::loadPixmap(typeName)));
408 item->setText(2, i->getHardwareName()); 438 item->setText(2, i->getHardwareName());
409 item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); 439 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
440 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
410} 441}
411 442
412void MainWindowImp::newProfileChanged(const QString& newText){ 443void MainWindowImp::newProfileChanged(const QString& newText){
413 if(newText.length() > 0) 444 if(newText.length() > 0)
414 newProfileButton->setEnabled(true); 445 newProfileButton->setEnabled(true);
415 else 446 else
@@ -434,29 +465,61 @@ void MainWindowImp::addProfile(){
434/** 465/**
435 * Removes the currently selected profile in the combo. 466 * Removes the currently selected profile in the combo.
436 * Doesn't delete if there are less then 2 profiles. 467 * Doesn't delete if there are less then 2 profiles.
437 */ 468 */
438void MainWindowImp::removeProfile(){ 469void MainWindowImp::removeProfile(){
439 if(profilesList->count() <= 1){ 470 if(profilesList->count() <= 1){
440 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok"); 471 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
441 return; 472 return;
442 } 473 }
443 QString profileToRemove = profilesList->currentText(); 474 QString profileToRemove = profilesList->currentText();
475 if(profileToRemove == "All"){
476 QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok");
477 return;
478 }
479 // Can't remove the curent profile
480 if(profileToRemove == currentProfileLabel->text()){
481 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok");
482 return;
483
484 }
485
444 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 486 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
445 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 487 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
446 profilesList->clear(); 488 profilesList->clear();
447 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 489 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
448 profilesList->insertItem((*it)); 490 profilesList->insertItem((*it));
449 } 491 }
450
451} 492}
452 493
453/** 494/**
454 * A new profile has been selected, change. 495 * A new profile has been selected, change.
455 * @param newProfile the new profile. 496 * @param newProfile the new profile.
456 */ 497 */
457void MainWindowImp::changeProfile(){ 498void MainWindowImp::changeProfile(){
458 currentProfileLabel->setText(profilesList->text(profilesList->currentItem())); 499 if(profilesList->currentItem() == -1){
500 QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok");
501 return;
502 }
503 QString newProfile = profilesList->text(profilesList->currentItem());
504 if(newProfile != currentProfileLabel->text()){
505 currentProfileLabel->setText(newProfile);
506 QFile file(SCHEME);
507 if ( file.open(IO_ReadWrite) ) {
508 QTextStream stream( &file );
509 stream << QString("SCHEME=%1").arg(newProfile);
510 file.close();
511 }
512 // restart all up devices?
513 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
514 // Go through them one by one
515 QMap<Interface*, QListViewItem*>::Iterator it;
516 for( it = items.begin(); it != items.end(); ++it ){
517 if(it.key()->getStatus() == true)
518 it.key()->restart();
519 }
520 }
521 }
459} 522}
460 523
461// mainwindowimp.cpp 524// mainwindowimp.cpp
462 525
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 74eef5f..517604f 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -94,13 +94,12 @@ bool WLANImp::writeConfig()
94 } 94 }
95 config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); 95 config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() );
96 config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); 96 config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() );
97 config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); 97 config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() );
98 config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); 98 config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() );
99 return writeWirelessOpts( config ); 99 return writeWirelessOpts( config );
100// return true;
101} 100}
102 101
103/** 102/**
104 */ 103 */
105void WLANImp::accept() 104void WLANImp::accept()
106{ 105{
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 9d34d75..53b5857 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -29,13 +29,13 @@ QString WLANModule::getPixmapName(Interface* ){
29 * Check to see if the interface i is owned by this module. 29 * Check to see if the interface i is owned by this module.
30 * @param Interface* interface to check against 30 * @param Interface* interface to check against
31 * @return bool true if i is owned by this module, false otherwise. 31 * @return bool true if i is owned by this module, false otherwise.
32 */ 32 */
33bool WLANModule::isOwner(Interface *i){ 33bool WLANModule::isOwner(Interface *i){
34 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ 34 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
35 i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName())); 35 i->setHardwareName("802.11b");
36 return true; 36 return true;
37 } 37 }
38 return false; 38 return false;
39} 39}
40 40
41/** 41/**