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