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
@@ -222,13 +222,13 @@
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>
@@ -297,12 +297,45 @@
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>
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
@@ -7,14 +7,14 @@
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;
@@ -86,15 +86,28 @@ QString WExtensions::mode(){
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();
@@ -107,15 +120,21 @@ QString WExtensions::ap(){
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;
@@ -128,30 +147,28 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){
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
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
@@ -13,12 +13,13 @@ public:
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;
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
@@ -80,20 +80,21 @@ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
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
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
@@ -222,13 +222,13 @@
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>
@@ -297,12 +297,45 @@
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>
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
@@ -7,14 +7,14 @@
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;
@@ -86,15 +86,28 @@ QString WExtensions::mode(){
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();
@@ -107,15 +120,21 @@ QString WExtensions::ap(){
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;
@@ -128,30 +147,28 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){
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
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
@@ -13,12 +13,13 @@ public:
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;
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
@@ -80,20 +80,21 @@ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
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