Diffstat (limited to 'noncore/net/networksetup/wlan') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/wlan/config.in | 4 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/info.ui | 321 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/infoimp.cpp | 56 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/infoimp.h | 27 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 200 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.h | 34 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlan.pro | 12 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlan.ui | 491 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 247 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.h | 34 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 113 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.h | 41 |
12 files changed, 0 insertions, 1580 deletions
diff --git a/noncore/net/networksetup/wlan/config.in b/noncore/net/networksetup/wlan/config.in deleted file mode 100644 index 36ced3a..0000000 --- a/noncore/net/networksetup/wlan/config.in +++ b/dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | config WLAN | ||
2 | boolean "Wireless LAN Module" | ||
3 | default "y" if NETWORKSETUP | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES | ||
diff --git a/noncore/net/networksetup/wlan/info.ui b/noncore/net/networksetup/wlan/info.ui deleted file mode 100644 index 7a5bf0b..0000000 --- a/noncore/net/networksetup/wlan/info.ui +++ b/dev/null | |||
@@ -1,321 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>WlanInfo</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>WlanInfo</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>238</width> | ||
15 | <height>316</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Interface Information</string> | ||
21 | </property> | ||
22 | <vbox> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>0</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>0</number> | ||
30 | </property> | ||
31 | <widget> | ||
32 | <class>QTabWidget</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>tabWidget</cstring> | ||
36 | </property> | ||
37 | <widget> | ||
38 | <class>QWidget</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>Widget2</cstring> | ||
42 | </property> | ||
43 | <attribute> | ||
44 | <name>title</name> | ||
45 | <string>802.11b</string> | ||
46 | </attribute> | ||
47 | <grid> | ||
48 | <property stdset="1"> | ||
49 | <name>margin</name> | ||
50 | <number>11</number> | ||
51 | </property> | ||
52 | <property stdset="1"> | ||
53 | <name>spacing</name> | ||
54 | <number>6</number> | ||
55 | </property> | ||
56 | <widget row="3" column="0" > | ||
57 | <class>QLabel</class> | ||
58 | <property stdset="1"> | ||
59 | <name>name</name> | ||
60 | <cstring>TextLabel4</cstring> | ||
61 | </property> | ||
62 | <property stdset="1"> | ||
63 | <name>text</name> | ||
64 | <string>Channel</string> | ||
65 | </property> | ||
66 | </widget> | ||
67 | <widget row="2" column="0" > | ||
68 | <class>QLabel</class> | ||
69 | <property stdset="1"> | ||
70 | <name>name</name> | ||
71 | <cstring>TextLabel3</cstring> | ||
72 | </property> | ||
73 | <property stdset="1"> | ||
74 | <name>text</name> | ||
75 | <string>Mode</string> | ||
76 | </property> | ||
77 | </widget> | ||
78 | <widget row="1" column="0" > | ||
79 | <class>QLabel</class> | ||
80 | <property stdset="1"> | ||
81 | <name>name</name> | ||
82 | <cstring>TextLabel2</cstring> | ||
83 | </property> | ||
84 | <property stdset="1"> | ||
85 | <name>text</name> | ||
86 | <string>ESSID</string> | ||
87 | </property> | ||
88 | </widget> | ||
89 | <widget row="0" column="0" > | ||
90 | <class>QLabel</class> | ||
91 | <property stdset="1"> | ||
92 | <name>name</name> | ||
93 | <cstring>TextLabel1</cstring> | ||
94 | </property> | ||
95 | <property stdset="1"> | ||
96 | <name>text</name> | ||
97 | <string>Station</string> | ||
98 | </property> | ||
99 | </widget> | ||
100 | <widget row="4" column="0" > | ||
101 | <class>QLabel</class> | ||
102 | <property stdset="1"> | ||
103 | <name>name</name> | ||
104 | <cstring>TextLabel9</cstring> | ||
105 | </property> | ||
106 | <property stdset="1"> | ||
107 | <name>text</name> | ||
108 | <string>AP</string> | ||
109 | </property> | ||
110 | </widget> | ||
111 | <widget row="4" column="1" > | ||
112 | <class>QLabel</class> | ||
113 | <property stdset="1"> | ||
114 | <name>name</name> | ||
115 | <cstring>apLabel</cstring> | ||
116 | </property> | ||
117 | <property stdset="1"> | ||
118 | <name>frameShape</name> | ||
119 | <enum>Panel</enum> | ||
120 | </property> | ||
121 | <property stdset="1"> | ||
122 | <name>frameShadow</name> | ||
123 | <enum>Sunken</enum> | ||
124 | </property> | ||
125 | </widget> | ||
126 | <widget row="2" column="1" > | ||
127 | <class>QLabel</class> | ||
128 | <property stdset="1"> | ||
129 | <name>name</name> | ||
130 | <cstring>modeLabel</cstring> | ||
131 | </property> | ||
132 | <property stdset="1"> | ||
133 | <name>frameShape</name> | ||
134 | <enum>Panel</enum> | ||
135 | </property> | ||
136 | <property stdset="1"> | ||
137 | <name>frameShadow</name> | ||
138 | <enum>Sunken</enum> | ||
139 | </property> | ||
140 | </widget> | ||
141 | <widget row="1" column="1" > | ||
142 | <class>QLabel</class> | ||
143 | <property stdset="1"> | ||
144 | <name>name</name> | ||
145 | <cstring>essidLabel</cstring> | ||
146 | </property> | ||
147 | <property stdset="1"> | ||
148 | <name>frameShape</name> | ||
149 | <enum>Panel</enum> | ||
150 | </property> | ||
151 | <property stdset="1"> | ||
152 | <name>frameShadow</name> | ||
153 | <enum>Sunken</enum> | ||
154 | </property> | ||
155 | </widget> | ||
156 | <widget row="0" column="1" > | ||
157 | <class>QLabel</class> | ||
158 | <property stdset="1"> | ||
159 | <name>name</name> | ||
160 | <cstring>stationLabel</cstring> | ||
161 | </property> | ||
162 | <property stdset="1"> | ||
163 | <name>frameShape</name> | ||
164 | <enum>Panel</enum> | ||
165 | </property> | ||
166 | <property stdset="1"> | ||
167 | <name>frameShadow</name> | ||
168 | <enum>Sunken</enum> | ||
169 | </property> | ||
170 | </widget> | ||
171 | <widget row="3" column="1" > | ||
172 | <class>QLabel</class> | ||
173 | <property stdset="1"> | ||
174 | <name>name</name> | ||
175 | <cstring>channelLabel</cstring> | ||
176 | </property> | ||
177 | <property stdset="1"> | ||
178 | <name>frameShape</name> | ||
179 | <enum>Panel</enum> | ||
180 | </property> | ||
181 | <property stdset="1"> | ||
182 | <name>frameShadow</name> | ||
183 | <enum>Sunken</enum> | ||
184 | </property> | ||
185 | </widget> | ||
186 | <spacer row="9" column="1" > | ||
187 | <property> | ||
188 | <name>name</name> | ||
189 | <cstring>Spacer7</cstring> | ||
190 | </property> | ||
191 | <property stdset="1"> | ||
192 | <name>orientation</name> | ||
193 | <enum>Vertical</enum> | ||
194 | </property> | ||
195 | <property stdset="1"> | ||
196 | <name>sizeType</name> | ||
197 | <enum>Expanding</enum> | ||
198 | </property> | ||
199 | <property> | ||
200 | <name>sizeHint</name> | ||
201 | <size> | ||
202 | <width>20</width> | ||
203 | <height>20</height> | ||
204 | </size> | ||
205 | </property> | ||
206 | </spacer> | ||
207 | <widget row="5" column="1" > | ||
208 | <class>QProgressBar</class> | ||
209 | <property stdset="1"> | ||
210 | <name>name</name> | ||
211 | <cstring>signalProgressBar</cstring> | ||
212 | </property> | ||
213 | </widget> | ||
214 | <widget row="6" column="1" > | ||
215 | <class>QProgressBar</class> | ||
216 | <property stdset="1"> | ||
217 | <name>name</name> | ||
218 | <cstring>noiseProgressBar</cstring> | ||
219 | </property> | ||
220 | </widget> | ||
221 | <widget row="7" column="1" > | ||
222 | <class>QProgressBar</class> | ||
223 | <property stdset="1"> | ||
224 | <name>name</name> | ||
225 | <cstring>qualityProgressBar</cstring> | ||
226 | </property> | ||
227 | </widget> | ||
228 | <widget row="8" column="1" > | ||
229 | <class>QLabel</class> | ||
230 | <property stdset="1"> | ||
231 | <name>name</name> | ||
232 | <cstring>rateLabel</cstring> | ||
233 | </property> | ||
234 | <property stdset="1"> | ||
235 | <name>sizePolicy</name> | ||
236 | <sizepolicy> | ||
237 | <hsizetype>7</hsizetype> | ||
238 | <vsizetype>1</vsizetype> | ||
239 | </sizepolicy> | ||
240 | </property> | ||
241 | <property stdset="1"> | ||
242 | <name>frameShape</name> | ||
243 | <enum>Panel</enum> | ||
244 | </property> | ||
245 | <property stdset="1"> | ||
246 | <name>frameShadow</name> | ||
247 | <enum>Sunken</enum> | ||
248 | </property> | ||
249 | </widget> | ||
250 | <widget row="8" column="0" > | ||
251 | <class>QLabel</class> | ||
252 | <property stdset="1"> | ||
253 | <name>name</name> | ||
254 | <cstring>TextLabel4_2</cstring> | ||
255 | </property> | ||
256 | <property stdset="1"> | ||
257 | <name>text</name> | ||
258 | <string>Rate</string> | ||
259 | </property> | ||
260 | </widget> | ||
261 | <widget row="7" column="0" > | ||
262 | <class>QLabel</class> | ||
263 | <property stdset="1"> | ||
264 | <name>name</name> | ||
265 | <cstring>TextLabel3_2</cstring> | ||
266 | </property> | ||
267 | <property stdset="1"> | ||
268 | <name>text</name> | ||
269 | <string>Quality</string> | ||
270 | </property> | ||
271 | </widget> | ||
272 | <widget row="6" column="0" > | ||
273 | <class>QLabel</class> | ||
274 | <property stdset="1"> | ||
275 | <name>name</name> | ||
276 | <cstring>TextLabel2_2</cstring> | ||
277 | </property> | ||
278 | <property stdset="1"> | ||
279 | <name>text</name> | ||
280 | <string>Noise</string> | ||
281 | </property> | ||
282 | </widget> | ||
283 | <widget row="5" column="0" > | ||
284 | <class>QLabel</class> | ||
285 | <property stdset="1"> | ||
286 | <name>name</name> | ||
287 | <cstring>TextLabel1_2</cstring> | ||
288 | </property> | ||
289 | <property stdset="1"> | ||
290 | <name>text</name> | ||
291 | <string>Signal</string> | ||
292 | </property> | ||
293 | </widget> | ||
294 | </grid> | ||
295 | </widget> | ||
296 | </widget> | ||
297 | </vbox> | ||
298 | </widget> | ||
299 | <customwidgets> | ||
300 | <customwidget> | ||
301 | <class>QWidget</class> | ||
302 | <header location="local">qwidget.h</header> | ||
303 | <sizehint> | ||
304 | <width>100</width> | ||
305 | <height>100</height> | ||
306 | </sizehint> | ||
307 | <container>0</container> | ||
308 | <sizepolicy> | ||
309 | <hordata>7</hordata> | ||
310 | <verdata>7</verdata> | ||
311 | </sizepolicy> | ||
312 | <pixmap>image0</pixmap> | ||
313 | </customwidget> | ||
314 | </customwidgets> | ||
315 | <images> | ||
316 | <image> | ||
317 | <name>image0</name> | ||
318 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | ||
319 | </image> | ||
320 | </images> | ||
321 | </UI> | ||
diff --git a/noncore/net/networksetup/wlan/infoimp.cpp b/noncore/net/networksetup/wlan/infoimp.cpp deleted file mode 100644 index bd56678..0000000 --- a/noncore/net/networksetup/wlan/infoimp.cpp +++ b/dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | #include "infoimp.h" | ||
2 | #include "wextensions.h" | ||
3 | |||
4 | #include <qtimer.h> | ||
5 | #include <qprogressbar.h> | ||
6 | #include <qlabel.h> | ||
7 | |||
8 | /** | ||
9 | * Constructor. If wireless extensions are enabled on device name then | ||
10 | * start a timer that every second will update the information. | ||
11 | */ | ||
12 | WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){ | ||
13 | WExtensions *wExtensions = new WExtensions(name); | ||
14 | if(!wExtensions->doesHaveWirelessExtensions()){ | ||
15 | delete wExtensions; | ||
16 | qDebug("WlanInfoImp::No wireless extension"); | ||
17 | return; | ||
18 | } | ||
19 | delete wExtensions; | ||
20 | timer = new QTimer( this ); | ||
21 | connect( timer, SIGNAL(timeout()), this, SLOT(update())); | ||
22 | timer->start( 1000, false ); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Updates the information about the wireless device. | ||
27 | */ | ||
28 | void WlanInfoImp::update(){ | ||
29 | WExtensions *wExtensions = new WExtensions(this->name()); | ||
30 | if(!wExtensions->doesHaveWirelessExtensions()){ | ||
31 | qDebug("No extension"); | ||
32 | delete wExtensions; | ||
33 | timer->stop(); | ||
34 | return; | ||
35 | } | ||
36 | essidLabel->setText(wExtensions->essid()); | ||
37 | apLabel->setText(wExtensions->ap()); | ||
38 | stationLabel->setText(wExtensions->station()); | ||
39 | modeLabel->setText(wExtensions->mode()); | ||
40 | channelLabel->setText(QString("%1").arg(wExtensions->channel())); | ||
41 | int signal = 0; | ||
42 | int noise = 0; | ||
43 | int quality = 0; | ||
44 | wExtensions->stats(signal, noise, quality); | ||
45 | if(signalProgressBar->progress() != signal) | ||
46 | signalProgressBar->setProgress(signal); | ||
47 | if(noiseProgressBar->progress() != noise) | ||
48 | noiseProgressBar->setProgress(noise); | ||
49 | if(qualityProgressBar->progress() != quality) | ||
50 | qualityProgressBar->setProgress(quality); | ||
51 | rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate())); | ||
52 | delete wExtensions; | ||
53 | } | ||
54 | |||
55 | // infoimp.cpp | ||
56 | |||
diff --git a/noncore/net/networksetup/wlan/infoimp.h b/noncore/net/networksetup/wlan/infoimp.h deleted file mode 100644 index 8f7f0d6..0000000 --- a/noncore/net/networksetup/wlan/infoimp.h +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | #ifndef INFOIMP_H | ||
2 | #define INFOIMP_H | ||
3 | |||
4 | #include "info.h" | ||
5 | |||
6 | class QTimer; | ||
7 | //class WExtensions; | ||
8 | |||
9 | class WlanInfoImp : public WlanInfo { | ||
10 | Q_OBJECT | ||
11 | |||
12 | public: | ||
13 | WlanInfoImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | ||
14 | |||
15 | private slots: | ||
16 | void update(); | ||
17 | |||
18 | private: | ||
19 | //WExtensions *wExtensions; | ||
20 | QTimer *timer; | ||
21 | |||
22 | }; | ||
23 | |||
24 | #endif | ||
25 | |||
26 | // infoimp.h | ||
27 | |||
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp deleted file mode 100644 index 827d075..0000000 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/dev/null | |||
@@ -1,200 +0,0 @@ | |||
1 | #include "wextensions.h" | ||
2 | |||
3 | #include <qfile.h> | ||
4 | #include <qtextstream.h> | ||
5 | |||
6 | #include <arpa/inet.h> | ||
7 | #include <sys/socket.h> | ||
8 | #include <sys/ioctl.h> | ||
9 | |||
10 | #include <math.h> | ||
11 | |||
12 | #define PROCNETWIRELESS "/proc/net/wireless" | ||
13 | #define IW_LOWER 0 | ||
14 | #define IW_UPPER 256 | ||
15 | |||
16 | /** | ||
17 | * Constructor. Sets hasWirelessExtensions | ||
18 | */ | ||
19 | WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { | ||
20 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); | ||
21 | if(fd == -1) | ||
22 | return; | ||
23 | |||
24 | const char* buffer[200]; | ||
25 | memset( &iwr, 0, sizeof( iwr ) ); | ||
26 | iwr.u.essid.pointer = (caddr_t) buffer; | ||
27 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | ||
28 | iwr.u.essid.flags = 0; | ||
29 | |||
30 | // check if it is an IEEE 802.11 standard conform | ||
31 | // wireless device by sending SIOCGIWESSID | ||
32 | // which also gives back the Extended Service Set ID | ||
33 | // (see IEEE 802.11 for more information) | ||
34 | |||
35 | const char* iname = interface.latin1(); | ||
36 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | ||
37 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) | ||
38 | hasWirelessExtensions = true; | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * @return QString the station name of the access point. | ||
43 | */ | ||
44 | QString WExtensions::station(){ | ||
45 | if(!hasWirelessExtensions) | ||
46 | return QString(); | ||
47 | const char* buffer[200]; | ||
48 | iwr.u.data.pointer = (caddr_t) buffer; | ||
49 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | ||
50 | iwr.u.data.flags = 0; | ||
51 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | ||
52 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | ||
53 | return QString(iwr.u.data.pointer); | ||
54 | } | ||
55 | return QString(); | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * @return QString the essid of the host 802.11 access point. | ||
60 | */ | ||
61 | QString WExtensions::essid(){ | ||
62 | if(!hasWirelessExtensions) | ||
63 | return QString(); | ||
64 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | ||
65 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | ||
66 | return QString(iwr.u.essid.pointer); | ||
67 | } | ||
68 | return QString(); | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * @return QString the mode of interface | ||
73 | */ | ||
74 | QString WExtensions::mode(){ | ||
75 | if(!hasWirelessExtensions) | ||
76 | return QString(); | ||
77 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | ||
78 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | ||
79 | return QString(); | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * Get the frequency that the interface is running at. | ||
84 | * @return int the frequency that the interfacae is running at. | ||
85 | */ | ||
86 | double WExtensions::frequency(){ | ||
87 | if(!hasWirelessExtensions) | ||
88 | return 0; | ||
89 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | ||
90 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * Get the channel that the interface is running at. | ||
96 | * @return int the channel that the interfacae is running at. | ||
97 | */ | ||
98 | int WExtensions::channel(){ | ||
99 | if(!hasWirelessExtensions) | ||
100 | return 0; | ||
101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) | ||
102 | return 0; | ||
103 | |||
104 | // http://www.elanix.com/pdf/an137e.pdf | ||
105 | |||
106 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | ||
107 | double left = 2.401; | ||
108 | double right = 2.416; | ||
109 | for(int channel = 1; channel<= 15; channel++){ | ||
110 | if( num >= left && num <= right ) | ||
111 | return channel; | ||
112 | left += 0.005; | ||
113 | right += 0.005; | ||
114 | } | ||
115 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); | ||
116 | return -1; | ||
117 | } | ||
118 | |||
119 | /*** | ||
120 | * Get the current rate that the card is transmiting at. | ||
121 | * @return double the rate, 0 if error. | ||
122 | */ | ||
123 | double WExtensions::rate(){ | ||
124 | if(!hasWirelessExtensions) | ||
125 | return 0; | ||
126 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | ||
127 | return ((double)iwr.u.bitrate.value)/1000000; | ||
128 | } | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | |||
133 | /** | ||
134 | * @return QString the AccessPoint that the interface is connected to. | ||
135 | */ | ||
136 | QString WExtensions::ap(){ | ||
137 | if(!hasWirelessExtensions) | ||
138 | return QString(); | ||
139 | if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ | ||
140 | QString ap; | ||
141 | ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | ||
142 | iwr.u.ap_addr.sa_data[0]&0xff, | ||
143 | iwr.u.ap_addr.sa_data[1]&0xff, | ||
144 | iwr.u.ap_addr.sa_data[2]&0xff, | ||
145 | iwr.u.ap_addr.sa_data[3]&0xff, | ||
146 | iwr.u.ap_addr.sa_data[4]&0xff, | ||
147 | iwr.u.ap_addr.sa_data[5]&0xff ); | ||
148 | return ap; | ||
149 | } | ||
150 | else return QString(); | ||
151 | } | ||
152 | |||
153 | /** | ||
154 | * Get the stats for interfaces | ||
155 | * @param signal the signal strength of interface | ||
156 | * @param noise the noise level of the interface | ||
157 | * @param quality the quality level of the interface | ||
158 | * @return bool true if successfull | ||
159 | */ | ||
160 | bool WExtensions::stats(int &signal, int &noise, int &quality){ | ||
161 | // gather link quality from /proc/net/wireless | ||
162 | if(!QFile::exists(PROCNETWIRELESS)) | ||
163 | return false; | ||
164 | |||
165 | char c; | ||
166 | QString status; | ||
167 | QString name; | ||
168 | |||
169 | QFile wfile( PROCNETWIRELESS ); | ||
170 | if(!wfile.open( IO_ReadOnly )) | ||
171 | return false; | ||
172 | |||
173 | QTextStream wstream( &wfile ); | ||
174 | wstream.readLine(); // skip the first two lines | ||
175 | wstream.readLine(); // because they only contain headers | ||
176 | while(!wstream.atEnd()){ | ||
177 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | ||
178 | if(name == QString("%1:").arg(interface)){ | ||
179 | if ( quality > 92 ) | ||
180 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | ||
181 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | ||
182 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | ||
183 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | ||
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()); | ||
186 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | ||
187 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | ||
188 | quality = ( quality*100 ) / 92; | ||
189 | return true; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | qDebug("WExtensions::statsCard no longer present."); | ||
194 | quality = -1; | ||
195 | signal = IW_LOWER; | ||
196 | noise = IW_LOWER; | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | // wextensions.cpp | ||
diff --git a/noncore/net/networksetup/wlan/wextensions.h b/noncore/net/networksetup/wlan/wextensions.h deleted file mode 100644 index a89e33a..0000000 --- a/noncore/net/networksetup/wlan/wextensions.h +++ b/dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | #ifndef WEXTENSIONS_H | ||
2 | #define WEXTENSIONS_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | |||
6 | #include <netinet/ip.h> | ||
7 | #include <linux/wireless.h> | ||
8 | |||
9 | class WExtensions { | ||
10 | |||
11 | public: | ||
12 | WExtensions(QString interfaceName); | ||
13 | QString getInterfaceName(){return interface;}; | ||
14 | bool doesHaveWirelessExtensions(){return hasWirelessExtensions;}; | ||
15 | QString station(); | ||
16 | QString essid(); | ||
17 | QString mode(); | ||
18 | double frequency(); | ||
19 | int channel(); | ||
20 | double rate(); | ||
21 | QString ap(); | ||
22 | bool stats( int &signal, int &noise, int &quality); | ||
23 | |||
24 | private: | ||
25 | bool hasWirelessExtensions; | ||
26 | QString interface; | ||
27 | |||
28 | // Used in we calls | ||
29 | struct iwreq iwr; | ||
30 | int fd; | ||
31 | |||
32 | }; | ||
33 | |||
34 | #endif | ||
diff --git a/noncore/net/networksetup/wlan/wlan.pro b/noncore/net/networksetup/wlan/wlan.pro deleted file mode 100644 index 23fc39a..0000000 --- a/noncore/net/networksetup/wlan/wlan.pro +++ b/dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on release | ||
3 | #CONFIG += qt warn_on debug | ||
4 | DESTDIR = $(OPIEDIR)/plugins/networksetup | ||
5 | HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h | ||
6 | SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp | ||
7 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | ||
8 | DEPENDPATH+= $(OPIEDIR)/include | ||
9 | LIBS += -lqpe -L../interfaces/ -linterfaces | ||
10 | INTERFACES= wlan.ui info.ui | ||
11 | TARGET = wlanplugin | ||
12 | VERSION = 1.0.0 | ||
diff --git a/noncore/net/networksetup/wlan/wlan.ui b/noncore/net/networksetup/wlan/wlan.ui deleted file mode 100644 index 744c559..0000000 --- a/noncore/net/networksetup/wlan/wlan.ui +++ b/dev/null | |||
@@ -1,491 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>WLAN</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>WLAN</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>239</width> | ||
15 | <height>277</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Wireless LAN Setting</string> | ||
21 | </property> | ||
22 | <property stdset="1"> | ||
23 | <name>sizeGripEnabled</name> | ||
24 | <bool>true</bool> | ||
25 | </property> | ||
26 | <property> | ||
27 | <name>layoutMargin</name> | ||
28 | </property> | ||
29 | <vbox> | ||
30 | <property stdset="1"> | ||
31 | <name>margin</name> | ||
32 | <number>0</number> | ||
33 | </property> | ||
34 | <property stdset="1"> | ||
35 | <name>spacing</name> | ||
36 | <number>6</number> | ||
37 | </property> | ||
38 | <widget> | ||
39 | <class>QTabWidget</class> | ||
40 | <property stdset="1"> | ||
41 | <name>name</name> | ||
42 | <cstring>tabWidget</cstring> | ||
43 | </property> | ||
44 | <property stdset="1"> | ||
45 | <name>enabled</name> | ||
46 | <bool>true</bool> | ||
47 | </property> | ||
48 | <widget> | ||
49 | <class>QWidget</class> | ||
50 | <property stdset="1"> | ||
51 | <name>name</name> | ||
52 | <cstring>ConfigPage</cstring> | ||
53 | </property> | ||
54 | <attribute> | ||
55 | <name>title</name> | ||
56 | <string>General</string> | ||
57 | </attribute> | ||
58 | <vbox> | ||
59 | <property stdset="1"> | ||
60 | <name>margin</name> | ||
61 | <number>11</number> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>spacing</name> | ||
65 | <number>6</number> | ||
66 | </property> | ||
67 | <widget> | ||
68 | <class>QCheckBox</class> | ||
69 | <property stdset="1"> | ||
70 | <name>name</name> | ||
71 | <cstring>essAny</cstring> | ||
72 | </property> | ||
73 | <property stdset="1"> | ||
74 | <name>text</name> | ||
75 | <string>&Specify Access Point</string> | ||
76 | </property> | ||
77 | </widget> | ||
78 | <widget> | ||
79 | <class>QGroupBox</class> | ||
80 | <property stdset="1"> | ||
81 | <name>name</name> | ||
82 | <cstring>GroupBox1</cstring> | ||
83 | </property> | ||
84 | <property stdset="1"> | ||
85 | <name>enabled</name> | ||
86 | <bool>false</bool> | ||
87 | </property> | ||
88 | <property stdset="1"> | ||
89 | <name>title</name> | ||
90 | <string>Specific &Access Point Settings</string> | ||
91 | </property> | ||
92 | <grid> | ||
93 | <property stdset="1"> | ||
94 | <name>margin</name> | ||
95 | <number>11</number> | ||
96 | </property> | ||
97 | <property stdset="1"> | ||
98 | <name>spacing</name> | ||
99 | <number>6</number> | ||
100 | </property> | ||
101 | <widget row="0" column="0" > | ||
102 | <class>QLabel</class> | ||
103 | <property stdset="1"> | ||
104 | <name>name</name> | ||
105 | <cstring>TextLabel1</cstring> | ||
106 | </property> | ||
107 | <property stdset="1"> | ||
108 | <name>text</name> | ||
109 | <string>ESS-ID</string> | ||
110 | </property> | ||
111 | </widget> | ||
112 | <widget row="1" column="0" > | ||
113 | <class>QLabel</class> | ||
114 | <property stdset="1"> | ||
115 | <name>name</name> | ||
116 | <cstring>TextLabel2</cstring> | ||
117 | </property> | ||
118 | <property stdset="1"> | ||
119 | <name>text</name> | ||
120 | <string>Network Type</string> | ||
121 | </property> | ||
122 | </widget> | ||
123 | <widget row="0" column="1" rowspan="1" colspan="2" > | ||
124 | <class>QLineEdit</class> | ||
125 | <property stdset="1"> | ||
126 | <name>name</name> | ||
127 | <cstring>essSpecificLineEdit</cstring> | ||
128 | </property> | ||
129 | </widget> | ||
130 | <widget row="1" column="1" rowspan="1" colspan="2" > | ||
131 | <class>QComboBox</class> | ||
132 | <item> | ||
133 | <property> | ||
134 | <name>text</name> | ||
135 | <string>Infrastructure</string> | ||
136 | </property> | ||
137 | </item> | ||
138 | <item> | ||
139 | <property> | ||
140 | <name>text</name> | ||
141 | <string>Ad-Hoc</string> | ||
142 | </property> | ||
143 | </item> | ||
144 | <property stdset="1"> | ||
145 | <name>name</name> | ||
146 | <cstring>networkType</cstring> | ||
147 | </property> | ||
148 | </widget> | ||
149 | <widget row="2" column="0" > | ||
150 | <class>QLabel</class> | ||
151 | <property stdset="1"> | ||
152 | <name>name</name> | ||
153 | <cstring>channelLabel</cstring> | ||
154 | </property> | ||
155 | <property stdset="1"> | ||
156 | <name>text</name> | ||
157 | <string>Channel</string> | ||
158 | </property> | ||
159 | </widget> | ||
160 | <widget row="2" column="1" > | ||
161 | <class>QSpinBox</class> | ||
162 | <property stdset="1"> | ||
163 | <name>name</name> | ||
164 | <cstring>networkChannel</cstring> | ||
165 | </property> | ||
166 | <property stdset="1"> | ||
167 | <name>enabled</name> | ||
168 | <bool>false</bool> | ||
169 | </property> | ||
170 | <property stdset="1"> | ||
171 | <name>maxValue</name> | ||
172 | <number>15</number> | ||
173 | </property> | ||
174 | <property stdset="1"> | ||
175 | <name>minValue</name> | ||
176 | <number>1</number> | ||
177 | </property> | ||
178 | <property stdset="1"> | ||
179 | <name>value</name> | ||
180 | <number>6</number> | ||
181 | </property> | ||
182 | </widget> | ||
183 | <spacer row="2" column="2" > | ||
184 | <property> | ||
185 | <name>name</name> | ||
186 | <cstring>Spacer4</cstring> | ||
187 | </property> | ||
188 | <property stdset="1"> | ||
189 | <name>orientation</name> | ||
190 | <enum>Horizontal</enum> | ||
191 | </property> | ||
192 | <property stdset="1"> | ||
193 | <name>sizeType</name> | ||
194 | <enum>Expanding</enum> | ||
195 | </property> | ||
196 | <property> | ||
197 | <name>sizeHint</name> | ||
198 | <size> | ||
199 | <width>20</width> | ||
200 | <height>20</height> | ||
201 | </size> | ||
202 | </property> | ||
203 | </spacer> | ||
204 | </grid> | ||
205 | </widget> | ||
206 | <spacer> | ||
207 | <property> | ||
208 | <name>name</name> | ||
209 | <cstring>Spacer31</cstring> | ||
210 | </property> | ||
211 | <property stdset="1"> | ||
212 | <name>orientation</name> | ||
213 | <enum>Vertical</enum> | ||
214 | </property> | ||
215 | <property stdset="1"> | ||
216 | <name>sizeType</name> | ||
217 | <enum>Expanding</enum> | ||
218 | </property> | ||
219 | <property> | ||
220 | <name>sizeHint</name> | ||
221 | <size> | ||
222 | <width>20</width> | ||
223 | <height>20</height> | ||
224 | </size> | ||
225 | </property> | ||
226 | </spacer> | ||
227 | </vbox> | ||
228 | </widget> | ||
229 | <widget> | ||
230 | <class>QWidget</class> | ||
231 | <property stdset="1"> | ||
232 | <name>name</name> | ||
233 | <cstring>WepPage</cstring> | ||
234 | </property> | ||
235 | <attribute> | ||
236 | <name>title</name> | ||
237 | <string>Encryption</string> | ||
238 | </attribute> | ||
239 | <vbox> | ||
240 | <property stdset="1"> | ||
241 | <name>margin</name> | ||
242 | <number>11</number> | ||
243 | </property> | ||
244 | <property stdset="1"> | ||
245 | <name>spacing</name> | ||
246 | <number>6</number> | ||
247 | </property> | ||
248 | <widget> | ||
249 | <class>QCheckBox</class> | ||
250 | <property stdset="1"> | ||
251 | <name>name</name> | ||
252 | <cstring>wepEnabled</cstring> | ||
253 | </property> | ||
254 | <property stdset="1"> | ||
255 | <name>text</name> | ||
256 | <string>&Enable WEP</string> | ||
257 | </property> | ||
258 | </widget> | ||
259 | <widget> | ||
260 | <class>QButtonGroup</class> | ||
261 | <property stdset="1"> | ||
262 | <name>name</name> | ||
263 | <cstring>ButtonGroup43</cstring> | ||
264 | </property> | ||
265 | <property stdset="1"> | ||
266 | <name>enabled</name> | ||
267 | <bool>false</bool> | ||
268 | </property> | ||
269 | <property stdset="1"> | ||
270 | <name>title</name> | ||
271 | <string>&Authentication Type</string> | ||
272 | </property> | ||
273 | <hbox> | ||
274 | <property stdset="1"> | ||
275 | <name>margin</name> | ||
276 | <number>11</number> | ||
277 | </property> | ||
278 | <property stdset="1"> | ||
279 | <name>spacing</name> | ||
280 | <number>6</number> | ||
281 | </property> | ||
282 | <widget> | ||
283 | <class>QRadioButton</class> | ||
284 | <property stdset="1"> | ||
285 | <name>name</name> | ||
286 | <cstring>authOpen</cstring> | ||
287 | </property> | ||
288 | <property stdset="1"> | ||
289 | <name>text</name> | ||
290 | <string>&Open System</string> | ||
291 | </property> | ||
292 | <property stdset="1"> | ||
293 | <name>checked</name> | ||
294 | <bool>true</bool> | ||
295 | </property> | ||
296 | </widget> | ||
297 | <widget> | ||
298 | <class>QRadioButton</class> | ||
299 | <property stdset="1"> | ||
300 | <name>name</name> | ||
301 | <cstring>authShared</cstring> | ||
302 | </property> | ||
303 | <property stdset="1"> | ||
304 | <name>text</name> | ||
305 | <string>&Shared Key</string> | ||
306 | </property> | ||
307 | </widget> | ||
308 | </hbox> | ||
309 | </widget> | ||
310 | <widget> | ||
311 | <class>QButtonGroup</class> | ||
312 | <property stdset="1"> | ||
313 | <name>name</name> | ||
314 | <cstring>KeyButtonGroup</cstring> | ||
315 | </property> | ||
316 | <property stdset="1"> | ||
317 | <name>enabled</name> | ||
318 | <bool>false</bool> | ||
319 | </property> | ||
320 | <property stdset="1"> | ||
321 | <name>title</name> | ||
322 | <string>&Key Setting</string> | ||
323 | </property> | ||
324 | <grid> | ||
325 | <property stdset="1"> | ||
326 | <name>margin</name> | ||
327 | <number>11</number> | ||
328 | </property> | ||
329 | <property stdset="1"> | ||
330 | <name>spacing</name> | ||
331 | <number>6</number> | ||
332 | </property> | ||
333 | <widget row="0" column="1" > | ||
334 | <class>QLineEdit</class> | ||
335 | <property stdset="1"> | ||
336 | <name>name</name> | ||
337 | <cstring>keyLineEdit0</cstring> | ||
338 | </property> | ||
339 | <property stdset="1"> | ||
340 | <name>echoMode</name> | ||
341 | <enum>Password</enum> | ||
342 | </property> | ||
343 | </widget> | ||
344 | <widget row="1" column="1" > | ||
345 | <class>QLineEdit</class> | ||
346 | <property stdset="1"> | ||
347 | <name>name</name> | ||
348 | <cstring>keyLineEdit1</cstring> | ||
349 | </property> | ||
350 | <property stdset="1"> | ||
351 | <name>echoMode</name> | ||
352 | <enum>Password</enum> | ||
353 | </property> | ||
354 | </widget> | ||
355 | <widget row="2" column="1" > | ||
356 | <class>QLineEdit</class> | ||
357 | <property stdset="1"> | ||
358 | <name>name</name> | ||
359 | <cstring>keyLineEdit2</cstring> | ||
360 | </property> | ||
361 | <property stdset="1"> | ||
362 | <name>echoMode</name> | ||
363 | <enum>Password</enum> | ||
364 | </property> | ||
365 | </widget> | ||
366 | <widget row="3" column="1" > | ||
367 | <class>QLineEdit</class> | ||
368 | <property stdset="1"> | ||
369 | <name>name</name> | ||
370 | <cstring>keyLineEdit3</cstring> | ||
371 | </property> | ||
372 | <property stdset="1"> | ||
373 | <name>echoMode</name> | ||
374 | <enum>Password</enum> | ||
375 | </property> | ||
376 | </widget> | ||
377 | <widget row="0" column="0" > | ||
378 | <class>QRadioButton</class> | ||
379 | <property stdset="1"> | ||
380 | <name>name</name> | ||
381 | <cstring>keyRadio0</cstring> | ||
382 | </property> | ||
383 | <property stdset="1"> | ||
384 | <name>text</name> | ||
385 | <string>Key 1</string> | ||
386 | </property> | ||
387 | <property stdset="1"> | ||
388 | <name>checked</name> | ||
389 | <bool>true</bool> | ||
390 | </property> | ||
391 | </widget> | ||
392 | <widget row="1" column="0" > | ||
393 | <class>QRadioButton</class> | ||
394 | <property stdset="1"> | ||
395 | <name>name</name> | ||
396 | <cstring>keyRadio1</cstring> | ||
397 | </property> | ||
398 | <property stdset="1"> | ||
399 | <name>text</name> | ||
400 | <string>Key 2</string> | ||
401 | </property> | ||
402 | </widget> | ||
403 | <widget row="2" column="0" > | ||
404 | <class>QRadioButton</class> | ||
405 | <property stdset="1"> | ||
406 | <name>name</name> | ||
407 | <cstring>keyRadio2</cstring> | ||
408 | </property> | ||
409 | <property stdset="1"> | ||
410 | <name>text</name> | ||
411 | <string>Key 3</string> | ||
412 | </property> | ||
413 | </widget> | ||
414 | <widget row="3" column="0" > | ||
415 | <class>QRadioButton</class> | ||
416 | <property stdset="1"> | ||
417 | <name>name</name> | ||
418 | <cstring>keyRadio3</cstring> | ||
419 | </property> | ||
420 | <property stdset="1"> | ||
421 | <name>text</name> | ||
422 | <string>Key 4</string> | ||
423 | </property> | ||
424 | </widget> | ||
425 | </grid> | ||
426 | </widget> | ||
427 | <spacer> | ||
428 | <property> | ||
429 | <name>name</name> | ||
430 | <cstring>Spacer30</cstring> | ||
431 | </property> | ||
432 | <property stdset="1"> | ||
433 | <name>orientation</name> | ||
434 | <enum>Vertical</enum> | ||
435 | </property> | ||
436 | <property stdset="1"> | ||
437 | <name>sizeType</name> | ||
438 | <enum>Expanding</enum> | ||
439 | </property> | ||
440 | <property> | ||
441 | <name>sizeHint</name> | ||
442 | <size> | ||
443 | <width>20</width> | ||
444 | <height>20</height> | ||
445 | </size> | ||
446 | </property> | ||
447 | </spacer> | ||
448 | </vbox> | ||
449 | </widget> | ||
450 | </widget> | ||
451 | </vbox> | ||
452 | </widget> | ||
453 | <connections> | ||
454 | <connection> | ||
455 | <sender>wepEnabled</sender> | ||
456 | <signal>toggled(bool)</signal> | ||
457 | <receiver>ButtonGroup43</receiver> | ||
458 | <slot>setEnabled(bool)</slot> | ||
459 | </connection> | ||
460 | <connection> | ||
461 | <sender>wepEnabled</sender> | ||
462 | <signal>toggled(bool)</signal> | ||
463 | <receiver>KeyButtonGroup</receiver> | ||
464 | <slot>setEnabled(bool)</slot> | ||
465 | </connection> | ||
466 | <connection> | ||
467 | <sender>essAny</sender> | ||
468 | <signal>toggled(bool)</signal> | ||
469 | <receiver>GroupBox1</receiver> | ||
470 | <slot>setEnabled(bool)</slot> | ||
471 | </connection> | ||
472 | </connections> | ||
473 | <tabstops> | ||
474 | <tabstop>tabWidget</tabstop> | ||
475 | <tabstop>essAny</tabstop> | ||
476 | <tabstop>essSpecificLineEdit</tabstop> | ||
477 | <tabstop>networkType</tabstop> | ||
478 | <tabstop>networkChannel</tabstop> | ||
479 | <tabstop>wepEnabled</tabstop> | ||
480 | <tabstop>authOpen</tabstop> | ||
481 | <tabstop>authShared</tabstop> | ||
482 | <tabstop>keyRadio0</tabstop> | ||
483 | <tabstop>keyLineEdit0</tabstop> | ||
484 | <tabstop>keyRadio1</tabstop> | ||
485 | <tabstop>keyLineEdit1</tabstop> | ||
486 | <tabstop>keyRadio2</tabstop> | ||
487 | <tabstop>keyLineEdit2</tabstop> | ||
488 | <tabstop>keyRadio3</tabstop> | ||
489 | <tabstop>keyLineEdit3</tabstop> | ||
490 | </tabstops> | ||
491 | </UI> | ||
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp deleted file mode 100644 index 1782c22..0000000 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/dev/null | |||
@@ -1,247 +0,0 @@ | |||
1 | #include "wlanimp.h" | ||
2 | #include "interfacesetupimp.h" | ||
3 | |||
4 | #include <qfile.h> | ||
5 | #include <qdir.h> | ||
6 | #include <qtextstream.h> | ||
7 | #include <qmessagebox.h> | ||
8 | #include <qlineedit.h> | ||
9 | #include <qlabel.h> | ||
10 | #include <qspinbox.h> | ||
11 | #include <qradiobutton.h> | ||
12 | #include <qcheckbox.h> | ||
13 | #include <qtabwidget.h> | ||
14 | #include <qcombobox.h> | ||
15 | |||
16 | /* system() */ | ||
17 | #include <stdlib.h> | ||
18 | |||
19 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | ||
20 | |||
21 | /** | ||
22 | * Constructor, read in the wireless.opts file for parsing later. | ||
23 | */ | ||
24 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { | ||
25 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); | ||
26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | ||
27 | |||
28 | // Read in the config file. | ||
29 | QString wlanFile = WIRELESS_OPTS; | ||
30 | QFile file(wlanFile); | ||
31 | if (file.open(IO_ReadOnly)){ | ||
32 | QTextStream stream( &file ); | ||
33 | QString line = ""; | ||
34 | while ( !stream.eof() ) { | ||
35 | line += stream.readLine(); | ||
36 | line += "\n"; | ||
37 | } | ||
38 | file.close(); | ||
39 | settingsFileText = QStringList::split("\n", line, true); | ||
40 | parseSettingFile(); | ||
41 | } | ||
42 | else | ||
43 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); | ||
44 | connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); | ||
45 | } | ||
46 | |||
47 | void WLANImp::typeChanged(int mod){ | ||
48 | networkChannel->setEnabled(mod); | ||
49 | channelLabel->setEnabled(mod); | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * Change the profile for both wireless settings and network settings. | ||
54 | */ | ||
55 | void WLANImp::setProfile(const QString &profile){ | ||
56 | interfaceSetup->setProfile(profile); | ||
57 | parseSettingFile(); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * Parses the settings file that was read in and gets any setting from it. | ||
62 | */ | ||
63 | void WLANImp::parseSettingFile(){ | ||
64 | bool foundCase = false; | ||
65 | bool found = false; | ||
66 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | ||
67 | QString line = (*it).simplifyWhiteSpace(); | ||
68 | if(line.contains("case")) | ||
69 | foundCase = true; | ||
70 | // See if we found our scheme to write or the sceme couldn't be found | ||
71 | if((foundCase && line.contains("esac")) || | ||
72 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) | ||
73 | found = true; | ||
74 | |||
75 | if(line.contains(";;")) | ||
76 | found = false; | ||
77 | if(found){ | ||
78 | // write out scheme | ||
79 | if(line.contains("ESSID=")){ | ||
80 | QString id = line.mid(line.find("ESSID=")+6, line.length()); | ||
81 | if(id == "any"){ | ||
82 | essAny->setChecked(false); | ||
83 | }else{ | ||
84 | essAny->setChecked(true); | ||
85 | essSpecificLineEdit->setText(id); | ||
86 | } | ||
87 | } | ||
88 | if(line.contains("MODE=")){ | ||
89 | QString mode = line.mid(line.find("MODE=")+5, line.length()); | ||
90 | if(mode == "Managed"){ | ||
91 | networkType->setCurrentItem(0); | ||
92 | channelLabel->setEnabled(false); | ||
93 | networkChannel->setEnabled(false); | ||
94 | } | ||
95 | else{ | ||
96 | networkType->setCurrentItem(1); | ||
97 | networkChannel->setEnabled(true); | ||
98 | channelLabel->setEnabled(true); | ||
99 | } | ||
100 | } | ||
101 | if(line.contains("#KEY0=")) | ||
102 | keyLineEdit0->setText(line.mid(6, line.length())); | ||
103 | if(line.contains("#KEY1=")) | ||
104 | keyLineEdit1->setText(line.mid(6, line.length())); | ||
105 | if(line.contains("#KEY2=")) | ||
106 | keyLineEdit2->setText(line.mid(6, line.length())); | ||
107 | if(line.contains("#KEY3=")) | ||
108 | keyLineEdit3->setText(line.mid(6, line.length())); | ||
109 | |||
110 | if(line.contains("KEY=")){ | ||
111 | wepEnabled->setChecked(true); | ||
112 | QString key; | ||
113 | if(line.right(5) == (" open")){ | ||
114 | key = line.mid(4, line.length()-5); | ||
115 | authOpen->setChecked(true); | ||
116 | authShared->setChecked(false); | ||
117 | } | ||
118 | else{ | ||
119 | authOpen->setChecked(false); | ||
120 | authShared->setChecked(true); | ||
121 | key = line.mid(4, line.length()); | ||
122 | } | ||
123 | if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); | ||
124 | if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); | ||
125 | if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); | ||
126 | if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); | ||
127 | } | ||
128 | if(line.contains("CHANNEL=")){ | ||
129 | networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * Saves settings to the wireless.opts file using the current profile | ||
137 | */ | ||
138 | void WLANImp::changeAndSaveSettingFile(){ | ||
139 | QString wlanFile = WIRELESS_OPTS; | ||
140 | QFile::remove(wlanFile); | ||
141 | QFile file(wlanFile); | ||
142 | |||
143 | if (!file.open(IO_ReadWrite)){ | ||
144 | qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | QTextStream stream( &file ); | ||
149 | bool foundCase = false; | ||
150 | bool found = false; | ||
151 | bool output = true; | ||
152 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | ||
153 | QString line = (*it).simplifyWhiteSpace(); | ||
154 | if(line.contains("case")) | ||
155 | foundCase = true; | ||
156 | // See if we found our scheme to write or the sceme couldn't be found | ||
157 | if((foundCase && line.contains("esac") && !found) || | ||
158 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ | ||
159 | // write out scheme | ||
160 | found = true; | ||
161 | output = false; | ||
162 | |||
163 | if(!line.contains("esac")) | ||
164 | stream << line << "\n"; | ||
165 | if(!essAny->isChecked() == true){ | ||
166 | stream << "\tESSID=any\n"; | ||
167 | stream << "\tMODE=Managed\n"; | ||
168 | } | ||
169 | else{ | ||
170 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; | ||
171 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; | ||
172 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | ||
173 | } | ||
174 | |||
175 | stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; | ||
176 | stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; | ||
177 | stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; | ||
178 | stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; | ||
179 | |||
180 | if(wepEnabled->isChecked()){ | ||
181 | stream << "\tKEY=\""; | ||
182 | if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); | ||
183 | if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); | ||
184 | if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); | ||
185 | if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); | ||
186 | if(authOpen->isChecked()) | ||
187 | stream << " open"; | ||
188 | else | ||
189 | stream << " restricted"; | ||
190 | stream << "\"\n"; | ||
191 | } | ||
192 | stream << "\tRATE=auto\n"; | ||
193 | if(line.contains("esac")) | ||
194 | stream << line << "\n"; | ||
195 | } | ||
196 | if(line.contains(";;")) | ||
197 | output = true; | ||
198 | if(output && (*it).length() ) | ||
199 | stream << (*it) << '\n'; | ||
200 | } | ||
201 | file.close(); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * Check to see if the current config is valid | ||
206 | * Save wireless.opts, save interfaces | ||
207 | */ | ||
208 | void WLANImp::accept(){ | ||
209 | if(wepEnabled->isChecked()){ | ||
210 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ | ||
211 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); | ||
212 | return; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){ | ||
217 | QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); | ||
218 | return; | ||
219 | } | ||
220 | |||
221 | // Ok settings are good here, save | ||
222 | changeAndSaveSettingFile(); | ||
223 | |||
224 | // Try to save the interfaces settings. | ||
225 | if(!interfaceSetup->saveChanges()) | ||
226 | return; | ||
227 | |||
228 | // Restart the device now that the settings have changed | ||
229 | QString initpath; | ||
230 | if( QDir("/etc/rc.d/init.d").exists() ) | ||
231 | initpath = "/etc/rc.d/init.d"; | ||
232 | else if( QDir("/etc/init.d").exists() ) | ||
233 | initpath = "/etc/init.d"; | ||
234 | |||
235 | // It would be kinda cool if we didn't have to do this and could just to ifup/down | ||
236 | |||
237 | if( initpath ) | ||
238 | system(QString("%1/pcmcia stop").arg(initpath)); | ||
239 | if( initpath ) | ||
240 | system(QString("%1/pcmcia start").arg(initpath)); | ||
241 | |||
242 | // Close out the dialog | ||
243 | QDialog::accept(); | ||
244 | } | ||
245 | |||
246 | // wlanimp.cpp | ||
247 | |||
diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h deleted file mode 100644 index 310836c..0000000 --- a/noncore/net/networksetup/wlan/wlanimp.h +++ b/dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | #ifndef WLANIMP_H | ||
2 | #define WLANIMP_H | ||
3 | |||
4 | #include "wlan.h" | ||
5 | #include <qstringlist.h> | ||
6 | |||
7 | class InterfaceSetupImp; | ||
8 | class Interface; | ||
9 | class Config; | ||
10 | |||
11 | class WLANImp : public WLAN { | ||
12 | Q_OBJECT | ||
13 | |||
14 | public: | ||
15 | WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); | ||
16 | void setProfile(const QString &profile); | ||
17 | |||
18 | protected: | ||
19 | void accept(); | ||
20 | |||
21 | private slots: | ||
22 | void typeChanged(int); | ||
23 | |||
24 | private: | ||
25 | void parseSettingFile(); | ||
26 | void changeAndSaveSettingFile(); | ||
27 | |||
28 | InterfaceSetupImp *interfaceSetup; | ||
29 | QStringList settingsFileText; | ||
30 | QString currentProfile; | ||
31 | }; | ||
32 | |||
33 | #endif | ||
34 | |||
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp deleted file mode 100644 index 3979e60..0000000 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | #include "wlanmodule.h" | ||
2 | #include "wlanimp.h" | ||
3 | #include "infoimp.h" | ||
4 | #include "wextensions.h" | ||
5 | #include "interfaceinformationimp.h" | ||
6 | |||
7 | #include <qlabel.h> | ||
8 | #include <qprogressbar.h> | ||
9 | #include <qtabwidget.h> | ||
10 | |||
11 | /** | ||
12 | * Constructor, find all of the possible interfaces | ||
13 | */ | ||
14 | WLANModule::WLANModule() : Module() { | ||
15 | } | ||
16 | |||
17 | /** | ||
18 | * Delete any interfaces that we own. | ||
19 | */ | ||
20 | WLANModule::~WLANModule(){ | ||
21 | Interface *i; | ||
22 | for ( i=list.first(); i != 0; i=list.next() ) | ||
23 | delete i; | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * Change the current profile | ||
28 | */ | ||
29 | void WLANModule::setProfile(const QString &newProfile){ | ||
30 | profile = newProfile; | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * get the icon name for this device. | ||
35 | * @param Interface* can be used in determining the icon. | ||
36 | * @return QString the icon name (minus .png, .gif etc) | ||
37 | */ | ||
38 | QString WLANModule::getPixmapName(Interface* ){ | ||
39 | return "wlan"; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * Check to see if the interface i is owned by this module. | ||
44 | * @param Interface* interface to check against | ||
45 | * @return bool true if i is owned by this module, false otherwise. | ||
46 | */ | ||
47 | bool WLANModule::isOwner(Interface *i){ | ||
48 | WExtensions we(i->getInterfaceName()); | ||
49 | if(!we.doesHaveWirelessExtensions()) | ||
50 | return false; | ||
51 | |||
52 | i->setHardwareName("802.11b"); | ||
53 | list.append(i); | ||
54 | return true; | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * Create, and return the WLANConfigure Module | ||
59 | * @return QWidget* pointer to this modules configure. | ||
60 | */ | ||
61 | QWidget *WLANModule::configure(Interface *i){ | ||
62 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); | ||
63 | wlanconfig->setProfile(profile); | ||
64 | return wlanconfig; | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * Create, and return the Information Module | ||
69 | * @return QWidget* pointer to this modules info. | ||
70 | */ | ||
71 | QWidget *WLANModule::information(Interface *i){ | ||
72 | WExtensions we(i->getInterfaceName()); | ||
73 | if(!we.doesHaveWirelessExtensions()) | ||
74 | return NULL; | ||
75 | |||
76 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); | ||
77 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); | ||
78 | info->tabWidget->insertTab(information, "TCP/IP"); | ||
79 | return info; | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * Get all active (up or down) interfaces | ||
84 | * @return QList<Interface> A list of interfaces that exsist that havn't | ||
85 | * been called by isOwner() | ||
86 | */ | ||
87 | QList<Interface> WLANModule::getInterfaces(){ | ||
88 | return list; | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * Attempt to add a new interface as defined by name | ||
93 | * @param name the name of the type of interface that should be created given | ||
94 | * by possibleNewInterfaces(); | ||
95 | * @return Interface* NULL if it was unable to be created. | ||
96 | */ | ||
97 | Interface *WLANModule::addNewInterface(const QString &){ | ||
98 | // We can't add a 802.11 interface, either the hardware will be there | ||
99 | // or it wont. | ||
100 | return NULL; | ||
101 | } | ||
102 | |||
103 | /** | ||
104 | * Attempts to remove the interface, doesn't delete i | ||
105 | * @return bool true if successfull, false otherwise. | ||
106 | */ | ||
107 | bool WLANModule::remove(Interface*){ | ||
108 | // Can't remove a hardware device, you can stop it though. | ||
109 | return false; | ||
110 | } | ||
111 | |||
112 | // wlanmodule.cpp | ||
113 | |||
diff --git a/noncore/net/networksetup/wlan/wlanmodule.h b/noncore/net/networksetup/wlan/wlanmodule.h deleted file mode 100644 index 3a54de6..0000000 --- a/noncore/net/networksetup/wlan/wlanmodule.h +++ b/dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | #ifndef WLAN_MODULE_H | ||
2 | #define WLAN_MODULE_H | ||
3 | |||
4 | #include "module.h" | ||
5 | |||
6 | class WLANModule : Module{ | ||
7 | |||
8 | signals: | ||
9 | void updateInterface(Interface *i); | ||
10 | |||
11 | public: | ||
12 | WLANModule(); | ||
13 | ~WLANModule(); | ||
14 | |||
15 | void setProfile(const QString &newProfile); | ||
16 | bool isOwner(Interface *); | ||
17 | QWidget *configure(Interface *i); | ||
18 | QWidget *information(Interface *i); | ||
19 | QList<Interface> getInterfaces(); | ||
20 | void possibleNewInterfaces(QMap<QString, QString> &){}; | ||
21 | Interface *addNewInterface(const QString &name); | ||
22 | bool remove(Interface* i); | ||
23 | QString getPixmapName(Interface* i); | ||
24 | |||
25 | private: | ||
26 | QList<Interface> list; | ||
27 | QString profile; | ||
28 | |||
29 | }; | ||
30 | |||
31 | extern "C" | ||
32 | { | ||
33 | void* create_plugin() { | ||
34 | return new WLANModule(); | ||
35 | } | ||
36 | }; | ||
37 | |||
38 | #endif | ||
39 | |||
40 | // wlanmodule.h | ||
41 | |||