author | zecke <zecke> | 2004-01-05 14:39:29 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-01-05 14:39:29 (UTC) |
commit | c127e5d582b1ae4033eca1c8454bee75d510b9e8 (patch) (unidiff) | |
tree | e4f6e610969f35e1e0954f762f317c0e9ccf76b3 /noncore/settings/networksettings/wlan | |
parent | 7fb9bc93eae8007a6eb298fc743bbf70dc50fbc5 (diff) | |
download | opie-c127e5d582b1ae4033eca1c8454bee75d510b9e8.zip opie-c127e5d582b1ae4033eca1c8454bee75d510b9e8.tar.gz opie-c127e5d582b1ae4033eca1c8454bee75d510b9e8.tar.bz2 |
Spelling fixes by Michael Opdenacker <zumbi2@netcourrier.com>
Diffstat (limited to 'noncore/settings/networksettings/wlan') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index bd7cf93..d1fff88 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -1,200 +1,200 @@ | |||
1 | #include "wextensions.h" | 1 | #include "wextensions.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | 5 | ||
6 | #include <arpa/inet.h> | 6 | #include <arpa/inet.h> |
7 | #include <sys/socket.h> | 7 | #include <sys/socket.h> |
8 | #include <sys/ioctl.h> | 8 | #include <sys/ioctl.h> |
9 | 9 | ||
10 | #include <math.h> | 10 | #include <math.h> |
11 | 11 | ||
12 | #define PROCNETWIRELESS "/proc/net/wireless" | 12 | #define PROCNETWIRELESS "/proc/net/wireless" |
13 | #define IW_LOWER 0 | 13 | #define IW_LOWER 0 |
14 | #define IW_UPPER 256 | 14 | #define IW_UPPER 256 |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Constructor. Sets hasWirelessExtensions | 17 | * Constructor. Sets hasWirelessExtensions |
18 | */ | 18 | */ |
19 | WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { | 19 | WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { |
20 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); | 20 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); |
21 | if(fd == -1) | 21 | if(fd == -1) |
22 | return; | 22 | return; |
23 | 23 | ||
24 | const char* buffer[200]; | 24 | const char* buffer[200]; |
25 | memset( &iwr, 0, sizeof( iwr ) ); | 25 | memset( &iwr, 0, sizeof( iwr ) ); |
26 | iwr.u.essid.pointer = (caddr_t) buffer; | 26 | iwr.u.essid.pointer = (caddr_t) buffer; |
27 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 27 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
28 | iwr.u.essid.flags = 0; | 28 | iwr.u.essid.flags = 0; |
29 | 29 | ||
30 | // check if it is an IEEE 802.11 standard conform | 30 | // check if it is an IEEE 802.11 standard conform |
31 | // wireless device by sending SIOCGIWESSID | 31 | // wireless device by sending SIOCGIWESSID |
32 | // which also gives back the Extended Service Set ID | 32 | // which also gives back the Extended Service Set ID |
33 | // (see IEEE 802.11 for more information) | 33 | // (see IEEE 802.11 for more information) |
34 | 34 | ||
35 | const char* iname = interface.latin1(); | 35 | const char* iname = interface.latin1(); |
36 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | 36 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); |
37 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) | 37 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) |
38 | hasWirelessExtensions = true; | 38 | hasWirelessExtensions = true; |
39 | } | 39 | } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * @return QString the station name of the access point. | 42 | * @return QString the station name of the access point. |
43 | */ | 43 | */ |
44 | QString WExtensions::station(){ | 44 | QString WExtensions::station(){ |
45 | if(!hasWirelessExtensions) | 45 | if(!hasWirelessExtensions) |
46 | return QString(); | 46 | return QString(); |
47 | const char* buffer[200]; | 47 | const char* buffer[200]; |
48 | iwr.u.data.pointer = (caddr_t) buffer; | 48 | iwr.u.data.pointer = (caddr_t) buffer; |
49 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 49 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
50 | iwr.u.data.flags = 0; | 50 | iwr.u.data.flags = 0; |
51 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | 51 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ |
52 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 52 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
53 | return QString(iwr.u.data.pointer); | 53 | return QString(iwr.u.data.pointer); |
54 | } | 54 | } |
55 | return QString(); | 55 | return QString(); |
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * @return QString the essid of the host 802.11 access point. | 59 | * @return QString the essid of the host 802.11 access point. |
60 | */ | 60 | */ |
61 | QString WExtensions::essid(){ | 61 | QString WExtensions::essid(){ |
62 | if(!hasWirelessExtensions) | 62 | if(!hasWirelessExtensions) |
63 | return QString(); | 63 | return QString(); |
64 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 64 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
65 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0'; | 65 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0'; |
66 | return QString(iwr.u.essid.pointer); | 66 | return QString(iwr.u.essid.pointer); |
67 | } | 67 | } |
68 | return QString(); | 68 | return QString(); |
69 | } | 69 | } |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * @return QString the mode of interface | 72 | * @return QString the mode of interface |
73 | */ | 73 | */ |
74 | QString WExtensions::mode(){ | 74 | QString WExtensions::mode(){ |
75 | if(!hasWirelessExtensions) | 75 | if(!hasWirelessExtensions) |
76 | return QString(); | 76 | return QString(); |
77 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 77 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
78 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 78 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
79 | return QString(); | 79 | return QString(); |
80 | } | 80 | } |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Get the frequency that the interface is running at. | 83 | * Get the frequency that the interface is running at. |
84 | * @return int the frequency that the interfacae is running at. | 84 | * @return int the frequency that the interfacae is running at. |
85 | */ | 85 | */ |
86 | double WExtensions::frequency(){ | 86 | double WExtensions::frequency(){ |
87 | if(!hasWirelessExtensions) | 87 | if(!hasWirelessExtensions) |
88 | return 0; | 88 | return 0; |
89 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 89 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
90 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 90 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Get the channel that the interface is running at. | 95 | * Get the channel that the interface is running at. |
96 | * @return int the channel that the interfacae is running at. | 96 | * @return int the channel that the interfacae is running at. |
97 | */ | 97 | */ |
98 | int WExtensions::channel(){ | 98 | int WExtensions::channel(){ |
99 | if(!hasWirelessExtensions) | 99 | if(!hasWirelessExtensions) |
100 | return 0; | 100 | return 0; |
101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) | 101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) |
102 | return 0; | 102 | return 0; |
103 | 103 | ||
104 | // http://www.elanix.com/pdf/an137e.pdf | 104 | // http://www.elanix.com/pdf/an137e.pdf |
105 | 105 | ||
106 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 106 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
107 | double left = 2.401; | 107 | double left = 2.401; |
108 | double right = 2.416; | 108 | double right = 2.416; |
109 | for(int channel = 1; channel<= 15; channel++){ | 109 | for(int channel = 1; channel<= 15; channel++){ |
110 | if( num >= left && num <= right ) | 110 | if( num >= left && num <= right ) |
111 | return channel; | 111 | return channel; |
112 | left += 0.005; | 112 | left += 0.005; |
113 | right += 0.005; | 113 | right += 0.005; |
114 | } | 114 | } |
115 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); | 115 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); |
116 | return -1; | 116 | return -1; |
117 | } | 117 | } |
118 | 118 | ||
119 | /*** | 119 | /*** |
120 | * Get the current rate that the card is transmiting at. | 120 | * Get the current rate that the card is transmiting at. |
121 | * @return double the rate, 0 if error. | 121 | * @return double the rate, 0 if error. |
122 | */ | 122 | */ |
123 | double WExtensions::rate(){ | 123 | double WExtensions::rate(){ |
124 | if(!hasWirelessExtensions) | 124 | if(!hasWirelessExtensions) |
125 | return 0; | 125 | return 0; |
126 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | 126 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ |
127 | return ((double)iwr.u.bitrate.value)/1000000; | 127 | return ((double)iwr.u.bitrate.value)/1000000; |
128 | } | 128 | } |
129 | return 0; | 129 | return 0; |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | /** | 133 | /** |
134 | * @return QString the AccessPoint that the interface is connected to. | 134 | * @return QString the AccessPoint that the interface is connected to. |
135 | */ | 135 | */ |
136 | QString WExtensions::ap(){ | 136 | QString WExtensions::ap(){ |
137 | if(!hasWirelessExtensions) | 137 | if(!hasWirelessExtensions) |
138 | return QString(); | 138 | return QString(); |
139 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ | 139 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ |
140 | QString ap; | 140 | QString ap; |
141 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 141 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
142 | iwr.u.ap_addr.sa_data[0]&0xff, | 142 | iwr.u.ap_addr.sa_data[0]&0xff, |
143 | iwr.u.ap_addr.sa_data[1]&0xff, | 143 | iwr.u.ap_addr.sa_data[1]&0xff, |
144 | iwr.u.ap_addr.sa_data[2]&0xff, | 144 | iwr.u.ap_addr.sa_data[2]&0xff, |
145 | iwr.u.ap_addr.sa_data[3]&0xff, | 145 | iwr.u.ap_addr.sa_data[3]&0xff, |
146 | iwr.u.ap_addr.sa_data[4]&0xff, | 146 | iwr.u.ap_addr.sa_data[4]&0xff, |
147 | iwr.u.ap_addr.sa_data[5]&0xff ); | 147 | iwr.u.ap_addr.sa_data[5]&0xff ); |
148 | return ap; | 148 | return ap; |
149 | } | 149 | } |
150 | else return QString(); | 150 | else return QString(); |
151 | } | 151 | } |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Get the stats for interfaces | 154 | * Get the stats for interfaces |
155 | * @param signal the signal strength of interface | 155 | * @param signal the signal strength of interface |
156 | * @param noise the noise level of the interface | 156 | * @param noise the noise level of the interface |
157 | * @param quality the quality level of the interface | 157 | * @param quality the quality level of the interface |
158 | * @return bool true if successfull | 158 | * @return bool true if successful |
159 | */ | 159 | */ |
160 | bool WExtensions::stats(int &signal, int &noise, int &quality){ | 160 | bool WExtensions::stats(int &signal, int &noise, int &quality){ |
161 | // gather link quality from /proc/net/wireless | 161 | // gather link quality from /proc/net/wireless |
162 | if(!QFile::exists(PROCNETWIRELESS)) | 162 | if(!QFile::exists(PROCNETWIRELESS)) |
163 | return false; | 163 | return false; |
164 | 164 | ||
165 | char c; | 165 | char c; |
166 | QString status; | 166 | QString status; |
167 | QString name; | 167 | QString name; |
168 | 168 | ||
169 | QFile wfile( PROCNETWIRELESS ); | 169 | QFile wfile( PROCNETWIRELESS ); |
170 | if(!wfile.open( IO_ReadOnly )) | 170 | if(!wfile.open( IO_ReadOnly )) |
171 | return false; | 171 | return false; |
172 | 172 | ||
173 | QTextStream wstream( &wfile ); | 173 | QTextStream wstream( &wfile ); |
174 | wstream.readLine(); // skip the first two lines | 174 | wstream.readLine(); // skip the first two lines |
175 | wstream.readLine(); // because they only contain headers | 175 | wstream.readLine(); // because they only contain headers |
176 | while(!wstream.atEnd()){ | 176 | while(!wstream.atEnd()){ |
177 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 177 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
178 | if(name == QString("%1:").arg(interface)){ | 178 | if(name == QString("%1:").arg(interface)){ |
179 | if ( quality > 92 ) | 179 | if ( quality > 92 ) |
180 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 180 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
181 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 181 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
182 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 182 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
183 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 183 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
184 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 184 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
185 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); | 185 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
186 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | 186 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; |
187 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | 187 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; |
188 | quality = ( quality*100 ) / 92; | 188 | quality = ( quality*100 ) / 92; |
189 | return true; | 189 | return true; |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | qDebug("WExtensions::statsCard no longer present."); | 193 | qDebug("WExtensions::statsCard no longer present."); |
194 | quality = -1; | 194 | quality = -1; |
195 | signal = IW_LOWER; | 195 | signal = IW_LOWER; |
196 | noise = IW_LOWER; | 196 | noise = IW_LOWER; |
197 | return false; | 197 | return false; |
198 | } | 198 | } |
199 | 199 | ||
200 | // wextensions.cpp | 200 | // wextensions.cpp |
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index b4c3509..07bf73f 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -1,252 +1,252 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp2.h" | 2 | #include "wlanimp2.h" |
3 | #include "infoimp.h" | 3 | #include "infoimp.h" |
4 | #include "wextensions.h" | 4 | #include "wextensions.h" |
5 | #include "interfaceinformationimp.h" | 5 | #include "interfaceinformationimp.h" |
6 | 6 | ||
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | #include <qlineedit.h> | 10 | #include <qlineedit.h> |
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qspinbox.h> | 12 | #include <qspinbox.h> |
13 | #include <qtabwidget.h> | 13 | #include <qtabwidget.h> |
14 | 14 | ||
15 | 15 | ||
16 | 16 | ||
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Constructor, find all of the possible interfaces | 19 | * Constructor, find all of the possible interfaces |
20 | */ | 20 | */ |
21 | WLANModule::WLANModule() | 21 | WLANModule::WLANModule() |
22 | : Module(), | 22 | : Module(), |
23 | wlanconfigWiget(0) | 23 | wlanconfigWiget(0) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Delete any interfaces that we own. | 28 | * Delete any interfaces that we own. |
29 | */ | 29 | */ |
30 | WLANModule::~WLANModule(){ | 30 | WLANModule::~WLANModule(){ |
31 | Interface *i; | 31 | Interface *i; |
32 | for ( i=list.first(); i != 0; i=list.next() ) | 32 | for ( i=list.first(); i != 0; i=list.next() ) |
33 | delete i; | 33 | delete i; |
34 | 34 | ||
35 | } | 35 | } |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Change the current profile | 38 | * Change the current profile |
39 | */ | 39 | */ |
40 | void WLANModule::setProfile(const QString &newProfile){ | 40 | void WLANModule::setProfile(const QString &newProfile){ |
41 | profile = newProfile; | 41 | profile = newProfile; |
42 | } | 42 | } |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * get the icon name for this device. | 45 | * get the icon name for this device. |
46 | * @param Interface* can be used in determining the icon. | 46 | * @param Interface* can be used in determining the icon. |
47 | * @return QString the icon name (minus .png, .gif etc) | 47 | * @return QString the icon name (minus .png, .gif etc) |
48 | */ | 48 | */ |
49 | QString WLANModule::getPixmapName(Interface* ){ | 49 | QString WLANModule::getPixmapName(Interface* ){ |
50 | return "wlan"; | 50 | return "wlan"; |
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Check to see if the interface i is owned by this module. | 54 | * Check to see if the interface i is owned by this module. |
55 | * @param Interface* interface to check against | 55 | * @param Interface* interface to check against |
56 | * @return bool true if i is owned by this module, false otherwise. | 56 | * @return bool true if i is owned by this module, false otherwise. |
57 | */ | 57 | */ |
58 | bool WLANModule::isOwner(Interface *i){ | 58 | bool WLANModule::isOwner(Interface *i){ |
59 | WExtensions we(i->getInterfaceName()); | 59 | WExtensions we(i->getInterfaceName()); |
60 | if(!we.doesHaveWirelessExtensions()) | 60 | if(!we.doesHaveWirelessExtensions()) |
61 | return false; | 61 | return false; |
62 | 62 | ||
63 | i->setHardwareName("802.11b"); | 63 | i->setHardwareName("802.11b"); |
64 | list.append(i); | 64 | list.append(i); |
65 | return true; | 65 | return true; |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Create, and return the WLANConfigure Module | 69 | * Create, and return the WLANConfigure Module |
70 | * @return QWidget* pointer to this modules configure. | 70 | * @return QWidget* pointer to this modules configure. |
71 | */ | 71 | */ |
72 | QWidget *WLANModule::configure(Interface *i){ | 72 | QWidget *WLANModule::configure(Interface *i){ |
73 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); | 73 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); |
74 | wlanconfig->setProfile(profile); | 74 | wlanconfig->setProfile(profile); |
75 | return wlanconfig; | 75 | return wlanconfig; |
76 | } | 76 | } |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Create, and return the Information Module | 79 | * Create, and return the Information Module |
80 | * @return QWidget* pointer to this modules info. | 80 | * @return QWidget* pointer to this modules info. |
81 | */ | 81 | */ |
82 | QWidget *WLANModule::information(Interface *i){ | 82 | QWidget *WLANModule::information(Interface *i){ |
83 | WExtensions we(i->getInterfaceName()); | 83 | WExtensions we(i->getInterfaceName()); |
84 | if(!we.doesHaveWirelessExtensions()) | 84 | if(!we.doesHaveWirelessExtensions()) |
85 | return NULL; | 85 | return NULL; |
86 | 86 | ||
87 | return getInfo( i ); | 87 | return getInfo( i ); |
88 | } | 88 | } |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Get all active (up or down) interfaces | 91 | * Get all active (up or down) interfaces |
92 | * @return QList<Interface> A list of interfaces that exsist that havn't | 92 | * @return QList<Interface> A list of interfaces that exsist that havn't |
93 | * been called by isOwner() | 93 | * been called by isOwner() |
94 | */ | 94 | */ |
95 | QList<Interface> WLANModule::getInterfaces(){ | 95 | QList<Interface> WLANModule::getInterfaces(){ |
96 | return list; | 96 | return list; |
97 | } | 97 | } |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Attempt to add a new interface as defined by name | 100 | * Attempt to add a new interface as defined by name |
101 | * @param name the name of the type of interface that should be created given | 101 | * @param name the name of the type of interface that should be created given |
102 | * by possibleNewInterfaces(); | 102 | * by possibleNewInterfaces(); |
103 | * @return Interface* NULL if it was unable to be created. | 103 | * @return Interface* NULL if it was unable to be created. |
104 | */ | 104 | */ |
105 | Interface *WLANModule::addNewInterface(const QString &){ | 105 | Interface *WLANModule::addNewInterface(const QString &){ |
106 | // We can't add a 802.11 interface, either the hardware will be there | 106 | // We can't add a 802.11 interface, either the hardware will be there |
107 | // or it wont. | 107 | // or it wont. |
108 | return NULL; | 108 | return NULL; |
109 | } | 109 | } |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Attempts to remove the interface, doesn't delete i | 112 | * Attempts to remove the interface, doesn't delete i |
113 | * @return bool true if successfull, false otherwise. | 113 | * @return bool true if successful, false otherwise. |
114 | */ | 114 | */ |
115 | bool WLANModule::remove(Interface*){ | 115 | bool WLANModule::remove(Interface*){ |
116 | // Can't remove a hardware device, you can stop it though. | 116 | // Can't remove a hardware device, you can stop it though. |
117 | return false; | 117 | return false; |
118 | } | 118 | } |
119 | 119 | ||
120 | void WLANModule::receive(const QCString ¶m, const QByteArray &arg) | 120 | void WLANModule::receive(const QCString ¶m, const QByteArray &arg) |
121 | { | 121 | { |
122 | qDebug("WLANModule::receive "+param); | 122 | qDebug("WLANModule::receive "+param); |
123 | QStringList params = QStringList::split(",",param); | 123 | QStringList params = QStringList::split(",",param); |
124 | int count = params.count(); | 124 | int count = params.count(); |
125 | qDebug("WLANModule got %i params", count ); | 125 | qDebug("WLANModule got %i params", count ); |
126 | if (count < 2){ | 126 | if (count < 2){ |
127 | qDebug("Erorr less than 2 parameter"); | 127 | qDebug("Erorr less than 2 parameter"); |
128 | qDebug("RETURNING"); | 128 | qDebug("RETURNING"); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | QDataStream stream(arg,IO_ReadOnly); | 132 | QDataStream stream(arg,IO_ReadOnly); |
133 | QString interface; | 133 | QString interface; |
134 | QString action; | 134 | QString action; |
135 | int countMsgs = 0; | 135 | int countMsgs = 0; |
136 | stream >> interface; | 136 | stream >> interface; |
137 | qDebug("got count? >%s<",interface.latin1()); | 137 | qDebug("got count? >%s<",interface.latin1()); |
138 | if (interface == "count"){ | 138 | if (interface == "count"){ |
139 | qDebug("got count"); | 139 | qDebug("got count"); |
140 | stream >> action; | 140 | stream >> action; |
141 | qDebug("Got count num >%s<", action.latin1()); | 141 | qDebug("Got count num >%s<", action.latin1()); |
142 | countMsgs = action.toInt(); | 142 | countMsgs = action.toInt(); |
143 | } | 143 | } |
144 | 144 | ||
145 | QDialog *toShow; | 145 | QDialog *toShow; |
146 | //while (! stream.atEnd() ){ | 146 | //while (! stream.atEnd() ){ |
147 | for (int i = 0; i < countMsgs; i++){ | 147 | for (int i = 0; i < countMsgs; i++){ |
148 | qDebug("start stream %d/%d",i,countMsgs); | 148 | qDebug("start stream %d/%d",i,countMsgs); |
149 | if (stream.atEnd()){ | 149 | if (stream.atEnd()){ |
150 | qDebug("end of stream"); | 150 | qDebug("end of stream"); |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | stream >> interface; | 153 | stream >> interface; |
154 | qDebug("got iface"); | 154 | qDebug("got iface"); |
155 | stream >> action; | 155 | stream >> action; |
156 | qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); | 156 | qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); |
157 | // find interfaces | 157 | // find interfaces |
158 | Interface *ifa=0; | 158 | Interface *ifa=0; |
159 | for ( Interface *i=list.first(); i != 0; i=list.next() ){ | 159 | for ( Interface *i=list.first(); i != 0; i=list.next() ){ |
160 | if (i->getInterfaceName() == interface){ | 160 | if (i->getInterfaceName() == interface){ |
161 | qDebug("WLANModule found interface %s",interface.latin1()); | 161 | qDebug("WLANModule found interface %s",interface.latin1()); |
162 | ifa = i; | 162 | ifa = i; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | if (ifa == 0){ | 166 | if (ifa == 0){ |
167 | qDebug("WLANModule Did not find %s",interface.latin1()); | 167 | qDebug("WLANModule Did not find %s",interface.latin1()); |
168 | qDebug("skipping"); | 168 | qDebug("skipping"); |
169 | count = 0; | 169 | count = 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | if (count == 2){ | 172 | if (count == 2){ |
173 | // those should call the interface directly | 173 | // those should call the interface directly |
174 | QWidget *info = getInfo( ifa ); | 174 | QWidget *info = getInfo( ifa ); |
175 | info->showMaximized(); | 175 | info->showMaximized(); |
176 | 176 | ||
177 | if ( action.contains("start" ) ){ | 177 | if ( action.contains("start" ) ){ |
178 | ifa->start(); | 178 | ifa->start(); |
179 | } else if ( action.contains("restart" ) ){ | 179 | } else if ( action.contains("restart" ) ){ |
180 | ifa->restart(); | 180 | ifa->restart(); |
181 | } else if ( action.contains("stop" ) ){ | 181 | } else if ( action.contains("stop" ) ){ |
182 | ifa->stop(); | 182 | ifa->stop(); |
183 | }else if ( action.contains("refresh" ) ){ | 183 | }else if ( action.contains("refresh" ) ){ |
184 | ifa->refresh(); | 184 | ifa->refresh(); |
185 | } | 185 | } |
186 | }else if (count == 3){ | 186 | }else if (count == 3){ |
187 | QString value; | 187 | QString value; |
188 | if (!wlanconfigWiget){ | 188 | if (!wlanconfigWiget){ |
189 | //FIXME: what if it got closed meanwhile? | 189 | //FIXME: what if it got closed meanwhile? |
190 | wlanconfigWiget = (WLANImp*) configure(ifa); | 190 | wlanconfigWiget = (WLANImp*) configure(ifa); |
191 | toShow = (QDialog*) wlanconfigWiget; | 191 | toShow = (QDialog*) wlanconfigWiget; |
192 | } | 192 | } |
193 | wlanconfigWiget->showMaximized(); | 193 | wlanconfigWiget->showMaximized(); |
194 | stream >> value; | 194 | stream >> value; |
195 | qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); | 195 | qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); |
196 | if (value.isEmpty()){ | 196 | if (value.isEmpty()){ |
197 | qDebug("value is empty!!!\nreturning"); | 197 | qDebug("value is empty!!!\nreturning"); |
198 | return; | 198 | return; |
199 | } | 199 | } |
200 | if ( action.contains("ESSID") ){ | 200 | if ( action.contains("ESSID") ){ |
201 | QComboBox *combo = wlanconfigWiget->essid; | 201 | QComboBox *combo = wlanconfigWiget->essid; |
202 | bool found = false; | 202 | bool found = false; |
203 | for ( int i = 0; i < combo->count(); i++) | 203 | for ( int i = 0; i < combo->count(); i++) |
204 | if ( combo->text( i ) == value ){ | 204 | if ( combo->text( i ) == value ){ |
205 | combo->setCurrentItem( i ); | 205 | combo->setCurrentItem( i ); |
206 | found = true; | 206 | found = true; |
207 | } | 207 | } |
208 | if (!found) combo->insertItem( value, 0 ); | 208 | if (!found) combo->insertItem( value, 0 ); |
209 | }else if ( action.contains("Mode") ){ | 209 | }else if ( action.contains("Mode") ){ |
210 | QComboBox *combo = wlanconfigWiget->mode; | 210 | QComboBox *combo = wlanconfigWiget->mode; |
211 | for ( int i = 0; i < combo->count(); i++) | 211 | for ( int i = 0; i < combo->count(); i++) |
212 | if ( combo->text( i ) == value ){ | 212 | if ( combo->text( i ) == value ){ |
213 | combo->setCurrentItem( i ); | 213 | combo->setCurrentItem( i ); |
214 | } | 214 | } |
215 | 215 | ||
216 | }else if (action.contains("Channel")){ | 216 | }else if (action.contains("Channel")){ |
217 | bool ok; | 217 | bool ok; |
218 | qDebug("converting channel"); | 218 | qDebug("converting channel"); |
219 | int chan = value.toInt( &ok ); | 219 | int chan = value.toInt( &ok ); |
220 | if (ok){ | 220 | if (ok){ |
221 | qDebug("ok setting channel"); | 221 | qDebug("ok setting channel"); |
222 | wlanconfigWiget->specifyChan->setChecked( true ); | 222 | wlanconfigWiget->specifyChan->setChecked( true ); |
223 | wlanconfigWiget->networkChannel->setValue( chan ); | 223 | wlanconfigWiget->networkChannel->setValue( chan ); |
224 | } | 224 | } |
225 | }else if (action.contains("MacAddr")){ | 225 | }else if (action.contains("MacAddr")){ |
226 | wlanconfigWiget->specifyAp->setChecked( true ); | 226 | wlanconfigWiget->specifyAp->setChecked( true ); |
227 | wlanconfigWiget->macEdit->setText( value ); | 227 | wlanconfigWiget->macEdit->setText( value ); |
228 | }else | 228 | }else |
229 | qDebug("wlan plugin has no clue"); | 229 | qDebug("wlan plugin has no clue"); |
230 | } | 230 | } |
231 | qDebug("next stream"); | 231 | qDebug("next stream"); |
232 | }// while stream | 232 | }// while stream |
233 | qDebug("end of stream"); | 233 | qDebug("end of stream"); |
234 | if (toShow) toShow->exec(); | 234 | if (toShow) toShow->exec(); |
235 | qDebug("returning"); | 235 | qDebug("returning"); |
236 | } | 236 | } |
237 | 237 | ||
238 | QWidget *WLANModule::getInfo( Interface *i) | 238 | QWidget *WLANModule::getInfo( Interface *i) |
239 | { | 239 | { |
240 | qDebug("WLANModule::getInfo start"); | 240 | qDebug("WLANModule::getInfo start"); |
241 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); | 241 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); |
242 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); | 242 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); |
243 | info->tabWidget->insertTab(information, "TCP/IP", 0); | 243 | info->tabWidget->insertTab(information, "TCP/IP", 0); |
244 | info->tabWidget->setCurrentPage( 0 ); | 244 | info->tabWidget->setCurrentPage( 0 ); |
245 | info->tabWidget->showPage( information ); | 245 | info->tabWidget->showPage( information ); |
246 | if (info->tabWidget->currentPage() == information ) qDebug("infotab OK"); | 246 | if (info->tabWidget->currentPage() == information ) qDebug("infotab OK"); |
247 | else qDebug("infotab NOT OK"); | 247 | else qDebug("infotab NOT OK"); |
248 | qDebug("current idx %d", info->tabWidget->currentPageIndex()); | 248 | qDebug("current idx %d", info->tabWidget->currentPageIndex()); |
249 | qDebug("WLANModule::getInfo return"); | 249 | qDebug("WLANModule::getInfo return"); |
250 | return info; | 250 | return info; |
251 | } | 251 | } |
252 | 252 | ||