-rw-r--r-- | noncore/net/networksetup/wlan/info.ui | 35 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 41 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.h | 1 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/info.ui | 35 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 41 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.h | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 3 |
8 files changed, 132 insertions, 28 deletions
diff --git a/noncore/net/networksetup/wlan/info.ui b/noncore/net/networksetup/wlan/info.ui index 4e85b1b..52d3a43 100644 --- a/noncore/net/networksetup/wlan/info.ui +++ b/noncore/net/networksetup/wlan/info.ui | |||
@@ -180,151 +180,184 @@ | |||
180 | </property> | 180 | </property> |
181 | <property stdset="1"> | 181 | <property stdset="1"> |
182 | <name>frameShadow</name> | 182 | <name>frameShadow</name> |
183 | <enum>Sunken</enum> | 183 | <enum>Sunken</enum> |
184 | </property> | 184 | </property> |
185 | </widget> | 185 | </widget> |
186 | <spacer row="5" column="1" > | 186 | <spacer row="5" column="1" > |
187 | <property> | 187 | <property> |
188 | <name>name</name> | 188 | <name>name</name> |
189 | <cstring>Spacer7</cstring> | 189 | <cstring>Spacer7</cstring> |
190 | </property> | 190 | </property> |
191 | <property stdset="1"> | 191 | <property stdset="1"> |
192 | <name>orientation</name> | 192 | <name>orientation</name> |
193 | <enum>Vertical</enum> | 193 | <enum>Vertical</enum> |
194 | </property> | 194 | </property> |
195 | <property stdset="1"> | 195 | <property stdset="1"> |
196 | <name>sizeType</name> | 196 | <name>sizeType</name> |
197 | <enum>Expanding</enum> | 197 | <enum>Expanding</enum> |
198 | </property> | 198 | </property> |
199 | <property> | 199 | <property> |
200 | <name>sizeHint</name> | 200 | <name>sizeHint</name> |
201 | <size> | 201 | <size> |
202 | <width>20</width> | 202 | <width>20</width> |
203 | <height>20</height> | 203 | <height>20</height> |
204 | </size> | 204 | </size> |
205 | </property> | 205 | </property> |
206 | </spacer> | 206 | </spacer> |
207 | </grid> | 207 | </grid> |
208 | </widget> | 208 | </widget> |
209 | <widget> | 209 | <widget> |
210 | <class>QWidget</class> | 210 | <class>QWidget</class> |
211 | <property stdset="1"> | 211 | <property stdset="1"> |
212 | <name>name</name> | 212 | <name>name</name> |
213 | <cstring>tab</cstring> | 213 | <cstring>tab</cstring> |
214 | </property> | 214 | </property> |
215 | <attribute> | 215 | <attribute> |
216 | <name>title</name> | 216 | <name>title</name> |
217 | <string>Statistics</string> | 217 | <string>Statistics</string> |
218 | </attribute> | 218 | </attribute> |
219 | <grid> | 219 | <grid> |
220 | <property stdset="1"> | 220 | <property stdset="1"> |
221 | <name>margin</name> | 221 | <name>margin</name> |
222 | <number>11</number> | 222 | <number>11</number> |
223 | </property> | 223 | </property> |
224 | <property stdset="1"> | 224 | <property stdset="1"> |
225 | <name>spacing</name> | 225 | <name>spacing</name> |
226 | <number>6</number> | 226 | <number>6</number> |
227 | </property> | 227 | </property> |
228 | <spacer row="3" column="1" > | 228 | <spacer row="4" column="1" > |
229 | <property> | 229 | <property> |
230 | <name>name</name> | 230 | <name>name</name> |
231 | <cstring>Spacer2</cstring> | 231 | <cstring>Spacer2</cstring> |
232 | </property> | 232 | </property> |
233 | <property stdset="1"> | 233 | <property stdset="1"> |
234 | <name>orientation</name> | 234 | <name>orientation</name> |
235 | <enum>Vertical</enum> | 235 | <enum>Vertical</enum> |
236 | </property> | 236 | </property> |
237 | <property stdset="1"> | 237 | <property stdset="1"> |
238 | <name>sizeType</name> | 238 | <name>sizeType</name> |
239 | <enum>Expanding</enum> | 239 | <enum>Expanding</enum> |
240 | </property> | 240 | </property> |
241 | <property> | 241 | <property> |
242 | <name>sizeHint</name> | 242 | <name>sizeHint</name> |
243 | <size> | 243 | <size> |
244 | <width>20</width> | 244 | <width>20</width> |
245 | <height>20</height> | 245 | <height>20</height> |
246 | </size> | 246 | </size> |
247 | </property> | 247 | </property> |
248 | </spacer> | 248 | </spacer> |
249 | <widget row="0" column="1" > | 249 | <widget row="0" column="1" > |
250 | <class>QProgressBar</class> | 250 | <class>QProgressBar</class> |
251 | <property stdset="1"> | 251 | <property stdset="1"> |
252 | <name>name</name> | 252 | <name>name</name> |
253 | <cstring>signalProgressBar</cstring> | 253 | <cstring>signalProgressBar</cstring> |
254 | </property> | 254 | </property> |
255 | </widget> | 255 | </widget> |
256 | <widget row="1" column="1" > | 256 | <widget row="1" column="1" > |
257 | <class>QProgressBar</class> | 257 | <class>QProgressBar</class> |
258 | <property stdset="1"> | 258 | <property stdset="1"> |
259 | <name>name</name> | 259 | <name>name</name> |
260 | <cstring>noiseProgressBar</cstring> | 260 | <cstring>noiseProgressBar</cstring> |
261 | </property> | 261 | </property> |
262 | </widget> | 262 | </widget> |
263 | <widget row="2" column="1" > | 263 | <widget row="2" column="1" > |
264 | <class>QProgressBar</class> | 264 | <class>QProgressBar</class> |
265 | <property stdset="1"> | 265 | <property stdset="1"> |
266 | <name>name</name> | 266 | <name>name</name> |
267 | <cstring>qualityProgressBar</cstring> | 267 | <cstring>qualityProgressBar</cstring> |
268 | </property> | 268 | </property> |
269 | </widget> | 269 | </widget> |
270 | <widget row="0" column="0" > | 270 | <widget row="0" column="0" > |
271 | <class>QLabel</class> | 271 | <class>QLabel</class> |
272 | <property stdset="1"> | 272 | <property stdset="1"> |
273 | <name>name</name> | 273 | <name>name</name> |
274 | <cstring>TextLabel1_2</cstring> | 274 | <cstring>TextLabel1_2</cstring> |
275 | </property> | 275 | </property> |
276 | <property stdset="1"> | 276 | <property stdset="1"> |
277 | <name>text</name> | 277 | <name>text</name> |
278 | <string>Signal</string> | 278 | <string>Signal</string> |
279 | </property> | 279 | </property> |
280 | </widget> | 280 | </widget> |
281 | <widget row="1" column="0" > | 281 | <widget row="1" column="0" > |
282 | <class>QLabel</class> | 282 | <class>QLabel</class> |
283 | <property stdset="1"> | 283 | <property stdset="1"> |
284 | <name>name</name> | 284 | <name>name</name> |
285 | <cstring>TextLabel2_2</cstring> | 285 | <cstring>TextLabel2_2</cstring> |
286 | </property> | 286 | </property> |
287 | <property stdset="1"> | 287 | <property stdset="1"> |
288 | <name>text</name> | 288 | <name>text</name> |
289 | <string>Noise</string> | 289 | <string>Noise</string> |
290 | </property> | 290 | </property> |
291 | </widget> | 291 | </widget> |
292 | <widget row="2" column="0" > | 292 | <widget row="2" column="0" > |
293 | <class>QLabel</class> | 293 | <class>QLabel</class> |
294 | <property stdset="1"> | 294 | <property stdset="1"> |
295 | <name>name</name> | 295 | <name>name</name> |
296 | <cstring>TextLabel3_2</cstring> | 296 | <cstring>TextLabel3_2</cstring> |
297 | </property> | 297 | </property> |
298 | <property stdset="1"> | 298 | <property stdset="1"> |
299 | <name>text</name> | 299 | <name>text</name> |
300 | <string>Quality</string> | 300 | <string>Quality</string> |
301 | </property> | 301 | </property> |
302 | </widget> | 302 | </widget> |
303 | <widget row="3" column="0" > | ||
304 | <class>QLabel</class> | ||
305 | <property stdset="1"> | ||
306 | <name>name</name> | ||
307 | <cstring>TextLabel4_2</cstring> | ||
308 | </property> | ||
309 | <property stdset="1"> | ||
310 | <name>text</name> | ||
311 | <string>Rate</string> | ||
312 | </property> | ||
313 | </widget> | ||
314 | <widget row="3" column="1" > | ||
315 | <class>QLabel</class> | ||
316 | <property stdset="1"> | ||
317 | <name>name</name> | ||
318 | <cstring>rateLabel</cstring> | ||
319 | </property> | ||
320 | <property stdset="1"> | ||
321 | <name>sizePolicy</name> | ||
322 | <sizepolicy> | ||
323 | <hsizetype>7</hsizetype> | ||
324 | <vsizetype>1</vsizetype> | ||
325 | </sizepolicy> | ||
326 | </property> | ||
327 | <property stdset="1"> | ||
328 | <name>frameShape</name> | ||
329 | <enum>Panel</enum> | ||
330 | </property> | ||
331 | <property stdset="1"> | ||
332 | <name>frameShadow</name> | ||
333 | <enum>Sunken</enum> | ||
334 | </property> | ||
335 | </widget> | ||
303 | </grid> | 336 | </grid> |
304 | </widget> | 337 | </widget> |
305 | </widget> | 338 | </widget> |
306 | </vbox> | 339 | </vbox> |
307 | </widget> | 340 | </widget> |
308 | <customwidgets> | 341 | <customwidgets> |
309 | <customwidget> | 342 | <customwidget> |
310 | <class>QWidget</class> | 343 | <class>QWidget</class> |
311 | <header location="local">qwidget.h</header> | 344 | <header location="local">qwidget.h</header> |
312 | <sizehint> | 345 | <sizehint> |
313 | <width>100</width> | 346 | <width>100</width> |
314 | <height>100</height> | 347 | <height>100</height> |
315 | </sizehint> | 348 | </sizehint> |
316 | <container>0</container> | 349 | <container>0</container> |
317 | <sizepolicy> | 350 | <sizepolicy> |
318 | <hordata>7</hordata> | 351 | <hordata>7</hordata> |
319 | <verdata>7</verdata> | 352 | <verdata>7</verdata> |
320 | </sizepolicy> | 353 | </sizepolicy> |
321 | <pixmap>image0</pixmap> | 354 | <pixmap>image0</pixmap> |
322 | </customwidget> | 355 | </customwidget> |
323 | </customwidgets> | 356 | </customwidgets> |
324 | <images> | 357 | <images> |
325 | <image> | 358 | <image> |
326 | <name>image0</name> | 359 | <name>image0</name> |
327 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | 360 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> |
328 | </image> | 361 | </image> |
329 | </images> | 362 | </images> |
330 | </UI> | 363 | </UI> |
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp index f45ebf2..ef4ba8f 100644 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/noncore/net/networksetup/wlan/wextensions.cpp | |||
@@ -1,158 +1,175 @@ | |||
1 | #include "wextensions.h" | 1 | #include "wextensions.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | 5 | ||
6 | #include <arpa/inet.h> | 6 | #include <arpa/inet.h> |
7 | #include <sys/socket.h> | 7 | #include <sys/socket.h> |
8 | #include <sys/ioctl.h> | 8 | #include <sys/ioctl.h> |
9 | 9 | ||
10 | #include <math.h> | 10 | #include <math.h> |
11 | 11 | ||
12 | #define PROCNETWIRELESS "/proc/net/wireless" | 12 | #define PROCNETWIRELESS "/proc/net/wireless" |
13 | #define IW_LOWER 140 | 13 | #define IW_LOWER 0 |
14 | #define IW_UPPER 200 | 14 | #define IW_UPPER 256 |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructor. Sets hasWirelessExtensions | 17 | * Constructor. Sets hasWirelessExtensions |
18 | */ | 18 | */ |
19 | WExtensions::WExtensions(QString interfaceName){ | 19 | WExtensions::WExtensions(QString interfaceName){ |
20 | interface = interfaceName; | 20 | interface = interfaceName; |
21 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); | 21 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); |
22 | 22 | ||
23 | const char* buffer[200]; | 23 | const char* buffer[200]; |
24 | memset( &iwr, 0, sizeof( iwr ) ); | 24 | memset( &iwr, 0, sizeof( iwr ) ); |
25 | iwr.u.essid.pointer = (caddr_t) buffer; | 25 | iwr.u.essid.pointer = (caddr_t) buffer; |
26 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 26 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
27 | iwr.u.essid.flags = 0; | 27 | iwr.u.essid.flags = 0; |
28 | 28 | ||
29 | // check if it is an IEEE 802.11 standard conform | 29 | // check if it is an IEEE 802.11 standard conform |
30 | // wireless device by sending SIOCGIWESSID | 30 | // wireless device by sending SIOCGIWESSID |
31 | // which also gives back the Extended Service Set ID | 31 | // which also gives back the Extended Service Set ID |
32 | // (see IEEE 802.11 for more information) | 32 | // (see IEEE 802.11 for more information) |
33 | 33 | ||
34 | const char* iname = interface.latin1(); | 34 | const char* iname = interface.latin1(); |
35 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | 35 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); |
36 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) | 36 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) |
37 | hasWirelessExtensions = true; | 37 | hasWirelessExtensions = true; |
38 | else | 38 | else |
39 | hasWirelessExtensions = false; | 39 | hasWirelessExtensions = false; |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * @return QString the station name of the access point. | 43 | * @return QString the station name of the access point. |
44 | */ | 44 | */ |
45 | QString WExtensions::station(){ | 45 | QString WExtensions::station(){ |
46 | if(!hasWirelessExtensions) | 46 | if(!hasWirelessExtensions) |
47 | return QString(); | 47 | return QString(); |
48 | const char* buffer[200]; | 48 | const char* buffer[200]; |
49 | iwr.u.data.pointer = (caddr_t) buffer; | 49 | iwr.u.data.pointer = (caddr_t) buffer; |
50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
51 | iwr.u.data.flags = 0; | 51 | iwr.u.data.flags = 0; |
52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | 52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ |
53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
54 | return QString(iwr.u.data.pointer); | 54 | return QString(iwr.u.data.pointer); |
55 | } | 55 | } |
56 | return QString(); | 56 | return QString(); |
57 | } | 57 | } |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * @return QString the essid of the host 802.11 access point. | 60 | * @return QString the essid of the host 802.11 access point. |
61 | */ | 61 | */ |
62 | QString WExtensions::essid(){ | 62 | QString WExtensions::essid(){ |
63 | if(!hasWirelessExtensions) | 63 | if(!hasWirelessExtensions) |
64 | return QString(); | 64 | return QString(); |
65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | 66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; |
67 | return QString(iwr.u.essid.pointer); | 67 | return QString(iwr.u.essid.pointer); |
68 | } | 68 | } |
69 | return QString(); | 69 | return QString(); |
70 | } | 70 | } |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * @return QString the mode of interface | 73 | * @return QString the mode of interface |
74 | */ | 74 | */ |
75 | QString WExtensions::mode(){ | 75 | QString WExtensions::mode(){ |
76 | if(!hasWirelessExtensions) | 76 | if(!hasWirelessExtensions) |
77 | return QString(); | 77 | return QString(); |
78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
80 | return QString(); | 80 | return QString(); |
81 | } | 81 | } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Get the frequency that the interface is running at. | 84 | * Get the frequency that the interface is running at. |
85 | * @return int the frequency that the interfacae is running at. | 85 | * @return int the frequency that the interfacae is running at. |
86 | */ | 86 | */ |
87 | double WExtensions::frequency(){ | 87 | double WExtensions::frequency(){ |
88 | if(!hasWirelessExtensions) | 88 | if(!hasWirelessExtensions) |
89 | return 0; | 89 | return 0; |
90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
92 | return 0;; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | /*** | ||
96 | * Get the current rate that the card is transmiting at. | ||
97 | */ | ||
98 | double WExtensions::rate(){ | ||
99 | if(!hasWirelessExtensions) | ||
100 | return 0; | ||
101 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | ||
102 | return ((double)iwr.u.bitrate.value)/1000000; | ||
103 | } | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | |||
95 | /** | 108 | /** |
96 | * @return QString the AccessPoint that the interface is connected to. | 109 | * @return QString the AccessPoint that the interface is connected to. |
97 | */ | 110 | */ |
98 | QString WExtensions::ap(){ | 111 | QString WExtensions::ap(){ |
99 | if(!hasWirelessExtensions) | 112 | if(!hasWirelessExtensions) |
100 | return QString(); | 113 | return QString(); |
101 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ | 114 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ |
102 | QString ap; | 115 | QString ap; |
103 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 116 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
104 | iwr.u.ap_addr.sa_data[0]&0xff, | 117 | iwr.u.ap_addr.sa_data[0]&0xff, |
105 | iwr.u.ap_addr.sa_data[1]&0xff, | 118 | iwr.u.ap_addr.sa_data[1]&0xff, |
106 | iwr.u.ap_addr.sa_data[2]&0xff, | 119 | iwr.u.ap_addr.sa_data[2]&0xff, |
107 | iwr.u.ap_addr.sa_data[3]&0xff, | 120 | iwr.u.ap_addr.sa_data[3]&0xff, |
108 | iwr.u.ap_addr.sa_data[4]&0xff, | 121 | iwr.u.ap_addr.sa_data[4]&0xff, |
109 | iwr.u.ap_addr.sa_data[5]&0xff ); | 122 | iwr.u.ap_addr.sa_data[5]&0xff ); |
110 | return ap; | 123 | return ap; |
111 | } | 124 | } |
112 | else return QString(); | 125 | else return QString(); |
113 | |||
114 | } | 126 | } |
115 | 127 | ||
128 | /** | ||
129 | * Get the stats for interfaces | ||
130 | * @param signal the signal strength of interface | ||
131 | * @param noise the noise level of the interface | ||
132 | * @param quality the quality level of the interface | ||
133 | * @return bool true if successfull | ||
134 | */ | ||
116 | bool WExtensions::stats(int &signal, int &noise, int &quality){ | 135 | bool WExtensions::stats(int &signal, int &noise, int &quality){ |
117 | // gather link quality from /proc/net/wireless | 136 | // gather link quality from /proc/net/wireless |
118 | if(!QFile::exists(PROCNETWIRELESS)) | 137 | if(!QFile::exists(PROCNETWIRELESS)) |
119 | return false; | 138 | return false; |
120 | 139 | ||
121 | char c; | 140 | char c; |
122 | QString status; | 141 | QString status; |
123 | QString name; | 142 | QString name; |
124 | 143 | ||
125 | QFile wfile( PROCNETWIRELESS ); | 144 | QFile wfile( PROCNETWIRELESS ); |
126 | if(!wfile.open( IO_ReadOnly )) | 145 | if(!wfile.open( IO_ReadOnly )) |
127 | return false; | 146 | return false; |
128 | 147 | ||
129 | QTextStream wstream( &wfile ); | 148 | QTextStream wstream( &wfile ); |
130 | wstream.readLine(); // skip the first two lines | 149 | wstream.readLine(); // skip the first two lines |
131 | wstream.readLine(); // because they only contain headers | 150 | wstream.readLine(); // because they only contain headers |
132 | while(!wstream.atEnd()){ | 151 | while(!wstream.atEnd()){ |
133 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
134 | if(name == interface){ | 153 | if(name == QString("%1:").arg(interface)){ |
135 | if ( quality > 92 ) | 154 | if ( quality > 92 ) |
136 | #ifdef MDEBUG | ||
137 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
138 | #endif | ||
139 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
140 | #ifdef MDEBUG | ||
141 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
142 | #endif | ||
143 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
144 | #ifdef MDEBUG | ||
145 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
146 | #endif | 160 | qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | ||
162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | ||
163 | quality = ( quality*100 ) / 92; | ||
147 | return true; | 164 | return true; |
148 | } | 165 | } |
149 | } | 166 | } |
150 | 167 | ||
151 | qDebug("Card no longer present"); | 168 | qDebug("WExtensions::statsCard no longer present."); |
152 | quality = -1; | 169 | quality = -1; |
153 | signal = IW_LOWER; | 170 | signal = IW_LOWER; |
154 | noise = IW_LOWER; | 171 | noise = IW_LOWER; |
155 | return false; | 172 | return false; |
156 | } | 173 | } |
157 | 174 | ||
158 | // wextensions.cpp | 175 | // wextensions.cpp |
diff --git a/noncore/net/networksetup/wlan/wextensions.h b/noncore/net/networksetup/wlan/wextensions.h index 29997f5..1565eb5 100644 --- a/noncore/net/networksetup/wlan/wextensions.h +++ b/noncore/net/networksetup/wlan/wextensions.h | |||
@@ -1,32 +1,33 @@ | |||
1 | #ifndef WEXTENSIONS_H | 1 | #ifndef WEXTENSIONS_H |
2 | #define WEXTENSIONS_H | 2 | #define WEXTENSIONS_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | 5 | ||
6 | #include <netinet/ip.h> | 6 | #include <netinet/ip.h> |
7 | #include <linux/wireless.h> | 7 | #include <linux/wireless.h> |
8 | 8 | ||
9 | class WExtensions { | 9 | class WExtensions { |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WExtensions(QString interfaceName); | 12 | WExtensions(QString interfaceName); |
13 | QString getInterfaceName(){return interface;}; | 13 | QString getInterfaceName(){return interface;}; |
14 | bool doesHaveWirelessExtensions(){return hasWirelessExtensions;}; | 14 | bool doesHaveWirelessExtensions(){return hasWirelessExtensions;}; |
15 | QString station(); | 15 | QString station(); |
16 | QString essid(); | 16 | QString essid(); |
17 | QString mode(); | 17 | QString mode(); |
18 | double frequency(); | 18 | double frequency(); |
19 | double rate(); | ||
19 | QString ap(); | 20 | QString ap(); |
20 | bool stats( int &signal, int &noise, int &quality); | 21 | bool stats( int &signal, int &noise, int &quality); |
21 | 22 | ||
22 | private: | 23 | private: |
23 | bool hasWirelessExtensions; | 24 | bool hasWirelessExtensions; |
24 | QString interface; | 25 | QString interface; |
25 | 26 | ||
26 | // Used in we calls | 27 | // Used in we calls |
27 | struct iwreq iwr; | 28 | struct iwreq iwr; |
28 | int fd; | 29 | int fd; |
29 | 30 | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif | 33 | #endif |
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index ab0b9a5..73e753c 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp | |||
@@ -38,91 +38,92 @@ QString WLANModule::getPixmapName(Interface* ){ | |||
38 | } | 38 | } |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Check to see if the interface i is owned by this module. | 41 | * Check to see if the interface i is owned by this module. |
42 | * @param Interface* interface to check against | 42 | * @param Interface* interface to check against |
43 | * @return bool true if i is owned by this module, false otherwise. | 43 | * @return bool true if i is owned by this module, false otherwise. |
44 | */ | 44 | */ |
45 | bool WLANModule::isOwner(Interface *i){ | 45 | bool WLANModule::isOwner(Interface *i){ |
46 | WExtensions we(i->getInterfaceName()); | 46 | WExtensions we(i->getInterfaceName()); |
47 | if(!we.doesHaveWirelessExtensions()) | 47 | if(!we.doesHaveWirelessExtensions()) |
48 | return false; | 48 | return false; |
49 | 49 | ||
50 | //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 50 | //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ |
51 | i->setHardwareName("802.11b"); | 51 | i->setHardwareName("802.11b"); |
52 | list.append(i); | 52 | list.append(i); |
53 | return true; | 53 | return true; |
54 | //} | 54 | //} |
55 | //return false; | 55 | //return false; |
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Create, set tabWiget and return the WLANConfigure Module | 59 | * Create, set tabWiget and return the WLANConfigure Module |
60 | * @param tabWidget a pointer to the tab widget that this configure has. | 60 | * @param tabWidget a pointer to the tab widget that this configure has. |
61 | * @return QWidget* pointer to the tab widget in this modules configure. | 61 | * @return QWidget* pointer to the tab widget in this modules configure. |
62 | */ | 62 | */ |
63 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ | 63 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ |
64 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); | 64 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); |
65 | (*tabWidget) = wlanconfig->tabWidget; | 65 | (*tabWidget) = wlanconfig->tabWidget; |
66 | return wlanconfig; | 66 | return wlanconfig; |
67 | } | 67 | } |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Create, set tabWiget and return the Information Module | 70 | * Create, set tabWiget and return the Information Module |
71 | * @param tabWidget a pointer to the tab widget that this information has. | 71 | * @param tabWidget a pointer to the tab widget that this information has. |
72 | * @return QWidget* pointer to the tab widget in this modules info. | 72 | * @return QWidget* pointer to the tab widget in this modules info. |
73 | */ | 73 | */ |
74 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 74 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
75 | WExtensions we(i->getInterfaceName()); | 75 | WExtensions we(i->getInterfaceName()); |
76 | if(!we.doesHaveWirelessExtensions()) | 76 | if(!we.doesHaveWirelessExtensions()) |
77 | return NULL; | 77 | return NULL; |
78 | 78 | ||
79 | WlanInfo *info = new WlanInfo(0, "wireless info"); | 79 | WlanInfo *info = new WlanInfo(0, "wireless info"); |
80 | (*tabWidget) = info->tabWidget; | 80 | (*tabWidget) = info->tabWidget; |
81 | 81 | ||
82 | info->essidLabel->setText(we.essid()); | 82 | info->essidLabel->setText(we.essid()); |
83 | info->apLabel->setText(we.ap()); | 83 | info->apLabel->setText(we.ap()); |
84 | info->stationLabel->setText(we.station()); | 84 | info->stationLabel->setText(we.station()); |
85 | info->modeLabel->setText(we.mode()); | 85 | info->modeLabel->setText(we.mode()); |
86 | info->freqLabel->setText(QString("%1").arg(we.frequency())); | 86 | info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); |
87 | int signal = 0; | 87 | int signal = 0; |
88 | int noise = 0; | 88 | int noise = 0; |
89 | int quality = 0; | 89 | int quality = 0; |
90 | we.stats(signal, noise, quality); | 90 | we.stats(signal, noise, quality); |
91 | info->signalProgressBar->setProgress(signal); | 91 | info->signalProgressBar->setProgress(signal); |
92 | info->noiseProgressBar->setProgress(noise); | 92 | info->noiseProgressBar->setProgress(noise); |
93 | info->qualityProgressBar->setProgress(quality); | 93 | info->qualityProgressBar->setProgress(quality); |
94 | info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); | ||
94 | return info; | 95 | return info; |
95 | } | 96 | } |
96 | 97 | ||
97 | /** | 98 | /** |
98 | * Get all active (up or down) interfaces | 99 | * Get all active (up or down) interfaces |
99 | * @return QList<Interface> A list of interfaces that exsist that havn't | 100 | * @return QList<Interface> A list of interfaces that exsist that havn't |
100 | * been called by isOwner() | 101 | * been called by isOwner() |
101 | */ | 102 | */ |
102 | QList<Interface> WLANModule::getInterfaces(){ | 103 | QList<Interface> WLANModule::getInterfaces(){ |
103 | return list; | 104 | return list; |
104 | } | 105 | } |
105 | 106 | ||
106 | /** | 107 | /** |
107 | * Attempt to add a new interface as defined by name | 108 | * Attempt to add a new interface as defined by name |
108 | * @param name the name of the type of interface that should be created given | 109 | * @param name the name of the type of interface that should be created given |
109 | * by possibleNewInterfaces(); | 110 | * by possibleNewInterfaces(); |
110 | * @return Interface* NULL if it was unable to be created. | 111 | * @return Interface* NULL if it was unable to be created. |
111 | */ | 112 | */ |
112 | Interface *WLANModule::addNewInterface(QString ){ | 113 | Interface *WLANModule::addNewInterface(QString ){ |
113 | // We can't add a 802.11 interface, either the hardware will be there | 114 | // We can't add a 802.11 interface, either the hardware will be there |
114 | // or it wont. | 115 | // or it wont. |
115 | return NULL; | 116 | return NULL; |
116 | } | 117 | } |
117 | 118 | ||
118 | /** | 119 | /** |
119 | * Attempts to remove the interface, doesn't delete i | 120 | * Attempts to remove the interface, doesn't delete i |
120 | * @return bool true if successfull, false otherwise. | 121 | * @return bool true if successfull, false otherwise. |
121 | */ | 122 | */ |
122 | bool WLANModule::remove(Interface*){ | 123 | bool WLANModule::remove(Interface*){ |
123 | // Can't remove a hardware device, you can stop it though. | 124 | // Can't remove a hardware device, you can stop it though. |
124 | return false; | 125 | return false; |
125 | } | 126 | } |
126 | 127 | ||
127 | // wlanmodule.cpp | 128 | // wlanmodule.cpp |
128 | 129 | ||
diff --git a/noncore/settings/networksettings/wlan/info.ui b/noncore/settings/networksettings/wlan/info.ui index 4e85b1b..52d3a43 100644 --- a/noncore/settings/networksettings/wlan/info.ui +++ b/noncore/settings/networksettings/wlan/info.ui | |||
@@ -180,151 +180,184 @@ | |||
180 | </property> | 180 | </property> |
181 | <property stdset="1"> | 181 | <property stdset="1"> |
182 | <name>frameShadow</name> | 182 | <name>frameShadow</name> |
183 | <enum>Sunken</enum> | 183 | <enum>Sunken</enum> |
184 | </property> | 184 | </property> |
185 | </widget> | 185 | </widget> |
186 | <spacer row="5" column="1" > | 186 | <spacer row="5" column="1" > |
187 | <property> | 187 | <property> |
188 | <name>name</name> | 188 | <name>name</name> |
189 | <cstring>Spacer7</cstring> | 189 | <cstring>Spacer7</cstring> |
190 | </property> | 190 | </property> |
191 | <property stdset="1"> | 191 | <property stdset="1"> |
192 | <name>orientation</name> | 192 | <name>orientation</name> |
193 | <enum>Vertical</enum> | 193 | <enum>Vertical</enum> |
194 | </property> | 194 | </property> |
195 | <property stdset="1"> | 195 | <property stdset="1"> |
196 | <name>sizeType</name> | 196 | <name>sizeType</name> |
197 | <enum>Expanding</enum> | 197 | <enum>Expanding</enum> |
198 | </property> | 198 | </property> |
199 | <property> | 199 | <property> |
200 | <name>sizeHint</name> | 200 | <name>sizeHint</name> |
201 | <size> | 201 | <size> |
202 | <width>20</width> | 202 | <width>20</width> |
203 | <height>20</height> | 203 | <height>20</height> |
204 | </size> | 204 | </size> |
205 | </property> | 205 | </property> |
206 | </spacer> | 206 | </spacer> |
207 | </grid> | 207 | </grid> |
208 | </widget> | 208 | </widget> |
209 | <widget> | 209 | <widget> |
210 | <class>QWidget</class> | 210 | <class>QWidget</class> |
211 | <property stdset="1"> | 211 | <property stdset="1"> |
212 | <name>name</name> | 212 | <name>name</name> |
213 | <cstring>tab</cstring> | 213 | <cstring>tab</cstring> |
214 | </property> | 214 | </property> |
215 | <attribute> | 215 | <attribute> |
216 | <name>title</name> | 216 | <name>title</name> |
217 | <string>Statistics</string> | 217 | <string>Statistics</string> |
218 | </attribute> | 218 | </attribute> |
219 | <grid> | 219 | <grid> |
220 | <property stdset="1"> | 220 | <property stdset="1"> |
221 | <name>margin</name> | 221 | <name>margin</name> |
222 | <number>11</number> | 222 | <number>11</number> |
223 | </property> | 223 | </property> |
224 | <property stdset="1"> | 224 | <property stdset="1"> |
225 | <name>spacing</name> | 225 | <name>spacing</name> |
226 | <number>6</number> | 226 | <number>6</number> |
227 | </property> | 227 | </property> |
228 | <spacer row="3" column="1" > | 228 | <spacer row="4" column="1" > |
229 | <property> | 229 | <property> |
230 | <name>name</name> | 230 | <name>name</name> |
231 | <cstring>Spacer2</cstring> | 231 | <cstring>Spacer2</cstring> |
232 | </property> | 232 | </property> |
233 | <property stdset="1"> | 233 | <property stdset="1"> |
234 | <name>orientation</name> | 234 | <name>orientation</name> |
235 | <enum>Vertical</enum> | 235 | <enum>Vertical</enum> |
236 | </property> | 236 | </property> |
237 | <property stdset="1"> | 237 | <property stdset="1"> |
238 | <name>sizeType</name> | 238 | <name>sizeType</name> |
239 | <enum>Expanding</enum> | 239 | <enum>Expanding</enum> |
240 | </property> | 240 | </property> |
241 | <property> | 241 | <property> |
242 | <name>sizeHint</name> | 242 | <name>sizeHint</name> |
243 | <size> | 243 | <size> |
244 | <width>20</width> | 244 | <width>20</width> |
245 | <height>20</height> | 245 | <height>20</height> |
246 | </size> | 246 | </size> |
247 | </property> | 247 | </property> |
248 | </spacer> | 248 | </spacer> |
249 | <widget row="0" column="1" > | 249 | <widget row="0" column="1" > |
250 | <class>QProgressBar</class> | 250 | <class>QProgressBar</class> |
251 | <property stdset="1"> | 251 | <property stdset="1"> |
252 | <name>name</name> | 252 | <name>name</name> |
253 | <cstring>signalProgressBar</cstring> | 253 | <cstring>signalProgressBar</cstring> |
254 | </property> | 254 | </property> |
255 | </widget> | 255 | </widget> |
256 | <widget row="1" column="1" > | 256 | <widget row="1" column="1" > |
257 | <class>QProgressBar</class> | 257 | <class>QProgressBar</class> |
258 | <property stdset="1"> | 258 | <property stdset="1"> |
259 | <name>name</name> | 259 | <name>name</name> |
260 | <cstring>noiseProgressBar</cstring> | 260 | <cstring>noiseProgressBar</cstring> |
261 | </property> | 261 | </property> |
262 | </widget> | 262 | </widget> |
263 | <widget row="2" column="1" > | 263 | <widget row="2" column="1" > |
264 | <class>QProgressBar</class> | 264 | <class>QProgressBar</class> |
265 | <property stdset="1"> | 265 | <property stdset="1"> |
266 | <name>name</name> | 266 | <name>name</name> |
267 | <cstring>qualityProgressBar</cstring> | 267 | <cstring>qualityProgressBar</cstring> |
268 | </property> | 268 | </property> |
269 | </widget> | 269 | </widget> |
270 | <widget row="0" column="0" > | 270 | <widget row="0" column="0" > |
271 | <class>QLabel</class> | 271 | <class>QLabel</class> |
272 | <property stdset="1"> | 272 | <property stdset="1"> |
273 | <name>name</name> | 273 | <name>name</name> |
274 | <cstring>TextLabel1_2</cstring> | 274 | <cstring>TextLabel1_2</cstring> |
275 | </property> | 275 | </property> |
276 | <property stdset="1"> | 276 | <property stdset="1"> |
277 | <name>text</name> | 277 | <name>text</name> |
278 | <string>Signal</string> | 278 | <string>Signal</string> |
279 | </property> | 279 | </property> |
280 | </widget> | 280 | </widget> |
281 | <widget row="1" column="0" > | 281 | <widget row="1" column="0" > |
282 | <class>QLabel</class> | 282 | <class>QLabel</class> |
283 | <property stdset="1"> | 283 | <property stdset="1"> |
284 | <name>name</name> | 284 | <name>name</name> |
285 | <cstring>TextLabel2_2</cstring> | 285 | <cstring>TextLabel2_2</cstring> |
286 | </property> | 286 | </property> |
287 | <property stdset="1"> | 287 | <property stdset="1"> |
288 | <name>text</name> | 288 | <name>text</name> |
289 | <string>Noise</string> | 289 | <string>Noise</string> |
290 | </property> | 290 | </property> |
291 | </widget> | 291 | </widget> |
292 | <widget row="2" column="0" > | 292 | <widget row="2" column="0" > |
293 | <class>QLabel</class> | 293 | <class>QLabel</class> |
294 | <property stdset="1"> | 294 | <property stdset="1"> |
295 | <name>name</name> | 295 | <name>name</name> |
296 | <cstring>TextLabel3_2</cstring> | 296 | <cstring>TextLabel3_2</cstring> |
297 | </property> | 297 | </property> |
298 | <property stdset="1"> | 298 | <property stdset="1"> |
299 | <name>text</name> | 299 | <name>text</name> |
300 | <string>Quality</string> | 300 | <string>Quality</string> |
301 | </property> | 301 | </property> |
302 | </widget> | 302 | </widget> |
303 | <widget row="3" column="0" > | ||
304 | <class>QLabel</class> | ||
305 | <property stdset="1"> | ||
306 | <name>name</name> | ||
307 | <cstring>TextLabel4_2</cstring> | ||
308 | </property> | ||
309 | <property stdset="1"> | ||
310 | <name>text</name> | ||
311 | <string>Rate</string> | ||
312 | </property> | ||
313 | </widget> | ||
314 | <widget row="3" column="1" > | ||
315 | <class>QLabel</class> | ||
316 | <property stdset="1"> | ||
317 | <name>name</name> | ||
318 | <cstring>rateLabel</cstring> | ||
319 | </property> | ||
320 | <property stdset="1"> | ||
321 | <name>sizePolicy</name> | ||
322 | <sizepolicy> | ||
323 | <hsizetype>7</hsizetype> | ||
324 | <vsizetype>1</vsizetype> | ||
325 | </sizepolicy> | ||
326 | </property> | ||
327 | <property stdset="1"> | ||
328 | <name>frameShape</name> | ||
329 | <enum>Panel</enum> | ||
330 | </property> | ||
331 | <property stdset="1"> | ||
332 | <name>frameShadow</name> | ||
333 | <enum>Sunken</enum> | ||
334 | </property> | ||
335 | </widget> | ||
303 | </grid> | 336 | </grid> |
304 | </widget> | 337 | </widget> |
305 | </widget> | 338 | </widget> |
306 | </vbox> | 339 | </vbox> |
307 | </widget> | 340 | </widget> |
308 | <customwidgets> | 341 | <customwidgets> |
309 | <customwidget> | 342 | <customwidget> |
310 | <class>QWidget</class> | 343 | <class>QWidget</class> |
311 | <header location="local">qwidget.h</header> | 344 | <header location="local">qwidget.h</header> |
312 | <sizehint> | 345 | <sizehint> |
313 | <width>100</width> | 346 | <width>100</width> |
314 | <height>100</height> | 347 | <height>100</height> |
315 | </sizehint> | 348 | </sizehint> |
316 | <container>0</container> | 349 | <container>0</container> |
317 | <sizepolicy> | 350 | <sizepolicy> |
318 | <hordata>7</hordata> | 351 | <hordata>7</hordata> |
319 | <verdata>7</verdata> | 352 | <verdata>7</verdata> |
320 | </sizepolicy> | 353 | </sizepolicy> |
321 | <pixmap>image0</pixmap> | 354 | <pixmap>image0</pixmap> |
322 | </customwidget> | 355 | </customwidget> |
323 | </customwidgets> | 356 | </customwidgets> |
324 | <images> | 357 | <images> |
325 | <image> | 358 | <image> |
326 | <name>image0</name> | 359 | <name>image0</name> |
327 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | 360 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> |
328 | </image> | 361 | </image> |
329 | </images> | 362 | </images> |
330 | </UI> | 363 | </UI> |
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index f45ebf2..ef4ba8f 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -1,158 +1,175 @@ | |||
1 | #include "wextensions.h" | 1 | #include "wextensions.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | 5 | ||
6 | #include <arpa/inet.h> | 6 | #include <arpa/inet.h> |
7 | #include <sys/socket.h> | 7 | #include <sys/socket.h> |
8 | #include <sys/ioctl.h> | 8 | #include <sys/ioctl.h> |
9 | 9 | ||
10 | #include <math.h> | 10 | #include <math.h> |
11 | 11 | ||
12 | #define PROCNETWIRELESS "/proc/net/wireless" | 12 | #define PROCNETWIRELESS "/proc/net/wireless" |
13 | #define IW_LOWER 140 | 13 | #define IW_LOWER 0 |
14 | #define IW_UPPER 200 | 14 | #define IW_UPPER 256 |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructor. Sets hasWirelessExtensions | 17 | * Constructor. Sets hasWirelessExtensions |
18 | */ | 18 | */ |
19 | WExtensions::WExtensions(QString interfaceName){ | 19 | WExtensions::WExtensions(QString interfaceName){ |
20 | interface = interfaceName; | 20 | interface = interfaceName; |
21 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); | 21 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); |
22 | 22 | ||
23 | const char* buffer[200]; | 23 | const char* buffer[200]; |
24 | memset( &iwr, 0, sizeof( iwr ) ); | 24 | memset( &iwr, 0, sizeof( iwr ) ); |
25 | iwr.u.essid.pointer = (caddr_t) buffer; | 25 | iwr.u.essid.pointer = (caddr_t) buffer; |
26 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 26 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
27 | iwr.u.essid.flags = 0; | 27 | iwr.u.essid.flags = 0; |
28 | 28 | ||
29 | // check if it is an IEEE 802.11 standard conform | 29 | // check if it is an IEEE 802.11 standard conform |
30 | // wireless device by sending SIOCGIWESSID | 30 | // wireless device by sending SIOCGIWESSID |
31 | // which also gives back the Extended Service Set ID | 31 | // which also gives back the Extended Service Set ID |
32 | // (see IEEE 802.11 for more information) | 32 | // (see IEEE 802.11 for more information) |
33 | 33 | ||
34 | const char* iname = interface.latin1(); | 34 | const char* iname = interface.latin1(); |
35 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | 35 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); |
36 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) | 36 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) |
37 | hasWirelessExtensions = true; | 37 | hasWirelessExtensions = true; |
38 | else | 38 | else |
39 | hasWirelessExtensions = false; | 39 | hasWirelessExtensions = false; |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * @return QString the station name of the access point. | 43 | * @return QString the station name of the access point. |
44 | */ | 44 | */ |
45 | QString WExtensions::station(){ | 45 | QString WExtensions::station(){ |
46 | if(!hasWirelessExtensions) | 46 | if(!hasWirelessExtensions) |
47 | return QString(); | 47 | return QString(); |
48 | const char* buffer[200]; | 48 | const char* buffer[200]; |
49 | iwr.u.data.pointer = (caddr_t) buffer; | 49 | iwr.u.data.pointer = (caddr_t) buffer; |
50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 50 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
51 | iwr.u.data.flags = 0; | 51 | iwr.u.data.flags = 0; |
52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | 52 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ |
53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 53 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
54 | return QString(iwr.u.data.pointer); | 54 | return QString(iwr.u.data.pointer); |
55 | } | 55 | } |
56 | return QString(); | 56 | return QString(); |
57 | } | 57 | } |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * @return QString the essid of the host 802.11 access point. | 60 | * @return QString the essid of the host 802.11 access point. |
61 | */ | 61 | */ |
62 | QString WExtensions::essid(){ | 62 | QString WExtensions::essid(){ |
63 | if(!hasWirelessExtensions) | 63 | if(!hasWirelessExtensions) |
64 | return QString(); | 64 | return QString(); |
65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 65 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | 66 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; |
67 | return QString(iwr.u.essid.pointer); | 67 | return QString(iwr.u.essid.pointer); |
68 | } | 68 | } |
69 | return QString(); | 69 | return QString(); |
70 | } | 70 | } |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * @return QString the mode of interface | 73 | * @return QString the mode of interface |
74 | */ | 74 | */ |
75 | QString WExtensions::mode(){ | 75 | QString WExtensions::mode(){ |
76 | if(!hasWirelessExtensions) | 76 | if(!hasWirelessExtensions) |
77 | return QString(); | 77 | return QString(); |
78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 78 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 79 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
80 | return QString(); | 80 | return QString(); |
81 | } | 81 | } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Get the frequency that the interface is running at. | 84 | * Get the frequency that the interface is running at. |
85 | * @return int the frequency that the interfacae is running at. | 85 | * @return int the frequency that the interfacae is running at. |
86 | */ | 86 | */ |
87 | double WExtensions::frequency(){ | 87 | double WExtensions::frequency(){ |
88 | if(!hasWirelessExtensions) | 88 | if(!hasWirelessExtensions) |
89 | return 0; | 89 | return 0; |
90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 90 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 91 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
92 | return 0;; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | /*** | ||
96 | * Get the current rate that the card is transmiting at. | ||
97 | */ | ||
98 | double WExtensions::rate(){ | ||
99 | if(!hasWirelessExtensions) | ||
100 | return 0; | ||
101 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | ||
102 | return ((double)iwr.u.bitrate.value)/1000000; | ||
103 | } | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | |||
95 | /** | 108 | /** |
96 | * @return QString the AccessPoint that the interface is connected to. | 109 | * @return QString the AccessPoint that the interface is connected to. |
97 | */ | 110 | */ |
98 | QString WExtensions::ap(){ | 111 | QString WExtensions::ap(){ |
99 | if(!hasWirelessExtensions) | 112 | if(!hasWirelessExtensions) |
100 | return QString(); | 113 | return QString(); |
101 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ | 114 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ |
102 | QString ap; | 115 | QString ap; |
103 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 116 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
104 | iwr.u.ap_addr.sa_data[0]&0xff, | 117 | iwr.u.ap_addr.sa_data[0]&0xff, |
105 | iwr.u.ap_addr.sa_data[1]&0xff, | 118 | iwr.u.ap_addr.sa_data[1]&0xff, |
106 | iwr.u.ap_addr.sa_data[2]&0xff, | 119 | iwr.u.ap_addr.sa_data[2]&0xff, |
107 | iwr.u.ap_addr.sa_data[3]&0xff, | 120 | iwr.u.ap_addr.sa_data[3]&0xff, |
108 | iwr.u.ap_addr.sa_data[4]&0xff, | 121 | iwr.u.ap_addr.sa_data[4]&0xff, |
109 | iwr.u.ap_addr.sa_data[5]&0xff ); | 122 | iwr.u.ap_addr.sa_data[5]&0xff ); |
110 | return ap; | 123 | return ap; |
111 | } | 124 | } |
112 | else return QString(); | 125 | else return QString(); |
113 | |||
114 | } | 126 | } |
115 | 127 | ||
128 | /** | ||
129 | * Get the stats for interfaces | ||
130 | * @param signal the signal strength of interface | ||
131 | * @param noise the noise level of the interface | ||
132 | * @param quality the quality level of the interface | ||
133 | * @return bool true if successfull | ||
134 | */ | ||
116 | bool WExtensions::stats(int &signal, int &noise, int &quality){ | 135 | bool WExtensions::stats(int &signal, int &noise, int &quality){ |
117 | // gather link quality from /proc/net/wireless | 136 | // gather link quality from /proc/net/wireless |
118 | if(!QFile::exists(PROCNETWIRELESS)) | 137 | if(!QFile::exists(PROCNETWIRELESS)) |
119 | return false; | 138 | return false; |
120 | 139 | ||
121 | char c; | 140 | char c; |
122 | QString status; | 141 | QString status; |
123 | QString name; | 142 | QString name; |
124 | 143 | ||
125 | QFile wfile( PROCNETWIRELESS ); | 144 | QFile wfile( PROCNETWIRELESS ); |
126 | if(!wfile.open( IO_ReadOnly )) | 145 | if(!wfile.open( IO_ReadOnly )) |
127 | return false; | 146 | return false; |
128 | 147 | ||
129 | QTextStream wstream( &wfile ); | 148 | QTextStream wstream( &wfile ); |
130 | wstream.readLine(); // skip the first two lines | 149 | wstream.readLine(); // skip the first two lines |
131 | wstream.readLine(); // because they only contain headers | 150 | wstream.readLine(); // because they only contain headers |
132 | while(!wstream.atEnd()){ | 151 | while(!wstream.atEnd()){ |
133 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
134 | if(name == interface){ | 153 | if(name == QString("%1:").arg(interface)){ |
135 | if ( quality > 92 ) | 154 | if ( quality > 92 ) |
136 | #ifdef MDEBUG | ||
137 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
138 | #endif | ||
139 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
140 | #ifdef MDEBUG | ||
141 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
142 | #endif | ||
143 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
144 | #ifdef MDEBUG | ||
145 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
146 | #endif | 160 | qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | ||
162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | ||
163 | quality = ( quality*100 ) / 92; | ||
147 | return true; | 164 | return true; |
148 | } | 165 | } |
149 | } | 166 | } |
150 | 167 | ||
151 | qDebug("Card no longer present"); | 168 | qDebug("WExtensions::statsCard no longer present."); |
152 | quality = -1; | 169 | quality = -1; |
153 | signal = IW_LOWER; | 170 | signal = IW_LOWER; |
154 | noise = IW_LOWER; | 171 | noise = IW_LOWER; |
155 | return false; | 172 | return false; |
156 | } | 173 | } |
157 | 174 | ||
158 | // wextensions.cpp | 175 | // wextensions.cpp |
diff --git a/noncore/settings/networksettings/wlan/wextensions.h b/noncore/settings/networksettings/wlan/wextensions.h index 29997f5..1565eb5 100644 --- a/noncore/settings/networksettings/wlan/wextensions.h +++ b/noncore/settings/networksettings/wlan/wextensions.h | |||
@@ -1,32 +1,33 @@ | |||
1 | #ifndef WEXTENSIONS_H | 1 | #ifndef WEXTENSIONS_H |
2 | #define WEXTENSIONS_H | 2 | #define WEXTENSIONS_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | 5 | ||
6 | #include <netinet/ip.h> | 6 | #include <netinet/ip.h> |
7 | #include <linux/wireless.h> | 7 | #include <linux/wireless.h> |
8 | 8 | ||
9 | class WExtensions { | 9 | class WExtensions { |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WExtensions(QString interfaceName); | 12 | WExtensions(QString interfaceName); |
13 | QString getInterfaceName(){return interface;}; | 13 | QString getInterfaceName(){return interface;}; |
14 | bool doesHaveWirelessExtensions(){return hasWirelessExtensions;}; | 14 | bool doesHaveWirelessExtensions(){return hasWirelessExtensions;}; |
15 | QString station(); | 15 | QString station(); |
16 | QString essid(); | 16 | QString essid(); |
17 | QString mode(); | 17 | QString mode(); |
18 | double frequency(); | 18 | double frequency(); |
19 | double rate(); | ||
19 | QString ap(); | 20 | QString ap(); |
20 | bool stats( int &signal, int &noise, int &quality); | 21 | bool stats( int &signal, int &noise, int &quality); |
21 | 22 | ||
22 | private: | 23 | private: |
23 | bool hasWirelessExtensions; | 24 | bool hasWirelessExtensions; |
24 | QString interface; | 25 | QString interface; |
25 | 26 | ||
26 | // Used in we calls | 27 | // Used in we calls |
27 | struct iwreq iwr; | 28 | struct iwreq iwr; |
28 | int fd; | 29 | int fd; |
29 | 30 | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif | 33 | #endif |
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index ab0b9a5..73e753c 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -38,91 +38,92 @@ QString WLANModule::getPixmapName(Interface* ){ | |||
38 | } | 38 | } |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Check to see if the interface i is owned by this module. | 41 | * Check to see if the interface i is owned by this module. |
42 | * @param Interface* interface to check against | 42 | * @param Interface* interface to check against |
43 | * @return bool true if i is owned by this module, false otherwise. | 43 | * @return bool true if i is owned by this module, false otherwise. |
44 | */ | 44 | */ |
45 | bool WLANModule::isOwner(Interface *i){ | 45 | bool WLANModule::isOwner(Interface *i){ |
46 | WExtensions we(i->getInterfaceName()); | 46 | WExtensions we(i->getInterfaceName()); |
47 | if(!we.doesHaveWirelessExtensions()) | 47 | if(!we.doesHaveWirelessExtensions()) |
48 | return false; | 48 | return false; |
49 | 49 | ||
50 | //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 50 | //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ |
51 | i->setHardwareName("802.11b"); | 51 | i->setHardwareName("802.11b"); |
52 | list.append(i); | 52 | list.append(i); |
53 | return true; | 53 | return true; |
54 | //} | 54 | //} |
55 | //return false; | 55 | //return false; |
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Create, set tabWiget and return the WLANConfigure Module | 59 | * Create, set tabWiget and return the WLANConfigure Module |
60 | * @param tabWidget a pointer to the tab widget that this configure has. | 60 | * @param tabWidget a pointer to the tab widget that this configure has. |
61 | * @return QWidget* pointer to the tab widget in this modules configure. | 61 | * @return QWidget* pointer to the tab widget in this modules configure. |
62 | */ | 62 | */ |
63 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ | 63 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ |
64 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); | 64 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); |
65 | (*tabWidget) = wlanconfig->tabWidget; | 65 | (*tabWidget) = wlanconfig->tabWidget; |
66 | return wlanconfig; | 66 | return wlanconfig; |
67 | } | 67 | } |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Create, set tabWiget and return the Information Module | 70 | * Create, set tabWiget and return the Information Module |
71 | * @param tabWidget a pointer to the tab widget that this information has. | 71 | * @param tabWidget a pointer to the tab widget that this information has. |
72 | * @return QWidget* pointer to the tab widget in this modules info. | 72 | * @return QWidget* pointer to the tab widget in this modules info. |
73 | */ | 73 | */ |
74 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 74 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
75 | WExtensions we(i->getInterfaceName()); | 75 | WExtensions we(i->getInterfaceName()); |
76 | if(!we.doesHaveWirelessExtensions()) | 76 | if(!we.doesHaveWirelessExtensions()) |
77 | return NULL; | 77 | return NULL; |
78 | 78 | ||
79 | WlanInfo *info = new WlanInfo(0, "wireless info"); | 79 | WlanInfo *info = new WlanInfo(0, "wireless info"); |
80 | (*tabWidget) = info->tabWidget; | 80 | (*tabWidget) = info->tabWidget; |
81 | 81 | ||
82 | info->essidLabel->setText(we.essid()); | 82 | info->essidLabel->setText(we.essid()); |
83 | info->apLabel->setText(we.ap()); | 83 | info->apLabel->setText(we.ap()); |
84 | info->stationLabel->setText(we.station()); | 84 | info->stationLabel->setText(we.station()); |
85 | info->modeLabel->setText(we.mode()); | 85 | info->modeLabel->setText(we.mode()); |
86 | info->freqLabel->setText(QString("%1").arg(we.frequency())); | 86 | info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); |
87 | int signal = 0; | 87 | int signal = 0; |
88 | int noise = 0; | 88 | int noise = 0; |
89 | int quality = 0; | 89 | int quality = 0; |
90 | we.stats(signal, noise, quality); | 90 | we.stats(signal, noise, quality); |
91 | info->signalProgressBar->setProgress(signal); | 91 | info->signalProgressBar->setProgress(signal); |
92 | info->noiseProgressBar->setProgress(noise); | 92 | info->noiseProgressBar->setProgress(noise); |
93 | info->qualityProgressBar->setProgress(quality); | 93 | info->qualityProgressBar->setProgress(quality); |
94 | info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); | ||
94 | return info; | 95 | return info; |
95 | } | 96 | } |
96 | 97 | ||
97 | /** | 98 | /** |
98 | * Get all active (up or down) interfaces | 99 | * Get all active (up or down) interfaces |
99 | * @return QList<Interface> A list of interfaces that exsist that havn't | 100 | * @return QList<Interface> A list of interfaces that exsist that havn't |
100 | * been called by isOwner() | 101 | * been called by isOwner() |
101 | */ | 102 | */ |
102 | QList<Interface> WLANModule::getInterfaces(){ | 103 | QList<Interface> WLANModule::getInterfaces(){ |
103 | return list; | 104 | return list; |
104 | } | 105 | } |
105 | 106 | ||
106 | /** | 107 | /** |
107 | * Attempt to add a new interface as defined by name | 108 | * Attempt to add a new interface as defined by name |
108 | * @param name the name of the type of interface that should be created given | 109 | * @param name the name of the type of interface that should be created given |
109 | * by possibleNewInterfaces(); | 110 | * by possibleNewInterfaces(); |
110 | * @return Interface* NULL if it was unable to be created. | 111 | * @return Interface* NULL if it was unable to be created. |
111 | */ | 112 | */ |
112 | Interface *WLANModule::addNewInterface(QString ){ | 113 | Interface *WLANModule::addNewInterface(QString ){ |
113 | // We can't add a 802.11 interface, either the hardware will be there | 114 | // We can't add a 802.11 interface, either the hardware will be there |
114 | // or it wont. | 115 | // or it wont. |
115 | return NULL; | 116 | return NULL; |
116 | } | 117 | } |
117 | 118 | ||
118 | /** | 119 | /** |
119 | * Attempts to remove the interface, doesn't delete i | 120 | * Attempts to remove the interface, doesn't delete i |
120 | * @return bool true if successfull, false otherwise. | 121 | * @return bool true if successfull, false otherwise. |
121 | */ | 122 | */ |
122 | bool WLANModule::remove(Interface*){ | 123 | bool WLANModule::remove(Interface*){ |
123 | // Can't remove a hardware device, you can stop it though. | 124 | // Can't remove a hardware device, you can stop it though. |
124 | return false; | 125 | return false; |
125 | } | 126 | } |
126 | 127 | ||
127 | // wlanmodule.cpp | 128 | // wlanmodule.cpp |
128 | 129 | ||