MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / Utility / authsecudlg.cpp
blobf2321e6a400b64c2d8d1eea43903ce3aba614d73
1 #include "authsecudlg.h"
3 #include <qvariant.h>
4 #include <qbuttongroup.h>
5 #include <qcombobox.h>
6 #include <qlabel.h>
7 #include <qlineedit.h>
8 #include <qpushbutton.h>
9 #include <qradiobutton.h>
10 #include <qlayout.h>
11 #include <qtooltip.h>
12 #include <qwhatsthis.h>
13 #include <qmessagebox.h>
15 /*
16 * Constructs a Security which is a child of 'parent', with the
17 * name 'name' and widget flags set to 'f'.
19 * The dialog will by default be modeless, unless you set 'modal' to
20 * TRUE to construct a modal dialog.
22 AuthSecuDlg::AuthSecuDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
23 : QDialog( parent, name, modal, fl )
25 if ( !name )
26 setName( "AuthSecuDlg" );
27 resize( 580, 325 );
28 setMinimumSize( 580, 325 );
29 setMaximumSize( 580, 325 );
30 setCaption("Authentication & AuthSecuDlg");
32 Security_TextLabel1 = new QLabel( this, "Security_TextLabel1" );
33 Security_TextLabel1->setGeometry( QRect( 20, 14, 120, 30 ) );
34 Security_TextLabel1->setText("Authentication Type:");
36 Security_ComboBox_AuthType = new QComboBox( FALSE, this, "Security_ComboBox_AuthType" );
37 Security_ComboBox_AuthType->insertItem("OPEN");
38 Security_ComboBox_AuthType->insertItem("SHARED");
39 Security_ComboBox_AuthType->setGeometry( QRect( 150, 14, 120, 30 ) );
41 Security_TextLabel2 = new QLabel( this, "Security_TextLabel2" );
42 Security_TextLabel2->setGeometry( QRect( 313, 14, 120, 30 ) );
43 Security_TextLabel2->setText("Encryptiion Type:");
45 Security_ComboBox_Encrypt = new QComboBox( FALSE, this, "Security_ComboBox_Encrypt" );
46 Security_ComboBox_Encrypt->insertItem("None");
47 Security_ComboBox_Encrypt->insertItem("WEP");
48 Security_ComboBox_Encrypt->setGeometry( QRect( 440, 15, 120, 30 ) );
50 Security_TextLabel3 = new QLabel( this, "Security_TextLabel3" );
51 Security_TextLabel3->setGeometry( QRect( 20, 59, 120, 31 ) );
52 Security_TextLabel3->setText("WPA Pre-Shared Key:");
54 Security_LineEdit_PSK = new QLineEdit( this, "Security_LineEdit_PSK" );
55 Security_LineEdit_PSK->setGeometry( QRect( 150, 59, 410, 30 ) );
56 Security_LineEdit_PSK->setMaxLength(64);
57 Security_LineEdit_PSK->setEnabled( FALSE );
59 Security_ButtonGroup_Key = new QButtonGroup( this, "Security_ButtonGroup_Key" );
60 Security_ButtonGroup_Key->setGeometry( QRect( 21, 98, 535, 170 ) );
61 Security_ButtonGroup_Key->setTitle("WEP Key");
63 Security_RadioButton_Key1 = new QRadioButton( Security_ButtonGroup_Key, "Security_RadioButton_Key1" );
64 Security_RadioButton_Key1->setGeometry( QRect( 10, 20, 70, 30 ) );
65 Security_RadioButton_Key1->setText("Key#1");
66 Security_RadioButton_Key1->setEnabled( FALSE );
67 Security_RadioButton_Key1->setChecked( TRUE );
68 Security_ButtonGroup_Key->insert( Security_RadioButton_Key1, 0 );
70 Security_RadioButton_Key2 = new QRadioButton( Security_ButtonGroup_Key, "Security_RadioButton_Key2" );
71 Security_RadioButton_Key2->setGeometry( QRect( 10, 55, 70, 30 ) );
72 Security_RadioButton_Key2->setText("Key#2");
73 Security_RadioButton_Key2->setEnabled( FALSE );
74 Security_RadioButton_Key2->setChecked( FALSE );
75 Security_ButtonGroup_Key->insert( Security_RadioButton_Key2, 1 );
77 Security_RadioButton_Key3 = new QRadioButton( Security_ButtonGroup_Key, "Security_RadioButton_Key3" );
78 Security_RadioButton_Key3->setGeometry( QRect( 10, 90, 70, 30 ) );
79 Security_RadioButton_Key3->setText("Key#3");
80 Security_RadioButton_Key3->setEnabled( FALSE );
81 Security_RadioButton_Key3->setChecked( FALSE );
82 Security_ButtonGroup_Key->insert( Security_RadioButton_Key3, 2 );
84 Security_RadioButton_Key4 = new QRadioButton( Security_ButtonGroup_Key, "Security_RadioButton_Key4" );
85 Security_RadioButton_Key4->setGeometry( QRect( 10, 125, 70, 30 ) );
86 Security_RadioButton_Key4->setText("Key#4");
87 Security_RadioButton_Key4->setEnabled( FALSE );
88 Security_RadioButton_Key4->setChecked( FALSE );
89 Security_ButtonGroup_Key->insert( Security_RadioButton_Key4, 3 );
91 Security_ComboBox_KeyType1 = new QComboBox( FALSE, Security_ButtonGroup_Key, "Security_ComboBox_KeyType1" );
92 Security_ComboBox_KeyType1->insertItem("Hexadecimal");
93 Security_ComboBox_KeyType1->insertItem("Ascii");
94 Security_ComboBox_KeyType1->setGeometry( QRect( 90, 20, 120, 30 ) );
95 Security_ComboBox_KeyType1->setEnabled( FALSE );
97 Security_ComboBox_KeyType2 = new QComboBox( FALSE, Security_ButtonGroup_Key, "Security_ComboBox_KeyType2" );
98 Security_ComboBox_KeyType2->insertItem("Hexadecimal");
99 Security_ComboBox_KeyType2->insertItem("Ascii");
100 Security_ComboBox_KeyType2->setGeometry( QRect( 90, 55, 120, 30 ) );
101 Security_ComboBox_KeyType2->setEnabled( FALSE );
103 Security_ComboBox_KeyType3 = new QComboBox( FALSE, Security_ButtonGroup_Key, "Security_ComboBox_KeyType3" );
104 Security_ComboBox_KeyType3->insertItem("Hexadecimal");
105 Security_ComboBox_KeyType3->insertItem("Ascii");
106 Security_ComboBox_KeyType3->setGeometry( QRect( 90, 90, 120, 30 ) );
107 Security_ComboBox_KeyType3->setEnabled( FALSE );
109 Security_ComboBox_KeyType4 = new QComboBox( FALSE, Security_ButtonGroup_Key, "Security_ComboBox_KeyType4" );
110 Security_ComboBox_KeyType4->insertItem("Hexadecimal");
111 Security_ComboBox_KeyType4->insertItem("Ascii");
112 Security_ComboBox_KeyType4->setGeometry( QRect( 90, 125, 120, 30 ) );
113 Security_ComboBox_KeyType4->setEnabled( FALSE );
115 m_hexValidator = new QHexValidator(this);
117 Security_LineEdit_Key1Hex = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key1Hex" );
118 Security_LineEdit_Key1Hex->setGeometry( QRect( 225, 20, 290, 30 ) );
119 Security_LineEdit_Key1Hex->setMaxLength(26);
120 Security_LineEdit_Key1Hex->setEnabled( FALSE );
121 Security_LineEdit_Key1Hex->setValidator(m_hexValidator);
123 Security_LineEdit_Key1Ascii = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key1Ascii" );
124 Security_LineEdit_Key1Ascii->setGeometry( QRect( 225, 20, 290, 30 ) );
125 Security_LineEdit_Key1Ascii->setMaxLength(13);
126 Security_LineEdit_Key1Ascii->hide();
127 Security_LineEdit_Key1Ascii->setEnabled( FALSE );
129 Security_LineEdit_Key2Hex = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key2Hex" );
130 Security_LineEdit_Key2Hex->setGeometry( QRect( 225, 55, 290, 30 ) );
131 Security_LineEdit_Key2Hex->setMaxLength(26);
132 Security_LineEdit_Key2Hex->setEnabled( FALSE );
133 Security_LineEdit_Key2Hex->setValidator(m_hexValidator);
135 Security_LineEdit_Key2Ascii = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key2Ascii" );
136 Security_LineEdit_Key2Ascii->setGeometry( QRect( 225, 55, 290, 30 ) );
137 Security_LineEdit_Key2Ascii->setMaxLength(13);
138 Security_LineEdit_Key2Ascii->hide();
139 Security_LineEdit_Key2Ascii->setEnabled( FALSE );
141 Security_LineEdit_Key3Hex = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key3Hex" );
142 Security_LineEdit_Key3Hex->setGeometry( QRect( 225, 90, 290, 30 ) );
143 Security_LineEdit_Key3Hex->setMaxLength(26);
144 Security_LineEdit_Key3Hex->setEnabled( FALSE );
145 Security_LineEdit_Key3Hex->setValidator(m_hexValidator);
147 Security_LineEdit_Key3Ascii = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key3Ascii" );
148 Security_LineEdit_Key3Ascii->setGeometry( QRect( 225, 90, 290, 30 ) );
149 Security_LineEdit_Key3Ascii->setMaxLength(13);
150 Security_LineEdit_Key3Ascii->hide();
151 Security_LineEdit_Key3Ascii->setEnabled( FALSE );
153 Security_LineEdit_Key4Hex = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key4Hex" );
154 Security_LineEdit_Key4Hex->setGeometry( QRect( 225, 125, 290, 30 ) );
155 Security_LineEdit_Key4Hex->setMaxLength(26);
156 Security_LineEdit_Key4Hex->setEnabled( FALSE );
157 Security_LineEdit_Key4Hex->setValidator(m_hexValidator);
159 Security_LineEdit_Key4Ascii = new QLineEdit( Security_ButtonGroup_Key, "Security_LineEdit_Key4Ascii" );
160 Security_LineEdit_Key4Ascii->setGeometry( QRect( 225, 125, 290, 30 ) );
161 Security_LineEdit_Key4Ascii->setMaxLength(13);
162 Security_LineEdit_Key4Ascii->hide();
163 Security_LineEdit_Key4Ascii->setEnabled( FALSE );
165 PushButton_OK = new QPushButton( this, "PushButton_OK" );
166 PushButton_OK->setGeometry( QRect( 144, 282, 120, 30 ) );
167 PushButton_OK->setText("&OK");
169 PushButton_Cancel = new QPushButton( this, "PushButton_Cancel" );
170 PushButton_Cancel->setGeometry( QRect( 314, 282, 120, 30 ) );
171 PushButton_Cancel->setText("&CANCEL");
173 connect( PushButton_OK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
174 connect( PushButton_Cancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
175 connect( Security_ComboBox_AuthType, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectAuthenType(int) ) );
176 connect( Security_ComboBox_Encrypt, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectEncryptType(int) ) );
177 connect( Security_ComboBox_KeyType1, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey1Type(int) ) );
178 connect( Security_ComboBox_KeyType2, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey2Type(int) ) );
179 connect( Security_ComboBox_KeyType3, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey3Type(int) ) );
180 connect( Security_ComboBox_KeyType4, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey4Type(int) ) );
182 m_isClickOk = FALSE;
186 * Destroys the object and frees any allocated resources
188 AuthSecuDlg::~AuthSecuDlg()
190 // no need to delete child widgets, Qt does it all for us
193 int AuthSecuDlg::Security_GetWepKeyType(int index)
195 int num;
197 switch (index)
199 case 1:
200 num = Security_ComboBox_KeyType2->currentItem();
201 break;
202 case 2:
203 num = Security_ComboBox_KeyType3->currentItem();
204 break;
205 case 3:
206 num = Security_ComboBox_KeyType4->currentItem();
207 break;
208 case 0:
209 default:
210 num = Security_ComboBox_KeyType1->currentItem();
211 break;
214 return num;
217 QString AuthSecuDlg::Security_GetWepKeyString(int index)
219 switch (index)
221 case 1:
222 if ( Security_GetWepKeyType(index) == 0) //Hex
223 return (Security_LineEdit_Key2Hex->text());
224 else
225 return (Security_LineEdit_Key2Ascii->text());
226 break;
227 case 2:
228 if ( Security_GetWepKeyType(index) == 0) //Hex
229 return (Security_LineEdit_Key3Hex->text());
230 else
231 return (Security_LineEdit_Key3Ascii->text());
232 break;
233 case 3:
234 if ( Security_GetWepKeyType(index) == 0) //Hex
235 return (Security_LineEdit_Key4Hex->text());
236 else
237 return (Security_LineEdit_Key4Ascii->text());
238 break;
239 case 0:
240 default:
241 if ( Security_GetWepKeyType(index) == 0) //Hex
242 return (Security_LineEdit_Key1Hex->text());
243 else
244 return (Security_LineEdit_Key1Ascii->text());
245 break;
249 QString AuthSecuDlg::Security_GetPSKString()
251 return (Security_LineEdit_PSK->text());
254 NDIS_802_11_AUTHENTICATION_MODE AuthSecuDlg::Security_GetAuthticationMode()
256 QString qstr;
257 NDIS_802_11_AUTHENTICATION_MODE mode = Ndis802_11AuthModeOpen;
259 qstr = Security_ComboBox_AuthType->currentText();
260 if (qstr.compare("OPEN") == 0)
261 mode = Ndis802_11AuthModeOpen;
262 else if (qstr.compare("SHARED") == 0)
263 mode = Ndis802_11AuthModeShared;
264 else if (qstr.compare("WPAPSK") == 0)
265 mode = Ndis802_11AuthModeWPAPSK;
267 return (mode);
270 NDIS_802_11_ENCRYPTION_STATUS AuthSecuDlg::Security_GetEncryptType()
272 QString qstr;
273 NDIS_802_11_ENCRYPTION_STATUS type = Ndis802_11WEPDisabled;
275 qstr = Security_ComboBox_Encrypt->currentText();
276 if (qstr.compare("NONE") == 0)
277 type = Ndis802_11WEPDisabled;
278 else if (qstr.compare("WEP") == 0)
279 type = Ndis802_11WEPEnabled;
280 else if (qstr.compare("TKIP") == 0)
281 type = Ndis802_11Encryption2Enabled;
282 else if (qstr.compare("AES") == 0)
283 type = Ndis802_11Encryption3Enabled;
285 return (type);
288 void AuthSecuDlg::Security_SetAuthModeAndEncryType(NDIS_802_11_AUTHENTICATION_MODE mode, NDIS_802_11_ENCRYPTION_STATUS type)
290 if ((mode == Ndis802_11AuthModeOpen) || (mode == Ndis802_11AuthModeShared))
292 Security_LineEdit_PSK->setEnabled( FALSE );
294 Security_ComboBox_AuthType->clear();
295 Security_ComboBox_AuthType->insertItem("OPEN");
296 Security_ComboBox_AuthType->insertItem("SHARED");
298 Security_ComboBox_Encrypt->clear();
299 Security_ComboBox_Encrypt->insertItem("NONE");
300 Security_ComboBox_Encrypt->insertItem("WEP");
302 if (type == Ndis802_11WEPEnabled)
304 Security_ComboBox_Encrypt->setCurrentItem( 1 );
306 Security_RadioButton_Key1->setEnabled( TRUE );
307 Security_RadioButton_Key2->setEnabled( TRUE );
308 Security_RadioButton_Key3->setEnabled( TRUE );
309 Security_RadioButton_Key4->setEnabled( TRUE );
311 Security_ComboBox_KeyType1->setEnabled( TRUE );
312 Security_ComboBox_KeyType2->setEnabled( TRUE );
313 Security_ComboBox_KeyType3->setEnabled( TRUE );
314 Security_ComboBox_KeyType4->setEnabled( TRUE );
316 Security_LineEdit_Key1Hex->setEnabled( TRUE );
317 Security_LineEdit_Key1Ascii->setEnabled( TRUE );
318 Security_LineEdit_Key2Hex->setEnabled( TRUE );
319 Security_LineEdit_Key2Ascii->setEnabled( TRUE );
320 Security_LineEdit_Key3Hex->setEnabled( TRUE );
321 Security_LineEdit_Key3Ascii->setEnabled( TRUE );
322 Security_LineEdit_Key4Hex->setEnabled( TRUE );
323 Security_LineEdit_Key4Ascii->setEnabled( TRUE );
325 else
327 Security_ComboBox_Encrypt->setCurrentItem( 0 );
329 Security_RadioButton_Key1->setEnabled( FALSE );
330 Security_RadioButton_Key2->setEnabled( FALSE );
331 Security_RadioButton_Key3->setEnabled( FALSE );
332 Security_RadioButton_Key4->setEnabled( FALSE );
334 Security_ComboBox_KeyType1->setEnabled( FALSE );
335 Security_ComboBox_KeyType2->setEnabled( FALSE );
336 Security_ComboBox_KeyType3->setEnabled( FALSE );
337 Security_ComboBox_KeyType4->setEnabled( FALSE );
339 Security_LineEdit_Key1Hex->setEnabled( FALSE );
340 Security_LineEdit_Key1Ascii->setEnabled( FALSE );
341 Security_LineEdit_Key2Hex->setEnabled( FALSE );
342 Security_LineEdit_Key2Ascii->setEnabled( FALSE );
343 Security_LineEdit_Key3Hex->setEnabled( FALSE );
344 Security_LineEdit_Key3Ascii->setEnabled( FALSE );
345 Security_LineEdit_Key4Hex->setEnabled( FALSE );
346 Security_LineEdit_Key4Ascii->setEnabled( FALSE );
349 else if ((mode == Ndis802_11AuthModeWPAPSK) || (mode == Ndis802_11AuthModeWPANone))
351 Security_LineEdit_PSK->setEnabled( TRUE );
353 Security_ComboBox_AuthType->clear();
354 if (mode == Ndis802_11AuthModeWPAPSK)
355 Security_ComboBox_AuthType->insertItem("WPAPSK");
356 else if (mode == Ndis802_11AuthModeWPANone)
357 Security_ComboBox_AuthType->insertItem("WPA-None");
358 else
360 Security_ComboBox_AuthType->insertItem("WPAPSK");
361 Security_ComboBox_AuthType->insertItem("WPA-None");
364 Security_ComboBox_Encrypt->clear();
365 Security_ComboBox_Encrypt->insertItem("TKIP");
366 Security_ComboBox_Encrypt->insertItem("AES");
368 if (type == Ndis802_11Encryption2Enabled )
369 Security_ComboBox_Encrypt->setCurrentItem( 0 );
370 else if(type == Ndis802_11Encryption3Enabled)
371 Security_ComboBox_Encrypt->setCurrentItem( 1 );
373 Security_RadioButton_Key1->setEnabled( FALSE );
374 Security_RadioButton_Key2->setEnabled( FALSE );
375 Security_RadioButton_Key3->setEnabled( FALSE );
376 Security_RadioButton_Key4->setEnabled( FALSE );
378 Security_ComboBox_KeyType1->setEnabled( FALSE );
379 Security_ComboBox_KeyType2->setEnabled( FALSE );
380 Security_ComboBox_KeyType3->setEnabled( FALSE );
381 Security_ComboBox_KeyType4->setEnabled( FALSE );
383 Security_LineEdit_Key1Hex->setEnabled( FALSE );
384 Security_LineEdit_Key1Ascii->setEnabled( FALSE );
385 Security_LineEdit_Key2Hex->setEnabled( FALSE );
386 Security_LineEdit_Key2Ascii->setEnabled( FALSE );
387 Security_LineEdit_Key3Hex->setEnabled( FALSE );
388 Security_LineEdit_Key3Ascii->setEnabled( FALSE );
389 Security_LineEdit_Key4Hex->setEnabled( FALSE );
390 Security_LineEdit_Key4Ascii->setEnabled( FALSE );
394 int AuthSecuDlg::Security_GetDefaultKeyId()
396 int keyId;
398 keyId = Security_ButtonGroup_Key->id(Security_ButtonGroup_Key->selected());
400 return (keyId);
403 void AuthSecuDlg::Security_SetDefaultKeyId(int keyId)
405 Security_ButtonGroup_Key->setButton(keyId);
408 void AuthSecuDlg::Security_SetKeyTypeAndKeyString(int keyIndex, int keyType, char *keyString)
410 switch (keyIndex)
412 case 0:
413 if (keyType == 0) //Hex
415 Security_ComboBox_KeyType1->setCurrentItem( 0 );
416 Security_LineEdit_Key1Hex->setText(keyString);
417 Security_LineEdit_Key1Hex->show();
418 Security_LineEdit_Key1Ascii->hide();
420 else
422 Security_ComboBox_KeyType1->setCurrentItem( 1 );
423 Security_LineEdit_Key1Ascii->setText(keyString);
424 Security_LineEdit_Key1Ascii->show();
425 Security_LineEdit_Key1Hex->hide();
427 break;
428 case 1:
429 if (keyType == 0) //Hex
431 Security_ComboBox_KeyType2->setCurrentItem( 0 );
432 Security_LineEdit_Key2Hex->setText(keyString);
433 Security_LineEdit_Key2Hex->show();
434 Security_LineEdit_Key2Ascii->hide();
436 else
438 Security_ComboBox_KeyType2->setCurrentItem( 1 );
439 Security_LineEdit_Key2Ascii->setText(keyString);
440 Security_LineEdit_Key2Ascii->show();
441 Security_LineEdit_Key2Hex->hide();
443 break;
444 case 2:
445 if (keyType == 0) //Hex
447 Security_ComboBox_KeyType3->setCurrentItem( 0 );
448 Security_LineEdit_Key3Hex->setText(keyString);
449 Security_LineEdit_Key3Hex->show();
450 Security_LineEdit_Key3Ascii->hide();
452 else
454 Security_ComboBox_KeyType3->setCurrentItem( 1 );
455 Security_LineEdit_Key3Ascii->setText(keyString);
456 Security_LineEdit_Key3Ascii->show();
457 Security_LineEdit_Key3Hex->hide();
459 break;
460 case 3:
461 if (keyType == 0) //Hex
463 Security_ComboBox_KeyType4->setCurrentItem( 0 );
464 Security_LineEdit_Key4Hex->setText(keyString);
465 Security_LineEdit_Key4Hex->show();
466 Security_LineEdit_Key4Ascii->hide();
468 else
470 Security_ComboBox_KeyType4->setCurrentItem( 1 );
471 Security_LineEdit_Key4Ascii->setText(keyString);
472 Security_LineEdit_Key4Ascii->show();
473 Security_LineEdit_Key4Hex->hide();
475 break;
479 void AuthSecuDlg::OnOK()
481 QString qstrEncryp;
482 QString qstrAuthen;
483 QString qstr;
484 int keyid;
485 char msg[255];
487 qstrAuthen = Security_ComboBox_AuthType->currentText();
488 qstrEncryp = Security_ComboBox_Encrypt->currentText();
489 if (qstrAuthen.compare("WPAPSK") == 0)
490 { //Use WPAPSK
491 qstr = Security_LineEdit_PSK->text();
492 if (qstr.length() < 8)
494 QMessageBox::warning(this, "Warning", "Invalid WPA Pre-Shared key. WPAPSK used field should use more than 8 characters.");
495 Security_LineEdit_PSK->setFocus();
496 return;
499 else if (qstrEncryp.compare("WEP") == 0)
501 keyid = Security_ButtonGroup_Key->id(Security_ButtonGroup_Key->selected());
502 qstr = Security_GetWepKeyString(keyid);
503 if (Security_GetWepKeyType(keyid) == 0)
504 {//Hex
505 if ((qstr.length() != 10) && (qstr.length() != 26))
507 sprintf(msg, "Invalid WEP KEY length. Key should be 10 or 26 hex digits!");
508 QMessageBox::warning(this, "Warning", msg);
509 switch (keyid)
511 case 0:
512 Security_LineEdit_Key1Hex->setFocus();
513 break;
514 case 1:
515 Security_LineEdit_Key2Hex->setFocus();
516 break;
517 case 2:
518 Security_LineEdit_Key3Hex->setFocus();
519 break;
520 case 3:
521 Security_LineEdit_Key4Hex->setFocus();
522 break;
524 return;
527 else
528 {//Ascii
529 if ((qstr.length() != 5) && (qstr.length() != 13))
531 sprintf(msg, "Invalid WEP KEY length. Key should be 5 or 13 ascii characters!");
532 QMessageBox::warning(this, "Warning", msg);
533 switch (keyid)
535 case 0:
536 Security_LineEdit_Key1Ascii->setFocus();
537 break;
538 case 1:
539 Security_LineEdit_Key2Ascii->setFocus();
540 break;
541 case 2:
542 Security_LineEdit_Key3Ascii->setFocus();
543 break;
544 case 3:
545 Security_LineEdit_Key4Ascii->setFocus();
546 break;
548 return;
553 m_isClickOk = TRUE;
554 close();
557 void AuthSecuDlg::OnCancel()
559 m_isClickOk = FALSE;
560 close();
563 void AuthSecuDlg::Security_OnSelectAuthenType(int id)
565 QString textAuthen;
567 textAuthen = Security_ComboBox_AuthType->text(id);
568 if ((textAuthen.compare("OPEN") == 0) || (textAuthen.compare("SHARED") == 0))
570 Security_LineEdit_PSK->setEnabled( FALSE );
572 Security_ComboBox_Encrypt->clear();
573 Security_ComboBox_Encrypt->insertItem("NONE");
574 Security_ComboBox_Encrypt->insertItem("WEP");
575 Security_ComboBox_Encrypt->setCurrentItem( 1 );
577 Security_RadioButton_Key1->setEnabled( TRUE );
578 Security_RadioButton_Key2->setEnabled( TRUE );
579 Security_RadioButton_Key3->setEnabled( TRUE );
580 Security_RadioButton_Key4->setEnabled( TRUE );
582 Security_ComboBox_KeyType1->setEnabled( TRUE );
583 Security_ComboBox_KeyType2->setEnabled( TRUE );
584 Security_ComboBox_KeyType3->setEnabled( TRUE );
585 Security_ComboBox_KeyType4->setEnabled( TRUE );
587 Security_LineEdit_Key1Hex->setEnabled( TRUE );
588 Security_LineEdit_Key1Ascii->setEnabled( TRUE );
589 Security_LineEdit_Key2Hex->setEnabled( TRUE );
590 Security_LineEdit_Key2Ascii->setEnabled( TRUE );
591 Security_LineEdit_Key3Hex->setEnabled( TRUE );
592 Security_LineEdit_Key3Ascii->setEnabled( TRUE );
593 Security_LineEdit_Key4Hex->setEnabled( TRUE );
594 Security_LineEdit_Key4Ascii->setEnabled( TRUE );
597 else if (textAuthen.compare("WPAPSK") == 0)
599 Security_LineEdit_PSK->setEnabled( TRUE );
601 Security_ComboBox_Encrypt->clear();
602 Security_ComboBox_Encrypt->insertItem("TKIP");
603 Security_ComboBox_Encrypt->insertItem("AES");
604 Security_ComboBox_Encrypt->setCurrentItem( 0 );
606 Security_RadioButton_Key1->setEnabled( FALSE );
607 Security_RadioButton_Key2->setEnabled( FALSE );
608 Security_RadioButton_Key3->setEnabled( FALSE );
609 Security_RadioButton_Key4->setEnabled( FALSE );
611 Security_ComboBox_KeyType1->setEnabled( FALSE );
612 Security_ComboBox_KeyType2->setEnabled( FALSE );
613 Security_ComboBox_KeyType3->setEnabled( FALSE );
614 Security_ComboBox_KeyType4->setEnabled( FALSE );
616 Security_LineEdit_Key1Hex->setEnabled( FALSE );
617 Security_LineEdit_Key1Ascii->setEnabled( FALSE );
618 Security_LineEdit_Key2Hex->setEnabled( FALSE );
619 Security_LineEdit_Key2Ascii->setEnabled( FALSE );
620 Security_LineEdit_Key3Hex->setEnabled( FALSE );
621 Security_LineEdit_Key3Ascii->setEnabled( FALSE );
622 Security_LineEdit_Key4Hex->setEnabled( FALSE );
623 Security_LineEdit_Key4Ascii->setEnabled( FALSE );
627 void AuthSecuDlg::Security_OnSelectEncryptType(int id)
629 QString textAuthen;
630 QString textEncry;
632 textEncry = Security_ComboBox_Encrypt->text(id);
633 textAuthen = Security_ComboBox_AuthType->currentText();
634 if ((textAuthen.compare("OPEN") == 0) || (textAuthen.compare("SHARED") == 0))
636 if (textEncry.compare("NONE") == 0)
638 Security_RadioButton_Key1->setEnabled( FALSE );
639 Security_RadioButton_Key2->setEnabled( FALSE );
640 Security_RadioButton_Key3->setEnabled( FALSE );
641 Security_RadioButton_Key4->setEnabled( FALSE );
643 Security_ComboBox_KeyType1->setEnabled( FALSE );
644 Security_ComboBox_KeyType2->setEnabled( FALSE );
645 Security_ComboBox_KeyType3->setEnabled( FALSE );
646 Security_ComboBox_KeyType4->setEnabled( FALSE );
648 Security_LineEdit_Key1Hex->setEnabled( FALSE );
649 Security_LineEdit_Key1Ascii->setEnabled( FALSE );
650 Security_LineEdit_Key2Hex->setEnabled( FALSE );
651 Security_LineEdit_Key2Ascii->setEnabled( FALSE );
652 Security_LineEdit_Key3Hex->setEnabled( FALSE );
653 Security_LineEdit_Key3Ascii->setEnabled( FALSE );
654 Security_LineEdit_Key4Hex->setEnabled( FALSE );
655 Security_LineEdit_Key4Ascii->setEnabled( FALSE );
657 Security_ComboBox_AuthType->setCurrentItem(0);
659 else
661 Security_RadioButton_Key1->setEnabled( TRUE );
662 Security_RadioButton_Key2->setEnabled( TRUE );
663 Security_RadioButton_Key3->setEnabled( TRUE );
664 Security_RadioButton_Key4->setEnabled( TRUE );
666 Security_ComboBox_KeyType1->setEnabled( TRUE );
667 Security_ComboBox_KeyType2->setEnabled( TRUE );
668 Security_ComboBox_KeyType3->setEnabled( TRUE );
669 Security_ComboBox_KeyType4->setEnabled( TRUE );
671 Security_LineEdit_Key1Hex->setEnabled( TRUE );
672 Security_LineEdit_Key1Ascii->setEnabled( TRUE );
673 Security_LineEdit_Key2Hex->setEnabled( TRUE );
674 Security_LineEdit_Key2Ascii->setEnabled( TRUE );
675 Security_LineEdit_Key3Hex->setEnabled( TRUE );
676 Security_LineEdit_Key3Ascii->setEnabled( TRUE );
677 Security_LineEdit_Key4Hex->setEnabled( TRUE );
678 Security_LineEdit_Key4Ascii->setEnabled( TRUE );
683 void AuthSecuDlg::Security_OnSelectKey1Type(int id)
685 if (id==0)
686 {//hex
687 Security_LineEdit_Key1Hex->show();
688 Security_LineEdit_Key1Ascii->hide();
690 else
691 {//Ascii
692 Security_LineEdit_Key1Hex->hide();
693 Security_LineEdit_Key1Ascii->show();
697 void AuthSecuDlg::Security_OnSelectKey2Type(int id)
699 if (id==0)
700 {//hex
701 Security_LineEdit_Key2Hex->show();
702 Security_LineEdit_Key2Ascii->hide();
704 else
705 {//Ascii
706 Security_LineEdit_Key2Hex->hide();
707 Security_LineEdit_Key2Ascii->show();
711 void AuthSecuDlg::Security_OnSelectKey3Type(int id)
713 if (id==0)
714 {//hex
715 Security_LineEdit_Key3Hex->show();
716 Security_LineEdit_Key3Ascii->hide();
718 else
719 {//Ascii
720 Security_LineEdit_Key3Hex->hide();
721 Security_LineEdit_Key3Ascii->show();
725 void AuthSecuDlg::Security_OnSelectKey4Type(int id)
727 if (id==0)
728 {//hex
729 Security_LineEdit_Key4Hex->show();
730 Security_LineEdit_Key4Ascii->hide();
732 else
733 {//Ascii
734 Security_LineEdit_Key4Hex->hide();
735 Security_LineEdit_Key4Ascii->show();
739 bool AuthSecuDlg::Security_IsClickOk()
741 return (m_isClickOk);