summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/wlan/info.ui6
-rw-r--r--noncore/net/networksetup/wlan/infoimp.cpp2
-rw-r--r--noncore/net/networksetup/wlan/wextensions.cpp23
-rw-r--r--noncore/net/networksetup/wlan/wextensions.h1
-rw-r--r--noncore/settings/networksettings/wlan/info.ui6
-rw-r--r--noncore/settings/networksettings/wlan/infoimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp23
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.h1
8 files changed, 56 insertions, 8 deletions
diff --git a/noncore/net/networksetup/wlan/info.ui b/noncore/net/networksetup/wlan/info.ui
index 1e3e8b5..7a5bf0b 100644
--- a/noncore/net/networksetup/wlan/info.ui
+++ b/noncore/net/networksetup/wlan/info.ui
@@ -8,13 +8,13 @@
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>242</width>
+ <width>238</width>
<height>316</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Interface Information</string>
@@ -58,13 +58,13 @@
<property stdset="1">
<name>name</name>
<cstring>TextLabel4</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Frequency</string>
+ <string>Channel</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
@@ -169,13 +169,13 @@
</property>
</widget>
<widget row="3" column="1" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
- <cstring>freqLabel</cstring>
+ <cstring>channelLabel</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
diff --git a/noncore/net/networksetup/wlan/infoimp.cpp b/noncore/net/networksetup/wlan/infoimp.cpp
index 6d3e167..bd56678 100644
--- a/noncore/net/networksetup/wlan/infoimp.cpp
+++ b/noncore/net/networksetup/wlan/infoimp.cpp
@@ -34,13 +34,13 @@ void WlanInfoImp::update(){
return;
}
essidLabel->setText(wExtensions->essid());
apLabel->setText(wExtensions->ap());
stationLabel->setText(wExtensions->station());
modeLabel->setText(wExtensions->mode());
- freqLabel->setText(QString("%1 GHz").arg(wExtensions->frequency()));
+ channelLabel->setText(QString("%1").arg(wExtensions->channel()));
int signal = 0;
int noise = 0;
int quality = 0;
wExtensions->stats(signal, noise, quality);
if(signalProgressBar->progress() != signal)
signalProgressBar->setProgress(signal);
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp
index 6335ebc..16654bb 100644
--- a/noncore/net/networksetup/wlan/wextensions.cpp
+++ b/noncore/net/networksetup/wlan/wextensions.cpp
@@ -88,14 +88,37 @@ double WExtensions::frequency(){
return 0;
if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr ))
return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
return 0;
}
+/**
+ * Get the channel that the interface is running at.
+ * @return int the channel that the interfacae is running at.
+ */
+int WExtensions::channel(){
+ if(!hasWirelessExtensions)
+ return 0;
+ if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr ))
+ return 0;
+ double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
+ double left = 2.401;
+ double right = 2.416;
+ for(int channel = 1; channel<= 15; channel++){
+ if( num >= left && num <= right )
+ return channel;
+ left += 0.005;
+ right += 0.005;
+ }
+ qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1());
+ return -1;
+}
+
/***
* Get the current rate that the card is transmiting at.
+ * @return double the rate, 0 if error.
*/
double WExtensions::rate(){
if(!hasWirelessExtensions)
return 0;
if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){
return ((double)iwr.u.bitrate.value)/1000000;
diff --git a/noncore/net/networksetup/wlan/wextensions.h b/noncore/net/networksetup/wlan/wextensions.h
index 1565eb5..a89e33a 100644
--- a/noncore/net/networksetup/wlan/wextensions.h
+++ b/noncore/net/networksetup/wlan/wextensions.h
@@ -13,12 +13,13 @@ public:
QString getInterfaceName(){return interface;};
bool doesHaveWirelessExtensions(){return hasWirelessExtensions;};
QString station();
QString essid();
QString mode();
double frequency();
+ int channel();
double rate();
QString ap();
bool stats( int &signal, int &noise, int &quality);
private:
bool hasWirelessExtensions;
diff --git a/noncore/settings/networksettings/wlan/info.ui b/noncore/settings/networksettings/wlan/info.ui
index 1e3e8b5..7a5bf0b 100644
--- a/noncore/settings/networksettings/wlan/info.ui
+++ b/noncore/settings/networksettings/wlan/info.ui
@@ -8,13 +8,13 @@
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>242</width>
+ <width>238</width>
<height>316</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Interface Information</string>
@@ -58,13 +58,13 @@
<property stdset="1">
<name>name</name>
<cstring>TextLabel4</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Frequency</string>
+ <string>Channel</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
@@ -169,13 +169,13 @@
</property>
</widget>
<widget row="3" column="1" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
- <cstring>freqLabel</cstring>
+ <cstring>channelLabel</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
diff --git a/noncore/settings/networksettings/wlan/infoimp.cpp b/noncore/settings/networksettings/wlan/infoimp.cpp
index 6d3e167..bd56678 100644
--- a/noncore/settings/networksettings/wlan/infoimp.cpp
+++ b/noncore/settings/networksettings/wlan/infoimp.cpp
@@ -34,13 +34,13 @@ void WlanInfoImp::update(){
return;
}
essidLabel->setText(wExtensions->essid());
apLabel->setText(wExtensions->ap());
stationLabel->setText(wExtensions->station());
modeLabel->setText(wExtensions->mode());
- freqLabel->setText(QString("%1 GHz").arg(wExtensions->frequency()));
+ channelLabel->setText(QString("%1").arg(wExtensions->channel()));
int signal = 0;
int noise = 0;
int quality = 0;
wExtensions->stats(signal, noise, quality);
if(signalProgressBar->progress() != signal)
signalProgressBar->setProgress(signal);
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp
index 6335ebc..16654bb 100644
--- a/noncore/settings/networksettings/wlan/wextensions.cpp
+++ b/noncore/settings/networksettings/wlan/wextensions.cpp
@@ -88,14 +88,37 @@ double WExtensions::frequency(){
return 0;
if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr ))
return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
return 0;
}
+/**
+ * Get the channel that the interface is running at.
+ * @return int the channel that the interfacae is running at.
+ */
+int WExtensions::channel(){
+ if(!hasWirelessExtensions)
+ return 0;
+ if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr ))
+ return 0;
+ double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
+ double left = 2.401;
+ double right = 2.416;
+ for(int channel = 1; channel<= 15; channel++){
+ if( num >= left && num <= right )
+ return channel;
+ left += 0.005;
+ right += 0.005;
+ }
+ qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1());
+ return -1;
+}
+
/***
* Get the current rate that the card is transmiting at.
+ * @return double the rate, 0 if error.
*/
double WExtensions::rate(){
if(!hasWirelessExtensions)
return 0;
if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){
return ((double)iwr.u.bitrate.value)/1000000;
diff --git a/noncore/settings/networksettings/wlan/wextensions.h b/noncore/settings/networksettings/wlan/wextensions.h
index 1565eb5..a89e33a 100644
--- a/noncore/settings/networksettings/wlan/wextensions.h
+++ b/noncore/settings/networksettings/wlan/wextensions.h
@@ -13,12 +13,13 @@ public:
QString getInterfaceName(){return interface;};
bool doesHaveWirelessExtensions(){return hasWirelessExtensions;};
QString station();
QString essid();
QString mode();
double frequency();
+ int channel();
double rate();
QString ap();
bool stats( int &signal, int &noise, int &quality);
private:
bool hasWirelessExtensions;