4 files changed, 189 insertions, 52 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index 8a9db66..64d8752 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -66,16 +66,19 @@ QString WExtensions::station(){ | |||
66 | * @return QString the essid of the host 802.11 access point. | 66 | * @return QString the essid of the host 802.11 access point. |
67 | */ | 67 | */ |
68 | QString WExtensions::essid(){ | 68 | QString WExtensions::essid(){ |
69 | if(!hasWirelessExtensions) | 69 | if(!hasWirelessExtensions) |
70 | return QString(); | 70 | return QString(); |
71 | const char* buffer[200]; | 71 | const char* buffer[200]; |
72 | memset(buffer,0x00,200); | ||
72 | iwr.u.data.pointer = (caddr_t) buffer; | 73 | iwr.u.data.pointer = (caddr_t) buffer; |
73 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 74 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
74 | iwr.u.data.flags = 0; | 75 | iwr.u.data.flags = 0; |
75 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 76 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
77 | if (iwr.u.essid.length > IW_ESSID_MAX_SIZE) | ||
78 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | ||
76 | buffer[(unsigned int) iwr.u.essid.length] = '\0'; | 79 | buffer[(unsigned int) iwr.u.essid.length] = '\0'; |
77 | return (const char*) buffer; | 80 | return (const char*) buffer; |
78 | } | 81 | } |
79 | return QString::null; | 82 | return QString::null; |
80 | } | 83 | } |
81 | 84 | ||
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro index eb9dd4f..3a064d3 100644 --- a/noncore/settings/networksettings/wlan/wlan.pro +++ b/noncore/settings/networksettings/wlan/wlan.pro | |||
@@ -5,13 +5,13 @@ HEADERS = infoimp.h wlanmodule.h wextensions.h keyedit.h | |||
5 | SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp keyedit.cpp | 5 | SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp keyedit.cpp |
6 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | 6 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ |
7 | DEPENDPATH+= $(OPIEDIR)/include | 7 | DEPENDPATH+= $(OPIEDIR)/include |
8 | LIBS += -lqpe -L../interfaces/ -linterfaces -lopiecore2 -lopienet2 | 8 | LIBS += -lqpe -L../interfaces/ -linterfaces -lopiecore2 -lopienet2 |
9 | INTERFACES= wlan.ui info.ui | 9 | INTERFACES= wlan.ui info.ui |
10 | TARGET = wlan | 10 | TARGET = wlan |
11 | VERSION = 1.0.1 | 11 | VERSION = 1.0.2 |
12 | 12 | ||
13 | #CONFIG += wirelessopts | 13 | #CONFIG += wirelessopts |
14 | 14 | ||
15 | wirelessopts { | 15 | wirelessopts { |
16 | HEADERS+= wlanimp.h | 16 | HEADERS+= wlanimp.h |
17 | SOURCES+= wlanimp.cpp | 17 | SOURCES+= wlanimp.cpp |
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 11dfe74..2fd97c3 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -76,18 +76,17 @@ void WLANImp::setProfile(const QString &profile){ | |||
76 | interfaceSetup->setProfile(profile); | 76 | interfaceSetup->setProfile(profile); |
77 | parseOpts(); | 77 | parseOpts(); |
78 | } | 78 | } |
79 | 79 | ||
80 | void WLANImp::parseOpts() { | 80 | void WLANImp::parseOpts() { |
81 | bool error; | 81 | bool error; |
82 | QString opt; | 82 | QString opt,key; |
83 | 83 | ||
84 | if (! interfaces->isInterfaceSet()) | 84 | if (! interfaces->isInterfaceSet()) |
85 | return; | 85 | return; |
86 | 86 | ||
87 | |||
88 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 87 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
89 | if(opt == "any" || opt == "off" || opt.isNull()){ | 88 | if(opt == "any" || opt == "off" || opt.isNull()){ |
90 | essid->setEditText("any"); | 89 | essid->setEditText("any"); |
91 | } else { | 90 | } else { |
92 | essid->setEditText(opt); | 91 | essid->setEditText(opt); |
93 | } | 92 | } |
@@ -106,16 +105,71 @@ void WLANImp::parseOpts() { | |||
106 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 105 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
107 | if (! opt.isNull()) { | 106 | if (! opt.isNull()) { |
108 | specifyChan->setChecked(true); | 107 | specifyChan->setChecked(true); |
109 | networkChannel->setValue(opt.toInt()); | 108 | networkChannel->setValue(opt.toInt()); |
110 | } | 109 | } |
111 | 110 | ||
112 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 111 | opt = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); |
113 | if (opt.isNull()) | 112 | |
113 | if ( opt == "wlan-ng") { | ||
114 | |||
115 | //FIXME:Handle wlan_ng_priv_genstr | ||
116 | |||
117 | // get default key_id | ||
118 | opt = interfaces->getInterfaceOption("wlan_ng_default_key_id", error).simplifyWhiteSpace(); | ||
119 | |||
120 | if (opt == "0") | ||
121 | keyRadio0->setChecked(true); | ||
122 | if (opt == "1") | ||
123 | keyRadio1->setChecked(true); | ||
124 | if (opt == "2") | ||
125 | keyRadio2->setChecked(true); | ||
126 | if (opt == "3") | ||
127 | keyRadio3->setChecked(true); | ||
128 | |||
129 | // get key0 | ||
130 | key = interfaces->getInterfaceOption("wlan_ng_key0", error).simplifyWhiteSpace(); | ||
131 | key.replace(QString(":"),QString("")); | ||
132 | keyLineEdit0->setText(key); | ||
133 | |||
134 | // get key1 | ||
135 | key = interfaces->getInterfaceOption("wlan_ng_key1", error).simplifyWhiteSpace(); | ||
136 | key.replace(QString(":"),QString("")); | ||
137 | keyLineEdit1->setText(key); | ||
138 | |||
139 | // get key2 | ||
140 | key = interfaces->getInterfaceOption("wlan_ng_key2", error).simplifyWhiteSpace(); | ||
141 | key.replace(QString(":"),QString("")); | ||
142 | keyLineEdit2->setText(key); | ||
143 | |||
144 | // get key3 | ||
145 | key = interfaces->getInterfaceOption("wlan_ng_key3", error).simplifyWhiteSpace(); | ||
146 | key.replace(QString(":"),QString("")); | ||
147 | keyLineEdit3->setText(key); | ||
148 | |||
114 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 149 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
115 | parseKeyStr(opt); | 150 | |
151 | // encryption on? | ||
152 | if(opt == "on"){ | ||
153 | wepEnabled->setChecked(true); | ||
154 | } else { | ||
155 | wepEnabled->setChecked(false); | ||
156 | } | ||
157 | |||
158 | opt = interfaces->getInterfaceOption("wireless_keymode", error).simplifyWhiteSpace(); | ||
159 | |||
160 | if(opt == "restricted"){ | ||
161 | // restricted mode, only accept encrypted packets | ||
162 | rejectNonEnc->setChecked(true); | ||
163 | } | ||
164 | } | ||
165 | else { | ||
166 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | ||
167 | |||
168 | parseKeyStr(opt); | ||
169 | } | ||
116 | } | 170 | } |
117 | 171 | ||
118 | void WLANImp::parseKeyStr(QString keystr) { | 172 | void WLANImp::parseKeyStr(QString keystr) { |
119 | int index = 1; | 173 | int index = 1; |
120 | QString key; | 174 | QString key; |
121 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 175 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
@@ -223,79 +277,158 @@ void WLANImp::accept() { | |||
223 | writeOpts(); | 277 | writeOpts(); |
224 | 278 | ||
225 | // Close out the dialog | 279 | // Close out the dialog |
226 | // FIXME: QDialog::accept(); | 280 | // FIXME: QDialog::accept(); |
227 | } | 281 | } |
228 | 282 | ||
283 | QString WLANImp::formatKey(QString input) | ||
284 | { | ||
285 | int len,r=0; | ||
286 | |||
287 | len = input.length(); | ||
288 | |||
289 | if (!len) | ||
290 | return input; | ||
291 | |||
292 | for(int i=1;i<len/2;i++) | ||
293 | { | ||
294 | input.insert(r+i*2,QString(":")); | ||
295 | r++; | ||
296 | } | ||
297 | |||
298 | return input; | ||
299 | } | ||
300 | |||
229 | void WLANImp::writeOpts() { | 301 | void WLANImp::writeOpts() { |
230 | // eh can't really do anything about it other then return. :-D | 302 | QString para, devicetype; |
231 | if(!interfaces->isInterfaceSet()){ | ||
232 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | ||
233 | return; | ||
234 | } | ||
235 | bool error = false; | ||
236 | 303 | ||
237 | odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; | 304 | // eh can't really do anything about it other then return. :-D |
305 | if(!interfaces->isInterfaceSet()){ | ||
306 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | ||
307 | return; | ||
308 | } | ||
309 | bool error = false; | ||
238 | 310 | ||
239 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 311 | odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; |
312 | |||
313 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); | ||
240 | 314 | ||
241 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); | 315 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); |
242 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); | 316 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); |
243 | 317 | ||
244 | if (specifyAp->isChecked()) { | 318 | if (specifyAp->isChecked()) { |
245 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); | 319 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); |
246 | } else { | 320 | } else { |
247 | interfaces->removeInterfaceOption(QString("wireless_ap")); | 321 | interfaces->removeInterfaceOption(QString("wireless_ap")); |
248 | } | 322 | } |
249 | 323 | ||
250 | if (specifyChan->isChecked()) { | 324 | if (specifyChan->isChecked()) { |
251 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); | 325 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); |
252 | } else { | 326 | } else { |
253 | interfaces->removeInterfaceOption(QString("wireless_channel")); | 327 | interfaces->removeInterfaceOption(QString("wireless_channel")); |
254 | } | 328 | } |
255 | 329 | ||
256 | if (wepEnabled->isChecked()) { | 330 | devicetype = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); |
257 | QStringList keyList; | 331 | |
258 | 332 | if ( devicetype == "wlan-ng") { | |
259 | if (! keyLineEdit0->text().isNull()) { | 333 | |
260 | keyList += keyLineEdit0->text(); | 334 | // wlan-ng style |
261 | keyList += "[1]"; | 335 | interfaces->removeInterfaceOption(QString("wireless_key")); |
262 | } //else | 336 | |
263 | if (! keyLineEdit1->text().isNull()) { | 337 | if (wepEnabled->isChecked()) { |
264 | keyList += keyLineEdit1->text(); | 338 | |
265 | keyList += "[2]"; | 339 | interfaces->setInterfaceOption(QString("wireless_enc"),"on"); |
266 | } //else | 340 | |
267 | if (! keyLineEdit2->text().isNull()) { | 341 | if (! keyLineEdit0->text().isNull()) { |
268 | keyList += keyLineEdit2->text(); | 342 | interfaces->setInterfaceOption(QString("wlan_ng_key0"), formatKey(keyLineEdit0->text())); |
269 | keyList += "[3]"; | 343 | } else |
270 | } //else | 344 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); |
271 | if (! keyLineEdit3->text().isNull()) { | 345 | if (! keyLineEdit1->text().isNull()) { |
272 | keyList += keyLineEdit3->text(); | 346 | interfaces->setInterfaceOption(QString("wlan_ng_key1"), formatKey(keyLineEdit1->text())); |
273 | keyList += "[4]"; | 347 | } else |
274 | } | 348 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); |
275 | if (acceptNonEnc->isChecked()) { | 349 | if (! keyLineEdit2->text().isNull()) { |
276 | keyList += "open"; | 350 | interfaces->setInterfaceOption(QString("wlan_ng_key2"), formatKey(keyLineEdit2->text())); |
351 | } else | ||
352 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); | ||
353 | if (! keyLineEdit3->text().isNull()) { | ||
354 | interfaces->setInterfaceOption(QString("wlan_ng_key3"), formatKey(keyLineEdit3->text())); | ||
355 | } else | ||
356 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); | ||
357 | |||
358 | if (acceptNonEnc->isChecked()) | ||
359 | interfaces->removeInterfaceOption(QString("wireless_keymode")); | ||
360 | else | ||
361 | interfaces->setInterfaceOption(QString("wireless_keymode"),"restricted"); | ||
362 | |||
363 | para = ""; | ||
364 | if (keyRadio0->isChecked()) { | ||
365 | para = "0"; | ||
366 | } else if (keyRadio1->isChecked()) { | ||
367 | para = "1"; | ||
368 | } else if (keyRadio2->isChecked()) { | ||
369 | para = "2"; | ||
370 | } else if (keyRadio3->isChecked()) { | ||
371 | para = "3"; | ||
372 | } | ||
373 | |||
374 | interfaces->setInterfaceOption(QString("wlan_ng_default_key_id"), para); | ||
375 | |||
277 | } else { | 376 | } else { |
278 | keyList += "restricted"; | 377 | // No wep, remove all previous keys |
378 | interfaces->removeInterfaceOption(QString("wireless_enc")); | ||
379 | interfaces->removeInterfaceOption(QString("wlan_ng_default_key_id")); | ||
380 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); | ||
381 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); | ||
382 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); | ||
383 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); | ||
279 | } | 384 | } |
280 | 385 | ||
281 | keyList += "key"; | ||
282 | if (keyRadio0->isChecked()) { | ||
283 | keyList += "[1]"; | ||
284 | } else if (keyRadio1->isChecked()) { | ||
285 | keyList += "[2]"; | ||
286 | } else if (keyRadio2->isChecked()) { | ||
287 | keyList += "[3]"; | ||
288 | } else if (keyRadio3->isChecked()) { | ||
289 | keyList += "[4]"; | ||
290 | } | ||
291 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); | ||
292 | } else { | 386 | } else { |
293 | interfaces->removeInterfaceOption(QString("wireless_key")); | 387 | // This is the old style |
388 | if (wepEnabled->isChecked()) { | ||
389 | QStringList keyList; | ||
390 | |||
391 | if (! keyLineEdit0->text().isNull()) { | ||
392 | keyList += keyLineEdit0->text(); | ||
393 | keyList += "[1]"; | ||
394 | } //else | ||
395 | if (! keyLineEdit1->text().isNull()) { | ||
396 | keyList += keyLineEdit1->text(); | ||
397 | keyList += "[2]"; | ||
398 | } //else | ||
399 | if (! keyLineEdit2->text().isNull()) { | ||
400 | keyList += keyLineEdit2->text(); | ||
401 | keyList += "[3]"; | ||
402 | } //else | ||
403 | if (! keyLineEdit3->text().isNull()) { | ||
404 | keyList += keyLineEdit3->text(); | ||
405 | keyList += "[4]"; | ||
406 | } | ||
407 | if (acceptNonEnc->isChecked()) { | ||
408 | keyList += "open"; | ||
409 | } else { | ||
410 | keyList += "restricted"; | ||
411 | } | ||
412 | |||
413 | keyList += "key"; | ||
414 | if (keyRadio0->isChecked()) { | ||
415 | keyList += "[1]"; | ||
416 | } else if (keyRadio1->isChecked()) { | ||
417 | keyList += "[2]"; | ||
418 | } else if (keyRadio2->isChecked()) { | ||
419 | keyList += "[3]"; | ||
420 | } else if (keyRadio3->isChecked()) { | ||
421 | keyList += "[4]"; | ||
422 | } | ||
423 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); | ||
424 | } else { | ||
425 | interfaces->removeInterfaceOption(QString("wireless_key")); | ||
426 | } | ||
427 | interfaces->removeInterfaceOption(QString("wireless_enc")); | ||
294 | } | 428 | } |
295 | interfaces->removeInterfaceOption(QString("wireless_enc")); | ||
296 | 429 | ||
297 | if(!interfaceSetup->saveChanges()) | 430 | if(!interfaceSetup->saveChanges()) |
298 | return; | 431 | return; |
299 | 432 | ||
300 | QDialog::accept(); | 433 | QDialog::accept(); |
301 | } | 434 | } |
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.h b/noncore/settings/networksettings/wlan/wlanimp2.h index c3d1eee..0e8d533 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.h +++ b/noncore/settings/networksettings/wlan/wlanimp2.h | |||
@@ -34,13 +34,14 @@ protected: | |||
34 | 34 | ||
35 | private: | 35 | private: |
36 | void parseOpts(); | 36 | void parseOpts(); |
37 | void writeOpts(); | 37 | void writeOpts(); |
38 | 38 | ||
39 | void parseKeyStr(QString keystr); | 39 | void parseKeyStr(QString keystr); |
40 | 40 | QString formatKey(QString input); | |
41 | |||
41 | void handlePacket( Opie::Net::OPacket* ); | 42 | void handlePacket( Opie::Net::OPacket* ); |
42 | void displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const Opie::Net::OMacAddress& mac ); | 43 | void displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const Opie::Net::OMacAddress& mac ); |
43 | 44 | ||
44 | InterfaceSetupImp *interfaceSetup; | 45 | InterfaceSetupImp *interfaceSetup; |
45 | Interfaces *interfaces; | 46 | Interfaces *interfaces; |
46 | Interface *interface; | 47 | Interface *interface; |