summaryrefslogtreecommitdiff
path: root/noncore/settings
authorkergoth <kergoth>2003-04-14 23:31:22 (UTC)
committer kergoth <kergoth>2003-04-14 23:31:22 (UTC)
commitfb07cc161b4adc5bc250569599a7164af2d7caba (patch) (unidiff)
tree1f391e35146e81835af5e0a395896b3fe3c0d46b /noncore/settings
parent68c558ca78e5416145b64ca87fd01361f033ef34 (diff)
downloadopie-fb07cc161b4adc5bc250569599a7164af2d7caba.zip
opie-fb07cc161b4adc5bc250569599a7164af2d7caba.tar.gz
opie-fb07cc161b4adc5bc250569599a7164af2d7caba.tar.bz2
Add new wireless parser that uses the wireless-tools if-pre-up.d
script to handle wireless configuration, as opposed to pcmcia-cs wireless.opts. This has a number of benefits. In addition to improving clarity, this means one can now configure their wireless non-pcmcia interfaces using networksettings. The only real question is, how to handle the fact that its largely useless without the if-pre-up.d script? I'll adapt the existing wlanimp.(cpp|h) to the new .ui, and leave it as a compiletime selection for now.
Diffstat (limited to 'noncore/settings') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wlan.pro14
-rw-r--r--noncore/settings/networksettings/wlan/wlan.ui482
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp266
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.h37
4 files changed, 644 insertions, 155 deletions
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro
index f193bcc..9ddc154 100644
--- a/noncore/settings/networksettings/wlan/wlan.pro
+++ b/noncore/settings/networksettings/wlan/wlan.pro
@@ -4,4 +4,4 @@ CONFIG += qt warn_on release
4DESTDIR = $(OPIEDIR)/plugins/networksettings 4DESTDIR = $(OPIEDIR)/plugins/networksettings
5 HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h 5 HEADERS = infoimp.h wlanmodule.h wextensions.h
6 SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp 6 SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ 7 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
@@ -13,3 +13,13 @@ VERSION = 1.0.0
13 13
14#CONFIG += wirelessopts
14 15
16wirelessopts {
17 HEADERS+= wlanimp.h
18 SOURCES+= wlanimp.cpp
19}
20
21! wirelessopts {
22 HEADERS+= wlanimp2.h
23 SOURCES += wlanimp2.cpp
24}
15 25
diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui
index 744c559..e7c8dbb 100644
--- a/noncore/settings/networksettings/wlan/wlan.ui
+++ b/noncore/settings/networksettings/wlan/wlan.ui
@@ -13,4 +13,4 @@
13 <y>0</y> 13 <y>0</y>
14 <width>239</width> 14 <width>255</width>
15 <height>277</height> 15 <height>299</height>
16 </rect> 16 </rect>
@@ -19,3 +19,3 @@
19 <name>caption</name> 19 <name>caption</name>
20 <string>Wireless LAN Setting</string> 20 <string>Wireless Configuration</string>
21 </property> 21 </property>
@@ -57,16 +57,48 @@
57 </attribute> 57 </attribute>
58 <vbox> 58 <spacer>
59 <property>
60 <name>name</name>
61 <cstring>Spacer31</cstring>
62 </property>
59 <property stdset="1"> 63 <property stdset="1">
60 <name>margin</name> 64 <name>orientation</name>
61 <number>11</number> 65 <enum>Vertical</enum>
62 </property> 66 </property>
63 <property stdset="1"> 67 <property stdset="1">
64 <name>spacing</name> 68 <name>sizeType</name>
65 <number>6</number> 69 <enum>Expanding</enum>
70 </property>
71 <property>
72 <name>sizeHint</name>
73 <size>
74 <width>20</width>
75 <height>20</height>
76 </size>
66 </property> 77 </property>
78 </spacer>
67 <widget> 79 <widget>
68 <class>QCheckBox</class> 80 <class>QLabel</class>
69 <property stdset="1"> 81 <property stdset="1">
70 <name>name</name> 82 <name>name</name>
71 <cstring>essAny</cstring> 83 <cstring>modeLabel</cstring>
84 </property>
85 <property stdset="1">
86 <name>enabled</name>
87 <bool>true</bool>
88 </property>
89 <property stdset="1">
90 <name>geometry</name>
91 <rect>
92 <x>11</x>
93 <y>11</y>
94 <width>84</width>
95 <height>29</height>
96 </rect>
97 </property>
98 <property stdset="1">
99 <name>sizePolicy</name>
100 <sizepolicy>
101 <hsizetype>1</hsizetype>
102 <vsizetype>1</vsizetype>
103 </sizepolicy>
72 </property> 104 </property>
@@ -74,3 +106,3 @@
74 <name>text</name> 106 <name>text</name>
75 <string>&amp;Specify Access Point</string> 107 <string>Mode</string>
76 </property> 108 </property>
@@ -78,6 +110,6 @@
78 <widget> 110 <widget>
79 <class>QGroupBox</class> 111 <class>QLabel</class>
80 <property stdset="1"> 112 <property stdset="1">
81 <name>name</name> 113 <name>name</name>
82 <cstring>GroupBox1</cstring> 114 <cstring>essidLabel</cstring>
83 </property> 115 </property>
@@ -85,40 +117,58 @@
85 <name>enabled</name> 117 <name>enabled</name>
86 <bool>false</bool> 118 <bool>true</bool>
87 </property> 119 </property>
88 <property stdset="1"> 120 <property stdset="1">
89 <name>title</name> 121 <name>geometry</name>
90 <string>Specific &amp;Access Point Settings</string> 122 <rect>
123 <x>11</x>
124 <y>46</y>
125 <width>84</width>
126 <height>29</height>
127 </rect>
91 </property> 128 </property>
92 <grid>
93 <property stdset="1"> 129 <property stdset="1">
94 <name>margin</name> 130 <name>sizePolicy</name>
95 <number>11</number> 131 <sizepolicy>
132 <hsizetype>1</hsizetype>
133 <vsizetype>1</vsizetype>
134 </sizepolicy>
96 </property> 135 </property>
97 <property stdset="1"> 136 <property stdset="1">
98 <name>spacing</name> 137 <name>text</name>
99 <number>6</number> 138 <string>ESS-ID</string>
100 </property> 139 </property>
101 <widget row="0" column="0" > 140 </widget>
102 <class>QLabel</class> 141 <widget>
142 <class>QSpinBox</class>
103 <property stdset="1"> 143 <property stdset="1">
104 <name>name</name> 144 <name>name</name>
105 <cstring>TextLabel1</cstring> 145 <cstring>networkChannel</cstring>
106 </property> 146 </property>
107 <property stdset="1"> 147 <property stdset="1">
108 <name>text</name> 148 <name>enabled</name>
109 <string>ESS-ID</string> 149 <bool>false</bool>
110 </property> 150 </property>
111 </widget>
112 <widget row="1" column="0" >
113 <class>QLabel</class>
114 <property stdset="1"> 151 <property stdset="1">
115 <name>name</name> 152 <name>geometry</name>
116 <cstring>TextLabel2</cstring> 153 <rect>
154 <x>146</x>
155 <y>139</y>
156 <width>58</width>
157 <height>25</height>
158 </rect>
117 </property> 159 </property>
118 <property stdset="1"> 160 <property stdset="1">
119 <name>text</name> 161 <name>maxValue</name>
120 <string>Network Type</string> 162 <number>15</number>
163 </property>
164 <property stdset="1">
165 <name>minValue</name>
166 <number>1</number>
167 </property>
168 <property stdset="1">
169 <name>value</name>
170 <number>1</number>
121 </property> 171 </property>
122 </widget> 172 </widget>
123 <widget row="0" column="1" rowspan="1" colspan="2" > 173 <widget>
124 <class>QLineEdit</class> 174 <class>QLineEdit</class>
@@ -126,25 +176,26 @@
126 <name>name</name> 176 <name>name</name>
127 <cstring>essSpecificLineEdit</cstring> 177 <cstring>macEdit</cstring>
128 </property> 178 </property>
129 </widget> 179 <property stdset="1">
130 <widget row="1" column="1" rowspan="1" colspan="2" > 180 <name>enabled</name>
131 <class>QComboBox</class> 181 <bool>false</bool>
132 <item>
133 <property>
134 <name>text</name>
135 <string>Infrastructure</string>
136 </property> 182 </property>
137 </item> 183 <property stdset="1">
138 <item> 184 <name>geometry</name>
139 <property> 185 <rect>
140 <name>text</name> 186 <x>56</x>
141 <string>Ad-Hoc</string> 187 <y>108</y>
188 <width>182</width>
189 <height>25</height>
190 </rect>
142 </property> 191 </property>
143 </item>
144 <property stdset="1"> 192 <property stdset="1">
145 <name>name</name> 193 <name>sizePolicy</name>
146 <cstring>networkType</cstring> 194 <sizepolicy>
195 <hsizetype>5</hsizetype>
196 <vsizetype>1</vsizetype>
197 </sizepolicy>
147 </property> 198 </property>
148 </widget> 199 </widget>
149 <widget row="2" column="0" > 200 <widget>
150 <class>QLabel</class> 201 <class>QLabel</class>
@@ -152,3 +203,16 @@
152 <name>name</name> 203 <name>name</name>
153 <cstring>channelLabel</cstring> 204 <cstring>macLabel</cstring>
205 </property>
206 <property stdset="1">
207 <name>enabled</name>
208 <bool>false</bool>
209 </property>
210 <property stdset="1">
211 <name>geometry</name>
212 <rect>
213 <x>11</x>
214 <y>108</y>
215 <width>39</width>
216 <height>25</height>
217 </rect>
154 </property> 218 </property>
@@ -156,32 +220,49 @@
156 <name>text</name> 220 <name>text</name>
157 <string>Channel</string> 221 <string>MAC</string>
158 </property> 222 </property>
159 </widget> 223 </widget>
160 <widget row="2" column="1" > 224 <widget>
161 <class>QSpinBox</class> 225 <class>QCheckBox</class>
162 <property stdset="1"> 226 <property stdset="1">
163 <name>name</name> 227 <name>name</name>
164 <cstring>networkChannel</cstring> 228 <cstring>specifyAp</cstring>
165 </property> 229 </property>
166 <property stdset="1"> 230 <property stdset="1">
167 <name>enabled</name> 231 <name>geometry</name>
168 <bool>false</bool> 232 <rect>
233 <x>11</x>
234 <y>81</y>
235 <width>227</width>
236 <height>21</height>
237 </rect>
169 </property> 238 </property>
170 <property stdset="1"> 239 <property stdset="1">
171 <name>maxValue</name> 240 <name>text</name>
172 <number>15</number> 241 <string>Specify &amp;Access Point</string>
242 </property>
243 </widget>
244 <widget>
245 <class>QCheckBox</class>
246 <property stdset="1">
247 <name>name</name>
248 <cstring>specifyChan</cstring>
173 </property> 249 </property>
174 <property stdset="1"> 250 <property stdset="1">
175 <name>minValue</name> 251 <name>geometry</name>
176 <number>1</number> 252 <rect>
253 <x>11</x>
254 <y>141</y>
255 <width>129</width>
256 <height>21</height>
257 </rect>
177 </property> 258 </property>
178 <property stdset="1"> 259 <property stdset="1">
179 <name>value</name> 260 <name>text</name>
180 <number>6</number> 261 <string>Specify &amp;Channel</string>
181 </property> 262 </property>
182 </widget> 263 </widget>
183 <spacer row="2" column="2" > 264 <spacer>
184 <property> 265 <property>
185 <name>name</name> 266 <name>name</name>
186 <cstring>Spacer4</cstring> 267 <cstring>Spacer10</cstring>
187 </property> 268 </property>
@@ -203,72 +284,108 @@
203 </spacer> 284 </spacer>
204 </grid> 285 <widget>
205 </widget> 286 <class>QComboBox</class>
206 <spacer> 287 <item>
207 <property> 288 <property>
289 <name>text</name>
290 <string>Auto</string>
291 </property>
292 </item>
293 <item>
294 <property>
295 <name>text</name>
296 <string>Managed</string>
297 </property>
298 </item>
299 <item>
300 <property>
301 <name>text</name>
302 <string>Ad-Hoc</string>
303 </property>
304 </item>
305 <property stdset="1">
208 <name>name</name> 306 <name>name</name>
209 <cstring>Spacer31</cstring> 307 <cstring>mode</cstring>
210 </property> 308 </property>
211 <property stdset="1"> 309 <property stdset="1">
212 <name>orientation</name> 310 <name>enabled</name>
213 <enum>Vertical</enum> 311 <bool>true</bool>
214 </property> 312 </property>
215 <property stdset="1"> 313 <property stdset="1">
216 <name>sizeType</name> 314 <name>geometry</name>
217 <enum>Expanding</enum> 315 <rect>
316 <x>101</x>
317 <y>11</y>
318 <width>103</width>
319 <height>29</height>
320 </rect>
218 </property> 321 </property>
219 <property> 322 <property stdset="1">
220 <name>sizeHint</name> 323 <name>sizePolicy</name>
221 <size> 324 <sizepolicy>
222 <width>20</width> 325 <hsizetype>1</hsizetype>
223 <height>20</height> 326 <vsizetype>0</vsizetype>
224 </size> 327 </sizepolicy>
225 </property> 328 </property>
226 </spacer>
227 </vbox>
228 </widget> 329 </widget>
229 <widget> 330 <widget>
230 <class>QWidget</class> 331 <class>QComboBox</class>
332 <item>
333 <property>
334 <name>text</name>
335 <string>any</string>
336 </property>
337 </item>
231 <property stdset="1"> 338 <property stdset="1">
232 <name>name</name> 339 <name>name</name>
233 <cstring>WepPage</cstring> 340 <cstring>essid</cstring>
234 </property> 341 </property>
235 <attribute>
236 <name>title</name>
237 <string>Encryption</string>
238 </attribute>
239 <vbox>
240 <property stdset="1"> 342 <property stdset="1">
241 <name>margin</name> 343 <name>geometry</name>
242 <number>11</number> 344 <rect>
345 <x>101</x>
346 <y>46</y>
347 <width>103</width>
348 <height>29</height>
349 </rect>
243 </property> 350 </property>
244 <property stdset="1"> 351 <property stdset="1">
245 <name>spacing</name> 352 <name>sizePolicy</name>
246 <number>6</number> 353 <sizepolicy>
354 <hsizetype>7</hsizetype>
355 <vsizetype>0</vsizetype>
356 </sizepolicy>
247 </property> 357 </property>
248 <widget>
249 <class>QCheckBox</class>
250 <property stdset="1"> 358 <property stdset="1">
251 <name>name</name> 359 <name>editable</name>
252 <cstring>wepEnabled</cstring> 360 <bool>true</bool>
253 </property> 361 </property>
254 <property stdset="1"> 362 <property stdset="1">
255 <name>text</name> 363 <name>currentItem</name>
256 <string>&amp;Enable WEP</string> 364 <number>0</number>
257 </property> 365 </property>
258 </widget>
259 <widget>
260 <class>QButtonGroup</class>
261 <property stdset="1"> 366 <property stdset="1">
262 <name>name</name> 367 <name>sizeLimit</name>
263 <cstring>ButtonGroup43</cstring> 368 <number>5</number>
264 </property> 369 </property>
265 <property stdset="1"> 370 <property stdset="1">
266 <name>enabled</name> 371 <name>autoCompletion</name>
372 <bool>true</bool>
373 </property>
374 <property stdset="1">
375 <name>duplicatesEnabled</name>
267 <bool>false</bool> 376 <bool>false</bool>
268 </property> 377 </property>
378 </widget>
379 </widget>
380 <widget>
381 <class>QWidget</class>
269 <property stdset="1"> 382 <property stdset="1">
270 <name>title</name> 383 <name>name</name>
271 <string>&amp;Authentication Type</string> 384 <cstring>WepPage</cstring>
272 </property> 385 </property>
273 <hbox> 386 <attribute>
387 <name>title</name>
388 <string>Encryption</string>
389 </attribute>
390 <grid>
274 <property stdset="1"> 391 <property stdset="1">
@@ -281,22 +398,28 @@
281 </property> 398 </property>
282 <widget> 399 <spacer row="0" column="0" >
283 <class>QRadioButton</class> 400 <property>
284 <property stdset="1">
285 <name>name</name> 401 <name>name</name>
286 <cstring>authOpen</cstring> 402 <cstring>Spacer30</cstring>
287 </property> 403 </property>
288 <property stdset="1"> 404 <property stdset="1">
289 <name>text</name> 405 <name>orientation</name>
290 <string>&amp;Open System</string> 406 <enum>Vertical</enum>
291 </property> 407 </property>
292 <property stdset="1"> 408 <property stdset="1">
293 <name>checked</name> 409 <name>sizeType</name>
294 <bool>true</bool> 410 <enum>Expanding</enum>
295 </property> 411 </property>
296 </widget> 412 <property>
297 <widget> 413 <name>sizeHint</name>
298 <class>QRadioButton</class> 414 <size>
415 <width>20</width>
416 <height>20</height>
417 </size>
418 </property>
419 </spacer>
420 <widget row="0" column="0" >
421 <class>QCheckBox</class>
299 <property stdset="1"> 422 <property stdset="1">
300 <name>name</name> 423 <name>name</name>
301 <cstring>authShared</cstring> 424 <cstring>wepEnabled</cstring>
302 </property> 425 </property>
@@ -304,8 +427,6 @@
304 <name>text</name> 427 <name>text</name>
305 <string>&amp;Shared Key</string> 428 <string>&amp;Enable Encryption</string>
306 </property> 429 </property>
307 </widget> 430 </widget>
308 </hbox> 431 <widget row="1" column="0" >
309 </widget>
310 <widget>
311 <class>QButtonGroup</class> 432 <class>QButtonGroup</class>
@@ -384,3 +505,3 @@
384 <name>text</name> 505 <name>text</name>
385 <string>Key 1</string> 506 <string>Key &amp;1</string>
386 </property> 507 </property>
@@ -399,3 +520,3 @@
399 <name>text</name> 520 <name>text</name>
400 <string>Key 2</string> 521 <string>Key &amp;2</string>
401 </property> 522 </property>
@@ -410,3 +531,3 @@
410 <name>text</name> 531 <name>text</name>
411 <string>Key 3</string> 532 <string>Key &amp;3</string>
412 </property> 533 </property>
@@ -421,3 +542,3 @@
421 <name>text</name> 542 <name>text</name>
422 <string>Key 4</string> 543 <string>Key &amp;4</string>
423 </property> 544 </property>
@@ -426,24 +547,66 @@
426 </widget> 547 </widget>
427 <spacer> 548 <widget row="2" column="0" >
428 <property> 549 <class>QButtonGroup</class>
550 <property stdset="1">
429 <name>name</name> 551 <name>name</name>
430 <cstring>Spacer30</cstring> 552 <cstring>NonEncButtonGroup</cstring>
431 </property> 553 </property>
432 <property stdset="1"> 554 <property stdset="1">
433 <name>orientation</name> 555 <name>enabled</name>
434 <enum>Vertical</enum> 556 <bool>false</bool>
435 </property> 557 </property>
436 <property stdset="1"> 558 <property stdset="1">
437 <name>sizeType</name> 559 <name>title</name>
438 <enum>Expanding</enum> 560 <string>Non-encrypted Packets</string>
439 </property> 561 </property>
440 <property> 562 <property stdset="1">
441 <name>sizeHint</name> 563 <name>radioButtonExclusive</name>
442 <size> 564 <bool>true</bool>
443 <width>20</width>
444 <height>20</height>
445 </size>
446 </property> 565 </property>
447 </spacer> 566 <grid>
448 </vbox> 567 <property stdset="1">
568 <name>margin</name>
569 <number>11</number>
570 </property>
571 <property stdset="1">
572 <name>spacing</name>
573 <number>6</number>
574 </property>
575 <widget row="0" column="0" >
576 <class>QRadioButton</class>
577 <property stdset="1">
578 <name>name</name>
579 <cstring>acceptNonEnc</cstring>
580 </property>
581 <property stdset="1">
582 <name>text</name>
583 <string>&amp;Accept</string>
584 </property>
585 <property stdset="1">
586 <name>checked</name>
587 <bool>true</bool>
588 </property>
589 <property stdset="1">
590 <name>buttonGroupId</name>
591 <number>0</number>
592 </property>
593 </widget>
594 <widget row="0" column="1" >
595 <class>QRadioButton</class>
596 <property stdset="1">
597 <name>name</name>
598 <cstring>rejectNonEnc</cstring>
599 </property>
600 <property stdset="1">
601 <name>text</name>
602 <string>&amp;Reject</string>
603 </property>
604 <property stdset="1">
605 <name>buttonGroupId</name>
606 <number>1</number>
607 </property>
608 </widget>
609 </grid>
610 </widget>
611 </grid>
449 </widget> 612 </widget>
@@ -454,5 +617,17 @@
454 <connection> 617 <connection>
455 <sender>wepEnabled</sender> 618 <sender>specifyAp</sender>
619 <signal>toggled(bool)</signal>
620 <receiver>macLabel</receiver>
621 <slot>setEnabled(bool)</slot>
622 </connection>
623 <connection>
624 <sender>specifyAp</sender>
625 <signal>toggled(bool)</signal>
626 <receiver>macEdit</receiver>
627 <slot>setEnabled(bool)</slot>
628 </connection>
629 <connection>
630 <sender>specifyChan</sender>
456 <signal>toggled(bool)</signal> 631 <signal>toggled(bool)</signal>
457 <receiver>ButtonGroup43</receiver> 632 <receiver>networkChannel</receiver>
458 <slot>setEnabled(bool)</slot> 633 <slot>setEnabled(bool)</slot>
@@ -466,5 +641,5 @@
466 <connection> 641 <connection>
467 <sender>essAny</sender> 642 <sender>wepEnabled</sender>
468 <signal>toggled(bool)</signal> 643 <signal>toggled(bool)</signal>
469 <receiver>GroupBox1</receiver> 644 <receiver>NonEncButtonGroup</receiver>
470 <slot>setEnabled(bool)</slot> 645 <slot>setEnabled(bool)</slot>
@@ -474,9 +649,3 @@
474 <tabstop>tabWidget</tabstop> 649 <tabstop>tabWidget</tabstop>
475 <tabstop>essAny</tabstop>
476 <tabstop>essSpecificLineEdit</tabstop>
477 <tabstop>networkType</tabstop>
478 <tabstop>networkChannel</tabstop>
479 <tabstop>wepEnabled</tabstop> 650 <tabstop>wepEnabled</tabstop>
480 <tabstop>authOpen</tabstop>
481 <tabstop>authShared</tabstop>
482 <tabstop>keyRadio0</tabstop> 651 <tabstop>keyRadio0</tabstop>
@@ -489,2 +658,9 @@
489 <tabstop>keyLineEdit3</tabstop> 658 <tabstop>keyLineEdit3</tabstop>
659 <tabstop>acceptNonEnc</tabstop>
660 <tabstop>mode</tabstop>
661 <tabstop>essid</tabstop>
662 <tabstop>specifyAp</tabstop>
663 <tabstop>macEdit</tabstop>
664 <tabstop>specifyChan</tabstop>
665 <tabstop>networkChannel</tabstop>
490</tabstops> 666</tabstops>
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
new file mode 100644
index 0000000..01c9668
--- a/dev/null
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -0,0 +1,266 @@
1#include "wlanimp2.h"
2#include "interfacesetupimp.h"
3
4#include <qfile.h>
5#include <qdir.h>
6#include <qtextstream.h>
7#include <qmessagebox.h>
8#include <qlineedit.h>
9#include <qlabel.h>
10#include <qspinbox.h>
11#include <qradiobutton.h>
12#include <qcheckbox.h>
13#include <qtabwidget.h>
14#include <qcombobox.h>
15
16#ifdef QWS
17 #include <opie/oprocess.h>
18#else
19 #define OProcess KProcess
20 #include <kprocess.h>
21#endif
22
23#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
24#define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools"
25
26/**
27 * Constructor, read in the wireless.opts file for parsing later.
28 */
29WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), currentProfile("*"), interface(i) {
30 interfaces = new Interfaces;
31 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
32 tabWidget->insertTab(interfaceSetup, "TCP/IP");
33
34 // Check sanity - the existance of the wireless-tools if-pre-up script
35 QFile file(QString(PREUP));
36 if (file.exists()) {
37 qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools"));
38 }
39}
40
41WLANImp::~WLANImp() {
42 delete interfaces;
43}
44
45/**
46 * Change the profile for both wireless settings and network settings.
47 */
48void WLANImp::setProfile(const QString &profile){
49 interfaceSetup->setProfile(profile);
50 parseOpts();
51}
52
53void WLANImp::parseOpts() {
54 bool error;
55 QString opt;
56
57 if (! interfaces->isInterfaceSet())
58 return;
59
60
61 opt = interfaces->getInterfaceOption("wireless_essid", error);
62 if(opt == "any" || opt == "off" || opt.isNull()){
63 essid->setEditText("any");
64 } else {
65 essid->setEditText(opt);
66 }
67
68 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
69 if (opt == "Auto") {
70 mode->setCurrentItem(0);
71 } else if (opt == "Ad-Hoc") {
72 mode->setCurrentItem(2);
73 } else {
74 // Managed/Infrastructure mode
75 mode->setCurrentItem(1);
76 }
77
78 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
79 if (! opt.isNull()) {
80 specifyAp->setChecked(true);
81 macEdit->setText(opt);
82 }
83
84 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
85 if (! opt.isNull()) {
86 specifyChan->setChecked(true);
87 networkChannel->setValue(opt.toInt());
88 }
89
90 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace();
91 if (opt.isNull())
92 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace();
93 parseKeyStr(opt);
94}
95
96void WLANImp::parseKeyStr(QString keystr) {
97 int loc = 0;
98 int index = 1;
99 QString key;
100 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr);
101 int enc = -1; // encryption state
102
103 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
104 if ((*it).left(3) == "off") {
105 // encryption disabled
106 enc = 0;
107 } else if ((*it).left(2) == "on") {
108 // encryption enabled
109 enc = 1;
110 } else if ((*it).left(4) == "open") {
111 // open mode, accept non encrypted packets
112 acceptNonEnc->setChecked(true);
113 } else if ((*it).left(10) == "restricted") {
114 // restricted mode, only accept encrypted packets
115 rejectNonEnc->setChecked(true);
116 } else if ((*it).left(3) == "key") {
117 // new set of options
118 } else if ((*it).left(1) == "[") {
119 index = (*it).mid(1, 1).toInt();
120 // switch current key to index
121 switch (index) {
122 case 1:
123 keyRadio0->setChecked(true);
124 break;
125 case 2:
126 keyRadio1->setChecked(true);
127 break;
128 case 3:
129 keyRadio2->setChecked(true);
130 break;
131 case 4:
132 keyRadio3->setChecked(true);
133 break;
134 }
135 } else {
136 // key
137 key = (*it);
138 }
139 if (! key.isNull()) {
140 if (enc == -1)
141 enc = 1;
142 QStringList::Iterator next = ++it;
143 if (it == keys.end()) {
144 break;
145 }
146 if ((*(next)).left(1) == "[") {
147 // set key at index
148 index = (*(next)).mid(1, 1).toInt();
149 } else {
150 index = 1;
151 }
152 switch (index) {
153 case 1:
154 keyLineEdit0->setText(key);
155 break;
156 case 2:
157 keyLineEdit1->setText(key);
158 break;
159 case 3:
160 keyLineEdit2->setText(key);
161 break;
162 case 4:
163 keyLineEdit3->setText(key);
164 break;
165 }
166 key = QString::null;
167 }
168 }
169 if (enc == 1) {
170 wepEnabled->setChecked(true);
171 } else {
172 wepEnabled->setChecked(false);
173 }
174}
175
176/**
177 * Check to see if the current config is valid
178 * Save interfaces
179 */
180void WLANImp::accept() {
181 if (wepEnabled->isChecked()) {
182 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
183 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
184 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
185 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
186 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
187 return;
188 }
189 }
190
191 if (essid->currentText().isEmpty()) {
192 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
193 return;
194 }
195
196 if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
197 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
198 return;
199 }
200
201 // Try to save the interfaces settings.
202 writeOpts();
203
204 // Close out the dialog
205 QDialog::accept();
206}
207
208void WLANImp::writeOpts() {
209 bool error = false;
210
211 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
212 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
213
214 if (specifyAp->isChecked()) {
215 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
216 } else {
217 interfaces->removeInterfaceOption(QString("wireless_ap"));
218 }
219
220 if (specifyChan->isChecked()) {
221 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
222 } else {
223 interfaces->removeInterfaceOption(QString("wireless_channel"));
224 }
225
226 if (wepEnabled->isChecked()) {
227 QStringList keyList;
228
229 if (! keyLineEdit0->text().isNull()) {
230 keyList += keyLineEdit0->text();
231 keyList += "[1]";
232 } else if (! keyLineEdit1->text().isNull()) {
233 keyList += keyLineEdit1->text();
234 keyList += "[2]";
235 } else if (! keyLineEdit2->text().isNull()) {
236 keyList += keyLineEdit2->text();
237 keyList += "[3]";
238 } else if (! keyLineEdit3->text().isNull()) {
239 keyList += keyLineEdit3->text();
240 keyList += "[4]";
241 }
242 if (acceptNonEnc->isChecked()) {
243 keyList += "open";
244 } else {
245 keyList += "restricted";
246 }
247
248 keyList += "key";
249 if (keyRadio0->isChecked()) {
250 keyList += "[1]";
251 } else if (keyRadio1->isChecked()) {
252 keyList += "[2]";
253 } else if (keyRadio2->isChecked()) {
254 keyList += "[3]";
255 } else if (keyRadio3->isChecked()) {
256 keyList += "[4]";
257 }
258 interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" ")));
259 } else {
260 interfaces->removeInterfaceOption(QString("wireless_key"));
261 }
262 interfaces->removeInterfaceOption(QString("wireless_enc"));
263
264 if(!interfaceSetup->saveChanges())
265 return;
266}
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.h b/noncore/settings/networksettings/wlan/wlanimp2.h
new file mode 100644
index 0000000..992d09a
--- a/dev/null
+++ b/noncore/settings/networksettings/wlan/wlanimp2.h
@@ -0,0 +1,37 @@
1#ifndef WLANIMP_H
2#define WLANIMP_H
3
4#include "wlan.h"
5#include "interfaces.h"
6#include <qstringlist.h>
7
8class InterfaceSetupImp;
9class Interface;
10class Config;
11
12class WLANImp : public WLAN {
13 Q_OBJECT
14
15public:
16 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
17 ~WLANImp();
18 void setProfile(const QString &profile);
19
20protected:
21 void accept();
22
23private:
24 void parseOpts();
25 void writeOpts();
26
27 void parseKeyStr(QString keystr);
28
29 InterfaceSetupImp *interfaceSetup;
30 Interfaces *interfaces;
31 Interface *interface;
32
33 QString currentProfile;
34};
35
36#endif
37