summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/wlan/wextensions.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/wlan/wextensions.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp
index d1fff88..9c64323 100644
--- a/noncore/settings/networksettings/wlan/wextensions.cpp
+++ b/noncore/settings/networksettings/wlan/wextensions.cpp
@@ -91,49 +91,49 @@ double WExtensions::frequency(){
91 return 0; 91 return 0;
92} 92}
93 93
94/** 94/**
95 * Get the channel that the interface is running at. 95 * Get the channel that the interface is running at.
96 * @return int the channel that the interfacae is running at. 96 * @return int the channel that the interfacae is running at.
97 */ 97 */
98int WExtensions::channel(){ 98int WExtensions::channel(){
99 if(!hasWirelessExtensions) 99 if(!hasWirelessExtensions)
100 return 0; 100 return 0;
101 if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) 101 if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr ))
102 return 0; 102 return 0;
103 103
104 // http://www.elanix.com/pdf/an137e.pdf 104 // http://www.elanix.com/pdf/an137e.pdf
105 105
106 double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); 106 double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
107 double left = 2.401; 107 double left = 2.401;
108 double right = 2.416; 108 double right = 2.416;
109 for(int channel = 1; channel<= 15; channel++){ 109 for(int channel = 1; channel<= 15; channel++){
110 if( num >= left && num <= right ) 110 if( num >= left && num <= right )
111 return channel; 111 return channel;
112 left += 0.005; 112 left += 0.005;
113 right += 0.005; 113 right += 0.005;
114 } 114 }
115 qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); 115 odebug << QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1() << oendl;
116 return -1; 116 return -1;
117} 117}
118 118
119/*** 119/***
120 * Get the current rate that the card is transmiting at. 120 * Get the current rate that the card is transmiting at.
121 * @return double the rate, 0 if error. 121 * @return double the rate, 0 if error.
122 */ 122 */
123double WExtensions::rate(){ 123double WExtensions::rate(){
124 if(!hasWirelessExtensions) 124 if(!hasWirelessExtensions)
125 return 0; 125 return 0;
126 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ 126 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){
127 return ((double)iwr.u.bitrate.value)/1000000; 127 return ((double)iwr.u.bitrate.value)/1000000;
128 } 128 }
129 return 0; 129 return 0;
130} 130}
131 131
132 132
133/** 133/**
134 * @return QString the AccessPoint that the interface is connected to. 134 * @return QString the AccessPoint that the interface is connected to.
135 */ 135 */
136QString WExtensions::ap(){ 136QString WExtensions::ap(){
137 if(!hasWirelessExtensions) 137 if(!hasWirelessExtensions)
138 return QString(); 138 return QString();
139 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ 139 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){
@@ -156,45 +156,45 @@ QString WExtensions::ap(){
156 * @param noise the noise level of the interface 156 * @param noise the noise level of the interface
157 * @param quality the quality level of the interface 157 * @param quality the quality level of the interface
158 * @return bool true if successful 158 * @return bool true if successful
159 */ 159 */
160bool WExtensions::stats(int &signal, int &noise, int &quality){ 160bool WExtensions::stats(int &signal, int &noise, int &quality){
161 // gather link quality from /proc/net/wireless 161 // gather link quality from /proc/net/wireless
162 if(!QFile::exists(PROCNETWIRELESS)) 162 if(!QFile::exists(PROCNETWIRELESS))
163 return false; 163 return false;
164 164
165 char c; 165 char c;
166 QString status; 166 QString status;
167 QString name; 167 QString name;
168 168
169 QFile wfile( PROCNETWIRELESS ); 169 QFile wfile( PROCNETWIRELESS );
170 if(!wfile.open( IO_ReadOnly )) 170 if(!wfile.open( IO_ReadOnly ))
171 return false; 171 return false;
172 172
173 QTextStream wstream( &wfile ); 173 QTextStream wstream( &wfile );
174 wstream.readLine(); // skip the first two lines 174 wstream.readLine(); // skip the first two lines
175 wstream.readLine(); // because they only contain headers 175 wstream.readLine(); // because they only contain headers
176 while(!wstream.atEnd()){ 176 while(!wstream.atEnd()){
177 wstream >> name >> status >> quality >> c >> signal >> c >> noise; 177 wstream >> name >> status >> quality >> c >> signal >> c >> noise;
178 if(name == QString("%1:").arg(interface)){ 178 if(name == QString("%1:").arg(interface)){
179 if ( quality > 92 ) 179 if ( quality > 92 )
180 qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); 180 odebug << "WIFIAPPLET: D'oh! Quality " << quality << " > estimated max!\n" << oendl;
181 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) 181 if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) )
182 qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); 182 odebug << "WIFIAPPLET: Doh! Strength " << signal << " > estimated max!\n" << oendl;
183 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) 183 if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) )
184 qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); 184 odebug << "WIFIAPPLET: Doh! Noise " << noise << " > estimated max!\n" << oendl;
185 //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); 185 //odebug << QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1() << oendl;
186 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; 186 signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER;
187 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; 187 noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER;
188 quality = ( quality*100 ) / 92; 188 quality = ( quality*100 ) / 92;
189 return true; 189 return true;
190 } 190 }
191 } 191 }
192 192
193 qDebug("WExtensions::statsCard no longer present."); 193 odebug << "WExtensions::statsCard no longer present." << oendl;
194 quality = -1; 194 quality = -1;
195 signal = IW_LOWER; 195 signal = IW_LOWER;
196 noise = IW_LOWER; 196 noise = IW_LOWER;
197 return false; 197 return false;
198} 198}
199 199
200// wextensions.cpp 200// wextensions.cpp