author | benmeyer <benmeyer> | 2002-10-18 17:36:19 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-18 17:36:19 (UTC) |
commit | addfc9900cbf3da2cdbfa54ea849bc7f7fb1b296 (patch) (unidiff) | |
tree | 76b57ebf419e13f23e36d62978386072080c1927 | |
parent | 0f230c7120d49a1718fe3e442e1559968a21f00d (diff) | |
download | opie-addfc9900cbf3da2cdbfa54ea849bc7f7fb1b296.zip opie-addfc9900cbf3da2cdbfa54ea849bc7f7fb1b296.tar.gz opie-addfc9900cbf3da2cdbfa54ea849bc7f7fb1b296.tar.bz2 |
added wlan info, very basic, needs to be cleaned
-rw-r--r-- | noncore/net/networksetup/wlan/wlan.pro | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 139 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.h | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlan.pro | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 139 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.h | 4 |
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 | |||
@@ -1,12 +1,12 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 3 | #CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/plugins/networksetup | 4 | DESTDIR = $(OPIEDIR)/plugins/networksetup |
5 | HEADERS = wlanimp.h wlanmodule.h | 5 | HEADERS = wlanimp.h wlanmodule.h |
6 | SOURCES = wlanimp.cpp wlanmodule.cpp | 6 | SOURCES = wlanimp.cpp wlanmodule.cpp |
7 | INCLUDEPATH+= $(OPIEDIR)/include ../ | 7 | INCLUDEPATH+= $(OPIEDIR)/include ../ |
8 | DEPENDPATH+= $(OPIEDIR)/include | 8 | DEPENDPATH+= $(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe |
10 | INTERFACES= wlan.ui | 10 | INTERFACES= wlan.ui info.ui |
11 | TARGET = wlanplugin | 11 | TARGET = wlanplugin |
12 | VERSION = 1.0.0 | 12 | 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,15 +1,34 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include <qpe/config.h> | 2 | #include <qpe/config.h> |
3 | #include "wlanimp.h" | 3 | #include "wlanimp.h" |
4 | #include "info.h" | ||
5 | |||
6 | |||
7 | #include <arpa/inet.h> | ||
8 | #include <sys/socket.h> | ||
9 | #include <linux/if_ether.h> | ||
10 | #include <netinet/ip.h> | ||
11 | #include <sys/ioctl.h> | ||
12 | #include <linux/wireless.h> | ||
13 | |||
14 | #include <unistd.h> | ||
15 | #include <math.h> | ||
16 | #include <errno.h> | ||
17 | #include <string.h> | ||
18 | #include <stdio.h> | ||
19 | |||
20 | #include <stdlib.h> | ||
21 | |||
22 | #include <qlabel.h> | ||
4 | 23 | ||
5 | /** | 24 | /** |
6 | * Constructor, find all of the possible interfaces | 25 | * Constructor, find all of the possible interfaces |
7 | */ | 26 | */ |
8 | WLANModule::WLANModule() : Module() { | 27 | WLANModule::WLANModule() : Module() { |
9 | // get output from iwconfig | 28 | // get output from iwconfig |
10 | } | 29 | } |
11 | 30 | ||
12 | /** | 31 | /** |
13 | * Change the current profile | 32 | * Change the current profile |
14 | */ | 33 | */ |
15 | void WLANModule::setProfile(QString newProfile){ | 34 | void WLANModule::setProfile(QString newProfile){ |
@@ -34,38 +53,150 @@ bool WLANModule::isOwner(Interface *i){ | |||
34 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 53 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ |
35 | i->setHardwareName("802.11b"); | 54 | i->setHardwareName("802.11b"); |
36 | return true; | 55 | return true; |
37 | } | 56 | } |
38 | return false; | 57 | return false; |
39 | } | 58 | } |
40 | 59 | ||
41 | /** | 60 | /** |
42 | * Create, set tabWiget and return the WLANConfigure Module | 61 | * Create, set tabWiget and return the WLANConfigure Module |
43 | * @param tabWidget a pointer to the tab widget that this configure has. | 62 | * @param tabWidget a pointer to the tab widget that this configure has. |
44 | * @return QWidget* pointer to the tab widget in this modules configure. | 63 | * @return QWidget* pointer to the tab widget in this modules configure. |
45 | */ | 64 | */ |
46 | QWidget *WLANModule::configure(QTabWidget **tabWidget){ | 65 | QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){ |
47 | Config *cfg = new Config("wireless"); | 66 | Config *cfg = new Config("wireless config"); |
48 | WLANImp *wlanconfig = new WLANImp(*cfg); | 67 | WLANImp *wlanconfig = new WLANImp(*cfg); |
49 | (*tabWidget) = wlanconfig->tabWidget; | 68 | (*tabWidget) = wlanconfig->tabWidget; |
50 | return wlanconfig; | 69 | return wlanconfig; |
51 | } | 70 | } |
52 | 71 | ||
53 | /** | 72 | /** |
54 | * Create, set tabWiget and return the Information Module | 73 | * Create, set tabWiget and return the Information Module |
55 | * @param tabWidget a pointer to the tab widget that this information has. | 74 | * @param tabWidget a pointer to the tab widget that this information has. |
56 | * @return QWidget* pointer to the tab widget in this modules info. | 75 | * @return QWidget* pointer to the tab widget in this modules info. |
57 | */ | 76 | */ |
58 | QWidget *WLANModule::information(QTabWidget **tabWidget){ | 77 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
59 | return NULL; | 78 | WlanInfo *info = new WlanInfo(0, "wireless info"); |
79 | (*tabWidget) = info->tabWidget; | ||
80 | |||
81 | struct ifreq ifr; | ||
82 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; | ||
83 | int fd = socket( AF_INET, SOCK_DGRAM, 0 ); | ||
84 | |||
85 | const char* buffer[200]; | ||
86 | struct iwreq iwr; | ||
87 | memset( &iwr, 0, sizeof( iwr ) ); | ||
88 | iwr.u.essid.pointer = (caddr_t) buffer; | ||
89 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | ||
90 | iwr.u.essid.flags = 0; | ||
91 | |||
92 | // check if it is an IEEE 802.11 standard conform | ||
93 | // wireless device by sending SIOCGIWESSID | ||
94 | // which also gives back the Extended Service Set ID | ||
95 | // (see IEEE 802.11 for more information) | ||
96 | |||
97 | QString n = (i->getInterfaceName()); | ||
98 | const char* iname = n.latin1(); | ||
99 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | ||
100 | int result = ioctl( fd, SIOCGIWESSID, &iwr ); | ||
101 | if ( result == 0 ){ | ||
102 | //hasWirelessExtensions = true; | ||
103 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | ||
104 | info->essidLabel->setText(QString(iwr.u.essid.pointer)); | ||
105 | } | ||
106 | else | ||
107 | return info; | ||
108 | //info->essidLabel->setText("*** Unknown ***"); | ||
109 | |||
110 | // Address of associated access-point | ||
111 | result = ioctl( fd, SIOCGIWAP, &iwr ); | ||
112 | if ( result == 0 ){ | ||
113 | QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | ||
114 | iwr.u.ap_addr.sa_data[0]&0xff, | ||
115 | iwr.u.ap_addr.sa_data[1]&0xff, | ||
116 | iwr.u.ap_addr.sa_data[2]&0xff, | ||
117 | iwr.u.ap_addr.sa_data[3]&0xff, | ||
118 | iwr.u.ap_addr.sa_data[4]&0xff, | ||
119 | iwr.u.ap_addr.sa_data[5]&0xff ); | ||
120 | info->apLabel->setText(foo); | ||
121 | } | ||
122 | else info->apLabel->setText("*** Unknown ***"); | ||
123 | |||
124 | iwr.u.data.pointer = (caddr_t) buffer; | ||
125 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | ||
126 | iwr.u.data.flags = 0; | ||
127 | result = ioctl( fd, SIOCGIWNICKN, &iwr ); | ||
128 | if ( result == 0 ){ | ||
129 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | ||
130 | info->stationLabel->setText(iwr.u.data.pointer); | ||
131 | } | ||
132 | else info->stationLabel->setText("*** Unknown ***"); | ||
133 | |||
134 | result = ioctl( fd, SIOCGIWMODE, &iwr ); | ||
135 | if ( result == 0 ) | ||
136 | info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed")); | ||
137 | else | ||
138 | info->modeLabel->setText("*** Unknown ***"); | ||
139 | |||
140 | result = ioctl( fd, SIOCGIWFREQ, &iwr ); | ||
141 | if ( result == 0 ) | ||
142 | info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000))); | ||
143 | else | ||
144 | info->freqLabel->setText("0"); | ||
145 | |||
146 | /* | ||
147 | // gather link quality from /proc/net/wireless | ||
148 | |||
149 | char c; | ||
150 | QString status; | ||
151 | QString name; | ||
152 | QFile wfile( PROCNETWIRELESS ); | ||
153 | bool hasFile = wfile.open( IO_ReadOnly ); | ||
154 | QTextStream wstream( &wfile ); | ||
155 | if ( hasFile ) | ||
156 | { | ||
157 | wstream.readLine(); // skip the first two lines | ||
158 | wstream.readLine(); // because they only contain headers | ||
159 | } | ||
160 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) | ||
161 | { | ||
162 | #ifdef MDEBUG | ||
163 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); | ||
164 | #endif | ||
165 | quality = -1; | ||
166 | signal = IW_LOWER; | ||
167 | noise = IW_LOWER; | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | ||
172 | |||
173 | if ( quality > 92 ) | ||
174 | #ifdef MDEBUG | ||
175 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | ||
176 | #endif | ||
177 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | ||
178 | #ifdef MDEBUG | ||
179 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | ||
180 | #endif | ||
181 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | ||
182 | #ifdef MDEBUG | ||
183 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | ||
184 | #endif | ||
185 | |||
186 | return true; | ||
187 | |||
188 | } | ||
189 | */ | ||
190 | return info; | ||
60 | } | 191 | } |
61 | 192 | ||
62 | /** | 193 | /** |
63 | * Get all active (up or down) interfaces | 194 | * Get all active (up or down) interfaces |
64 | * @return QList<Interface> A list of interfaces that exsist that havn't | 195 | * @return QList<Interface> A list of interfaces that exsist that havn't |
65 | * been called by isOwner() | 196 | * been called by isOwner() |
66 | */ | 197 | */ |
67 | QList<Interface> WLANModule::getInterfaces(){ | 198 | QList<Interface> WLANModule::getInterfaces(){ |
68 | return list; | 199 | return list; |
69 | } | 200 | } |
70 | 201 | ||
71 | /** | 202 | /** |
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 | |||
@@ -4,26 +4,26 @@ | |||
4 | #include "module.h" | 4 | #include "module.h" |
5 | 5 | ||
6 | class WLANModule : Module{ | 6 | class WLANModule : Module{ |
7 | 7 | ||
8 | signals: | 8 | signals: |
9 | void updateInterface(Interface *i); | 9 | void updateInterface(Interface *i); |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WLANModule(); | 12 | WLANModule(); |
13 | 13 | ||
14 | virtual void setProfile(QString newProfile); | 14 | virtual void setProfile(QString newProfile); |
15 | virtual bool isOwner(Interface *); | 15 | virtual bool isOwner(Interface *); |
16 | virtual QWidget *configure(QTabWidget **tabWidget); | 16 | virtual QWidget *configure(Interface *i, QTabWidget **tabWidget); |
17 | virtual QWidget *information(QTabWidget **tabWidget); | 17 | virtual QWidget *information(Interface *i, QTabWidget **tabWidget); |
18 | virtual QList<Interface> getInterfaces(); | 18 | virtual QList<Interface> getInterfaces(); |
19 | virtual void possibleNewInterfaces(QMap<QString, QString> &list){}; | 19 | virtual void possibleNewInterfaces(QMap<QString, QString> &list){}; |
20 | virtual Interface *addNewInterface(QString name); | 20 | virtual Interface *addNewInterface(QString name); |
21 | virtual bool remove(Interface* i); | 21 | virtual bool remove(Interface* i); |
22 | virtual QString getPixmapName(Interface* i); | 22 | virtual QString getPixmapName(Interface* i); |
23 | 23 | ||
24 | private: | 24 | private: |
25 | QList<Interface> list; | 25 | QList<Interface> list; |
26 | QString profile; | 26 | QString profile; |
27 | 27 | ||
28 | }; | 28 | }; |
29 | 29 | ||
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 | |||
@@ -1,12 +1,12 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 3 | #CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/plugins/networksetup | 4 | DESTDIR = $(OPIEDIR)/plugins/networksetup |
5 | HEADERS = wlanimp.h wlanmodule.h | 5 | HEADERS = wlanimp.h wlanmodule.h |
6 | SOURCES = wlanimp.cpp wlanmodule.cpp | 6 | SOURCES = wlanimp.cpp wlanmodule.cpp |
7 | INCLUDEPATH+= $(OPIEDIR)/include ../ | 7 | INCLUDEPATH+= $(OPIEDIR)/include ../ |
8 | DEPENDPATH+= $(OPIEDIR)/include | 8 | DEPENDPATH+= $(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe |
10 | INTERFACES= wlan.ui | 10 | INTERFACES= wlan.ui info.ui |
11 | TARGET = wlanplugin | 11 | TARGET = wlanplugin |
12 | VERSION = 1.0.0 | 12 | 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,15 +1,34 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include <qpe/config.h> | 2 | #include <qpe/config.h> |
3 | #include "wlanimp.h" | 3 | #include "wlanimp.h" |
4 | #include "info.h" | ||
5 | |||
6 | |||
7 | #include <arpa/inet.h> | ||
8 | #include <sys/socket.h> | ||
9 | #include <linux/if_ether.h> | ||
10 | #include <netinet/ip.h> | ||
11 | #include <sys/ioctl.h> | ||
12 | #include <linux/wireless.h> | ||
13 | |||
14 | #include <unistd.h> | ||
15 | #include <math.h> | ||
16 | #include <errno.h> | ||
17 | #include <string.h> | ||
18 | #include <stdio.h> | ||
19 | |||
20 | #include <stdlib.h> | ||
21 | |||
22 | #include <qlabel.h> | ||
4 | 23 | ||
5 | /** | 24 | /** |
6 | * Constructor, find all of the possible interfaces | 25 | * Constructor, find all of the possible interfaces |
7 | */ | 26 | */ |
8 | WLANModule::WLANModule() : Module() { | 27 | WLANModule::WLANModule() : Module() { |
9 | // get output from iwconfig | 28 | // get output from iwconfig |
10 | } | 29 | } |
11 | 30 | ||
12 | /** | 31 | /** |
13 | * Change the current profile | 32 | * Change the current profile |
14 | */ | 33 | */ |
15 | void WLANModule::setProfile(QString newProfile){ | 34 | void WLANModule::setProfile(QString newProfile){ |
@@ -34,38 +53,150 @@ bool WLANModule::isOwner(Interface *i){ | |||
34 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 53 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ |
35 | i->setHardwareName("802.11b"); | 54 | i->setHardwareName("802.11b"); |
36 | return true; | 55 | return true; |
37 | } | 56 | } |
38 | return false; | 57 | return false; |
39 | } | 58 | } |
40 | 59 | ||
41 | /** | 60 | /** |
42 | * Create, set tabWiget and return the WLANConfigure Module | 61 | * Create, set tabWiget and return the WLANConfigure Module |
43 | * @param tabWidget a pointer to the tab widget that this configure has. | 62 | * @param tabWidget a pointer to the tab widget that this configure has. |
44 | * @return QWidget* pointer to the tab widget in this modules configure. | 63 | * @return QWidget* pointer to the tab widget in this modules configure. |
45 | */ | 64 | */ |
46 | QWidget *WLANModule::configure(QTabWidget **tabWidget){ | 65 | QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){ |
47 | Config *cfg = new Config("wireless"); | 66 | Config *cfg = new Config("wireless config"); |
48 | WLANImp *wlanconfig = new WLANImp(*cfg); | 67 | WLANImp *wlanconfig = new WLANImp(*cfg); |
49 | (*tabWidget) = wlanconfig->tabWidget; | 68 | (*tabWidget) = wlanconfig->tabWidget; |
50 | return wlanconfig; | 69 | return wlanconfig; |
51 | } | 70 | } |
52 | 71 | ||
53 | /** | 72 | /** |
54 | * Create, set tabWiget and return the Information Module | 73 | * Create, set tabWiget and return the Information Module |
55 | * @param tabWidget a pointer to the tab widget that this information has. | 74 | * @param tabWidget a pointer to the tab widget that this information has. |
56 | * @return QWidget* pointer to the tab widget in this modules info. | 75 | * @return QWidget* pointer to the tab widget in this modules info. |
57 | */ | 76 | */ |
58 | QWidget *WLANModule::information(QTabWidget **tabWidget){ | 77 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
59 | return NULL; | 78 | WlanInfo *info = new WlanInfo(0, "wireless info"); |
79 | (*tabWidget) = info->tabWidget; | ||
80 | |||
81 | struct ifreq ifr; | ||
82 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; | ||
83 | int fd = socket( AF_INET, SOCK_DGRAM, 0 ); | ||
84 | |||
85 | const char* buffer[200]; | ||
86 | struct iwreq iwr; | ||
87 | memset( &iwr, 0, sizeof( iwr ) ); | ||
88 | iwr.u.essid.pointer = (caddr_t) buffer; | ||
89 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | ||
90 | iwr.u.essid.flags = 0; | ||
91 | |||
92 | // check if it is an IEEE 802.11 standard conform | ||
93 | // wireless device by sending SIOCGIWESSID | ||
94 | // which also gives back the Extended Service Set ID | ||
95 | // (see IEEE 802.11 for more information) | ||
96 | |||
97 | QString n = (i->getInterfaceName()); | ||
98 | const char* iname = n.latin1(); | ||
99 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | ||
100 | int result = ioctl( fd, SIOCGIWESSID, &iwr ); | ||
101 | if ( result == 0 ){ | ||
102 | //hasWirelessExtensions = true; | ||
103 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | ||
104 | info->essidLabel->setText(QString(iwr.u.essid.pointer)); | ||
105 | } | ||
106 | else | ||
107 | return info; | ||
108 | //info->essidLabel->setText("*** Unknown ***"); | ||
109 | |||
110 | // Address of associated access-point | ||
111 | result = ioctl( fd, SIOCGIWAP, &iwr ); | ||
112 | if ( result == 0 ){ | ||
113 | QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | ||
114 | iwr.u.ap_addr.sa_data[0]&0xff, | ||
115 | iwr.u.ap_addr.sa_data[1]&0xff, | ||
116 | iwr.u.ap_addr.sa_data[2]&0xff, | ||
117 | iwr.u.ap_addr.sa_data[3]&0xff, | ||
118 | iwr.u.ap_addr.sa_data[4]&0xff, | ||
119 | iwr.u.ap_addr.sa_data[5]&0xff ); | ||
120 | info->apLabel->setText(foo); | ||
121 | } | ||
122 | else info->apLabel->setText("*** Unknown ***"); | ||
123 | |||
124 | iwr.u.data.pointer = (caddr_t) buffer; | ||
125 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | ||
126 | iwr.u.data.flags = 0; | ||
127 | result = ioctl( fd, SIOCGIWNICKN, &iwr ); | ||
128 | if ( result == 0 ){ | ||
129 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | ||
130 | info->stationLabel->setText(iwr.u.data.pointer); | ||
131 | } | ||
132 | else info->stationLabel->setText("*** Unknown ***"); | ||
133 | |||
134 | result = ioctl( fd, SIOCGIWMODE, &iwr ); | ||
135 | if ( result == 0 ) | ||
136 | info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed")); | ||
137 | else | ||
138 | info->modeLabel->setText("*** Unknown ***"); | ||
139 | |||
140 | result = ioctl( fd, SIOCGIWFREQ, &iwr ); | ||
141 | if ( result == 0 ) | ||
142 | info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000))); | ||
143 | else | ||
144 | info->freqLabel->setText("0"); | ||
145 | |||
146 | /* | ||
147 | // gather link quality from /proc/net/wireless | ||
148 | |||
149 | char c; | ||
150 | QString status; | ||
151 | QString name; | ||
152 | QFile wfile( PROCNETWIRELESS ); | ||
153 | bool hasFile = wfile.open( IO_ReadOnly ); | ||
154 | QTextStream wstream( &wfile ); | ||
155 | if ( hasFile ) | ||
156 | { | ||
157 | wstream.readLine(); // skip the first two lines | ||
158 | wstream.readLine(); // because they only contain headers | ||
159 | } | ||
160 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) | ||
161 | { | ||
162 | #ifdef MDEBUG | ||
163 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); | ||
164 | #endif | ||
165 | quality = -1; | ||
166 | signal = IW_LOWER; | ||
167 | noise = IW_LOWER; | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | ||
172 | |||
173 | if ( quality > 92 ) | ||
174 | #ifdef MDEBUG | ||
175 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | ||
176 | #endif | ||
177 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | ||
178 | #ifdef MDEBUG | ||
179 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | ||
180 | #endif | ||
181 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | ||
182 | #ifdef MDEBUG | ||
183 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | ||
184 | #endif | ||
185 | |||
186 | return true; | ||
187 | |||
188 | } | ||
189 | */ | ||
190 | return info; | ||
60 | } | 191 | } |
61 | 192 | ||
62 | /** | 193 | /** |
63 | * Get all active (up or down) interfaces | 194 | * Get all active (up or down) interfaces |
64 | * @return QList<Interface> A list of interfaces that exsist that havn't | 195 | * @return QList<Interface> A list of interfaces that exsist that havn't |
65 | * been called by isOwner() | 196 | * been called by isOwner() |
66 | */ | 197 | */ |
67 | QList<Interface> WLANModule::getInterfaces(){ | 198 | QList<Interface> WLANModule::getInterfaces(){ |
68 | return list; | 199 | return list; |
69 | } | 200 | } |
70 | 201 | ||
71 | /** | 202 | /** |
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 | |||
@@ -4,26 +4,26 @@ | |||
4 | #include "module.h" | 4 | #include "module.h" |
5 | 5 | ||
6 | class WLANModule : Module{ | 6 | class WLANModule : Module{ |
7 | 7 | ||
8 | signals: | 8 | signals: |
9 | void updateInterface(Interface *i); | 9 | void updateInterface(Interface *i); |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WLANModule(); | 12 | WLANModule(); |
13 | 13 | ||
14 | virtual void setProfile(QString newProfile); | 14 | virtual void setProfile(QString newProfile); |
15 | virtual bool isOwner(Interface *); | 15 | virtual bool isOwner(Interface *); |
16 | virtual QWidget *configure(QTabWidget **tabWidget); | 16 | virtual QWidget *configure(Interface *i, QTabWidget **tabWidget); |
17 | virtual QWidget *information(QTabWidget **tabWidget); | 17 | virtual QWidget *information(Interface *i, QTabWidget **tabWidget); |
18 | virtual QList<Interface> getInterfaces(); | 18 | virtual QList<Interface> getInterfaces(); |
19 | virtual void possibleNewInterfaces(QMap<QString, QString> &list){}; | 19 | virtual void possibleNewInterfaces(QMap<QString, QString> &list){}; |
20 | virtual Interface *addNewInterface(QString name); | 20 | virtual Interface *addNewInterface(QString name); |
21 | virtual bool remove(Interface* i); | 21 | virtual bool remove(Interface* i); |
22 | virtual QString getPixmapName(Interface* i); | 22 | virtual QString getPixmapName(Interface* i); |
23 | 23 | ||
24 | private: | 24 | private: |
25 | QList<Interface> list; | 25 | QList<Interface> list; |
26 | QString profile; | 26 | QString profile; |
27 | 27 | ||
28 | }; | 28 | }; |
29 | 29 | ||