-rw-r--r-- | noncore/net/networksetup/wlan/info.ui | 35 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 41 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.h | 1 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/info.ui | 35 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 41 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.h | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 3 |
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 @@ -204,49 +204,49 @@ </size> </property> </spacer> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Statistics</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <spacer row="3" column="1" > + <spacer row="4" column="1" > <property> <name>name</name> <cstring>Spacer2</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="0" column="1" > <class>QProgressBar</class> <property stdset="1"> <name>name</name> @@ -279,48 +279,81 @@ </property> </widget> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Noise</string> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Quality</string> </property> </widget> + <widget row="3" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Rate</string> + </property> + </widget> + <widget row="3" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>rateLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>Panel</enum> + </property> + <property stdset="1"> + <name>frameShadow</name> + <enum>Sunken</enum> + </property> + </widget> </grid> </widget> </widget> </vbox> </widget> <customwidgets> <customwidget> <class>QWidget</class> <header location="local">qwidget.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>7</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> 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 @@ -1,38 +1,38 @@ #include "wextensions.h" #include <qfile.h> #include <qtextstream.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <math.h> #define PROCNETWIRELESS "/proc/net/wireless" -#define IW_LOWER 140 -#define IW_UPPER 200 +#define IW_LOWER 0 +#define IW_UPPER 256 /** * Constructor. Sets hasWirelessExtensions */ WExtensions::WExtensions(QString interfaceName){ interface = interfaceName; fd = socket( AF_INET, SOCK_DGRAM, 0 ); const char* buffer[200]; memset( &iwr, 0, sizeof( iwr ) ); iwr.u.essid.pointer = (caddr_t) buffer; iwr.u.essid.length = IW_ESSID_MAX_SIZE; iwr.u.essid.flags = 0; // check if it is an IEEE 802.11 standard conform // wireless device by sending SIOCGIWESSID // which also gives back the Extended Service Set ID // (see IEEE 802.11 for more information) const char* iname = interface.latin1(); strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) hasWirelessExtensions = true; else @@ -68,91 +68,108 @@ QString WExtensions::essid(){ } 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;; + return 0; } +/*** + * Get the current rate that the card is transmiting at. + */ +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(); - } +/** + * Get the stats for interfaces + * @param signal the signal strength of interface + * @param noise the noise level of the interface + * @param quality the quality level of the interface + * @return bool true if successfull + */ bool WExtensions::stats(int &signal, int &noise, int &quality){ // gather link quality from /proc/net/wireless if(!QFile::exists(PROCNETWIRELESS)) return false; char c; QString status; QString name; QFile wfile( PROCNETWIRELESS ); if(!wfile.open( IO_ReadOnly )) return false; QTextStream wstream( &wfile ); wstream.readLine(); // skip the first two lines wstream.readLine(); // because they only contain headers while(!wstream.atEnd()){ wstream >> name >> status >> quality >> c >> signal >> c >> noise; - if(name == interface){ + if(name == QString("%1:").arg(interface)){ if ( quality > 92 ) - #ifdef MDEBUG qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); - #endif if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) - #ifdef MDEBUG qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); - #endif if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) - #ifdef MDEBUG qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); - #endif + qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); + signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; + noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; + quality = ( quality*100 ) / 92; return true; } } - qDebug("Card no longer present"); + qDebug("WExtensions::statsCard no longer present."); quality = -1; signal = IW_LOWER; noise = IW_LOWER; return false; } // wextensions.cpp 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 @@ -1,32 +1,33 @@ #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(); + 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/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 @@ -62,56 +62,57 @@ bool WLANModule::isOwner(Interface *i){ */ QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); (*tabWidget) = wlanconfig->tabWidget; return wlanconfig; } /** * Create, set tabWiget and return the Information Module * @param tabWidget a pointer to the tab widget that this information has. * @return QWidget* pointer to the tab widget in this modules info. */ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return NULL; WlanInfo *info = new WlanInfo(0, "wireless info"); (*tabWidget) = info->tabWidget; info->essidLabel->setText(we.essid()); info->apLabel->setText(we.ap()); info->stationLabel->setText(we.station()); info->modeLabel->setText(we.mode()); - info->freqLabel->setText(QString("%1").arg(we.frequency())); + info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); int signal = 0; int noise = 0; int quality = 0; we.stats(signal, noise, quality); info->signalProgressBar->setProgress(signal); info->noiseProgressBar->setProgress(noise); info->qualityProgressBar->setProgress(quality); + info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); return info; } /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ QList<Interface> WLANModule::getInterfaces(){ return list; } /** * Attempt to add a new interface as defined by name * @param name the name of the type of interface that should be created given * by possibleNewInterfaces(); * @return Interface* NULL if it was unable to be created. */ Interface *WLANModule::addNewInterface(QString ){ // We can't add a 802.11 interface, either the hardware will be there // or it wont. return NULL; } 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 @@ -204,49 +204,49 @@ </size> </property> </spacer> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Statistics</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <spacer row="3" column="1" > + <spacer row="4" column="1" > <property> <name>name</name> <cstring>Spacer2</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="0" column="1" > <class>QProgressBar</class> <property stdset="1"> <name>name</name> @@ -279,48 +279,81 @@ </property> </widget> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Noise</string> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Quality</string> </property> </widget> + <widget row="3" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Rate</string> + </property> + </widget> + <widget row="3" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>rateLabel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>Panel</enum> + </property> + <property stdset="1"> + <name>frameShadow</name> + <enum>Sunken</enum> + </property> + </widget> </grid> </widget> </widget> </vbox> </widget> <customwidgets> <customwidget> <class>QWidget</class> <header location="local">qwidget.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>7</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> 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 @@ -1,38 +1,38 @@ #include "wextensions.h" #include <qfile.h> #include <qtextstream.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <math.h> #define PROCNETWIRELESS "/proc/net/wireless" -#define IW_LOWER 140 -#define IW_UPPER 200 +#define IW_LOWER 0 +#define IW_UPPER 256 /** * Constructor. Sets hasWirelessExtensions */ WExtensions::WExtensions(QString interfaceName){ interface = interfaceName; fd = socket( AF_INET, SOCK_DGRAM, 0 ); const char* buffer[200]; memset( &iwr, 0, sizeof( iwr ) ); iwr.u.essid.pointer = (caddr_t) buffer; iwr.u.essid.length = IW_ESSID_MAX_SIZE; iwr.u.essid.flags = 0; // check if it is an IEEE 802.11 standard conform // wireless device by sending SIOCGIWESSID // which also gives back the Extended Service Set ID // (see IEEE 802.11 for more information) const char* iname = interface.latin1(); strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) hasWirelessExtensions = true; else @@ -68,91 +68,108 @@ QString WExtensions::essid(){ } 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;; + return 0; } +/*** + * Get the current rate that the card is transmiting at. + */ +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(); - } +/** + * Get the stats for interfaces + * @param signal the signal strength of interface + * @param noise the noise level of the interface + * @param quality the quality level of the interface + * @return bool true if successfull + */ bool WExtensions::stats(int &signal, int &noise, int &quality){ // gather link quality from /proc/net/wireless if(!QFile::exists(PROCNETWIRELESS)) return false; char c; QString status; QString name; QFile wfile( PROCNETWIRELESS ); if(!wfile.open( IO_ReadOnly )) return false; QTextStream wstream( &wfile ); wstream.readLine(); // skip the first two lines wstream.readLine(); // because they only contain headers while(!wstream.atEnd()){ wstream >> name >> status >> quality >> c >> signal >> c >> noise; - if(name == interface){ + if(name == QString("%1:").arg(interface)){ if ( quality > 92 ) - #ifdef MDEBUG qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); - #endif if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) - #ifdef MDEBUG qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); - #endif if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) - #ifdef MDEBUG qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); - #endif + qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); + signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; + noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; + quality = ( quality*100 ) / 92; return true; } } - qDebug("Card no longer present"); + qDebug("WExtensions::statsCard no longer present."); quality = -1; signal = IW_LOWER; noise = IW_LOWER; return false; } // wextensions.cpp 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 @@ -1,32 +1,33 @@ #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(); + 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/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 @@ -62,56 +62,57 @@ bool WLANModule::isOwner(Interface *i){ */ QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); (*tabWidget) = wlanconfig->tabWidget; return wlanconfig; } /** * Create, set tabWiget and return the Information Module * @param tabWidget a pointer to the tab widget that this information has. * @return QWidget* pointer to the tab widget in this modules info. */ QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return NULL; WlanInfo *info = new WlanInfo(0, "wireless info"); (*tabWidget) = info->tabWidget; info->essidLabel->setText(we.essid()); info->apLabel->setText(we.ap()); info->stationLabel->setText(we.station()); info->modeLabel->setText(we.mode()); - info->freqLabel->setText(QString("%1").arg(we.frequency())); + info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); int signal = 0; int noise = 0; int quality = 0; we.stats(signal, noise, quality); info->signalProgressBar->setProgress(signal); info->noiseProgressBar->setProgress(noise); info->qualityProgressBar->setProgress(quality); + info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); return info; } /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ QList<Interface> WLANModule::getInterfaces(){ return list; } /** * Attempt to add a new interface as defined by name * @param name the name of the type of interface that should be created given * by possibleNewInterfaces(); * @return Interface* NULL if it was unable to be created. */ Interface *WLANModule::addNewInterface(QString ){ // We can't add a 802.11 interface, either the hardware will be there // or it wont. return NULL; } |