summaryrefslogtreecommitdiff
Unidiff
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
@@ -225,7 +225,7 @@
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>
@@ -300,6 +300,39 @@
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>
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
@@ -10,8 +10,8 @@
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
@@ -89,9 +89,22 @@ double WExtensions::frequency(){
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 */
@@ -110,9 +123,15 @@ QString WExtensions::ap(){
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))
@@ -131,24 +150,22 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){
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;
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
@@ -16,6 +16,7 @@ public:
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
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
@@ -83,7 +83,7 @@ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
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;
@@ -91,6 +91,7 @@ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
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
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
@@ -225,7 +225,7 @@
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>
@@ -300,6 +300,39 @@
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>
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
@@ -10,8 +10,8 @@
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
@@ -89,9 +89,22 @@ double WExtensions::frequency(){
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 */
@@ -110,9 +123,15 @@ QString WExtensions::ap(){
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))
@@ -131,24 +150,22 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){
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;
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
@@ -16,6 +16,7 @@ public:
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
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
@@ -83,7 +83,7 @@ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
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;
@@ -91,6 +91,7 @@ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
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