summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-22 20:41:01 (UTC)
committer benmeyer <benmeyer>2002-10-22 20:41:01 (UTC)
commit1e1b3e398d6b978a9c2bbd85d8f6b7aafbf72b2f (patch) (unidiff)
treec1e6feec60794552bdca607f4dbe180e1988a924
parent44a60b35b903b68f2f60f5ba29b84db1563dd9f3 (diff)
downloadopie-1e1b3e398d6b978a9c2bbd85d8f6b7aafbf72b2f.zip
opie-1e1b3e398d6b978a9c2bbd85d8f6b7aafbf72b2f.tar.gz
opie-1e1b3e398d6b978a9c2bbd85d8f6b7aafbf72b2f.tar.bz2
info now works
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/wlan/info.ui35
-rw-r--r--noncore/net/networksetup/wlan/wextensions.cpp41
-rw-r--r--noncore/net/networksetup/wlan/wextensions.h1
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp3
-rw-r--r--noncore/settings/networksettings/wlan/info.ui35
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp41
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.h1
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp3
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
@@ -216,25 +216,25 @@
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>
@@ -291,24 +291,57 @@
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>
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,26 +1,26 @@
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 */
19WExtensions::WExtensions(QString interfaceName){ 19WExtensions::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;
@@ -80,79 +80,96 @@ QString WExtensions::mode(){
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 */
87double WExtensions::frequency(){ 87double 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 */
98double 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 */
98QString WExtensions::ap(){ 111QString 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 */
116bool WExtensions::stats(int &signal, int &noise, int &quality){ 135bool 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
@@ -7,24 +7,25 @@
7#include <linux/wireless.h> 7#include <linux/wireless.h>
8 8
9class WExtensions { 9class WExtensions {
10 10
11public: 11public:
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
22private: 23private:
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};
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
@@ -74,32 +74,33 @@ QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){
74QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 74QWidget *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 */
102QList<Interface> WLANModule::getInterfaces(){ 103QList<Interface> WLANModule::getInterfaces(){
103 return list; 104 return list;
104} 105}
105 106
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
@@ -216,25 +216,25 @@
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>
@@ -291,24 +291,57 @@
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>
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,26 +1,26 @@
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 */
19WExtensions::WExtensions(QString interfaceName){ 19WExtensions::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;
@@ -80,79 +80,96 @@ QString WExtensions::mode(){
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 */
87double WExtensions::frequency(){ 87double 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 */
98double 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 */
98QString WExtensions::ap(){ 111QString 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 */
116bool WExtensions::stats(int &signal, int &noise, int &quality){ 135bool 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
@@ -7,24 +7,25 @@
7#include <linux/wireless.h> 7#include <linux/wireless.h>
8 8
9class WExtensions { 9class WExtensions {
10 10
11public: 11public:
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
22private: 23private:
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};
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
@@ -74,32 +74,33 @@ QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){
74QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ 74QWidget *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 */
102QList<Interface> WLANModule::getInterfaces(){ 103QList<Interface> WLANModule::getInterfaces(){
103 return list; 104 return list;
104} 105}
105 106