summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/wlan/wlan.pro2
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp139
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.h4
-rw-r--r--noncore/settings/networksettings/wlan/wlan.pro2
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp139
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.h4
6 files changed, 276 insertions, 14 deletions
diff --git a/noncore/net/networksetup/wlan/wlan.pro b/noncore/net/networksetup/wlan/wlan.pro
index 5cfe468..5b94a95 100644
--- a/noncore/net/networksetup/wlan/wlan.pro
+++ b/noncore/net/networksetup/wlan/wlan.pro
@@ -4,9 +4,9 @@ CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/plugins/networksetup
HEADERS = wlanimp.h wlanmodule.h
SOURCES = wlanimp.cpp wlanmodule.cpp
INCLUDEPATH += $(OPIEDIR)/include ../
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
-INTERFACES = wlan.ui
+INTERFACES = wlan.ui info.ui
TARGET = wlanplugin
VERSION = 1.0.0
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 53b5857..8d25d99 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -1,9 +1,28 @@
#include "wlanmodule.h"
#include <qpe/config.h>
#include "wlanimp.h"
+#include "info.h"
+
+
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <linux/if_ether.h>
+#include <netinet/ip.h>
+#include <sys/ioctl.h>
+#include <linux/wireless.h>
+
+#include <unistd.h>
+#include <math.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <stdlib.h>
+
+#include <qlabel.h>
/**
* Constructor, find all of the possible interfaces
*/
WLANModule::WLANModule() : Module() {
// get output from iwconfig
@@ -40,26 +59,138 @@ bool WLANModule::isOwner(Interface *i){
/**
* Create, set tabWiget and return the WLANConfigure Module
* @param tabWidget a pointer to the tab widget that this configure has.
* @return QWidget* pointer to the tab widget in this modules configure.
*/
-QWidget *WLANModule::configure(QTabWidget **tabWidget){
- Config *cfg = new Config("wireless");
+QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){
+ Config *cfg = new Config("wireless config");
WLANImp *wlanconfig = new WLANImp(*cfg);
(*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(QTabWidget **tabWidget){
- return NULL;
+QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
+ WlanInfo *info = new WlanInfo(0, "wireless info");
+ (*tabWidget) = info->tabWidget;
+
+ struct ifreq ifr;
+ struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr;
+ int fd = socket( AF_INET, SOCK_DGRAM, 0 );
+
+ const char* buffer[200];
+ struct iwreq iwr;
+ 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)
+
+ QString n = (i->getInterfaceName());
+ const char* iname = n.latin1();
+ strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
+ int result = ioctl( fd, SIOCGIWESSID, &iwr );
+ if ( result == 0 ){
+ //hasWirelessExtensions = true;
+ iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
+ info->essidLabel->setText(QString(iwr.u.essid.pointer));
+ }
+ else
+ return info;
+ //info->essidLabel->setText("*** Unknown ***");
+
+ // Address of associated access-point
+ result = ioctl( fd, SIOCGIWAP, &iwr );
+ if ( result == 0 ){
+ QString foo = foo.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 );
+ info->apLabel->setText(foo);
+ }
+ else info->apLabel->setText("*** Unknown ***");
+
+ iwr.u.data.pointer = (caddr_t) buffer;
+ iwr.u.data.length = IW_ESSID_MAX_SIZE;
+ iwr.u.data.flags = 0;
+ result = ioctl( fd, SIOCGIWNICKN, &iwr );
+ if ( result == 0 ){
+ iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0';
+ info->stationLabel->setText(iwr.u.data.pointer);
+ }
+ else info->stationLabel->setText("*** Unknown ***");
+
+ result = ioctl( fd, SIOCGIWMODE, &iwr );
+ if ( result == 0 )
+ info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"));
+ else
+ info->modeLabel->setText("*** Unknown ***");
+
+ result = ioctl( fd, SIOCGIWFREQ, &iwr );
+ if ( result == 0 )
+ info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000)));
+ else
+ info->freqLabel->setText("0");
+
+ /*
+ // gather link quality from /proc/net/wireless
+
+ char c;
+ QString status;
+ QString name;
+ QFile wfile( PROCNETWIRELESS );
+ bool hasFile = wfile.open( IO_ReadOnly );
+ QTextStream wstream( &wfile );
+ if ( hasFile )
+ {
+ wstream.readLine(); // skip the first two lines
+ wstream.readLine(); // because they only contain headers
+ }
+ if ( ( !hasFile ) || ( wstream.atEnd() ) )
+ {
+#ifdef MDEBUG
+ qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." );
+#endif
+ quality = -1;
+ signal = IW_LOWER;
+ noise = IW_LOWER;
+ return false;
+ }
+
+ wstream >> name >> status >> quality >> c >> signal >> c >> noise;
+
+ 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
+
+ return true;
+
+}
+*/
+ 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()
diff --git a/noncore/net/networksetup/wlan/wlanmodule.h b/noncore/net/networksetup/wlan/wlanmodule.h
index 833d4b1..63f0949 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.h
+++ b/noncore/net/networksetup/wlan/wlanmodule.h
@@ -10,14 +10,14 @@ signals:
public:
WLANModule();
virtual void setProfile(QString newProfile);
virtual bool isOwner(Interface *);
- virtual QWidget *configure(QTabWidget **tabWidget);
- virtual QWidget *information(QTabWidget **tabWidget);
+ virtual QWidget *configure(Interface *i, QTabWidget **tabWidget);
+ virtual QWidget *information(Interface *i, QTabWidget **tabWidget);
virtual QList<Interface> getInterfaces();
virtual void possibleNewInterfaces(QMap<QString, QString> &list){};
virtual Interface *addNewInterface(QString name);
virtual bool remove(Interface* i);
virtual QString getPixmapName(Interface* i);
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro
index 5cfe468..5b94a95 100644
--- a/noncore/settings/networksettings/wlan/wlan.pro
+++ b/noncore/settings/networksettings/wlan/wlan.pro
@@ -4,9 +4,9 @@ CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/plugins/networksetup
HEADERS = wlanimp.h wlanmodule.h
SOURCES = wlanimp.cpp wlanmodule.cpp
INCLUDEPATH += $(OPIEDIR)/include ../
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
-INTERFACES = wlan.ui
+INTERFACES = wlan.ui info.ui
TARGET = wlanplugin
VERSION = 1.0.0
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 53b5857..8d25d99 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,9 +1,28 @@
#include "wlanmodule.h"
#include <qpe/config.h>
#include "wlanimp.h"
+#include "info.h"
+
+
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <linux/if_ether.h>
+#include <netinet/ip.h>
+#include <sys/ioctl.h>
+#include <linux/wireless.h>
+
+#include <unistd.h>
+#include <math.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <stdlib.h>
+
+#include <qlabel.h>
/**
* Constructor, find all of the possible interfaces
*/
WLANModule::WLANModule() : Module() {
// get output from iwconfig
@@ -40,26 +59,138 @@ bool WLANModule::isOwner(Interface *i){
/**
* Create, set tabWiget and return the WLANConfigure Module
* @param tabWidget a pointer to the tab widget that this configure has.
* @return QWidget* pointer to the tab widget in this modules configure.
*/
-QWidget *WLANModule::configure(QTabWidget **tabWidget){
- Config *cfg = new Config("wireless");
+QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){
+ Config *cfg = new Config("wireless config");
WLANImp *wlanconfig = new WLANImp(*cfg);
(*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(QTabWidget **tabWidget){
- return NULL;
+QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
+ WlanInfo *info = new WlanInfo(0, "wireless info");
+ (*tabWidget) = info->tabWidget;
+
+ struct ifreq ifr;
+ struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr;
+ int fd = socket( AF_INET, SOCK_DGRAM, 0 );
+
+ const char* buffer[200];
+ struct iwreq iwr;
+ 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)
+
+ QString n = (i->getInterfaceName());
+ const char* iname = n.latin1();
+ strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
+ int result = ioctl( fd, SIOCGIWESSID, &iwr );
+ if ( result == 0 ){
+ //hasWirelessExtensions = true;
+ iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
+ info->essidLabel->setText(QString(iwr.u.essid.pointer));
+ }
+ else
+ return info;
+ //info->essidLabel->setText("*** Unknown ***");
+
+ // Address of associated access-point
+ result = ioctl( fd, SIOCGIWAP, &iwr );
+ if ( result == 0 ){
+ QString foo = foo.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 );
+ info->apLabel->setText(foo);
+ }
+ else info->apLabel->setText("*** Unknown ***");
+
+ iwr.u.data.pointer = (caddr_t) buffer;
+ iwr.u.data.length = IW_ESSID_MAX_SIZE;
+ iwr.u.data.flags = 0;
+ result = ioctl( fd, SIOCGIWNICKN, &iwr );
+ if ( result == 0 ){
+ iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0';
+ info->stationLabel->setText(iwr.u.data.pointer);
+ }
+ else info->stationLabel->setText("*** Unknown ***");
+
+ result = ioctl( fd, SIOCGIWMODE, &iwr );
+ if ( result == 0 )
+ info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"));
+ else
+ info->modeLabel->setText("*** Unknown ***");
+
+ result = ioctl( fd, SIOCGIWFREQ, &iwr );
+ if ( result == 0 )
+ info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000)));
+ else
+ info->freqLabel->setText("0");
+
+ /*
+ // gather link quality from /proc/net/wireless
+
+ char c;
+ QString status;
+ QString name;
+ QFile wfile( PROCNETWIRELESS );
+ bool hasFile = wfile.open( IO_ReadOnly );
+ QTextStream wstream( &wfile );
+ if ( hasFile )
+ {
+ wstream.readLine(); // skip the first two lines
+ wstream.readLine(); // because they only contain headers
+ }
+ if ( ( !hasFile ) || ( wstream.atEnd() ) )
+ {
+#ifdef MDEBUG
+ qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." );
+#endif
+ quality = -1;
+ signal = IW_LOWER;
+ noise = IW_LOWER;
+ return false;
+ }
+
+ wstream >> name >> status >> quality >> c >> signal >> c >> noise;
+
+ 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
+
+ return true;
+
+}
+*/
+ 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()
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h
index 833d4b1..63f0949 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.h
+++ b/noncore/settings/networksettings/wlan/wlanmodule.h
@@ -10,14 +10,14 @@ signals:
public:
WLANModule();
virtual void setProfile(QString newProfile);
virtual bool isOwner(Interface *);
- virtual QWidget *configure(QTabWidget **tabWidget);
- virtual QWidget *information(QTabWidget **tabWidget);
+ virtual QWidget *configure(Interface *i, QTabWidget **tabWidget);
+ virtual QWidget *information(Interface *i, QTabWidget **tabWidget);
virtual QList<Interface> getInterfaces();
virtual void possibleNewInterfaces(QMap<QString, QString> &list){};
virtual Interface *addNewInterface(QString name);
virtual bool remove(Interface* i);
virtual QString getPixmapName(Interface* i);