author | benmeyer <benmeyer> | 2002-12-11 20:16:34 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-12-11 20:16:34 (UTC) |
commit | 3b2ec1e3ba172771365ff7822f623c3c6cb4d378 (patch) (side-by-side diff) | |
tree | d65ee26af6ee85b804ca3de5e738ba4fdb37d17c | |
parent | 3faddab31483bda0dd9d093cd473ffb801207b9c (diff) | |
download | opie-3b2ec1e3ba172771365ff7822f623c3c6cb4d378.zip opie-3b2ec1e3ba172771365ff7822f623c3c6cb4d378.tar.gz opie-3b2ec1e3ba172771365ff7822f623c3c6cb4d378.tar.bz2 |
Now will display the channel and not the freqency
-rw-r--r-- | noncore/net/networksetup/wlan/info.ui | 6 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/infoimp.cpp | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 23 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.h | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/info.ui | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/infoimp.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 23 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.h | 1 |
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 @@ -1,96 +1,96 @@ <!DOCTYPE UI><UI> <class>WlanInfo</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>WlanInfo</cstring> </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> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tabWidget</cstring> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Widget2</cstring> </property> <attribute> <name>title</name> <string>802.11b</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="3" column="0" > <class>QLabel</class> <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> <cstring>TextLabel3</cstring> </property> <property stdset="1"> <name>text</name> <string>Mode</string> </property> </widget> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2</cstring> </property> <property stdset="1"> <name>text</name> <string>ESSID</string> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> @@ -143,65 +143,65 @@ <property stdset="1"> <name>name</name> <cstring>essidLabel</cstring> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> </widget> <widget row="0" column="1" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>stationLabel</cstring> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </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"> <name>frameShadow</name> <enum>Sunken</enum> </property> </widget> <spacer row="9" column="1" > <property> <name>name</name> <cstring>Spacer7</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget row="5" column="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 @@ -8,49 +8,49 @@ /** * Constructor. If wireless extensions are enabled on device name then * start a timer that every second will update the information. */ WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){ WExtensions *wExtensions = new WExtensions(name); if(!wExtensions->doesHaveWirelessExtensions()){ delete wExtensions; qDebug("WlanInfoImp::No wireless extension"); return; } delete wExtensions; timer = new QTimer( this ); connect( timer, SIGNAL(timeout()), this, SLOT(update())); timer->start( 1000, false ); } /** * Updates the information about the wireless device. */ void WlanInfoImp::update(){ WExtensions *wExtensions = new WExtensions(this->name()); if(!wExtensions->doesHaveWirelessExtensions()){ qDebug("No extension"); delete wExtensions; timer->stop(); 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); if(noiseProgressBar->progress() != noise) noiseProgressBar->setProgress(noise); if(qualityProgressBar->progress() != quality) qualityProgressBar->setProgress(quality); rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate())); delete wExtensions; } // infoimp.cpp 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 @@ -62,66 +62,89 @@ QString WExtensions::essid(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; return QString(iwr.u.essid.pointer); } return QString(); } /** * @return QString the mode of interface */ QString WExtensions::mode(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); return QString(); } /** * Get the frequency that the interface is running at. * @return int the frequency that the interfacae is running at. */ double WExtensions::frequency(){ if(!hasWirelessExtensions) 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; } return 0; } /** * @return QString the AccessPoint that the interface is connected to. */ QString WExtensions::ap(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ QString ap; ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", iwr.u.ap_addr.sa_data[0]&0xff, iwr.u.ap_addr.sa_data[1]&0xff, iwr.u.ap_addr.sa_data[2]&0xff, iwr.u.ap_addr.sa_data[3]&0xff, iwr.u.ap_addr.sa_data[4]&0xff, iwr.u.ap_addr.sa_data[5]&0xff ); return ap; } else return QString(); } /** 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 @@ -1,33 +1,34 @@ #ifndef WEXTENSIONS_H #define WEXTENSIONS_H #include <qstring.h> #include <netinet/ip.h> #include <linux/wireless.h> class WExtensions { public: WExtensions(QString interfaceName); 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; QString interface; // Used in we calls struct iwreq iwr; int fd; }; #endif 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 @@ -1,96 +1,96 @@ <!DOCTYPE UI><UI> <class>WlanInfo</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>WlanInfo</cstring> </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> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tabWidget</cstring> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Widget2</cstring> </property> <attribute> <name>title</name> <string>802.11b</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="3" column="0" > <class>QLabel</class> <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> <cstring>TextLabel3</cstring> </property> <property stdset="1"> <name>text</name> <string>Mode</string> </property> </widget> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2</cstring> </property> <property stdset="1"> <name>text</name> <string>ESSID</string> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> @@ -143,65 +143,65 @@ <property stdset="1"> <name>name</name> <cstring>essidLabel</cstring> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> </widget> <widget row="0" column="1" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>stationLabel</cstring> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </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"> <name>frameShadow</name> <enum>Sunken</enum> </property> </widget> <spacer row="9" column="1" > <property> <name>name</name> <cstring>Spacer7</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget row="5" column="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 @@ -8,49 +8,49 @@ /** * Constructor. If wireless extensions are enabled on device name then * start a timer that every second will update the information. */ WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){ WExtensions *wExtensions = new WExtensions(name); if(!wExtensions->doesHaveWirelessExtensions()){ delete wExtensions; qDebug("WlanInfoImp::No wireless extension"); return; } delete wExtensions; timer = new QTimer( this ); connect( timer, SIGNAL(timeout()), this, SLOT(update())); timer->start( 1000, false ); } /** * Updates the information about the wireless device. */ void WlanInfoImp::update(){ WExtensions *wExtensions = new WExtensions(this->name()); if(!wExtensions->doesHaveWirelessExtensions()){ qDebug("No extension"); delete wExtensions; timer->stop(); 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); if(noiseProgressBar->progress() != noise) noiseProgressBar->setProgress(noise); if(qualityProgressBar->progress() != quality) qualityProgressBar->setProgress(quality); rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate())); delete wExtensions; } // infoimp.cpp 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 @@ -62,66 +62,89 @@ QString WExtensions::essid(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; return QString(iwr.u.essid.pointer); } return QString(); } /** * @return QString the mode of interface */ QString WExtensions::mode(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); return QString(); } /** * Get the frequency that the interface is running at. * @return int the frequency that the interfacae is running at. */ double WExtensions::frequency(){ if(!hasWirelessExtensions) 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; } return 0; } /** * @return QString the AccessPoint that the interface is connected to. */ QString WExtensions::ap(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ QString ap; ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", iwr.u.ap_addr.sa_data[0]&0xff, iwr.u.ap_addr.sa_data[1]&0xff, iwr.u.ap_addr.sa_data[2]&0xff, iwr.u.ap_addr.sa_data[3]&0xff, iwr.u.ap_addr.sa_data[4]&0xff, iwr.u.ap_addr.sa_data[5]&0xff ); return ap; } else return QString(); } /** 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 @@ -1,33 +1,34 @@ #ifndef WEXTENSIONS_H #define WEXTENSIONS_H #include <qstring.h> #include <netinet/ip.h> #include <linux/wireless.h> class WExtensions { public: WExtensions(QString interfaceName); 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; QString interface; // Used in we calls struct iwreq iwr; int fd; }; #endif |