summaryrefslogtreecommitdiff
path: root/noncore
authormickeyl <mickeyl>2003-10-10 02:24:48 (UTC)
committer mickeyl <mickeyl>2003-10-10 02:24:48 (UTC)
commit2b2620fee2bbd6f7045b237aa33c277c47512345 (patch) (unidiff)
tree31f92a166da4ae596d55fe5079f058dd4a16fce4 /noncore
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 (limited to 'noncore') (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
7 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
@@ -4,7 +4,7 @@ Priority: 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
@@ -8,7 +8,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
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
@@ -11,8 +11,8 @@
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">
@@ -45,6 +45,12 @@
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">
@@ -55,333 +61,345 @@
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>
@@ -396,11 +414,11 @@
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>
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
@@ -218,7 +218,7 @@ void WLANImp::accept(){
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
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
@@ -2,27 +2,42 @@
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.
@@ -37,6 +52,13 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W
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() {
@@ -274,3 +296,195 @@ void WLANImp::writeOpts() {
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
@@ -4,12 +4,20 @@
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:
@@ -17,6 +25,10 @@ public:
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
@@ -25,7 +37,10 @@ private:
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;
@@ -34,4 +49,4 @@ private:
34}; 49};
35 50
36#endif 51#endif
37 52