summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-10 02:24:48 (UTC)
committer mickeyl <mickeyl>2003-10-10 02:24:48 (UTC)
commit2b2620fee2bbd6f7045b237aa33c277c47512345 (patch) (unidiff)
tree31f92a166da4ae596d55fe5079f058dd4a16fce4
parentc1a897e63513c9647666970794c1684b2439501e (diff)
downloadopie-2b2620fee2bbd6f7045b237aa33c277c47512345.zip
opie-2b2620fee2bbd6f7045b237aa33c277c47512345.tar.gz
opie-2b2620fee2bbd6f7045b237aa33c277c47512345.tar.bz2
This patch adds scanning the "network neighbourhood" in networksettings-wlan
(powered by the Wellenreiter II scanning engine found in libopienet2). Detected networks are put in a list and you can select parameters by clicking on an entry in the list. See http://opie.net.wox.org/images/wlanplugin.png Two inherent drawbacks: 1.) networksettingsplugin-wlan now needs libopienet2. Well, my library work pays off. If you like to rewrite the stuff so that libopienet2 is not needed, then just go ahead ;) 2.) Scanning won't work on linux distributions without patched monitor mode drivers. I think we can live with these two "issues". Feel free to revert, if you don't like my work :D
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/config.in4
-rw-r--r--noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control2
-rw-r--r--noncore/settings/networksettings/wlan/wlan.pro2
-rw-r--r--noncore/settings/networksettings/wlan/wlan.ui658
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp216
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.h21
-rw-r--r--pics/networksettings/adhoc.pngbin0 -> 694 bytes
-rw-r--r--pics/networksettings/managed.pngbin0 -> 410 bytes
9 files changed, 577 insertions, 328 deletions
diff --git a/noncore/settings/networksettings/wlan/config.in b/noncore/settings/networksettings/wlan/config.in
index 53bcb1e..e459788 100644
--- a/noncore/settings/networksettings/wlan/config.in
+++ b/noncore/settings/networksettings/wlan/config.in
@@ -1,4 +1,6 @@
1 config WLAN 1 config WLAN
2 boolean "opie-networksettingsplugin-wlan (wireless LAN module)" 2 boolean "opie-networksettingsplugin-wlan (wireless LAN module)"
3 default "n" if NETWORKSETUP 3 default "n" if NETWORKSETUP
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET
5 #comment "opie-networksettingsplugin-wlan needs libopie, libopie2net and networksetup"
6 #depends !( LIBOPIE2NET && LIBOPIE && NETWORKSETUP) \ No newline at end of file
diff --git a/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control b/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
index 719337f..ec3078d 100644
--- a/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
+++ b/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
@@ -1,10 +1,10 @@
1Package: opie-networksettingsplugin-wlan 1Package: opie-networksettingsplugin-wlan
2Files: plugins/networksettings/libwlan.so* 2Files: plugins/networksettings/libwlan.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Patrick S. Vogt <tille@handhelds.org> 5Maintainer: Patrick S. Vogt <tille@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: opie-networksettings 7Depends: opie-networksettings, libopie2net (1.8.1)
8Description: Network settings wavelan plugin. 8Description: Network settings wavelan plugin.
9 9
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro
index 552c669..82a5b2f 100644
--- a/noncore/settings/networksettings/wlan/wlan.pro
+++ b/noncore/settings/networksettings/wlan/wlan.pro
@@ -1,28 +1,28 @@
1# 1#
2TEMPLATE = lib 2TEMPLATE = lib
3#TEMPLATE = app 3#TEMPLATE = app
4CONFIG += qt warn_on release 4CONFIG += qt warn_on release
5 #CONFIG += qt warn_on debug 5 #CONFIG += qt warn_on debug
6DESTDIR = $(OPIEDIR)/plugins/networksettings 6DESTDIR = $(OPIEDIR)/plugins/networksettings
7 HEADERS = infoimp.h wlanmodule.h wextensions.h keyedit.h 7 HEADERS = infoimp.h wlanmodule.h wextensions.h keyedit.h
8 SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp keyedit.cpp 8 SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp keyedit.cpp
9 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ 9 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
10 DEPENDPATH+= $(OPIEDIR)/include 10 DEPENDPATH+= $(OPIEDIR)/include
11LIBS += -lqpe -L../interfaces/ -linterfaces 11LIBS += -lqpe -L../interfaces/ -linterfaces -lopienet2
12 INTERFACES= wlan.ui info.ui 12 INTERFACES= wlan.ui info.ui
13 TARGET = wlan 13 TARGET = wlan
14 VERSION = 1.0.0 14 VERSION = 1.0.0
15 15
16#CONFIG += wirelessopts 16#CONFIG += wirelessopts
17 17
18wirelessopts { 18wirelessopts {
19 HEADERS+= wlanimp.h 19 HEADERS+= wlanimp.h
20 SOURCES+= wlanimp.cpp 20 SOURCES+= wlanimp.cpp
21} 21}
22 22
23! wirelessopts { 23! wirelessopts {
24 HEADERS+= wlanimp2.h 24 HEADERS+= wlanimp2.h
25 SOURCES += wlanimp2.cpp 25 SOURCES += wlanimp2.cpp
26} 26}
27 27
28include ( $(OPIEDIR)/include.pro ) 28include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui
index 7e39e23..195ead9 100644
--- a/noncore/settings/networksettings/wlan/wlan.ui
+++ b/noncore/settings/networksettings/wlan/wlan.ui
@@ -1,499 +1,517 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>WLAN</class> 2<class>WLAN</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>WLAN</cstring> 7 <cstring>WLAN</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>247</width> 14 <width>216</width>
15 <height>299</height> 15 <height>342</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>Wireless Configuration</string> 20 <string>Wireless Configuration</string>
21 </property> 21 </property>
22 <property stdset="1"> 22 <property stdset="1">
23 <name>sizeGripEnabled</name> 23 <name>sizeGripEnabled</name>
24 <bool>true</bool> 24 <bool>true</bool>
25 </property> 25 </property>
26 <property> 26 <property>
27 <name>layoutMargin</name> 27 <name>layoutMargin</name>
28 </property> 28 </property>
29 <vbox> 29 <vbox>
30 <property stdset="1"> 30 <property stdset="1">
31 <name>margin</name> 31 <name>margin</name>
32 <number>0</number> 32 <number>0</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> 38 <widget>
39 <class>QTabWidget</class> 39 <class>QTabWidget</class>
40 <property stdset="1"> 40 <property stdset="1">
41 <name>name</name> 41 <name>name</name>
42 <cstring>tabWidget</cstring> 42 <cstring>tabWidget</cstring>
43 </property> 43 </property>
44 <property stdset="1"> 44 <property stdset="1">
45 <name>enabled</name> 45 <name>enabled</name>
46 <bool>true</bool> 46 <bool>true</bool>
47 </property> 47 </property>
48 <property>
49 <name>layoutMargin</name>
50 </property>
51 <property>
52 <name>layoutSpacing</name>
53 </property>
48 <widget> 54 <widget>
49 <class>QWidget</class> 55 <class>QWidget</class>
50 <property stdset="1"> 56 <property stdset="1">
51 <name>name</name> 57 <name>name</name>
52 <cstring>ConfigPage</cstring> 58 <cstring>ConfigPage</cstring>
53 </property> 59 </property>
54 <attribute> 60 <attribute>
55 <name>title</name> 61 <name>title</name>
56 <string>General</string> 62 <string>General</string>
57 </attribute> 63 </attribute>
58 <spacer> 64 <vbox>
59 <property>
60 <name>name</name>
61 <cstring>Spacer31</cstring>
62 </property>
63 <property stdset="1">
64 <name>orientation</name>
65 <enum>Vertical</enum>
66 </property>
67 <property stdset="1">
68 <name>sizeType</name>
69 <enum>Expanding</enum>
70 </property>
71 <property>
72 <name>sizeHint</name>
73 <size>
74 <width>20</width>
75 <height>20</height>
76 </size>
77 </property>
78 </spacer>
79 <widget>
80 <class>QLabel</class>
81 <property stdset="1">
82 <name>name</name>
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>
104 </property>
105 <property stdset="1">
106 <name>text</name>
107 <string>Mode</string>
108 </property>
109 </widget>
110 <widget>
111 <class>QLabel</class>
112 <property stdset="1">
113 <name>name</name>
114 <cstring>essidLabel</cstring>
115 </property>
116 <property stdset="1">
117 <name>enabled</name>
118 <bool>true</bool>
119 </property>
120 <property stdset="1">
121 <name>geometry</name>
122 <rect>
123 <x>11</x>
124 <y>46</y>
125 <width>84</width>
126 <height>29</height>
127 </rect>
128 </property>
129 <property stdset="1">
130 <name>sizePolicy</name>
131 <sizepolicy>
132 <hsizetype>1</hsizetype>
133 <vsizetype>1</vsizetype>
134 </sizepolicy>
135 </property>
136 <property stdset="1">
137 <name>text</name>
138 <string>ESS-ID</string>
139 </property>
140 </widget>
141 <widget>
142 <class>QSpinBox</class>
143 <property stdset="1">
144 <name>name</name>
145 <cstring>networkChannel</cstring>
146 </property>
147 <property stdset="1">
148 <name>enabled</name>
149 <bool>false</bool>
150 </property>
151 <property stdset="1">
152 <name>geometry</name>
153 <rect>
154 <x>146</x>
155 <y>139</y>
156 <width>58</width>
157 <height>25</height>
158 </rect>
159 </property>
160 <property stdset="1">
161 <name>maxValue</name>
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>
171 </property>
172 </widget>
173 <widget>
174 <class>QLineEdit</class>
175 <property stdset="1">
176 <name>name</name>
177 <cstring>macEdit</cstring>
178 </property>
179 <property stdset="1">
180 <name>enabled</name>
181 <bool>false</bool>
182 </property>
183 <property stdset="1">
184 <name>geometry</name>
185 <rect>
186 <x>56</x>
187 <y>108</y>
188 <width>182</width>
189 <height>25</height>
190 </rect>
191 </property>
192 <property stdset="1">
193 <name>sizePolicy</name>
194 <sizepolicy>
195 <hsizetype>5</hsizetype>
196 <vsizetype>1</vsizetype>
197 </sizepolicy>
198 </property>
199 </widget>
200 <widget>
201 <class>QLabel</class>
202 <property stdset="1">
203 <name>name</name>
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>
218 </property>
219 <property stdset="1">
220 <name>text</name>
221 <string>MAC</string>
222 </property>
223 </widget>
224 <widget>
225 <class>QCheckBox</class>
226 <property stdset="1">
227 <name>name</name>
228 <cstring>specifyAp</cstring>
229 </property>
230 <property stdset="1">
231 <name>geometry</name>
232 <rect>
233 <x>11</x>
234 <y>81</y>
235 <width>227</width>
236 <height>21</height>
237 </rect>
238 </property>
239 <property stdset="1">
240 <name>text</name>
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>
249 </property>
250 <property stdset="1">
251 <name>geometry</name>
252 <rect>
253 <x>11</x>
254 <y>141</y>
255 <width>129</width>
256 <height>21</height>
257 </rect>
258 </property>
259 <property stdset="1">
260 <name>text</name>
261 <string>Specify &amp;Channel</string>
262 </property>
263 </widget>
264 <spacer>
265 <property>
266 <name>name</name>
267 <cstring>Spacer10</cstring>
268 </property>
269 <property stdset="1"> 65 <property stdset="1">
270 <name>orientation</name> 66 <name>margin</name>
271 <enum>Horizontal</enum> 67 <number>3</number>
272 </property> 68 </property>
273 <property stdset="1"> 69 <property stdset="1">
274 <name>sizeType</name> 70 <name>spacing</name>
275 <enum>Expanding</enum> 71 <number>2</number>
276 </property>
277 <property>
278 <name>sizeHint</name>
279 <size>
280 <width>20</width>
281 <height>20</height>
282 </size>
283 </property> 72 </property>
284 </spacer> 73 <widget>
285 <widget> 74 <class>QLayoutWidget</class>
286 <class>QComboBox</class> 75 <property stdset="1">
287 <item> 76 <name>name</name>
288 <property> 77 <cstring>Layout1</cstring>
289 <name>text</name>
290 <string>any</string>
291 </property> 78 </property>
292 </item> 79 <grid>
293 <property stdset="1"> 80 <property stdset="1">
294 <name>name</name> 81 <name>margin</name>
295 <cstring>essid</cstring> 82 <number>0</number>
296 </property> 83 </property>
297 <property stdset="1"> 84 <property stdset="1">
298 <name>geometry</name> 85 <name>spacing</name>
299 <rect> 86 <number>6</number>
300 <x>101</x> 87 </property>
301 <y>46</y> 88 <widget row="1" column="1" >
302 <width>103</width> 89 <class>QComboBox</class>
303 <height>29</height> 90 <item>
304 </rect> 91 <property>
305 </property> 92 <name>text</name>
306 <property stdset="1"> 93 <string>any</string>
307 <name>sizePolicy</name> 94 </property>
308 <sizepolicy> 95 </item>
309 <hsizetype>7</hsizetype> 96 <property stdset="1">
310 <vsizetype>0</vsizetype> 97 <name>name</name>
311 </sizepolicy> 98 <cstring>essid</cstring>
312 </property> 99 </property>
313 <property stdset="1"> 100 <property stdset="1">
314 <name>editable</name> 101 <name>sizePolicy</name>
315 <bool>true</bool> 102 <sizepolicy>
316 </property> 103 <hsizetype>7</hsizetype>
317 <property stdset="1"> 104 <vsizetype>0</vsizetype>
318 <name>currentItem</name> 105 </sizepolicy>
319 <number>0</number> 106 </property>
320 </property> 107 <property stdset="1">
321 <property stdset="1"> 108 <name>editable</name>
322 <name>sizeLimit</name> 109 <bool>true</bool>
323 <number>5</number> 110 </property>
324 </property> 111 <property stdset="1">
325 <property stdset="1"> 112 <name>currentItem</name>
326 <name>autoCompletion</name> 113 <number>0</number>
327 <bool>true</bool> 114 </property>
328 </property> 115 <property stdset="1">
329 <property stdset="1"> 116 <name>sizeLimit</name>
330 <name>duplicatesEnabled</name> 117 <number>5</number>
331 <bool>false</bool> 118 </property>
332 </property> 119 <property stdset="1">
333 </widget> 120 <name>autoCompletion</name>
334 <widget> 121 <bool>true</bool>
335 <class>QComboBox</class> 122 </property>
336 <item> 123 <property stdset="1">
337 <property> 124 <name>duplicatesEnabled</name>
338 <name>text</name> 125 <bool>false</bool>
339 <string>Infrastructure</string> 126 </property>
127 </widget>
128 <widget row="1" column="0" >
129 <class>QLabel</class>
130 <property stdset="1">
131 <name>name</name>
132 <cstring>essidLabel</cstring>
133 </property>
134 <property stdset="1">
135 <name>enabled</name>
136 <bool>true</bool>
137 </property>
138 <property stdset="1">
139 <name>sizePolicy</name>
140 <sizepolicy>
141 <hsizetype>1</hsizetype>
142 <vsizetype>1</vsizetype>
143 </sizepolicy>
144 </property>
145 <property stdset="1">
146 <name>text</name>
147 <string>SSID</string>
148 </property>
149 </widget>
150 <widget row="0" column="1" >
151 <class>QComboBox</class>
152 <item>
153 <property>
154 <name>text</name>
155 <string>Infrastructure</string>
156 </property>
157 </item>
158 <item>
159 <property>
160 <name>text</name>
161 <string>Auto</string>
162 </property>
163 </item>
164 <item>
165 <property>
166 <name>text</name>
167 <string>Managed</string>
168 </property>
169 </item>
170 <item>
171 <property>
172 <name>text</name>
173 <string>Ad-Hoc</string>
174 </property>
175 </item>
176 <property stdset="1">
177 <name>name</name>
178 <cstring>mode</cstring>
179 </property>
180 <property stdset="1">
181 <name>enabled</name>
182 <bool>true</bool>
183 </property>
184 <property stdset="1">
185 <name>sizePolicy</name>
186 <sizepolicy>
187 <hsizetype>7</hsizetype>
188 <vsizetype>0</vsizetype>
189 </sizepolicy>
190 </property>
191 </widget>
192 <widget row="0" column="0" >
193 <class>QLabel</class>
194 <property stdset="1">
195 <name>name</name>
196 <cstring>modeLabel</cstring>
197 </property>
198 <property stdset="1">
199 <name>enabled</name>
200 <bool>true</bool>
201 </property>
202 <property stdset="1">
203 <name>sizePolicy</name>
204 <sizepolicy>
205 <hsizetype>1</hsizetype>
206 <vsizetype>1</vsizetype>
207 </sizepolicy>
208 </property>
209 <property stdset="1">
210 <name>text</name>
211 <string>Mode</string>
212 </property>
213 </widget>
214 </grid>
215 </widget>
216 <widget>
217 <class>QCheckBox</class>
218 <property stdset="1">
219 <name>name</name>
220 <cstring>specifyAp</cstring>
340 </property> 221 </property>
341 </item> 222 <property stdset="1">
342 <item>
343 <property>
344 <name>text</name> 223 <name>text</name>
345 <string>Auto</string> 224 <string>Specify &amp;Access Point</string>
346 </property> 225 </property>
347 </item> 226 </widget>
348 <item> 227 <widget>
349 <property> 228 <class>QLayoutWidget</class>
350 <name>text</name> 229 <property stdset="1">
351 <string>Managed</string> 230 <name>name</name>
231 <cstring>Layout3</cstring>
352 </property> 232 </property>
353 </item> 233 <hbox>
354 <item> 234 <property stdset="1">
355 <property> 235 <name>margin</name>
236 <number>0</number>
237 </property>
238 <property stdset="1">
239 <name>spacing</name>
240 <number>6</number>
241 </property>
242 <widget>
243 <class>QLabel</class>
244 <property stdset="1">
245 <name>name</name>
246 <cstring>macLabel</cstring>
247 </property>
248 <property stdset="1">
249 <name>enabled</name>
250 <bool>false</bool>
251 </property>
252 <property stdset="1">
253 <name>text</name>
254 <string>MAC</string>
255 </property>
256 </widget>
257 <widget>
258 <class>QLineEdit</class>
259 <property stdset="1">
260 <name>name</name>
261 <cstring>macEdit</cstring>
262 </property>
263 <property stdset="1">
264 <name>enabled</name>
265 <bool>false</bool>
266 </property>
267 <property stdset="1">
268 <name>sizePolicy</name>
269 <sizepolicy>
270 <hsizetype>7</hsizetype>
271 <vsizetype>1</vsizetype>
272 </sizepolicy>
273 </property>
274 </widget>
275 </hbox>
276 </widget>
277 <widget>
278 <class>QLayoutWidget</class>
279 <property stdset="1">
280 <name>name</name>
281 <cstring>Layout4</cstring>
282 </property>
283 <hbox>
284 <property stdset="1">
285 <name>margin</name>
286 <number>0</number>
287 </property>
288 <property stdset="1">
289 <name>spacing</name>
290 <number>6</number>
291 </property>
292 <widget>
293 <class>QCheckBox</class>
294 <property stdset="1">
295 <name>name</name>
296 <cstring>specifyChan</cstring>
297 </property>
298 <property stdset="1">
299 <name>text</name>
300 <string>Specify &amp;Channel</string>
301 </property>
302 </widget>
303 <widget>
304 <class>QSpinBox</class>
305 <property stdset="1">
306 <name>name</name>
307 <cstring>networkChannel</cstring>
308 </property>
309 <property stdset="1">
310 <name>enabled</name>
311 <bool>false</bool>
312 </property>
313 <property stdset="1">
314 <name>maxValue</name>
315 <number>15</number>
316 </property>
317 <property stdset="1">
318 <name>minValue</name>
319 <number>1</number>
320 </property>
321 <property stdset="1">
322 <name>value</name>
323 <number>1</number>
324 </property>
325 </widget>
326 </hbox>
327 </widget>
328 <widget>
329 <class>QPushButton</class>
330 <property stdset="1">
331 <name>name</name>
332 <cstring>rescanButton</cstring>
333 </property>
334 <property stdset="1">
356 <name>text</name> 335 <name>text</name>
357 <string>Ad-Hoc</string> 336 <string>Rescan Neighbourhood</string>
358 </property> 337 </property>
359 </item> 338 </widget>
360 <property stdset="1"> 339 <widget>
361 <name>name</name> 340 <class>QListView</class>
362 <cstring>mode</cstring> 341 <column>
363 </property> 342 <property>
364 <property stdset="1"> 343 <name>text</name>
365 <name>enabled</name> 344 <string></string>
366 <bool>true</bool> 345 </property>
367 </property> 346 <property>
368 <property stdset="1"> 347 <name>clickable</name>
369 <name>geometry</name> 348 <bool>true</bool>
370 <rect> 349 </property>
371 <x>101</x> 350 <property>
372 <y>11</y> 351 <name>resizeable</name>
373 <width>103</width> 352 <bool>true</bool>
374 <height>29</height> 353 </property>
375 </rect> 354 </column>
376 </property> 355 <column>
377 <property stdset="1"> 356 <property>
378 <name>sizePolicy</name> 357 <name>text</name>
379 <sizepolicy> 358 <string>SSID</string>
380 <hsizetype>1</hsizetype> 359 </property>
381 <vsizetype>0</vsizetype> 360 <property>
382 </sizepolicy> 361 <name>clickable</name>
383 </property> 362 <bool>true</bool>
384 </widget> 363 </property>
364 <property>
365 <name>resizeable</name>
366 <bool>true</bool>
367 </property>
368 </column>
369 <column>
370 <property>
371 <name>text</name>
372 <string>Chn</string>
373 </property>
374 <property>
375 <name>clickable</name>
376 <bool>true</bool>
377 </property>
378 <property>
379 <name>resizeable</name>
380 <bool>true</bool>
381 </property>
382 </column>
383 <column>
384 <property>
385 <name>text</name>
386 <string>MAC</string>
387 </property>
388 <property>
389 <name>clickable</name>
390 <bool>true</bool>
391 </property>
392 <property>
393 <name>resizeable</name>
394 <bool>true</bool>
395 </property>
396 </column>
397 <property stdset="1">
398 <name>name</name>
399 <cstring>netView</cstring>
400 </property>
401 </widget>
402 </vbox>
385 </widget> 403 </widget>
386 <widget> 404 <widget>
387 <class>QWidget</class> 405 <class>QWidget</class>
388 <property stdset="1"> 406 <property stdset="1">
389 <name>name</name> 407 <name>name</name>
390 <cstring>WepPage</cstring> 408 <cstring>WepPage</cstring>
391 </property> 409 </property>
392 <attribute> 410 <attribute>
393 <name>title</name> 411 <name>title</name>
394 <string>Encryption</string> 412 <string>Encryption</string>
395 </attribute> 413 </attribute>
396 <grid> 414 <grid>
397 <property stdset="1"> 415 <property stdset="1">
398 <name>margin</name> 416 <name>margin</name>
399 <number>11</number> 417 <number>7</number>
400 </property> 418 </property>
401 <property stdset="1"> 419 <property stdset="1">
402 <name>spacing</name> 420 <name>spacing</name>
403 <number>6</number> 421 <number>3</number>
404 </property> 422 </property>
405 <widget row="0" column="0" > 423 <widget row="0" column="0" >
406 <class>QCheckBox</class> 424 <class>QCheckBox</class>
407 <property stdset="1"> 425 <property stdset="1">
408 <name>name</name> 426 <name>name</name>
409 <cstring>wepEnabled</cstring> 427 <cstring>wepEnabled</cstring>
410 </property> 428 </property>
411 <property stdset="1"> 429 <property stdset="1">
412 <name>text</name> 430 <name>text</name>
413 <string>&amp;Enable Encryption</string> 431 <string>&amp;Enable Encryption</string>
414 </property> 432 </property>
415 </widget> 433 </widget>
416 <widget row="1" column="0" > 434 <widget row="1" column="0" >
417 <class>QButtonGroup</class> 435 <class>QButtonGroup</class>
418 <property stdset="1"> 436 <property stdset="1">
419 <name>name</name> 437 <name>name</name>
420 <cstring>KeyButtonGroup</cstring> 438 <cstring>KeyButtonGroup</cstring>
421 </property> 439 </property>
422 <property stdset="1"> 440 <property stdset="1">
423 <name>enabled</name> 441 <name>enabled</name>
424 <bool>false</bool> 442 <bool>false</bool>
425 </property> 443 </property>
426 <property stdset="1"> 444 <property stdset="1">
427 <name>title</name> 445 <name>title</name>
428 <string>&amp;Key Setting</string> 446 <string>&amp;Key Setting</string>
429 </property> 447 </property>
430 <grid> 448 <grid>
431 <property stdset="1"> 449 <property stdset="1">
432 <name>margin</name> 450 <name>margin</name>
433 <number>11</number> 451 <number>11</number>
434 </property> 452 </property>
435 <property stdset="1"> 453 <property stdset="1">
436 <name>spacing</name> 454 <name>spacing</name>
437 <number>6</number> 455 <number>6</number>
438 </property> 456 </property>
439 <widget row="0" column="0" > 457 <widget row="0" column="0" >
440 <class>QRadioButton</class> 458 <class>QRadioButton</class>
441 <property stdset="1"> 459 <property stdset="1">
442 <name>name</name> 460 <name>name</name>
443 <cstring>keyRadio0</cstring> 461 <cstring>keyRadio0</cstring>
444 </property> 462 </property>
445 <property stdset="1"> 463 <property stdset="1">
446 <name>text</name> 464 <name>text</name>
447 <string>Key &amp;1</string> 465 <string>Key &amp;1</string>
448 </property> 466 </property>
449 <property stdset="1"> 467 <property stdset="1">
450 <name>checked</name> 468 <name>checked</name>
451 <bool>true</bool> 469 <bool>true</bool>
452 </property> 470 </property>
453 </widget> 471 </widget>
454 <widget row="1" column="0" > 472 <widget row="1" column="0" >
455 <class>QRadioButton</class> 473 <class>QRadioButton</class>
456 <property stdset="1"> 474 <property stdset="1">
457 <name>name</name> 475 <name>name</name>
458 <cstring>keyRadio1</cstring> 476 <cstring>keyRadio1</cstring>
459 </property> 477 </property>
460 <property stdset="1"> 478 <property stdset="1">
461 <name>text</name> 479 <name>text</name>
462 <string>Key &amp;2</string> 480 <string>Key &amp;2</string>
463 </property> 481 </property>
464 </widget> 482 </widget>
465 <widget row="2" column="0" > 483 <widget row="2" column="0" >
466 <class>QRadioButton</class> 484 <class>QRadioButton</class>
467 <property stdset="1"> 485 <property stdset="1">
468 <name>name</name> 486 <name>name</name>
469 <cstring>keyRadio2</cstring> 487 <cstring>keyRadio2</cstring>
470 </property> 488 </property>
471 <property stdset="1"> 489 <property stdset="1">
472 <name>text</name> 490 <name>text</name>
473 <string>Key &amp;3</string> 491 <string>Key &amp;3</string>
474 </property> 492 </property>
475 </widget> 493 </widget>
476 <widget row="3" column="0" > 494 <widget row="3" column="0" >
477 <class>QRadioButton</class> 495 <class>QRadioButton</class>
478 <property stdset="1"> 496 <property stdset="1">
479 <name>name</name> 497 <name>name</name>
480 <cstring>keyRadio3</cstring> 498 <cstring>keyRadio3</cstring>
481 </property> 499 </property>
482 <property stdset="1"> 500 <property stdset="1">
483 <name>text</name> 501 <name>text</name>
484 <string>Key &amp;4</string> 502 <string>Key &amp;4</string>
485 </property> 503 </property>
486 </widget> 504 </widget>
487 <widget row="0" column="1" > 505 <widget row="0" column="1" >
488 <class>KeyEdit</class> 506 <class>KeyEdit</class>
489 <property stdset="1"> 507 <property stdset="1">
490 <name>name</name> 508 <name>name</name>
491 <cstring>keyLineEdit0</cstring> 509 <cstring>keyLineEdit0</cstring>
492 </property> 510 </property>
493 <property stdset="1"> 511 <property stdset="1">
494 <name>sizePolicy</name> 512 <name>sizePolicy</name>
495 <sizepolicy> 513 <sizepolicy>
496 <hsizetype>3</hsizetype> 514 <hsizetype>3</hsizetype>
497 <vsizetype>5</vsizetype> 515 <vsizetype>5</vsizetype>
498 </sizepolicy> 516 </sizepolicy>
499 </property> 517 </property>
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 8bf004f..719be1b 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -125,120 +125,120 @@ void WLANImp::parseSettingFile(){
125 key = line.mid(4, line.length()); 125 key = line.mid(4, line.length());
126 } 126 }
127 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); 127 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true);
128 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 128 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
129 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 129 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
130 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 130 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
131 } 131 }
132 if(line.contains("CHANNEL=")){ 132 if(line.contains("CHANNEL=")){
133 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 133 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
134 } 134 }
135 } 135 }
136 } 136 }
137} 137}
138 138
139/** 139/**
140 * Saves settings to the wireless.opts file using the current profile 140 * Saves settings to the wireless.opts file using the current profile
141 */ 141 */
142void WLANImp::changeAndSaveSettingFile(){ 142void WLANImp::changeAndSaveSettingFile(){
143 QString wlanFile = WIRELESS_OPTS; 143 QString wlanFile = WIRELESS_OPTS;
144 QFile::remove(wlanFile); 144 QFile::remove(wlanFile);
145 QFile file(wlanFile); 145 QFile file(wlanFile);
146 146
147 if (!file.open(IO_ReadWrite)){ 147 if (!file.open(IO_ReadWrite)){
148 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 148 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
149 return; 149 return;
150 } 150 }
151 151
152 QTextStream stream( &file ); 152 QTextStream stream( &file );
153 bool foundCase = false; 153 bool foundCase = false;
154 bool found = false; 154 bool found = false;
155 bool output = true; 155 bool output = true;
156 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 156 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
157 QString line = (*it).simplifyWhiteSpace(); 157 QString line = (*it).simplifyWhiteSpace();
158 if(line.contains("case")) 158 if(line.contains("case"))
159 foundCase = true; 159 foundCase = true;
160 // See if we found our scheme to write or the sceme couldn't be found 160 // See if we found our scheme to write or the sceme couldn't be found
161 if((foundCase && line.contains("esac") && !found) || 161 if((foundCase && line.contains("esac") && !found) ||
162 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ 162 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){
163 // write out scheme 163 // write out scheme
164 found = true; 164 found = true;
165 output = false; 165 output = false;
166 166
167 if(!line.contains("esac")) 167 if(!line.contains("esac"))
168 stream << line << "\n"; 168 stream << line << "\n";
169 if(!essAny->isChecked() == true){ 169 if(!essAny->isChecked() == true){
170 stream << "\tESSID=any\n"; 170 stream << "\tESSID=any\n";
171 stream << "\tMODE=Managed\n"; 171 stream << "\tMODE=Managed\n";
172 } 172 }
173 else{ 173 else{
174 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; 174 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n';
175 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; 175 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n';
176 stream << "\tCHANNEL=" << networkChannel->value() << "\n"; 176 stream << "\tCHANNEL=" << networkChannel->value() << "\n";
177 } 177 }
178 178
179 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; 179 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n";
180 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; 180 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n";
181 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; 181 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n";
182 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; 182 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n";
183 183
184 if(wepEnabled->isChecked()){ 184 if(wepEnabled->isChecked()){
185 stream << "\tKEY=\""; 185 stream << "\tKEY=\"";
186 if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); 186 if(keyRadio0->isChecked()) stream << keyLineEdit0->text();
187 if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); 187 if(keyRadio1->isChecked()) stream << keyLineEdit1->text();
188 if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); 188 if(keyRadio2->isChecked()) stream << keyLineEdit2->text();
189 if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); 189 if(keyRadio3->isChecked()) stream << keyLineEdit3->text();
190 if(authOpen->isChecked()) 190 if(authOpen->isChecked())
191 stream << " open"; 191 stream << " open";
192 else 192 else
193 stream << " restricted"; 193 stream << " restricted";
194 stream << "\"\n"; 194 stream << "\"\n";
195 } 195 }
196 stream << "\tRATE=auto\n"; 196 stream << "\tRATE=auto\n";
197 if(line.contains("esac")) 197 if(line.contains("esac"))
198 stream << line << "\n"; 198 stream << line << "\n";
199 } 199 }
200 if(line.contains(";;")) 200 if(line.contains(";;"))
201 output = true; 201 output = true;
202 if(output && (*it).length() ) 202 if(output && (*it).length() )
203 stream << (*it) << '\n'; 203 stream << (*it) << '\n';
204 } 204 }
205 file.close(); 205 file.close();
206} 206}
207 207
208/** 208/**
209 * Check to see if the current config is valid 209 * Check to see if the current config is valid
210 * Save wireless.opts, save interfaces 210 * Save wireless.opts, save interfaces
211 */ 211 */
212void WLANImp::accept(){ 212void WLANImp::accept(){
213 if(wepEnabled->isChecked()){ 213 if(wepEnabled->isChecked()){
214 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ 214 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){
215 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); 215 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok);
216 return; 216 return;
217 } 217 }
218 } 218 }
219 219
220 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){ 220 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){
221 QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); 221 QMessageBox::information(this, "Error", "Please enter a SSID.", QMessageBox::Ok);
222 return; 222 return;
223 } 223 }
224 224
225 // Ok settings are good here, save 225 // Ok settings are good here, save
226 changeAndSaveSettingFile(); 226 changeAndSaveSettingFile();
227 227
228 // Try to save the interfaces settings. 228 // Try to save the interfaces settings.
229 if(!interfaceSetup->saveChanges()) 229 if(!interfaceSetup->saveChanges())
230 return; 230 return;
231 231
232 OProcess insert; 232 OProcess insert;
233 insert << "sh"; 233 insert << "sh";
234 insert << "-c"; 234 insert << "-c";
235 insert << "cardctl eject && cardctl insert"; 235 insert << "cardctl eject && cardctl insert";
236 236
237 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) { 237 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) {
238 qWarning("could not start cardctl"); 238 qWarning("could not start cardctl");
239 } 239 }
240 240
241 // Close out the dialog 241 // Close out the dialog
242 QDialog::accept(); 242 QDialog::accept();
243} 243}
244 244
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index 26e3aa9..7ce096f 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,135 +1,157 @@
1#include "wlanimp2.h" 1#include "wlanimp2.h"
2#include "keyedit.h" 2#include "keyedit.h"
3#include "interfacesetupimp.h" 3#include "interfacesetupimp.h"
4 4
5#include "../interfaces/interface.h"
6
7#include <assert.h>
8#include <errno.h>
9#include <string.h>
10
11#include <qapplication.h>
5#include <qfile.h> 12#include <qfile.h>
6#include <qdir.h> 13#include <qdir.h>
14#include <qdialog.h>
7#include <qtextstream.h> 15#include <qtextstream.h>
8#include <qmessagebox.h> 16#include <qmessagebox.h>
9#include <qlineedit.h> 17#include <qlineedit.h>
10#include <qlabel.h> 18#include <qlabel.h>
11#include <qspinbox.h> 19#include <qspinbox.h>
12#include <qradiobutton.h> 20#include <qradiobutton.h>
21#include <qpushbutton.h>
13#include <qcheckbox.h> 22#include <qcheckbox.h>
14#include <qtabwidget.h> 23#include <qtabwidget.h>
15#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qlistview.h>
26#include <qvbox.h>
27#include <qprogressbar.h>
16 28
17#ifdef QWS 29#ifdef QWS
30 #include <qpe/resource.h>
18 #include <opie/oprocess.h> 31 #include <opie/oprocess.h>
32 #include <opie2/onetwork.h>
33 #include <opie2/opcap.h>
19#else 34#else
20 #define OProcess KProcess 35 #define OProcess KProcess
21 #include <kprocess.h> 36 #include <kprocess.h>
22#endif 37#endif
23 38
24#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 39#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
25#define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools" 40#define PREUP "/etc/network/if-pre-up.d/wireless-tools"
26 41
27/** 42/**
28 * Constructor, read in the wireless.opts file for parsing later. 43 * Constructor, read in the wireless.opts file for parsing later.
29 */ 44 */
30WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { 45WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") {
31 interfaces = new Interfaces(); 46 interfaces = new Interfaces();
32 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); 47 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
33 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 48 tabWidget->insertTab(interfaceSetup, "TCP/IP");
34 49
35 // Check sanity - the existance of the wireless-tools if-pre-up script 50 // Check sanity - the existance of the wireless-tools if-pre-up script
36 QFile file(QString(PREUP)); 51 QFile file(QString(PREUP));
37 if (file.exists()) { 52 if (file.exists()) {
38 qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); 53 qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools"));
39 } 54 }
55
56 connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) );
57 connect( netView, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectNetwork( QListViewItem* ) ) );
58 netView->setColumnAlignment( col_chn, AlignCenter );
59 netView->setItemMargin( 3 );
60 netView->setAllColumnsShowFocus( true );
61
40} 62}
41 63
42WLANImp::~WLANImp() { 64WLANImp::~WLANImp() {
43//FIXME: delete interfaces; 65//FIXME: delete interfaces;
44} 66}
45 67
46/** 68/**
47 * Change the profile for both wireless settings and network settings. 69 * Change the profile for both wireless settings and network settings.
48 */ 70 */
49void WLANImp::setProfile(const QString &profile){ 71void WLANImp::setProfile(const QString &profile){
50 interfaceSetup->setProfile(profile); 72 interfaceSetup->setProfile(profile);
51 parseOpts(); 73 parseOpts();
52} 74}
53 75
54void WLANImp::parseOpts() { 76void WLANImp::parseOpts() {
55 bool error; 77 bool error;
56 QString opt; 78 QString opt;
57 79
58 if (! interfaces->isInterfaceSet()) 80 if (! interfaces->isInterfaceSet())
59 return; 81 return;
60 82
61 83
62 opt = interfaces->getInterfaceOption("wireless_essid", error); 84 opt = interfaces->getInterfaceOption("wireless_essid", error);
63 if(opt == "any" || opt == "off" || opt.isNull()){ 85 if(opt == "any" || opt == "off" || opt.isNull()){
64 essid->setEditText("any"); 86 essid->setEditText("any");
65 } else { 87 } else {
66 essid->setEditText(opt); 88 essid->setEditText(opt);
67 } 89 }
68 90
69 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); 91 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
70 92
71 for ( int i = 0; i < mode->count(); i++) 93 for ( int i = 0; i < mode->count(); i++)
72 if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); 94 if ( mode->text( i ) == opt ) mode->setCurrentItem( i );
73 95
74 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); 96 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
75 if (! opt.isNull()) { 97 if (! opt.isNull()) {
76 specifyAp->setChecked(true); 98 specifyAp->setChecked(true);
77 macEdit->setText(opt); 99 macEdit->setText(opt);
78 } 100 }
79 101
80 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); 102 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
81 if (! opt.isNull()) { 103 if (! opt.isNull()) {
82 specifyChan->setChecked(true); 104 specifyChan->setChecked(true);
83 networkChannel->setValue(opt.toInt()); 105 networkChannel->setValue(opt.toInt());
84 } 106 }
85 107
86 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); 108 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace();
87 if (opt.isNull()) 109 if (opt.isNull())
88 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); 110 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace();
89 parseKeyStr(opt); 111 parseKeyStr(opt);
90} 112}
91 113
92void WLANImp::parseKeyStr(QString keystr) { 114void WLANImp::parseKeyStr(QString keystr) {
93 int loc = 0; 115 int loc = 0;
94 int index = 1; 116 int index = 1;
95 QString key; 117 QString key;
96 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); 118 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr);
97 int enc = -1; // encryption state 119 int enc = -1; // encryption state
98 120
99 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { 121 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
100 if ((*it).left(3) == "off") { 122 if ((*it).left(3) == "off") {
101 // encryption disabled 123 // encryption disabled
102 enc = 0; 124 enc = 0;
103 } else if ((*it).left(2) == "on") { 125 } else if ((*it).left(2) == "on") {
104 // encryption enabled 126 // encryption enabled
105 enc = 1; 127 enc = 1;
106 } else if ((*it).left(4) == "open") { 128 } else if ((*it).left(4) == "open") {
107 // open mode, accept non encrypted packets 129 // open mode, accept non encrypted packets
108 acceptNonEnc->setChecked(true); 130 acceptNonEnc->setChecked(true);
109 } else if ((*it).left(10) == "restricted") { 131 } else if ((*it).left(10) == "restricted") {
110 // restricted mode, only accept encrypted packets 132 // restricted mode, only accept encrypted packets
111 rejectNonEnc->setChecked(true); 133 rejectNonEnc->setChecked(true);
112 } else if ((*it).left(3) == "key") { 134 } else if ((*it).left(3) == "key") {
113 // new set of options 135 // new set of options
114 } else if ((*it).left(1) == "[") { 136 } else if ((*it).left(1) == "[") {
115 index = (*it).mid(1, 1).toInt(); 137 index = (*it).mid(1, 1).toInt();
116 // switch current key to index 138 // switch current key to index
117 switch (index) { 139 switch (index) {
118 case 1: 140 case 1:
119 keyRadio0->setChecked(true); 141 keyRadio0->setChecked(true);
120 break; 142 break;
121 case 2: 143 case 2:
122 keyRadio1->setChecked(true); 144 keyRadio1->setChecked(true);
123 break; 145 break;
124 case 3: 146 case 3:
125 keyRadio2->setChecked(true); 147 keyRadio2->setChecked(true);
126 break; 148 break;
127 case 4: 149 case 4:
128 keyRadio3->setChecked(true); 150 keyRadio3->setChecked(true);
129 break; 151 break;
130 } 152 }
131 } else { 153 } else {
132 // key 154 // key
133 key = (*it); 155 key = (*it);
134 } 156 }
135 if (! key.isNull()) { 157 if (! key.isNull()) {
@@ -181,96 +203,288 @@ void WLANImp::accept() {
181 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { 203 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
182 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); 204 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
183 return; 205 return;
184 } 206 }
185 } 207 }
186 208
187 if (essid->currentText().isEmpty()) { 209 if (essid->currentText().isEmpty()) {
188 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); 210 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
189 return; 211 return;
190 } 212 }
191 213
192 if (specifyAp->isChecked() && macEdit->text().isEmpty()) { 214 if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
193 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); 215 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
194 return; 216 return;
195 } 217 }
196 218
197 // Try to save the interfaces settings. 219 // Try to save the interfaces settings.
198 writeOpts(); 220 writeOpts();
199 221
200 // Close out the dialog 222 // Close out the dialog
201// FIXME: QDialog::accept(); 223// FIXME: QDialog::accept();
202} 224}
203 225
204void WLANImp::writeOpts() { 226void WLANImp::writeOpts() {
205 // eh can't really do anything about it other then return. :-D 227 // eh can't really do anything about it other then return. :-D
206 if(!interfaces->isInterfaceSet()){ 228 if(!interfaces->isInterfaceSet()){
207 QMessageBox::warning(0,"Inface not set","should not happen!!!"); 229 QMessageBox::warning(0,"Inface not set","should not happen!!!");
208 return; 230 return;
209 } 231 }
210 bool error = false; 232 bool error = false;
211 233
212 qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() ); 234 qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() );
213 235
214 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); 236 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
215 237
216 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); 238 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
217 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); 239 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
218 240
219 if (specifyAp->isChecked()) { 241 if (specifyAp->isChecked()) {
220 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); 242 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
221 } else { 243 } else {
222 interfaces->removeInterfaceOption(QString("wireless_ap")); 244 interfaces->removeInterfaceOption(QString("wireless_ap"));
223 } 245 }
224 246
225 if (specifyChan->isChecked()) { 247 if (specifyChan->isChecked()) {
226 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); 248 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
227 } else { 249 } else {
228 interfaces->removeInterfaceOption(QString("wireless_channel")); 250 interfaces->removeInterfaceOption(QString("wireless_channel"));
229 } 251 }
230 252
231 if (wepEnabled->isChecked()) { 253 if (wepEnabled->isChecked()) {
232 QStringList keyList; 254 QStringList keyList;
233 255
234 if (! keyLineEdit0->text().isNull()) { 256 if (! keyLineEdit0->text().isNull()) {
235 keyList += keyLineEdit0->text(); 257 keyList += keyLineEdit0->text();
236 keyList += "[1]"; 258 keyList += "[1]";
237 } //else 259 } //else
238 if (! keyLineEdit1->text().isNull()) { 260 if (! keyLineEdit1->text().isNull()) {
239 keyList += keyLineEdit1->text(); 261 keyList += keyLineEdit1->text();
240 keyList += "[2]"; 262 keyList += "[2]";
241 } //else 263 } //else
242 if (! keyLineEdit2->text().isNull()) { 264 if (! keyLineEdit2->text().isNull()) {
243 keyList += keyLineEdit2->text(); 265 keyList += keyLineEdit2->text();
244 keyList += "[3]"; 266 keyList += "[3]";
245 } //else 267 } //else
246 if (! keyLineEdit3->text().isNull()) { 268 if (! keyLineEdit3->text().isNull()) {
247 keyList += keyLineEdit3->text(); 269 keyList += keyLineEdit3->text();
248 keyList += "[4]"; 270 keyList += "[4]";
249 } 271 }
250 if (acceptNonEnc->isChecked()) { 272 if (acceptNonEnc->isChecked()) {
251 keyList += "open"; 273 keyList += "open";
252 } else { 274 } else {
253 keyList += "restricted"; 275 keyList += "restricted";
254 } 276 }
255 277
256 keyList += "key"; 278 keyList += "key";
257 if (keyRadio0->isChecked()) { 279 if (keyRadio0->isChecked()) {
258 keyList += "[1]"; 280 keyList += "[1]";
259 } else if (keyRadio1->isChecked()) { 281 } else if (keyRadio1->isChecked()) {
260 keyList += "[2]"; 282 keyList += "[2]";
261 } else if (keyRadio2->isChecked()) { 283 } else if (keyRadio2->isChecked()) {
262 keyList += "[3]"; 284 keyList += "[3]";
263 } else if (keyRadio3->isChecked()) { 285 } else if (keyRadio3->isChecked()) {
264 keyList += "[4]"; 286 keyList += "[4]";
265 } 287 }
266 interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); 288 interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" ")));
267 } else { 289 } else {
268 interfaces->removeInterfaceOption(QString("wireless_key")); 290 interfaces->removeInterfaceOption(QString("wireless_key"));
269 } 291 }
270 interfaces->removeInterfaceOption(QString("wireless_enc")); 292 interfaces->removeInterfaceOption(QString("wireless_enc"));
271 293
272 if(!interfaceSetup->saveChanges()) 294 if(!interfaceSetup->saveChanges())
273 return; 295 return;
274 296
275 QDialog::accept(); 297 QDialog::accept();
276} 298}
299
300/*
301 * Scan for possible wireless networks around...
302 * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org>
303 */
304
305void WLANImp::rescanNeighbourhood()
306{
307 QString name = interface->getInterfaceName();
308 qDebug( "rescanNeighbourhood via '%s'", (const char*) name );
309
310 OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) );
311 assert( wiface );
312
313 // try to guess device type
314 QString devicetype;
315 QFile m( "/proc/modules" );
316 if ( m.open( IO_ReadOnly ) )
317 {
318 QString line;
319 QTextStream modules( &m );
320 while( !modules.atEnd() && !devicetype )
321 {
322 modules >> line;
323 if ( line.contains( "cisco" ) ) devicetype = "cisco";
324 else if ( line.contains( "hostap" ) ) devicetype = "hostap";
325 else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */
326 else if ( line.contains( "orinoco" ) ) devicetype = "orinoco";
327 }
328 }
329 if ( devicetype.isEmpty() )
330 {
331 qWarning( "rescanNeighbourhood(): couldn't guess device type :(" );
332 return;
333 }
334 else
335 {
336 qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype );
337 }
338
339 // configure interface to receive 802.11 management frames
340
341 wiface->setUp( true );
342 wiface->setPromiscuousMode( true );
343
344 if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) );
345 else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) );
346 else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) );
347 else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) );
348 else
349 {
350 qDebug( "rescanNeighbourhood(): unsupported device type for monitoring :(" );
351 return;
352 }
353
354 wiface->setMonitorMode( true );
355 if ( !wiface->monitorMode() )
356 {
357 qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) );
358 return;
359 }
360
361 // open a packet capturer
362 OPacketCapturer* cap = new OPacketCapturer();
363 cap->open( name );
364 if ( !cap->isOpen() )
365 {
366 qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) );
367 return;
368 }
369
370 // display splash screen
371 QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize );
372 splash->setLineWidth( 2 );
373 splash->setFrameStyle( QFrame::Panel | QFrame::Raised );
374 QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 );
375 QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash );
376 QProgressBar* pb = new QProgressBar( wiface->channels(), splash );
377 vbox->addWidget( lab );
378 vbox->addWidget( pb );
379 pb->setCenterIndicator( true );
380 pb->setFixedHeight( pb->sizeHint().height() );
381 QWidget* widgetDesktop = qApp->desktop();
382 int dw = widgetDesktop->width();
383 int dh = widgetDesktop->height();
384 int pw = vbox->sizeHint().width();
385 int ph = vbox->sizeHint().height();
386 splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph);
387 splash->show();
388 splash->raise();
389 qApp->processEvents();
390
391 // set capturer to non-blocking mode
392 cap->setBlocking( false );
393
394 for ( int i = 1; i <= wiface->channels(); ++i )
395 {
396 wiface->setChannel( i );
397 pb->setProgress( i );
398 qApp->processEvents();
399 qDebug( "rescanNeighbourhood(): listening on channel %d...", i );
400 OPacket* p = cap->next( 1000 );
401 if ( !p )
402 {
403 qDebug( "rescanNeighbourhood(): nothing received on channel %d", i );
404 }
405 else
406 {
407 qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i );
408 handlePacket( p );
409 }
410 }
411
412 cap->close();
413 wiface->setMonitorMode( false );
414 wiface->setPromiscuousMode( true );
415
416 splash->hide();
417 delete splash;
418
419}
420
421void WLANImp::handlePacket( OPacket* p )
422{
423
424 // check if we received a beacon frame
425 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
426 if ( beacon && beacon->managementType() == "Beacon" )
427 {
428
429 QString type;
430 if ( beacon->canIBSS() )
431 {
432 type = "adhoc";
433 }
434 else if ( beacon->canESS() )
435 {
436 type = "managed";
437 }
438 else
439 {
440 qWarning( "handlePacket(): invalid frame [possibly noise] detected!" );
441 return;
442 }
443
444 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
445 QString essid = ssid ? ssid->ID() : QString("<unknown>");
446 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
447 int channel = ds ? ds->channel() : -1;
448 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
449 displayFoundNetwork( type, channel, essid, header->macAddress2() );
450 }
451}
452
453
454void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac )
455{
456
457 qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel,
458 (const char*) ssid,
459 (const char*) mac.toString() );
460
461 QListViewItemIterator it( netView );
462 while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it;
463 if ( !it.current() ) // ssid didn't show up yet
464 {
465 QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() );
466 QString name;
467 name.sprintf( "networksettings/%s", (const char*) mode );
468 item->setPixmap( col_mode, Resource::loadPixmap( name ) );
469 qApp->processEvents();
470 }
471
472}
473
474
475void WLANImp::selectNetwork( QListViewItem* item )
476{
477 bool ok;
478 if ( item )
479 {
480 specifyAp->setChecked(true);
481 macEdit->setText( item->text( col_mac ) );
482 specifyChan->setChecked( item->text( col_mode ) == "A" );
483 networkChannel->setValue( item->text( col_chn ).toInt( &ok ) );
484 essid->setEditText( item->text( col_ssid ) );
485 if ( item->text( col_mode ) == "A" )
486 mode->setCurrentItem( 3 );
487 else
488 mode->setCurrentItem( 2 );
489 }
490}
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.h b/noncore/settings/networksettings/wlan/wlanimp2.h
index 992d09a..a777203 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.h
+++ b/noncore/settings/networksettings/wlan/wlanimp2.h
@@ -1,37 +1,52 @@
1#ifndef WLANIMP_H 1#ifndef WLANIMP_H
2#define WLANIMP_H 2#define WLANIMP_H
3 3
4#include "wlan.h" 4#include "wlan.h"
5#include "interfaces.h" 5#include "interfaces.h"
6#include <qstringlist.h> 6#include <qstringlist.h>
7#include <opie2/onetutils.h>
7 8
8class InterfaceSetupImp; 9class InterfaceSetupImp;
9class Interface; 10class Interface;
10class Config; 11class Config;
12class OPacket;
13class QListViewItem;
11 14
12class WLANImp : public WLAN { 15const int col_mode= 0;
16const int col_ssid = 1;
17const int col_chn = 2;
18const int col_mac = 3;
19
20class WLANImp : public WLAN {
13 Q_OBJECT 21 Q_OBJECT
14 22
15public: 23public:
16 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); 24 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
17 ~WLANImp(); 25 ~WLANImp();
18 void setProfile(const QString &profile); 26 void setProfile(const QString &profile);
19 27
28public slots:
29 void rescanNeighbourhood();
30 void selectNetwork( QListViewItem* );
31
20protected: 32protected:
21 void accept(); 33 void accept();
22 34
23private: 35private:
24 void parseOpts(); 36 void parseOpts();
25 void writeOpts(); 37 void writeOpts();
26 38
27 void parseKeyStr(QString keystr); 39 void parseKeyStr(QString keystr);
28 40
41 void handlePacket( OPacket* );
42 void displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac );
43
29 InterfaceSetupImp *interfaceSetup; 44 InterfaceSetupImp *interfaceSetup;
30 Interfaces *interfaces; 45 Interfaces *interfaces;
31 Interface *interface; 46 Interface *interface;
32 47
33 QString currentProfile; 48 QString currentProfile;
34}; 49};
35 50
36#endif 51#endif
37 52
diff --git a/pics/networksettings/adhoc.png b/pics/networksettings/adhoc.png
new file mode 100644
index 0000000..dcf5ad2
--- a/dev/null
+++ b/pics/networksettings/adhoc.png
Binary files differ
diff --git a/pics/networksettings/managed.png b/pics/networksettings/managed.png
new file mode 100644
index 0000000..4554533
--- a/dev/null
+++ b/pics/networksettings/managed.png
Binary files differ