author | benmeyer <benmeyer> | 2002-10-18 14:28:42 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-18 14:28:42 (UTC) |
commit | 88b3a159060ed7057bfee4cc1ccfcf81a63a4780 (patch) (unidiff) | |
tree | 3dd78d403f337c73bb3ca9d75ef0a29f2adae9b6 /noncore/settings/networksettings | |
parent | 461113126af82cd6343eedab36ecabb4253780ee (diff) | |
download | opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.zip opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.gz opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.bz2 |
More profile stuff works
Diffstat (limited to 'noncore/settings/networksettings') (more/less context) (show whitespace changes)
13 files changed, 150 insertions, 131 deletions
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 @@ | |||
1 | Write a class that parses /proc and not ifconfig | 1 | Write a class that parses /proc and not ifconfig |
2 | WLAN needs to be re-written to not use Config | ||
3 | remove 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 | |||
@@ -1,45 +1,45 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>InterfaceAdvanced</class> | 2 | <class>InterfaceAdvanced</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>InterfaceAdvanced</cstring> | 7 | <cstring>InterfaceAdvanced</cstring> |
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>214</width> | 14 | <width>214</width> |
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> |
28 | </property> | 28 | </property> |
29 | <grid> | 29 | <grid> |
30 | <property stdset="1"> | 30 | <property stdset="1"> |
31 | <name>margin</name> | 31 | <name>margin</name> |
32 | <number>11</number> | 32 | <number>11</number> |
33 | </property> | 33 | </property> |
34 | <property stdset="1"> | 34 | <property stdset="1"> |
35 | <name>spacing</name> | 35 | <name>spacing</name> |
36 | <number>6</number> | 36 | <number>6</number> |
37 | </property> | 37 | </property> |
38 | <widget row="1" column="0" > | 38 | <widget row="1" column="0" > |
39 | <class>QLabel</class> | 39 | <class>QLabel</class> |
40 | <property stdset="1"> | 40 | <property stdset="1"> |
41 | <name>name</name> | 41 | <name>name</name> |
42 | <cstring>TextLabel1</cstring> | 42 | <cstring>TextLabel1</cstring> |
43 | </property> | 43 | </property> |
44 | <property stdset="1"> | 44 | <property stdset="1"> |
45 | <name>text</name> | 45 | <name>text</name> |
@@ -168,49 +168,49 @@ | |||
168 | <property stdset="1"> | 168 | <property stdset="1"> |
169 | <name>text</name> | 169 | <name>text</name> |
170 | <string>Broadcast</string> | 170 | <string>Broadcast</string> |
171 | </property> | 171 | </property> |
172 | </widget> | 172 | </widget> |
173 | <widget row="3" column="1" > | 173 | <widget row="3" column="1" > |
174 | <class>QLabel</class> | 174 | <class>QLabel</class> |
175 | <property stdset="1"> | 175 | <property stdset="1"> |
176 | <name>name</name> | 176 | <name>name</name> |
177 | <cstring>broadcastLabel</cstring> | 177 | <cstring>broadcastLabel</cstring> |
178 | </property> | 178 | </property> |
179 | <property stdset="1"> | 179 | <property stdset="1"> |
180 | <name>frameShape</name> | 180 | <name>frameShape</name> |
181 | <enum>Panel</enum> | 181 | <enum>Panel</enum> |
182 | </property> | 182 | </property> |
183 | <property stdset="1"> | 183 | <property stdset="1"> |
184 | <name>frameShadow</name> | 184 | <name>frameShadow</name> |
185 | <enum>Sunken</enum> | 185 | <enum>Sunken</enum> |
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> |
199 | <property stdset="1"> | 199 | <property stdset="1"> |
200 | <name>margin</name> | 200 | <name>margin</name> |
201 | <number>11</number> | 201 | <number>11</number> |
202 | </property> | 202 | </property> |
203 | <property stdset="1"> | 203 | <property stdset="1"> |
204 | <name>spacing</name> | 204 | <name>spacing</name> |
205 | <number>6</number> | 205 | <number>6</number> |
206 | </property> | 206 | </property> |
207 | <widget row="0" column="0" > | 207 | <widget row="0" column="0" > |
208 | <class>QLabel</class> | 208 | <class>QLabel</class> |
209 | <property stdset="1"> | 209 | <property stdset="1"> |
210 | <name>name</name> | 210 | <name>name</name> |
211 | <cstring>TextLabel6</cstring> | 211 | <cstring>TextLabel6</cstring> |
212 | </property> | 212 | </property> |
213 | <property stdset="1"> | 213 | <property stdset="1"> |
214 | <name>text</name> | 214 | <name>text</name> |
215 | <string>DHCP Server</string> | 215 | <string>DHCP Server</string> |
216 | </property> | 216 | </property> |
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 | |||
@@ -1,39 +1,39 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>InterfaceInformation</class> | 2 | <class>InterfaceInformation</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>InterfaceInformation</cstring> | 7 | <cstring>InterfaceInformation</cstring> |
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> |
22 | <grid> | 22 | <grid> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>margin</name> | 24 | <name>margin</name> |
25 | <number>11</number> | 25 | <number>11</number> |
26 | </property> | 26 | </property> |
27 | <property stdset="1"> | 27 | <property stdset="1"> |
28 | <name>spacing</name> | 28 | <name>spacing</name> |
29 | <number>6</number> | 29 | <number>6</number> |
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> |
@@ -312,32 +312,34 @@ | |||
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> | ||
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> |
342 | </tabstops> | 344 | </tabstops> |
343 | </UI> | 345 | </UI> |
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,29 +1,30 @@ | |||
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 | */ |
12 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ | 13 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ |
13 | assert(i); | 14 | assert(i); |
14 | 15 | ||
15 | interface = i; | 16 | interface = i; |
16 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 17 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
17 | updateInterface(interface); | 18 | updateInterface(interface); |
18 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); | 19 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); |
19 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); | 20 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); |
20 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); | 21 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); |
21 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); | 22 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); |
22 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); | 23 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); |
23 | 24 | ||
24 | } | 25 | } |
25 | 26 | ||
26 | /** | 27 | /** |
27 | * Update the interface information and buttons. | 28 | * Update the interface information and buttons. |
28 | * @param Intarface *i the interface to update (should be the one we already | 29 | * @param Intarface *i the interface to update (should be the one we already |
29 | * know about). | 30 | * know about). |
@@ -38,30 +39,32 @@ void InterfaceInformationImp::updateInterface(Interface *i){ | |||
38 | startButton->setEnabled(true); | 39 | startButton->setEnabled(true); |
39 | stopButton->setEnabled(false); | 40 | stopButton->setEnabled(false); |
40 | restartButton->setEnabled(false); | 41 | restartButton->setEnabled(false); |
41 | } | 42 | } |
42 | macAddressLabel->setText(interface->getMacAddress()); | 43 | macAddressLabel->setText(interface->getMacAddress()); |
43 | ipAddressLabel->setText(interface->getIp()); | 44 | ipAddressLabel->setText(interface->getIp()); |
44 | subnetMaskLabel->setText(interface->getSubnetMask()); | 45 | subnetMaskLabel->setText(interface->getSubnetMask()); |
45 | broadcastLabel->setText(interface->getBroadcast()); | 46 | broadcastLabel->setText(interface->getBroadcast()); |
46 | } | 47 | } |
47 | 48 | ||
48 | /** | 49 | /** |
49 | * Create the advanced widget. Fill it with the current interface's information. | 50 | * Create the advanced widget. Fill it with the current interface's information. |
50 | * Display it. | 51 | * Display it. |
51 | */ | 52 | */ |
52 | void InterfaceInformationImp::advanced(){ | 53 | void InterfaceInformationImp::advanced(){ |
53 | InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); | 54 | InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); |
54 | a->interfaceName->setText(interface->getInterfaceName()); | 55 | a->interfaceName->setText(interface->getInterfaceName()); |
55 | a->macAddressLabel->setText(interface->getMacAddress()); | 56 | a->macAddressLabel->setText(interface->getMacAddress()); |
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 | |||
@@ -324,51 +324,51 @@ bool Interfaces::setInterfaceOption(QString option, QString value){ | |||
324 | * Removes all of the options from the currently selected interface. | 324 | * Removes all of the options from the currently selected interface. |
325 | * @return bool error if if successfull | 325 | * @return bool error if if successfull |
326 | */ | 326 | */ |
327 | bool Interfaces::removeAllInterfaceOptions(){ | 327 | bool Interfaces::removeAllInterfaceOptions(){ |
328 | return removeAllOptions(currentIface); | 328 | return removeAllOptions(currentIface); |
329 | } | 329 | } |
330 | 330 | ||
331 | /** | 331 | /** |
332 | * Set the current map to interface's map. This needs to be done before you | 332 | * Set the current map to interface's map. This needs to be done before you |
333 | * can call addMapping(), set/getMap(), and get/setScript(). | 333 | * can call addMapping(), set/getMap(), and get/setScript(). |
334 | * @param interface the name of the interface to set. All whitespace is | 334 | * @param interface the name of the interface to set. All whitespace is |
335 | * removed from the interface name. | 335 | * removed from the interface name. |
336 | * @return bool true if it is successfull. | 336 | * @return bool true if it is successfull. |
337 | */ | 337 | */ |
338 | bool Interfaces::setMapping(QString interface){ | 338 | bool Interfaces::setMapping(QString interface){ |
339 | interface = interface.simplifyWhiteSpace(); | 339 | interface = interface.simplifyWhiteSpace(); |
340 | interface = interface.replace(QRegExp(" "), ""); | 340 | interface = interface.replace(QRegExp(" "), ""); |
341 | return setStanza(MAPPING, interface, currentMapping); | 341 | return setStanza(MAPPING, interface, currentMapping); |
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 | */ |
348 | void Interfaces::addMapping(QString interfaces){ | 348 | void 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 |
357 | * @return bool true if it is successfull. | 357 | * @return bool true if it is successfull. |
358 | */ | 358 | */ |
359 | bool Interfaces::setMap(QString map, QString value){ | 359 | bool Interfaces::setMap(QString map, QString value){ |
360 | return setOption(currentMapping, map, value); | 360 | return setOption(currentMapping, map, value); |
361 | } | 361 | } |
362 | 362 | ||
363 | /** | 363 | /** |
364 | * Get a map value within a mapping. | 364 | * Get a map value within a mapping. |
365 | * @param map map to get value of | 365 | * @param map map to get value of |
366 | * @param bool true if it is successfull. | 366 | * @param bool true if it is successfull. |
367 | * @return value that goes to the map | 367 | * @return value that goes to the map |
368 | */ | 368 | */ |
369 | QString Interfaces::getMap(QString map, bool &error){ | 369 | QString Interfaces::getMap(QString map, bool &error){ |
370 | return getOption(currentMapping, map, error); | 370 | return getOption(currentMapping, map, error); |
371 | } | 371 | } |
372 | 372 | ||
373 | /** | 373 | /** |
374 | * Sets a script value of the current mapping to argument. | 374 | * Sets a script value of the current mapping to argument. |
@@ -383,86 +383,93 @@ bool Interfaces::setScript(QString argument){ | |||
383 | * @param error true if could not retrieve the current script argument. | 383 | * @param error true if could not retrieve the current script argument. |
384 | * @return QString the argument of the script for the current mapping. | 384 | * @return QString the argument of the script for the current mapping. |
385 | */ | 385 | */ |
386 | QString Interfaces::getScript(bool &error){ | 386 | QString Interfaces::getScript(bool &error){ |
387 | return getOption(currentMapping, "script", error); | 387 | return getOption(currentMapping, "script", error); |
388 | } | 388 | } |
389 | 389 | ||
390 | /** | 390 | /** |
391 | * Helper function used to parse through the QStringList and put pointers in | 391 | * Helper function used to parse through the QStringList and put pointers in |
392 | * the correct place. | 392 | * the correct place. |
393 | * @param stanza The stanza (auto, iface, mapping) to look for. | 393 | * @param stanza The stanza (auto, iface, mapping) to look for. |
394 | * @param option string that must be in the stanza's main line. | 394 | * @param option string that must be in the stanza's main line. |
395 | * @param interator interator to place at location of stanza if successfull. | 395 | * @param interator interator to place at location of stanza if successfull. |
396 | * @return bool true if the stanza is found. | 396 | * @return bool true if the stanza is found. |
397 | */ | 397 | */ |
398 | bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ | 398 | bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ |
399 | bool found = false; | 399 | bool found = false; |
400 | iterator = interfaces.end(); | 400 | iterator = interfaces.end(); |
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. |
418 | * @return bool true if successfull, false otherwise. | 419 | * @return bool true if successfull, false otherwise. |
419 | */ | 420 | */ |
420 | bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ | 421 | bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ |
421 | if(start == interfaces.end()) | 422 | if(start == interfaces.end()) |
422 | return false; | 423 | return false; |
423 | 424 | ||
424 | bool found = false; | 425 | bool found = false; |
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. |
451 | */ | 458 | */ |
452 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ | 459 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ |
453 | if(start == interfaces.end()) | 460 | if(start == interfaces.end()) |
454 | return false; | 461 | return false; |
455 | 462 | ||
456 | QStringList::Iterator it = start; | 463 | QStringList::Iterator it = start; |
457 | it = ++it; | 464 | it = ++it; |
458 | for (it; it != interfaces.end(); ++it ) { | 465 | for (it; it != interfaces.end(); ++it ) { |
459 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 466 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
460 | break; | 467 | break; |
461 | } | 468 | } |
462 | it = interfaces.remove(it); | 469 | it = interfaces.remove(it); |
463 | it = --it; | 470 | it = --it; |
464 | } | 471 | } |
465 | // Leave a space between this interface and the next. | 472 | // Leave a space between this interface and the next. |
466 | interfaces.insert(it, QString("")); | 473 | interfaces.insert(it, QString("")); |
467 | return true; | 474 | return true; |
468 | } | 475 | } |
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 | |||
@@ -22,49 +22,49 @@ | |||
22 | class Interfaces { | 22 | class Interfaces { |
23 | 23 | ||
24 | public: | 24 | public: |
25 | Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); | 25 | Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); |
26 | QStringList getInterfaceList(); | 26 | QStringList getInterfaceList(); |
27 | 27 | ||
28 | bool isAuto(QString interface); | 28 | bool isAuto(QString interface); |
29 | bool setAuto(QString interface, bool setAuto); | 29 | bool setAuto(QString interface, bool setAuto); |
30 | 30 | ||
31 | bool removeInterface(); | 31 | bool removeInterface(); |
32 | bool addInterface(QString interface, QString family, QString method); | 32 | bool addInterface(QString interface, QString family, QString method); |
33 | bool setInterface(QString interface); | 33 | bool setInterface(QString interface); |
34 | bool isInterfaceSet(); | 34 | bool isInterfaceSet(); |
35 | QString getInterfaceName(bool &error); | 35 | QString getInterfaceName(bool &error); |
36 | bool setInterfaceName(QString newName); | 36 | bool setInterfaceName(QString newName); |
37 | QString getInterfaceFamily(bool &error); | 37 | QString getInterfaceFamily(bool &error); |
38 | bool setInterfaceFamily(QString newName); | 38 | bool setInterfaceFamily(QString newName); |
39 | QString getInterfaceMethod(bool &error); | 39 | QString getInterfaceMethod(bool &error); |
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(); |
53 | 53 | ||
54 | private: | 54 | private: |
55 | bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); | 55 | bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); |
56 | bool setOption(QStringList::Iterator start, QString option, QString value); | 56 | bool setOption(QStringList::Iterator start, QString option, QString value); |
57 | QString getOption(QStringList::Iterator start, QString option, bool &error); | 57 | QString getOption(QStringList::Iterator start, QString option, bool &error); |
58 | bool removeAllOptions(QStringList::Iterator start); | 58 | bool removeAllOptions(QStringList::Iterator start); |
59 | 59 | ||
60 | QString interfacesFile; | 60 | QString interfacesFile; |
61 | QStringList interfaces; | 61 | QStringList interfaces; |
62 | QStringList::Iterator currentIface; | 62 | QStringList::Iterator currentIface; |
63 | QStringList::Iterator currentMapping; | 63 | QStringList::Iterator currentMapping; |
64 | 64 | ||
65 | QStringList acceptedFamily; | 65 | QStringList acceptedFamily; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | // interfaces | 70 | // interfaces |
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 | |||
@@ -1,131 +1,69 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>InterfaceSetup</class> | 2 | <class>InterfaceSetup</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QDialog</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>InterfaceSetup</cstring> | 7 | <cstring>InterfaceSetup</cstring> |
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> |
21 | </property> | 21 | </property> |
22 | <vbox> | 22 | <vbox> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>margin</name> | 24 | <name>margin</name> |
25 | <number>11</number> | 25 | <number>11</number> |
26 | </property> | 26 | </property> |
27 | <property stdset="1"> | 27 | <property stdset="1"> |
28 | <name>spacing</name> | 28 | <name>spacing</name> |
29 | <number>6</number> | 29 | <number>6</number> |
30 | </property> | 30 | </property> |
31 | <widget> | 31 | <widget> |
32 | <class>QCheckBox</class> | 32 | <class>QCheckBox</class> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>name</name> | 34 | <name>name</name> |
35 | <cstring>autoStart</cstring> | 35 | <cstring>autoStart</cstring> |
36 | </property> | 36 | </property> |
37 | <property stdset="1"> | 37 | <property stdset="1"> |
38 | <name>text</name> | 38 | <name>text</name> |
39 | <string>Automaticly bring up</string> | 39 | <string>Automaticly bring up</string> |
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> |
114 | </property> | 52 | </property> |
115 | <property stdset="1"> | 53 | <property stdset="1"> |
116 | <name>spacing</name> | 54 | <name>spacing</name> |
117 | <number>6</number> | 55 | <number>6</number> |
118 | </property> | 56 | </property> |
119 | <widget> | 57 | <widget> |
120 | <class>QCheckBox</class> | 58 | <class>QCheckBox</class> |
121 | <property stdset="1"> | 59 | <property stdset="1"> |
122 | <name>name</name> | 60 | <name>name</name> |
123 | <cstring>dhcpCheckBox</cstring> | 61 | <cstring>dhcpCheckBox</cstring> |
124 | </property> | 62 | </property> |
125 | <property stdset="1"> | 63 | <property stdset="1"> |
126 | <name>text</name> | 64 | <name>text</name> |
127 | <string>DHCP</string> | 65 | <string>DHCP</string> |
128 | </property> | 66 | </property> |
129 | <property stdset="1"> | 67 | <property stdset="1"> |
130 | <name>checked</name> | 68 | <name>checked</name> |
131 | <bool>true</bool> | 69 | <bool>true</bool> |
@@ -133,215 +71,214 @@ | |||
133 | </widget> | 71 | </widget> |
134 | <widget> | 72 | <widget> |
135 | <class>QLabel</class> | 73 | <class>QLabel</class> |
136 | <property stdset="1"> | 74 | <property stdset="1"> |
137 | <name>name</name> | 75 | <name>name</name> |
138 | <cstring>leaseHoursLabel</cstring> | 76 | <cstring>leaseHoursLabel</cstring> |
139 | </property> | 77 | </property> |
140 | <property stdset="1"> | 78 | <property stdset="1"> |
141 | <name>text</name> | 79 | <name>text</name> |
142 | <string>Requested Lease</string> | 80 | <string>Requested Lease</string> |
143 | </property> | 81 | </property> |
144 | </widget> | 82 | </widget> |
145 | <widget> | 83 | <widget> |
146 | <class>QSpinBox</class> | 84 | <class>QSpinBox</class> |
147 | <property stdset="1"> | 85 | <property stdset="1"> |
148 | <name>name</name> | 86 | <name>name</name> |
149 | <cstring>leaseTime</cstring> | 87 | <cstring>leaseTime</cstring> |
150 | </property> | 88 | </property> |
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> |
172 | <property stdset="1"> | 110 | <property stdset="1"> |
173 | <name>name</name> | 111 | <name>name</name> |
174 | <cstring>staticGroupBox</cstring> | 112 | <cstring>staticGroupBox</cstring> |
175 | </property> | 113 | </property> |
176 | <property stdset="1"> | 114 | <property stdset="1"> |
177 | <name>enabled</name> | 115 | <name>enabled</name> |
178 | <bool>false</bool> | 116 | <bool>false</bool> |
179 | </property> | 117 | </property> |
180 | <property stdset="1"> | 118 | <property stdset="1"> |
181 | <name>frameShape</name> | 119 | <name>frameShape</name> |
182 | <enum>Box</enum> | 120 | <enum>Box</enum> |
183 | </property> | 121 | </property> |
184 | <property stdset="1"> | 122 | <property stdset="1"> |
185 | <name>frameShadow</name> | 123 | <name>frameShadow</name> |
186 | <enum>Sunken</enum> | 124 | <enum>Sunken</enum> |
187 | </property> | 125 | </property> |
188 | <property stdset="1"> | 126 | <property stdset="1"> |
189 | <name>title</name> | 127 | <name>title</name> |
190 | <string>Static Ip Configuration</string> | 128 | <string>Static Ip Configuration</string> |
191 | </property> | 129 | </property> |
192 | <grid> | 130 | <grid> |
193 | <property stdset="1"> | 131 | <property stdset="1"> |
194 | <name>margin</name> | 132 | <name>margin</name> |
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> |
214 | <property stdset="1"> | 145 | <property stdset="1"> |
215 | <name>text</name> | 146 | <name>text</name> |
216 | <string>Subnet Mask</string> | 147 | <string>Subnet Mask</string> |
217 | </property> | 148 | </property> |
218 | </widget> | 149 | </widget> |
219 | <widget row="2" column="1" > | 150 | <widget row="2" column="1" > |
220 | <class>QLineEdit</class> | 151 | <class>QLineEdit</class> |
221 | <property stdset="1"> | 152 | <property stdset="1"> |
222 | <name>name</name> | 153 | <name>name</name> |
223 | <cstring>gatewayEdit</cstring> | 154 | <cstring>gatewayEdit</cstring> |
224 | </property> | 155 | </property> |
225 | </widget> | 156 | </widget> |
226 | <widget row="1" column="1" > | 157 | <widget row="1" column="1" > |
227 | <class>QLineEdit</class> | 158 | <class>QLineEdit</class> |
228 | <property stdset="1"> | 159 | <property stdset="1"> |
229 | <name>name</name> | 160 | <name>name</name> |
230 | <cstring>subnetMaskEdit</cstring> | 161 | <cstring>subnetMaskEdit</cstring> |
231 | </property> | 162 | </property> |
232 | </widget> | 163 | </widget> |
233 | <widget row="0" column="1" > | 164 | <widget row="0" column="1" > |
234 | <class>QLineEdit</class> | 165 | <class>QLineEdit</class> |
235 | <property stdset="1"> | 166 | <property stdset="1"> |
236 | <name>name</name> | 167 | <name>name</name> |
237 | <cstring>ipAddressEdit</cstring> | 168 | <cstring>ipAddressEdit</cstring> |
238 | </property> | 169 | </property> |
239 | </widget> | 170 | </widget> |
240 | <widget row="3" column="0" > | 171 | <widget row="3" column="0" > |
241 | <class>QLabel</class> | 172 | <class>QLabel</class> |
242 | <property stdset="1"> | 173 | <property stdset="1"> |
243 | <name>name</name> | 174 | <name>name</name> |
244 | <cstring>TextLabel2</cstring> | 175 | <cstring>TextLabel2</cstring> |
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> |
264 | <property stdset="1"> | 188 | <property stdset="1"> |
265 | <name>text</name> | 189 | <name>text</name> |
266 | <string>IP Address</string> | 190 | <string>IP Address</string> |
267 | </property> | 191 | </property> |
268 | </widget> | 192 | </widget> |
269 | <widget row="2" column="0" > | 193 | <widget row="2" column="0" > |
270 | <class>QLabel</class> | 194 | <class>QLabel</class> |
271 | <property stdset="1"> | 195 | <property stdset="1"> |
272 | <name>name</name> | 196 | <name>name</name> |
273 | <cstring>TextLabel1_2</cstring> | 197 | <cstring>TextLabel1_2</cstring> |
274 | </property> | 198 | </property> |
275 | <property stdset="1"> | 199 | <property stdset="1"> |
276 | <name>text</name> | 200 | <name>text</name> |
277 | <string>Gateway</string> | 201 | <string>Gateway</string> |
278 | </property> | 202 | </property> |
279 | </widget> | 203 | </widget> |
280 | <widget row="4" column="0" > | 204 | <widget row="4" column="0" > |
281 | <class>QLabel</class> | 205 | <class>QLabel</class> |
282 | <property stdset="1"> | 206 | <property stdset="1"> |
283 | <name>name</name> | 207 | <name>name</name> |
284 | <cstring>TextLabel3</cstring> | 208 | <cstring>TextLabel3</cstring> |
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> |
297 | </property> | 235 | </property> |
298 | <property stdset="1"> | 236 | <property stdset="1"> |
299 | <name>orientation</name> | 237 | <name>orientation</name> |
300 | <enum>Vertical</enum> | 238 | <enum>Vertical</enum> |
301 | </property> | 239 | </property> |
302 | <property stdset="1"> | 240 | <property stdset="1"> |
303 | <name>sizeType</name> | 241 | <name>sizeType</name> |
304 | <enum>Expanding</enum> | 242 | <enum>Expanding</enum> |
305 | </property> | 243 | </property> |
306 | <property> | 244 | <property> |
307 | <name>sizeHint</name> | 245 | <name>sizeHint</name> |
308 | <size> | 246 | <size> |
309 | <width>20</width> | 247 | <width>20</width> |
310 | <height>20</height> | 248 | <height>20</height> |
311 | </size> | 249 | </size> |
312 | </property> | 250 | </property> |
313 | </spacer> | 251 | </spacer> |
314 | </vbox> | 252 | </vbox> |
315 | </widget> | 253 | </widget> |
316 | <connections> | 254 | <connections> |
317 | <connection> | 255 | <connection> |
318 | <sender>dhcpCheckBox</sender> | 256 | <sender>dhcpCheckBox</sender> |
319 | <signal>toggled(bool)</signal> | 257 | <signal>toggled(bool)</signal> |
320 | <receiver>leaseHoursLabel</receiver> | 258 | <receiver>leaseHoursLabel</receiver> |
321 | <slot>setEnabled(bool)</slot> | 259 | <slot>setEnabled(bool)</slot> |
322 | </connection> | 260 | </connection> |
323 | <connection> | 261 | <connection> |
324 | <sender>dhcpCheckBox</sender> | 262 | <sender>dhcpCheckBox</sender> |
325 | <signal>toggled(bool)</signal> | 263 | <signal>toggled(bool)</signal> |
326 | <receiver>leaseTime</receiver> | 264 | <receiver>leaseTime</receiver> |
327 | <slot>setEnabled(bool)</slot> | 265 | <slot>setEnabled(bool)</slot> |
328 | </connection> | 266 | </connection> |
329 | <connection> | 267 | <connection> |
330 | <sender>dhcpCheckBox</sender> | 268 | <sender>dhcpCheckBox</sender> |
331 | <signal>toggled(bool)</signal> | 269 | <signal>toggled(bool)</signal> |
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> |
345 | <tabstop>secondDNSLineEdit</tabstop> | 282 | <tabstop>secondDNSLineEdit</tabstop> |
346 | </tabstops> | 283 | </tabstops> |
347 | </UI> | 284 | </UI> |
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 | |||
@@ -1,57 +1,55 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | #include "interfaces.h" | 3 | #include "interfaces.h" |
4 | 4 | ||
5 | #include <qcombobox.h> | 5 | #include <qcombobox.h> |
6 | #include <qcheckbox.h> | 6 | #include <qcheckbox.h> |
7 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
8 | #include <qspinbox.h> | 8 | #include <qspinbox.h> |
9 | #include <qgroupbox.h> | 9 | #include <qgroupbox.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | 11 | ||
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | 13 | ||
14 | #include <assert.h> | 14 | #include <assert.h> |
15 | 15 | ||
16 | #define DNSSCRIPT "interfacednsscript" | 16 | #define DNSSCRIPT "interfacednsscript" |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Constuctor. Set up the connection and load the first profile. | 19 | * Constuctor. Set up the connection and load the first profile. |
20 | */ | 20 | */ |
21 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ | 21 | InterfaceSetupImp::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 | */ |
39 | void InterfaceSetupImp::accept(){ | 37 | void InterfaceSetupImp::accept(){ |
40 | if(!saveSettings()) | 38 | if(!saveSettings()) |
41 | return; | 39 | return; |
42 | interfaces->write(); | 40 | interfaces->write(); |
43 | close(true); | 41 | close(true); |
44 | } | 42 | } |
45 | 43 | ||
46 | /** | 44 | /** |
47 | * Save the settings for the current Interface. | 45 | * Save the settings for the current Interface. |
48 | * @return bool true if successfull, false otherwise | 46 | * @return bool true if successfull, false otherwise |
49 | */ | 47 | */ |
50 | bool InterfaceSetupImp::saveSettings(){ | 48 | bool InterfaceSetupImp::saveSettings(){ |
51 | // eh can't really do anything about it other then return. :-D | 49 | // eh can't really do anything about it other then return. :-D |
52 | if(!interfaces->isInterfaceSet()) | 50 | if(!interfaces->isInterfaceSet()) |
53 | return true; | 51 | return true; |
54 | 52 | ||
55 | bool error = false; | 53 | bool error = false; |
56 | // Loopback case | 54 | // Loopback case |
57 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 55 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
@@ -69,77 +67,76 @@ bool InterfaceSetupImp::saveSettings(){ | |||
69 | if(dhcpCheckBox->isChecked()){ | 67 | if(dhcpCheckBox->isChecked()){ |
70 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 68 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
71 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 69 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
72 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 70 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
73 | } | 71 | } |
74 | else{ | 72 | else{ |
75 | interfaces->setInterfaceMethod("static"); | 73 | interfaces->setInterfaceMethod("static"); |
76 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 74 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
77 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 75 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
78 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 76 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
79 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 77 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
80 | interfaces->setInterfaceOption("up "DNSSCRIPT" add ", dns); | 78 | interfaces->setInterfaceOption("up "DNSSCRIPT" add ", dns); |
81 | interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns); | 79 | interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns); |
82 | } | 80 | } |
83 | 81 | ||
84 | // IP Information | 82 | // IP Information |
85 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 83 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
86 | return true; | 84 | return true; |
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 | */ |
93 | void InterfaceSetupImp::changeProfile(const QString &profile){ | 91 | void 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) |
128 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 125 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
129 | if(error) | 126 | if(error) |
130 | leaseTime->setValue(24); | 127 | leaseTime->setValue(24); |
131 | 128 | ||
132 | // IP Information | 129 | // IP Information |
133 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 130 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
134 | QString dns = interfaces->getInterfaceOption("up interfacednsscript add", error); | 131 | QString dns = interfaces->getInterfaceOption("up interfacednsscript add", error); |
135 | if(dns.contains(" ")){ | 132 | if(dns.contains(" ")){ |
136 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 133 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
137 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 134 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
138 | } | 135 | } |
139 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 136 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
140 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 137 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
141 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 138 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
142 | } | 139 | } |
143 | 140 | ||
144 | 141 | ||
145 | // interfacesetup.cpp | 142 | // interfacesetup.cpp |
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 | |||
@@ -1,30 +1,31 @@ | |||
1 | #ifndef INTERFACESETUPIMP_H | 1 | #ifndef INTERFACESETUPIMP_H |
2 | #define INTERFACESETUPIMP_H | 2 | #define INTERFACESETUPIMP_H |
3 | 3 | ||
4 | #include "interfacesetup.h" | 4 | #include "interfacesetup.h" |
5 | 5 | ||
6 | class Interface; | 6 | class Interface; |
7 | class Interfaces; | 7 | class Interfaces; |
8 | 8 | ||
9 | class InterfaceSetupImp : public InterfaceSetup { | 9 | class InterfaceSetupImp : public InterfaceSetup { |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
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 | ||
15 | protected slots: | 15 | protected slots: |
16 | void accept(); | 16 | void accept(); |
17 | void changeProfile(const QString &profile); | 17 | |
18 | public slots: | ||
19 | void setProfile(const QString &profile); | ||
18 | 20 | ||
19 | private: | 21 | private: |
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 |
30 | 31 | ||
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 | |||
@@ -1,38 +1,38 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>MainWindow</class> | 2 | <class>MainWindow</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>MainWindow</cstring> | 7 | <cstring>MainWindow</cstring> |
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> |
21 | </property> | 21 | </property> |
22 | <vbox> | 22 | <vbox> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>margin</name> | 24 | <name>margin</name> |
25 | <number>0</number> | 25 | <number>0</number> |
26 | </property> | 26 | </property> |
27 | <property stdset="1"> | 27 | <property stdset="1"> |
28 | <name>spacing</name> | 28 | <name>spacing</name> |
29 | <number>6</number> | 29 | <number>6</number> |
30 | </property> | 30 | </property> |
31 | <widget> | 31 | <widget> |
32 | <class>QTabWidget</class> | 32 | <class>QTabWidget</class> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>name</name> | 34 | <name>name</name> |
35 | <cstring>tabWidget</cstring> | 35 | <cstring>tabWidget</cstring> |
36 | </property> | 36 | </property> |
37 | <property> | 37 | <property> |
38 | <name>layoutMargin</name> | 38 | <name>layoutMargin</name> |
@@ -40,90 +40,104 @@ | |||
40 | <widget> | 40 | <widget> |
41 | <class>QWidget</class> | 41 | <class>QWidget</class> |
42 | <property stdset="1"> | 42 | <property stdset="1"> |
43 | <name>name</name> | 43 | <name>name</name> |
44 | <cstring>Widget3</cstring> | 44 | <cstring>Widget3</cstring> |
45 | </property> | 45 | </property> |
46 | <attribute> | 46 | <attribute> |
47 | <name>title</name> | 47 | <name>title</name> |
48 | <string>Connections</string> | 48 | <string>Connections</string> |
49 | </attribute> | 49 | </attribute> |
50 | <vbox> | 50 | <vbox> |
51 | <property stdset="1"> | 51 | <property stdset="1"> |
52 | <name>margin</name> | 52 | <name>margin</name> |
53 | <number>0</number> | 53 | <number>0</number> |
54 | </property> | 54 | </property> |
55 | <property stdset="1"> | 55 | <property stdset="1"> |
56 | <name>spacing</name> | 56 | <name>spacing</name> |
57 | <number>6</number> | 57 | <number>6</number> |
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> |
71 | <name>resizeable</name> | 71 | <name>resizeable</name> |
72 | <bool>true</bool> | 72 | <bool>true</bool> |
73 | </property> | 73 | </property> |
74 | </column> | 74 | </column> |
75 | <column> | 75 | <column> |
76 | <property> | 76 | <property> |
77 | <name>text</name> | 77 | <name>text</name> |
78 | <string>t</string> | 78 | <string>t</string> |
79 | </property> | 79 | </property> |
80 | <property> | 80 | <property> |
81 | <name>clickable</name> | 81 | <name>clickable</name> |
82 | <bool>true</bool> | 82 | <bool>true</bool> |
83 | </property> | 83 | </property> |
84 | <property> | 84 | <property> |
85 | <name>resizeable</name> | 85 | <name>resizeable</name> |
86 | <bool>true</bool> | 86 | <bool>true</bool> |
87 | </property> | 87 | </property> |
88 | </column> | 88 | </column> |
89 | <column> | 89 | <column> |
90 | <property> | 90 | <property> |
91 | <name>text</name> | 91 | <name>text</name> |
92 | <string>Name</string> | 92 | <string>Name</string> |
93 | </property> | 93 | </property> |
94 | <property> | 94 | <property> |
95 | <name>clickable</name> | 95 | <name>clickable</name> |
96 | <bool>true</bool> | 96 | <bool>true</bool> |
97 | </property> | 97 | </property> |
98 | <property> | 98 | <property> |
99 | <name>resizeable</name> | 99 | <name>resizeable</name> |
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> |
112 | <property> | 126 | <property> |
113 | <name>resizeable</name> | 127 | <name>resizeable</name> |
114 | <bool>true</bool> | 128 | <bool>true</bool> |
115 | </property> | 129 | </property> |
116 | </column> | 130 | </column> |
117 | <property stdset="1"> | 131 | <property stdset="1"> |
118 | <name>name</name> | 132 | <name>name</name> |
119 | <cstring>connectionList</cstring> | 133 | <cstring>connectionList</cstring> |
120 | </property> | 134 | </property> |
121 | <property stdset="1"> | 135 | <property stdset="1"> |
122 | <name>allColumnsShowFocus</name> | 136 | <name>allColumnsShowFocus</name> |
123 | <bool>true</bool> | 137 | <bool>true</bool> |
124 | </property> | 138 | </property> |
125 | </widget> | 139 | </widget> |
126 | <widget> | 140 | <widget> |
127 | <class>QLayoutWidget</class> | 141 | <class>QLayoutWidget</class> |
128 | <property stdset="1"> | 142 | <property stdset="1"> |
129 | <name>name</name> | 143 | <name>name</name> |
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 | |||
@@ -11,82 +11,97 @@ | |||
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qtabwidget.h> | 12 | #include <qtabwidget.h> |
13 | #include <qlistbox.h> | 13 | #include <qlistbox.h> |
14 | #include <qlineedit.h> | 14 | #include <qlineedit.h> |
15 | #include <qlistview.h> | 15 | #include <qlistview.h> |
16 | #include <qheader.h> | 16 | #include <qheader.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | 18 | ||
19 | #include <qmainwindow.h> | 19 | #include <qmainwindow.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | 21 | ||
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qpe/qlibrary.h> | 23 | #include <qpe/qlibrary.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | 26 | ||
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
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" | ||
35 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ | 36 | MainWindowImp::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 | ||
41 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 42 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
42 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 43 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
43 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 44 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
44 | 45 | ||
45 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 46 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
46 | // Load connections. | 47 | // Load connections. |
47 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); | 48 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); |
48 | getInterfaceList(); | 49 | getInterfaceList(); |
49 | connectionList->header()->hide(); | 50 | connectionList->header()->hide(); |
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 | */ |
62 | MainWindowImp::~MainWindowImp(){ | 78 | MainWindowImp::~MainWindowImp(){ |
63 | // Save profiles. | 79 | // Save profiles. |
64 | if(profiles.count() > 1){ | ||
65 | Config cfg("NetworkSetup"); | 80 | Config cfg("NetworkSetup"); |
66 | cfg.setGroup("General"); | 81 | cfg.setGroup("General"); |
67 | cfg.writeEntry("Profiles", profiles.join(" ")); | 82 | cfg.writeEntry("Profiles", profiles.join(" ")); |
68 | } | 83 | |
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 | } |
75 | } | 90 | } |
76 | 91 | ||
77 | /** | 92 | /** |
78 | * Load all modules that are found in the path | 93 | * Load all modules that are found in the path |
79 | * @param path a directory that is scaned for any plugins that can be loaded | 94 | * @param path a directory that is scaned for any plugins that can be loaded |
80 | * and attempts to load them | 95 | * and attempts to load them |
81 | */ | 96 | */ |
82 | void MainWindowImp::loadModules(QString path){ | 97 | void MainWindowImp::loadModules(QString path){ |
83 | qDebug(path.latin1()); | 98 | qDebug(path.latin1()); |
84 | QDir d(path); | 99 | QDir d(path); |
85 | if(!d.exists()) | 100 | if(!d.exists()) |
86 | return; | 101 | return; |
87 | 102 | ||
88 | // Don't want sym links | 103 | // Don't want sym links |
89 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 104 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
90 | const QFileInfoList *list = d.entryInfoList(); | 105 | const QFileInfoList *list = d.entryInfoList(); |
91 | QFileInfoListIterator it( *list ); | 106 | QFileInfoListIterator it( *list ); |
92 | QFileInfo *fi; | 107 | QFileInfo *fi; |
@@ -185,86 +200,101 @@ void MainWindowImp::removeClicked(){ | |||
185 | else{ | 200 | else{ |
186 | if(!i->getModuleOwner()->remove(i)) | 201 | if(!i->getModuleOwner()->remove(i)) |
187 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 202 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
188 | else{ | 203 | else{ |
189 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 204 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
190 | // TODO memory managment.... | 205 | // TODO memory managment.... |
191 | // who deletes the interface? | 206 | // who deletes the interface? |
192 | } | 207 | } |
193 | } | 208 | } |
194 | } | 209 | } |
195 | 210 | ||
196 | /** | 211 | /** |
197 | * Pull up the configure about the currently selected interface. | 212 | * Pull up the configure about the currently selected interface. |
198 | * Report an error if no interface is selected. | 213 | * Report an error if no interface is selected. |
199 | * If the interface has a module owner then request its configure with a empty | 214 | * If the interface has a module owner then request its configure with a empty |
200 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 215 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
201 | */ | 216 | */ |
202 | void MainWindowImp::configureClicked(){ | 217 | void 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); |
237 | configure->setProfile(currentProfileLabel->text()); | ||
216 | tabWidget->insertTab(configure, "TCP/IP"); | 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. |
231 | * Report an error if no interface is selected. | 255 | * Report an error if no interface is selected. |
232 | * If the interface has a module owner then request its configure with a empty | 256 | * If the interface has a module owner then request its configure with a empty |
233 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 257 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
234 | */ | 258 | */ |
235 | void MainWindowImp::informationClicked(){ | 259 | void MainWindowImp::informationClicked(){ |
236 | QListViewItem *item = connectionList->currentItem(); | 260 | QListViewItem *item = connectionList->currentItem(); |
237 | if(!item){ | 261 | if(!item){ |
238 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 262 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
239 | return; | 263 | return; |
240 | } | 264 | } |
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); |
253 | tabWidget->insertTab(information, "TCP/IP"); | 283 | tabWidget->insertTab(information, "TCP/IP"); |
254 | } | 284 | } |
255 | moduleInformation->showMaximized(); | 285 | moduleInformation->showMaximized(); |
256 | moduleInformation->show(); | 286 | moduleInformation->show(); |
257 | return; | 287 | return; |
258 | } | 288 | } |
259 | } | 289 | } |
260 | 290 | ||
261 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); | 291 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); |
262 | information->showMaximized(); | 292 | information->showMaximized(); |
263 | information->show(); | 293 | information->show(); |
264 | } | 294 | } |
265 | 295 | ||
266 | /** | 296 | /** |
267 | * Aquire the list of active interfaces from ifconfig | 297 | * Aquire the list of active interfaces from ifconfig |
268 | * Call ifconfig and ifconfig -a | 298 | * Call ifconfig and ifconfig -a |
269 | */ | 299 | */ |
270 | void MainWindowImp::getInterfaceList(){ | 300 | void MainWindowImp::getInterfaceList(){ |
@@ -299,78 +329,78 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
299 | QString line; | 329 | QString line; |
300 | while ( !stream.eof() ) { | 330 | while ( !stream.eof() ) { |
301 | line = stream.readLine(); | 331 | line = stream.readLine(); |
302 | int space = line.find(" "); | 332 | int space = line.find(" "); |
303 | if(space > 1){ | 333 | if(space > 1){ |
304 | // We have found an interface | 334 | // We have found an interface |
305 | QString interfaceName = line.mid(0, space); | 335 | QString interfaceName = line.mid(0, space); |
306 | Interface *i; | 336 | Interface *i; |
307 | // We have found an interface | 337 | // We have found an interface |
308 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | 338 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); |
309 | // See if we already have it | 339 | // See if we already have it |
310 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 340 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
311 | if(fileName == TEMP_ALL) | 341 | if(fileName == TEMP_ALL) |
312 | i = new Interface(this, interfaceName, false); | 342 | i = new Interface(this, interfaceName, false); |
313 | else | 343 | else |
314 | i = new Interface(this, interfaceName, true); | 344 | i = new Interface(this, interfaceName, true); |
315 | i->setAttached(true); | 345 | i->setAttached(true); |
316 | 346 | ||
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. |
330 | else{ | 360 | else{ |
331 | if(fileName != TEMP_ALL) | 361 | if(fileName != TEMP_ALL) |
332 | (interfaceNames[interfaceName])->setStatus(true); | 362 | (interfaceNames[interfaceName])->setStatus(true); |
333 | } | 363 | } |
334 | } | 364 | } |
335 | } | 365 | } |
336 | file.close(); | 366 | file.close(); |
337 | QFile::remove(fileName); | 367 | QFile::remove(fileName); |
338 | 368 | ||
339 | if(threads.count() == 0){ | 369 | if(threads.count() == 0){ |
340 | Interfaces i; | 370 | Interfaces i; |
341 | QStringList list = i.getInterfaceList(); | 371 | QStringList list = i.getInterfaceList(); |
342 | QMap<QString, Interface*>::Iterator it; | 372 | QMap<QString, Interface*>::Iterator it; |
343 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 373 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
344 | bool found = false; | 374 | bool found = false; |
345 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 375 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
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 | } |
359 | } | 389 | } |
360 | 390 | ||
361 | /** | 391 | /** |
362 | * Update this interface. If no QListViewItem exists create one. | 392 | * Update this interface. If no QListViewItem exists create one. |
363 | * @param Interface* pointer to the interface that needs to be updated. | 393 | * @param Interface* pointer to the interface that needs to be updated. |
364 | */ | 394 | */ |
365 | void MainWindowImp::updateInterface(Interface *i){ | 395 | void MainWindowImp::updateInterface(Interface *i){ |
366 | if(!advancedUserMode){ | 396 | if(!advancedUserMode){ |
367 | if(i->getInterfaceName() == "lo") | 397 | if(i->getInterfaceName() == "lo") |
368 | return; | 398 | return; |
369 | } | 399 | } |
370 | 400 | ||
371 | QListViewItem *item = NULL; | 401 | QListViewItem *item = NULL; |
372 | 402 | ||
373 | // Find the interface, making it if needed. | 403 | // Find the interface, making it if needed. |
374 | if(items.find(i) == items.end()){ | 404 | if(items.find(i) == items.end()){ |
375 | item = new QListViewItem(connectionList, "", "", ""); | 405 | item = new QListViewItem(connectionList, "", "", ""); |
376 | // See if you can't find a module owner for this interface | 406 | // See if you can't find a module owner for this interface |
@@ -385,78 +415,111 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
385 | else | 415 | else |
386 | item = items[i]; | 416 | item = items[i]; |
387 | 417 | ||
388 | // Update the icons and information | 418 | // Update the icons and information |
389 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 419 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
390 | 420 | ||
391 | QString typeName = "lan"; | 421 | QString typeName = "lan"; |
392 | if(i->getHardwareName().contains("Local Loopback")) | 422 | if(i->getHardwareName().contains("Local Loopback")) |
393 | typeName = "lo"; | 423 | typeName = "lo"; |
394 | if(i->getInterfaceName().contains("irda")) | 424 | if(i->getInterfaceName().contains("irda")) |
395 | typeName = "irda"; | 425 | typeName = "irda"; |
396 | if(i->getInterfaceName().contains("wlan")) | 426 | if(i->getInterfaceName().contains("wlan")) |
397 | typeName = "wlan"; | 427 | typeName = "wlan"; |
398 | if(i->getInterfaceName().contains("usb")) | 428 | if(i->getInterfaceName().contains("usb")) |
399 | typeName = "usb"; | 429 | typeName = "usb"; |
400 | 430 | ||
401 | if(!i->isAttached()) | 431 | if(!i->isAttached()) |
402 | typeName = "connect_no"; | 432 | typeName = "connect_no"; |
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 | ||
412 | void MainWindowImp::newProfileChanged(const QString& newText){ | 443 | void 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 |
416 | newProfileButton->setEnabled(false); | 447 | newProfileButton->setEnabled(false); |
417 | } | 448 | } |
418 | 449 | ||
419 | /** | 450 | /** |
420 | * Adds a new profile to the list of profiles. | 451 | * Adds a new profile to the list of profiles. |
421 | * Don't add profiles that already exists. | 452 | * Don't add profiles that already exists. |
422 | * Appends to the list and QStringList | 453 | * Appends to the list and QStringList |
423 | */ | 454 | */ |
424 | void MainWindowImp::addProfile(){ | 455 | void MainWindowImp::addProfile(){ |
425 | QString newProfileName = newProfile->text(); | 456 | QString newProfileName = newProfile->text(); |
426 | if(profiles.grep(newProfileName).count() > 0){ | 457 | if(profiles.grep(newProfileName).count() > 0){ |
427 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); | 458 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); |
428 | return; | 459 | return; |
429 | } | 460 | } |
430 | profiles.append(newProfileName); | 461 | profiles.append(newProfileName); |
431 | profilesList->insertItem(newProfileName); | 462 | profilesList->insertItem(newProfileName); |
432 | } | 463 | } |
433 | 464 | ||
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 | */ |
438 | void MainWindowImp::removeProfile(){ | 469 | void 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 | */ |
457 | void MainWindowImp::changeProfile(){ | 498 | void 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 | |||
@@ -76,49 +76,48 @@ bool WLANImp::writeConfig() | |||
76 | if( networkInfrastructure->isChecked() ){ | 76 | if( networkInfrastructure->isChecked() ){ |
77 | config.writeEntry( "Mode", "Managed" ); | 77 | config.writeEntry( "Mode", "Managed" ); |
78 | } else if( network802->isChecked() ){ | 78 | } else if( network802->isChecked() ){ |
79 | config.writeEntry( "Mode", "adhoc" ); | 79 | config.writeEntry( "Mode", "adhoc" ); |
80 | } | 80 | } |
81 | config.writeEntry( "CHANNEL", networkChannel->value() ); | 81 | config.writeEntry( "CHANNEL", networkChannel->value() ); |
82 | // config.readEntry( "RATE", "auto" ); | 82 | // config.readEntry( "RATE", "auto" ); |
83 | wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); | 83 | wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); |
84 | authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); | 84 | authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); |
85 | key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); | 85 | key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); |
86 | if( keyRadio0->isChecked() ){ | 86 | if( keyRadio0->isChecked() ){ |
87 | config.writeEntry( "dot11WEPDefaultKeyID", 0 ); | 87 | config.writeEntry( "dot11WEPDefaultKeyID", 0 ); |
88 | } else if( keyRadio1->isChecked() ){ | 88 | } else if( keyRadio1->isChecked() ){ |
89 | config.writeEntry( "dot11WEPDefaultKeyID", 1 ); | 89 | config.writeEntry( "dot11WEPDefaultKeyID", 1 ); |
90 | } else if( keyRadio2->isChecked() ){ | 90 | } else if( keyRadio2->isChecked() ){ |
91 | config.writeEntry( "dot11WEPDefaultKeyID", 2 ); | 91 | config.writeEntry( "dot11WEPDefaultKeyID", 2 ); |
92 | } else if( keyRadio3->isChecked() ){ | 92 | } else if( keyRadio3->isChecked() ){ |
93 | config.writeEntry( "dot11WEPDefaultKeyID", 3 ); | 93 | config.writeEntry( "dot11WEPDefaultKeyID", 3 ); |
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 | */ |
105 | void WLANImp::accept() | 104 | void WLANImp::accept() |
106 | { | 105 | { |
107 | if ( writeConfig() ) | 106 | if ( writeConfig() ) |
108 | QDialog::accept(); | 107 | QDialog::accept(); |
109 | } | 108 | } |
110 | 109 | ||
111 | void WLANImp::done ( int r ) | 110 | void WLANImp::done ( int r ) |
112 | { | 111 | { |
113 | QDialog::done ( r ); | 112 | QDialog::done ( r ); |
114 | close ( ); | 113 | close ( ); |
115 | } | 114 | } |
116 | 115 | ||
117 | bool WLANImp::writeWirelessOpts( Config &config, QString scheme ) | 116 | bool WLANImp::writeWirelessOpts( Config &config, QString scheme ) |
118 | { | 117 | { |
119 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 118 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
120 | QString prev = "/etc/pcmcia/wireless.opts"; | 119 | QString prev = "/etc/pcmcia/wireless.opts"; |
121 | QFile prevFile(prev); | 120 | QFile prevFile(prev); |
122 | if ( !prevFile.open( IO_ReadOnly ) ) | 121 | if ( !prevFile.open( IO_ReadOnly ) ) |
123 | return false; | 122 | return false; |
124 | 123 | ||
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 | |||
@@ -11,49 +11,49 @@ WLANModule::WLANModule() : Module() { | |||
11 | 11 | ||
12 | /** | 12 | /** |
13 | * Change the current profile | 13 | * Change the current profile |
14 | */ | 14 | */ |
15 | void WLANModule::setProfile(QString newProfile){ | 15 | void WLANModule::setProfile(QString newProfile){ |
16 | profile = newProfile; | 16 | profile = newProfile; |
17 | } | 17 | } |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * get the icon name for this device. | 20 | * get the icon name for this device. |
21 | * @param Interface* can be used in determining the icon. | 21 | * @param Interface* can be used in determining the icon. |
22 | * @return QString the icon name (minus .png, .gif etc) | 22 | * @return QString the icon name (minus .png, .gif etc) |
23 | */ | 23 | */ |
24 | QString WLANModule::getPixmapName(Interface* ){ | 24 | QString WLANModule::getPixmapName(Interface* ){ |
25 | return "wlan"; | 25 | return "wlan"; |
26 | } | 26 | } |
27 | 27 | ||
28 | /** | 28 | /** |
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 | */ |
33 | bool WLANModule::isOwner(Interface *i){ | 33 | bool 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 | /** |
42 | * Create, set tabWiget and return the WLANConfigure Module | 42 | * Create, set tabWiget and return the WLANConfigure Module |
43 | * @param tabWidget a pointer to the tab widget that this configure has. | 43 | * @param tabWidget a pointer to the tab widget that this configure has. |
44 | * @return QWidget* pointer to the tab widget in this modules configure. | 44 | * @return QWidget* pointer to the tab widget in this modules configure. |
45 | */ | 45 | */ |
46 | QWidget *WLANModule::configure(QTabWidget **tabWidget){ | 46 | QWidget *WLANModule::configure(QTabWidget **tabWidget){ |
47 | Config *cfg = new Config("wireless"); | 47 | Config *cfg = new Config("wireless"); |
48 | WLANImp *wlanconfig = new WLANImp(*cfg); | 48 | WLANImp *wlanconfig = new WLANImp(*cfg); |
49 | (*tabWidget) = wlanconfig->tabWidget; | 49 | (*tabWidget) = wlanconfig->tabWidget; |
50 | return wlanconfig; | 50 | return wlanconfig; |
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Create, set tabWiget and return the Information Module | 54 | * Create, set tabWiget and return the Information Module |
55 | * @param tabWidget a pointer to the tab widget that this information has. | 55 | * @param tabWidget a pointer to the tab widget that this information has. |
56 | * @return QWidget* pointer to the tab widget in this modules info. | 56 | * @return QWidget* pointer to the tab widget in this modules info. |
57 | */ | 57 | */ |
58 | QWidget *WLANModule::information(QTabWidget **tabWidget){ | 58 | QWidget *WLANModule::information(QTabWidget **tabWidget){ |
59 | return NULL; | 59 | return NULL; |