1 #include "addprofiledlg.h"
3 #include <qapplication.h>
6 #include <qdragobject.h>
8 #include <qbuttongroup.h>
10 #include <qcombobox.h>
12 #include <qlineedit.h>
13 #include <qpushbutton.h>
14 #include <qradiobutton.h>
17 #include <qtabwidget.h>
21 #include <qwhatsthis.h>
24 #include <qvalidator.h>
25 #include <qmessagebox.h>
26 #include <qlistview.h>
30 #include <sys/socket.h>
31 #include <sys/ioctl.h>
32 #include <linux/wireless.h>
37 extern bool G_bSupportAMode
;
38 extern RT_802_11_PHY_MODE G_enumWirelessMode
;
39 extern PAIR_CHANNEL_FREQ_ENTRY ChannelFreqTable
[];
40 extern int G_nChanFreqCount
;
41 extern UINT G_nCountryRegion
;
42 extern const char *strAryNetworkType
[];
44 // 2.4 Ghz channel plan
45 static UCHAR Ra24Ghz_FCC
[] = {1,2,3,4,5,6,7,8,9,10,11};
46 static UCHAR Ra24Ghz_IC
[] = {1,2,3,4,5,6,7,8,9,10,11};
47 static UCHAR Ra24Ghz_ESTI
[]= {1,2,3,4,5,6,7,8,9,10,11,12,13};
48 static UCHAR Ra24Ghz_SPAIN
[] = {10,11};
49 static UCHAR Ra24Ghz_FRANCE
[] = {10,11,12,13};
50 static UCHAR Ra24Ghz_MKK
[] = {14};
51 static UCHAR Ra24Ghz_MKK1
[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14};
52 static UCHAR Ra24Ghz_ISRAEL
[] = {3,4,5,6,7,8,9};
54 static UCHAR Ra5Ghz_UNII
[] = {36,40,44,48,52,56,60,64, 149,153,157,161};
55 //static UCHAR Ra5Ghz_MMAC[] = {34,38,42,46};
56 //static UCHAR Ra5Ghz_HyperLAN2[] = {36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140};
58 static QPixmap
uic_load_pixmap_AddProfileDlg( const QString
&name
)
60 const QMimeSource
*m
= QMimeSourceFactory::defaultFactory()->data( name
);
64 QImageDrag::decode( m
, pix
);
68 * Constructs a AddProfileDlg which is a child of 'parent', with the
69 * name 'name' and widget flags set to 'f'.
71 * The dialog will by default be modeless, unless you set 'modal' to
72 * TRUE to construct a modal dialog.
74 AddProfileDlg::AddProfileDlg( int socket_id
, const char *device_name
, QWidget
* parent
, const char* name
, int Type
, QListView
* pListView
, PRT_PROFILE_SETTING
*pProfilePtr
, NDIS_802_11_MAC_ADDRESS
*pBSsid
, bool modal
, WFlags fl
)
75 : QDialog( parent
, name
, modal
, fl
)
78 setName( "AddProfileDlg" );
80 setMinimumSize( 620, 420 );
81 setMaximumSize( 620, 420 );
82 setCaption("AddProfile");
83 qApp
->setStyle("Windows");
85 TextLabel1
= new QLabel( this, "TextLabel1" );
86 TextLabel1
->setGeometry( QRect( 30, 15, 90, 30 ) );
87 TextLabel1
->setText("Profile Name");
89 LineEdit_ProfileName
= new QLineEdit( this, "LineEdit_ProfileName" );
90 LineEdit_ProfileName
->setGeometry( QRect( 140, 15, 200, 30 ) );
92 TextLabel2
= new QLabel( this, "TextLabel2" );
93 TextLabel2
->setGeometry( QRect( 360, 15, 50, 30 ) );
94 TextLabel2
->setText("SSID");
96 ComboBox_SSID
= new QComboBox( FALSE
, this, "ComboBox_SSID" );
97 ComboBox_SSID
->setGeometry( QRect( 410, 15, 200, 30 ) );
98 ComboBox_SSID
->setEditable( TRUE
);
100 TabWidget_Config
= new QTabWidget( this, "TabWidget_Config" );
101 TabWidget_Config
->setGeometry( QRect( 20, 50, 580, 320 ) );
103 ConfigPage_tab
= new QWidget( TabWidget_Config
, "ConfigPage_tab" );
105 Config_ButtonGroup_PowerSaveing
= new QButtonGroup( ConfigPage_tab
, "Config_ButtonGroup_PowerSaveing" );
106 Config_ButtonGroup_PowerSaveing
->setGeometry( QRect( 20, 10, 535, 60 ) );
107 Config_ButtonGroup_PowerSaveing
->setTitle("Power Saving Mode");
108 Config_ButtonGroup_PowerSaveing
->setExclusive( FALSE
);
110 Config_RadioButton_CAM
= new QRadioButton( Config_ButtonGroup_PowerSaveing
, "Config_RadioButton_CAM" );
111 Config_RadioButton_CAM
->setEnabled( TRUE
);
112 Config_RadioButton_CAM
->setGeometry( QRect( 25, 20, 200, 30 ) );
113 Config_RadioButton_CAM
->setText("CAM (Constantly Awake Mode)");
114 Config_RadioButton_CAM
->setChecked( TRUE
);
115 Config_ButtonGroup_PowerSaveing
->insert( Config_RadioButton_CAM
, 0 );
117 Config_RadioButton_PSMode
= new QRadioButton( Config_ButtonGroup_PowerSaveing
, "Config_RadioButton_PSMode" );
118 Config_RadioButton_PSMode
->setEnabled( TRUE
);
119 Config_RadioButton_PSMode
->setGeometry( QRect( 300, 20, 200, 30 ) );
120 Config_RadioButton_PSMode
->setText("Power Saving Mode");
121 Config_RadioButton_PSMode
->setChecked( FALSE
);
122 Config_ButtonGroup_PowerSaveing
->insert( Config_RadioButton_PSMode
, 1 );
124 Config_TextLabel1
= new QLabel( ConfigPage_tab
, "Config_TextLabel1" );
125 Config_TextLabel1
->setGeometry( QRect( 25, 85, 100, 30 ) );
126 Config_TextLabel1
->setText("Network Type");
128 Config_ComboBox_NetworkType
= new QComboBox( FALSE
, ConfigPage_tab
, "Config_ComboBox_NetworkType" );
129 Config_ComboBox_NetworkType
->insertItem("802.11 Ad Hoc");
130 Config_ComboBox_NetworkType
->insertItem("Infrasturcture");
131 Config_ComboBox_NetworkType
->setGeometry( QRect( 150, 85, 180, 30 ) );
132 Config_ComboBox_NetworkType
->setCurrentItem( 1 );
134 Config_TextLabel2
= new QLabel( ConfigPage_tab
, "Config_TextLabel2" );
135 Config_TextLabel2
->setGeometry( QRect( 25, 130, 120, 30 ) );
136 Config_TextLabel2
->setText("11B Preamble Type");
138 Config_ComboBox_Preamble
= new QComboBox( FALSE
, ConfigPage_tab
, "Config_ComboBox_Preamble" );
139 Config_ComboBox_Preamble
->insertItem("Auto");
140 Config_ComboBox_Preamble
->insertItem("Long");
141 Config_ComboBox_Preamble
->setEnabled( FALSE
);
142 Config_ComboBox_Preamble
->setGeometry( QRect( 150, 130, 180, 30 ) );
144 Config_CheckBox_RTS
= new QCheckBox( ConfigPage_tab
, "Config_CheckBox_RTS" );
145 Config_CheckBox_RTS
->setGeometry( QRect( 15, 187, 130, 30 ) );
146 Config_CheckBox_RTS
->setText("RTS Threshold");
148 Config_TextLabel3
= new QLabel( ConfigPage_tab
, "Config_TextLabel3" );
149 Config_TextLabel3
->setGeometry( QRect( 165, 167, 20, 30 ) );
150 Config_TextLabel3
->setText("0");
152 Config_Slider_RTS
= new QSlider( ConfigPage_tab
, "Config_Slider_RTS" );
153 Config_Slider_RTS
->setEnabled( FALSE
);
154 Config_Slider_RTS
->setGeometry( QRect( 195, 187, 180, 30 ) );
155 Config_Slider_RTS
->setMaxValue( 2312 );
156 Config_Slider_RTS
->setValue( 2312 );
157 Config_Slider_RTS
->setOrientation( QSlider::Horizontal
);
159 Config_TextLabel4
= new QLabel( ConfigPage_tab
, "Config_TextLabel4" );
160 Config_TextLabel4
->setGeometry( QRect( 385, 167, 35, 30 ) );
161 Config_TextLabel4
->setText("2312");
163 Config_SpinBox_RTS
= new QSpinBox( ConfigPage_tab
, "Config_SpinBox_RTS" );
164 Config_SpinBox_RTS
->setEnabled( FALSE
);
165 Config_SpinBox_RTS
->setGeometry( QRect( 425, 187, 50, 30 ) );
166 Config_SpinBox_RTS
->setMaxValue( 2312 );
167 Config_SpinBox_RTS
->setValue( 2312 );
169 Config_CheckBox_Fragment
= new QCheckBox( ConfigPage_tab
, "Config_CheckBox_Fragment" );
170 Config_CheckBox_Fragment
->setGeometry( QRect( 15, 220, 140, 30 ) );
171 Config_CheckBox_Fragment
->setText("Fragment Threshold");
173 Config_Slider_Fragment
= new QSlider( ConfigPage_tab
, "Config_Slider_Fragment" );
174 Config_Slider_Fragment
->setEnabled( FALSE
);
175 Config_Slider_Fragment
->setGeometry( QRect( 195, 225, 180, 30 ) );
176 Config_Slider_Fragment
->setMinValue( 256 );
177 Config_Slider_Fragment
->setMaxValue( 2312 );
178 Config_Slider_Fragment
->setValue( 2312 );
179 Config_Slider_Fragment
->setOrientation( QSlider::Horizontal
);
181 Config_TextLabel5
= new QLabel( ConfigPage_tab
, "Config_TextLabel5" );
182 Config_TextLabel5
->setGeometry( QRect( 165, 205, 20, 30 ) );
183 Config_TextLabel5
->setText("256");
185 Config_SpinBox_Fragment
= new QSpinBox( ConfigPage_tab
, "Config_SpinBox_Fragment" );
186 Config_SpinBox_Fragment
->setEnabled( FALSE
);
187 Config_SpinBox_Fragment
->setGeometry( QRect( 425, 225, 50, 30 ) );
188 Config_SpinBox_Fragment
->setMaxValue( 2312 );
189 Config_SpinBox_Fragment
->setMinValue( 256 );
190 Config_SpinBox_Fragment
->setValue( 2312 );
192 Config_TextLabel6
= new QLabel( ConfigPage_tab
, "Config_TextLabel6" );
193 Config_TextLabel6
->setGeometry( QRect( 385, 205, 35, 30 ) );
194 Config_TextLabel6
->setText("2312");
196 Config_TextLabel_Channel
= new QLabel( ConfigPage_tab
, "Config_TextLabel_Channel" );
197 Config_TextLabel_Channel
->setGeometry( QRect( 490, 187, 61, 31 ) );
198 Config_TextLabel_Channel
->setText("Channel");
199 Config_TextLabel_Channel
->hide();
201 Config_ComboBox_Channel
= new QComboBox( FALSE
, ConfigPage_tab
, "Config_ComboBox_Channel" );
202 Config_ComboBox_Channel
->insertItem("1");
203 Config_ComboBox_Channel
->setGeometry( QRect( 490, 225, 71, 31 ) );
204 Config_ComboBox_Channel
->hide();
206 TabWidget_Config
->insertTab( ConfigPage_tab
, "System Configuration");
208 //Authentication_Security Page
209 SecurityPage_tab
= new QWidget( TabWidget_Config
, "SecurityPage_tab" );
211 Security_TextLabel1
= new QLabel( SecurityPage_tab
, "Security_TextLabel1" );
212 Security_TextLabel1
->setGeometry( QRect( 15, 15, 120, 30 ) );
213 Security_TextLabel1
->setText("Authentication Type:");
215 Security_ComboBox_AuthType
= new QComboBox( FALSE
, SecurityPage_tab
, "Security_ComboBox_AuthType" );
216 Security_ComboBox_AuthType
->insertItem("OPEN");
217 Security_ComboBox_AuthType
->insertItem("SHARED");
218 Security_ComboBox_AuthType
->insertItem("WPAPSK");
219 Security_ComboBox_AuthType
->setGeometry( QRect( 145, 15, 120, 30 ) );
220 Security_ComboBox_AuthType
->setCurrentItem(0);
222 Security_TextLabel2
= new QLabel( SecurityPage_tab
, "Security_TextLabel2" );
223 Security_TextLabel2
->setGeometry( QRect( 308, 15, 120, 30 ) );
224 Security_TextLabel2
->setText("Encryptiion Type:");
226 Security_ComboBox_Encrypt
= new QComboBox( FALSE
, SecurityPage_tab
, "Security_ComboBox_Encrypt" );
227 Security_ComboBox_Encrypt
->insertItem("NONE");
228 Security_ComboBox_Encrypt
->insertItem("WEP");
229 Security_ComboBox_Encrypt
->setGeometry( QRect( 435, 16, 120, 30 ) );
230 Security_ComboBox_Encrypt
->setCurrentItem(0);
232 Security_TextLabel3
= new QLabel( SecurityPage_tab
, "Security_TextLabel3" );
233 Security_TextLabel3
->setGeometry( QRect( 15, 60, 120, 31 ) );
234 Security_TextLabel3
->setText("WPA Pre-Shared Key:");
236 Security_LineEdit_PSK
= new QLineEdit( SecurityPage_tab
, "Security_LineEdit_PSK" );
237 Security_LineEdit_PSK
->setGeometry( QRect( 145, 60, 410, 30 ) );
238 Security_LineEdit_PSK
->setMaxLength(64);
239 Security_LineEdit_PSK
->setEnabled( FALSE
);
241 Security_ButtonGroup_Key
= new QButtonGroup( SecurityPage_tab
, "Security_ButtonGroup_Key" );
242 Security_ButtonGroup_Key
->setGeometry( QRect( 20, 108, 535, 170 ) );
243 Security_ButtonGroup_Key
->setTitle("WEP Key");
245 Security_RadioButton_Key1
= new QRadioButton( Security_ButtonGroup_Key
, "Security_RadioButton_Key1" );
246 Security_RadioButton_Key1
->setGeometry( QRect( 10, 20, 70, 30 ) );
247 Security_RadioButton_Key1
->setText("Key#1");
248 Security_RadioButton_Key1
->setEnabled( FALSE
);
249 Security_RadioButton_Key1
->setChecked( TRUE
);
250 Security_ButtonGroup_Key
->insert( Security_RadioButton_Key1
, 0 );
252 Security_ComboBox_KeyType1
= new QComboBox( FALSE
, Security_ButtonGroup_Key
, "Security_ComboBox_KeyType1" );
253 Security_ComboBox_KeyType1
->insertItem("Hexadecimal");
254 Security_ComboBox_KeyType1
->insertItem("Ascii");
255 Security_ComboBox_KeyType1
->setGeometry( QRect( 90, 20, 120, 30 ) );
256 Security_ComboBox_KeyType1
->setEnabled( FALSE
);
258 m_hexValidator
= new QHexValidator(this);
260 Security_LineEdit_Key1Hex
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key1Hex" );
261 Security_LineEdit_Key1Hex
->setGeometry( QRect( 225, 20, 290, 30 ) );
262 Security_LineEdit_Key1Hex
->setMaxLength(26);
263 Security_LineEdit_Key1Hex
->setEnabled( FALSE
);
264 Security_LineEdit_Key1Hex
->setValidator(m_hexValidator
);
266 Security_LineEdit_Key1Ascii
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key1Ascii" );
267 Security_LineEdit_Key1Ascii
->setGeometry( QRect( 225, 20, 290, 30 ) );
268 Security_LineEdit_Key1Ascii
->setMaxLength(13);
269 Security_LineEdit_Key1Ascii
->hide();
270 Security_LineEdit_Key1Ascii
->setEnabled( FALSE
);
272 Security_RadioButton_Key2
= new QRadioButton( Security_ButtonGroup_Key
, "Security_RadioButton_Key2" );
273 Security_RadioButton_Key2
->setGeometry( QRect( 10, 55, 70, 30 ) );
274 Security_RadioButton_Key2
->setText("Key#2");
275 Security_RadioButton_Key2
->setEnabled( FALSE
);
276 Security_RadioButton_Key2
->setChecked( FALSE
);
277 Security_ButtonGroup_Key
->insert( Security_RadioButton_Key2
, 1 );
279 Security_ComboBox_KeyType2
= new QComboBox( FALSE
, Security_ButtonGroup_Key
, "Security_ComboBox_KeyType2" );
280 Security_ComboBox_KeyType2
->insertItem("Hexadecimal");
281 Security_ComboBox_KeyType2
->insertItem("Ascii");
282 Security_ComboBox_KeyType2
->setGeometry( QRect( 90, 55, 120, 30 ) );
283 Security_ComboBox_KeyType2
->setEnabled( FALSE
);
285 Security_LineEdit_Key2Hex
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key2Hex" );
286 Security_LineEdit_Key2Hex
->setGeometry( QRect( 225, 55, 290, 30 ) );
287 Security_LineEdit_Key2Hex
->setMaxLength(26);
288 Security_LineEdit_Key2Hex
->setEnabled( FALSE
);
289 Security_LineEdit_Key2Hex
->setValidator(m_hexValidator
);
291 Security_LineEdit_Key2Ascii
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key2Ascii" );
292 Security_LineEdit_Key2Ascii
->setGeometry( QRect( 225, 55, 290, 30 ) );
293 Security_LineEdit_Key2Ascii
->setMaxLength(13);
294 Security_LineEdit_Key2Ascii
->hide();
295 Security_LineEdit_Key2Ascii
->setEnabled( FALSE
);
297 Security_RadioButton_Key3
= new QRadioButton( Security_ButtonGroup_Key
, "Security_RadioButton_Key3" );
298 Security_RadioButton_Key3
->setGeometry( QRect( 10, 90, 70, 30 ) );
299 Security_RadioButton_Key3
->setText("Key#3");
300 Security_RadioButton_Key3
->setEnabled( FALSE
);
301 Security_RadioButton_Key3
->setChecked( FALSE
);
302 Security_ButtonGroup_Key
->insert( Security_RadioButton_Key3
, 2 );
304 Security_ComboBox_KeyType3
= new QComboBox( FALSE
, Security_ButtonGroup_Key
, "Security_ComboBox_KeyType3" );
305 Security_ComboBox_KeyType3
->insertItem("Hexadecimal");
306 Security_ComboBox_KeyType3
->insertItem("Ascii");
307 Security_ComboBox_KeyType3
->setGeometry( QRect( 90, 90, 120, 30 ) );
308 Security_ComboBox_KeyType3
->setEnabled( FALSE
);
310 Security_LineEdit_Key3Hex
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key3Hex" );
311 Security_LineEdit_Key3Hex
->setGeometry( QRect( 225, 90, 290, 30 ) );
312 Security_LineEdit_Key3Hex
->setMaxLength(26);
313 Security_LineEdit_Key3Hex
->setEnabled( FALSE
);
314 Security_LineEdit_Key3Hex
->setValidator(m_hexValidator
);
316 Security_LineEdit_Key3Ascii
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key3Ascii" );
317 Security_LineEdit_Key3Ascii
->setGeometry( QRect( 225, 90, 290, 30 ) );
318 Security_LineEdit_Key3Ascii
->setMaxLength(13);
319 Security_LineEdit_Key3Ascii
->hide();
320 Security_LineEdit_Key3Ascii
->setEnabled( FALSE
);
322 Security_RadioButton_Key4
= new QRadioButton( Security_ButtonGroup_Key
, "Security_RadioButton_Key4" );
323 Security_RadioButton_Key4
->setGeometry( QRect( 10, 125, 70, 30 ) );
324 Security_RadioButton_Key4
->setText("Key#4");
325 Security_RadioButton_Key4
->setEnabled( FALSE
);
326 Security_RadioButton_Key4
->setChecked( FALSE
);
327 Security_ButtonGroup_Key
->insert( Security_RadioButton_Key4
, 3 );
329 Security_ComboBox_KeyType4
= new QComboBox( FALSE
, Security_ButtonGroup_Key
, "Security_ComboBox_KeyType4" );
330 Security_ComboBox_KeyType4
->insertItem("Hexadecimal");
331 Security_ComboBox_KeyType4
->insertItem("Ascii");
332 Security_ComboBox_KeyType4
->setGeometry( QRect( 90, 125, 120, 30 ) );
333 Security_ComboBox_KeyType4
->setEnabled( FALSE
);
335 Security_LineEdit_Key4Hex
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key4Hex" );
336 Security_LineEdit_Key4Hex
->setGeometry( QRect( 225, 125, 290, 30 ) );
337 Security_LineEdit_Key4Hex
->setMaxLength(26);
338 Security_LineEdit_Key4Hex
->setEnabled( FALSE
);
339 Security_LineEdit_Key4Hex
->setValidator(m_hexValidator
);
341 Security_LineEdit_Key4Ascii
= new QLineEdit( Security_ButtonGroup_Key
, "Security_LineEdit_Key4Ascii" );
342 Security_LineEdit_Key4Ascii
->setGeometry( QRect( 225, 125, 290, 30 ) );
343 Security_LineEdit_Key4Ascii
->setEnabled( FALSE
);
344 Security_LineEdit_Key4Ascii
->setMaxLength(13);
345 Security_LineEdit_Key4Ascii
->hide();
346 Security_LineEdit_Key4Ascii
->setEnabled( FALSE
);
348 TabWidget_Config
->insertTab( SecurityPage_tab
, "Authentication && Security");
350 PushButton_OK
= new QPushButton( this, "PushButton_OK" );
351 PushButton_OK
->setGeometry( QRect( 170, 380, 120, 30 ) );
352 PushButton_OK
->setText("&OK");
354 PushButton_Cancel
= new QPushButton( this, "PushButton_Cancel" );
355 PushButton_Cancel
->setGeometry( QRect( 340, 380, 120, 30 ) );
356 PushButton_Cancel
->setText("&CANCEL");
358 connect( PushButton_OK
, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
359 connect( PushButton_Cancel
, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
360 connect( ComboBox_SSID
, SIGNAL( activated(int) ), this, SLOT( Config_OnSelectSSID(int) ) );
361 connect( Config_ComboBox_NetworkType
, SIGNAL( activated(int) ), this, SLOT( Config_OnSelectNetworkType(int) ) );
362 connect( Config_CheckBox_RTS
, SIGNAL( toggled(bool) ), this, SLOT( Config_OnEnableRTS(bool) ) );
363 connect( Config_CheckBox_Fragment
, SIGNAL( toggled(bool) ), this, SLOT( Config_OnEnableFragment(bool) ) );
364 connect( Config_Slider_RTS
, SIGNAL( valueChanged(int) ), this, SLOT( Config_OnRTSSliderChanged(int) ) );
365 connect( Config_Slider_Fragment
, SIGNAL( valueChanged(int) ), this, SLOT( Config_OnFragmentSliderChanged(int) ) );
366 connect( Config_SpinBox_RTS
, SIGNAL( valueChanged(int) ), this, SLOT( Config_OnRTSSpinBoxChanged(int) ) );
367 connect( Config_SpinBox_Fragment
, SIGNAL( valueChanged(int) ), this, SLOT( Config_OnFragmentSpinBoxChanged(int) ) );
368 connect( Security_ComboBox_AuthType
, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectAuthenType(int) ) );
369 connect( Security_ComboBox_Encrypt
, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectEncryptType(int) ) );
370 connect( Security_ComboBox_KeyType1
, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey1Type(int) ) );
371 connect( Security_ComboBox_KeyType2
, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey2Type(int) ) );
372 connect( Security_ComboBox_KeyType3
, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey3Type(int) ) );
373 connect( Security_ComboBox_KeyType4
, SIGNAL( activated(int) ), this, SLOT( Security_OnSelectKey4Type(int) ) );
375 m_IsAddToProfile
= FALSE
;
376 m_pBssidList
= (PNDIS_802_11_BSSID_LIST_EX
) malloc(65536); //64K
377 m_nSocketId
= socket_id
;
381 m_strDeviceName
= (char *)malloc(strlen(device_name
)+1);
383 strcpy(m_strDeviceName
, device_name
);
388 memcpy(m_BSsid
, pBSsid
, sizeof(NDIS_802_11_MAC_ADDRESS
));
392 m_pProfileSetting
= *pProfilePtr
;
394 if (m_pProfileSetting
== NULL
)
396 m_pProfileSetting
= (PRT_PROFILE_SETTING
) malloc(sizeof(RT_PROFILE_SETTING
));
397 memset(m_pProfileSetting
, 0x00, sizeof(RT_PROFILE_SETTING
));
398 *pProfilePtr
= m_pProfileSetting
;
399 m_bIsProfileNull
= TRUE
;
403 m_pProfileSetting
= *pProfilePtr
;
404 m_bIsProfileNull
= FALSE
;
408 m_ProfileListView
= pListView
;
410 m_ProfileListView
= NULL
;
416 * Destroys the object and frees any allocated resources
418 AddProfileDlg::~AddProfileDlg()
420 // no need to delete child widgets, Qt does it all for us
423 void AddProfileDlg::InitDlg()
427 PRT_PROFILE_SETTING ptr
= NULL
;
435 if (m_type
== PROFILE_ADD
)
437 for (i
=1; i
< 1000; i
++)
439 sprintf(tmp
, "PROF%03d", i
);
440 ptr
= m_pProfileSetting
;
444 if (strcmp(tmp
, (const char *)ptr
->Profile
) == 0)
454 LineEdit_ProfileName
->setText(tmp
);
460 else if (m_type
== PROFILE_EDIT
)
462 Item
= m_ProfileListView
->currentItem();
463 qstr
= Item
->text(0);
465 ptr
= m_pProfileSetting
;
468 if (qstr
.compare((const char *)ptr
->Profile
) == 0)
471 m_pEditProfileSetting
= ptr
;
472 LineEdit_ProfileName
->setText((const char *)ptr
->Profile
);
473 ComboBox_SSID
->setCurrentText((const char *)ptr
->SSID
);
477 case Ndis802_11PowerModeCAM
:
478 Config_ButtonGroup_PowerSaveing
->setButton(0);
480 case Ndis802_11PowerModeMAX_PSP
:
481 Config_ButtonGroup_PowerSaveing
->setButton(1);
483 case Ndis802_11PowerModeFast_PSP
:
484 Config_ButtonGroup_PowerSaveing
->setButton(2);
490 if (ptr
->NetworkType
== Ndis802_11IBSS
)
492 Config_ComboBox_NetworkType
->setCurrentItem(0);
493 Config_TextLabel_Channel
->show();
494 Config_ComboBox_Channel
->show();
495 if (ptr
->Channel
== 0)
496 Config_ComboBox_Channel
->setCurrentItem(0);
499 sprintf(tmp
, "%d", ptr
->Channel
);
500 Config_ComboBox_Channel
->setCurrentText(tmp
);
505 Config_ComboBox_NetworkType
->setCurrentItem(1);
506 Config_TextLabel_Channel
->hide();
507 Config_ComboBox_Channel
->hide();
510 if (ptr
->PreamType
== Rt802_11PreambleAuto
)
511 Config_ComboBox_Preamble
->setCurrentItem(0);
513 Config_ComboBox_Preamble
->setCurrentItem(1);
515 Config_CheckBox_RTS
->setChecked(ptr
->RTSCheck
);
517 Config_Slider_RTS
->setValue( ptr
->RTS
);
519 Config_SpinBox_RTS
->setValue( ptr
->RTS
);
521 Config_CheckBox_Fragment
->setChecked(ptr
->FragmentCheck
);
523 Config_Slider_Fragment
->setValue(ptr
->Fragment
);
525 Config_SpinBox_Fragment
->setValue(ptr
->Fragment
);
527 Security_SetAuthModeAndEncryType(ptr
->NetworkType
, ptr
->Authentication
, ptr
->Encryption
);
529 Security_LineEdit_PSK
->setText(ptr
->WpaPsk
);
530 Security_SetDefaultKeyId(ptr
->KeyDefaultId
);
531 Security_SetKeyTypeAndKeyString(0, ptr
->Key1Type
, ptr
->Key1
);
532 Security_SetKeyTypeAndKeyString(1, ptr
->Key2Type
, ptr
->Key2
);
533 Security_SetKeyTypeAndKeyString(2, ptr
->Key3Type
, ptr
->Key3
);
534 Security_SetKeyTypeAndKeyString(3, ptr
->Key4Type
, ptr
->Key4
);
540 QMessageBox::warning(this, "Warning", "Edit Profile failed, try again!");
546 void AddProfileDlg::GetAllSsid()
548 PNDIS_WLAN_BSSID_EX pBssid
;
550 char strSSID
[NDIS_802_11_LENGTH_SSID
+ 1];
551 ULONG lBufLen
= 65536; // 64K
556 if (OidQueryInformation(OID_802_11_BSSID_LIST
, m_nSocketId
, m_strDeviceName
, m_pBssidList
, lBufLen
) < 0)
559 ComboBox_SSID
->clear();
560 ComboBox_SSID
->insertItem("");
562 pBssid
= m_pBssidList
->Bssid
;
564 // Add each SSID to the combo
565 for(i
= 0; i
< m_pBssidList
->NumberOfItems
; i
++)
567 memset(strSSID
, 0x00, NDIS_802_11_LENGTH_SSID
+ 1);
568 memcpy(strSSID
, pBssid
->Ssid
.Ssid
, pBssid
->Ssid
.SsidLength
);
570 ComboBox_SSID
->insertItem(strSSID
);
572 if(memcmp(pBssid
->MacAddress
, m_BSsid
, 6) == 0)
574 ComboBox_SSID
->setCurrentText(strSSID
);
575 if (pBssid
->InfrastructureMode
== Ndis802_11Infrastructure
)
577 Config_ComboBox_NetworkType
->setCurrentItem(1);
578 Config_TextLabel_Channel
->hide();
579 Config_ComboBox_Channel
->hide();
583 Config_ComboBox_NetworkType
->setCurrentItem(0);
584 Config_TextLabel_Channel
->show();
585 Config_ComboBox_Channel
->show();
587 if (pBssid
->Configuration
.DSConfig
== 2484000)
589 else if (pBssid
->Configuration
.DSConfig
>= 2412000 && pBssid
->Configuration
.DSConfig
< 2484000)
590 nChannel
= (int)((pBssid
->Configuration
.DSConfig
- 2412000) / 5000) + 1;
592 sprintf(tmp
, "%d", nChannel
);
593 Config_ComboBox_Channel
->setCurrentText( tmp
);
596 pBssid
= (PNDIS_WLAN_BSSID_EX
)((char *)pBssid
+ pBssid
->Length
);
600 void AddProfileDlg::InitChannel()
602 UCHAR aryChan
[32] = {0};
603 char channelString
[10];
607 if (G_enumWirelessMode
!= PHY_11A
)
609 switch (G_nCountryRegion
)
611 case REGSTR_COUNTRYREGION_IC
:
612 memcpy(&aryChan
[nIndex
], Ra24Ghz_IC
, sizeof(Ra24Ghz_IC
));
613 nIndex
+= sizeof(Ra24Ghz_IC
);
615 case REGSTR_COUNTRYREGION_ETSI
:
616 memcpy(&aryChan
[nIndex
], Ra24Ghz_ESTI
, sizeof(Ra24Ghz_ESTI
));
617 nIndex
+= sizeof(Ra24Ghz_ESTI
);
619 case REGSTR_COUNTRYREGION_SPAIN
:
620 memcpy(&aryChan
[nIndex
], Ra24Ghz_SPAIN
, sizeof(Ra24Ghz_SPAIN
));
621 nIndex
+= sizeof(Ra24Ghz_SPAIN
);
623 case REGSTR_COUNTRYREGION_FRANCE
:
624 memcpy(&aryChan
[nIndex
], Ra24Ghz_FRANCE
, sizeof(Ra24Ghz_FRANCE
));
625 nIndex
+= sizeof(Ra24Ghz_FRANCE
);
627 case REGSTR_COUNTRYREGION_MKK
:
628 memcpy(&aryChan
[nIndex
], Ra24Ghz_MKK
, sizeof(Ra24Ghz_MKK
));
629 nIndex
+= sizeof(Ra24Ghz_MKK
);
631 case REGSTR_COUNTRYREGION_MKK1
:
632 memcpy(&aryChan
[nIndex
], Ra24Ghz_MKK1
, sizeof(Ra24Ghz_MKK1
));
633 nIndex
+= sizeof(Ra24Ghz_MKK1
);
635 case REGSTR_COUNTRYREGION_ISRAEL
:
636 memcpy(&aryChan
[nIndex
], Ra24Ghz_ISRAEL
, sizeof(Ra24Ghz_ISRAEL
));
637 nIndex
+= sizeof(Ra24Ghz_ISRAEL
);
639 case REGSTR_COUNTRYREGION_FCC
:
641 memcpy(&aryChan
[nIndex
], Ra24Ghz_FCC
, sizeof(Ra24Ghz_FCC
));
642 nIndex
+= sizeof(Ra24Ghz_FCC
);
647 if (G_enumWirelessMode
== PHY_11A
|| G_enumWirelessMode
== PHY_11ABG_MIXED
)
649 memcpy(&aryChan
[nIndex
], Ra5Ghz_UNII
, sizeof(Ra5Ghz_UNII
));
650 nIndex
+= sizeof(Ra5Ghz_UNII
);
653 Config_ComboBox_Channel
->clear();
654 for (i
= 0; i
< nIndex
; i
++)
656 sprintf(channelString
, "%d", aryChan
[i
]);
657 Config_ComboBox_Channel
->insertItem(channelString
);
661 bool AddProfileDlg::IsOk()
663 return (m_IsAddToProfile
);
666 void AddProfileDlg::OnCancel()
671 void AddProfileDlg::OnOK()
674 PRT_PROFILE_SETTING ptr
= NULL
;
675 PRT_PROFILE_SETTING previous
=NULL
;
676 NDIS_802_11_AUTHENTICATION_MODE AuthMode
;
677 NDIS_802_11_WEP_STATUS EncryType
;
685 qstrAuthen
= Security_ComboBox_AuthType
->currentText();
686 qstrEncryp
= Security_ComboBox_Encrypt
->currentText();
687 if ((qstrAuthen
.compare("WPAPSK") == 0) || (qstrAuthen
.compare("WPA-None") == 0))
689 qstr
= Security_LineEdit_PSK
->text();
690 if (qstr
.length() < 8)
692 QMessageBox::warning(this, "Warning", "Invalid WPA Pre-Shared key. WPAPSK used field should use more than 8 characters.");
693 TabWidget_Config
->setCurrentPage(1);
694 Security_LineEdit_PSK
->setFocus();
698 else if (qstrEncryp
.compare("WEP") == 0)
700 keyid
= Security_ButtonGroup_Key
->id(Security_ButtonGroup_Key
->selected());
701 qstr
= Security_GetWepKeyString(keyid
);
702 if (Security_GetWepKeyType(keyid
) == 0)
704 if ((qstr
.length() != 10) && (qstr
.length() != 26))
706 sprintf(msg
, "Invalid WEP KEY length. Key should be 10 or 26 hex digits!");
707 QMessageBox::warning(this, "Warning", msg
);
708 TabWidget_Config
->setCurrentPage(1);
712 Security_LineEdit_Key1Hex
->setFocus();
715 Security_LineEdit_Key2Hex
->setFocus();
718 Security_LineEdit_Key3Hex
->setFocus();
721 Security_LineEdit_Key4Hex
->setFocus();
729 if ((qstr
.length() != 5) && (qstr
.length() != 13))
731 sprintf(msg
, "Invalid WEP KEY length. Key should be 5 or 13 ascii characters!");
732 QMessageBox::warning(this, "Warning", msg
);
733 TabWidget_Config
->setCurrentPage(1);
737 Security_LineEdit_Key1Ascii
->setFocus();
740 Security_LineEdit_Key2Ascii
->setFocus();
743 Security_LineEdit_Key3Ascii
->setFocus();
746 Security_LineEdit_Key4Ascii
->setFocus();
754 qstr
= LineEdit_ProfileName
->text();
757 QMessageBox::warning(this, "Warning", "Profile name can't be empty!");
761 qstr
= ComboBox_SSID
->currentText();
762 if ( (Config_ComboBox_NetworkType
->currentItem() == 0) && qstr
.isEmpty())
764 QMessageBox::warning(this, "Warning", "Ad Hoc mode must input SSID!");
768 qstr
= LineEdit_ProfileName
->text();
769 if (m_type
== PROFILE_ADD
)
771 ptr
= m_pProfileSetting
;
772 if (!m_bIsProfileNull
)
776 if (qstr
.compare((const char *)ptr
->Profile
) == 0)
787 m_pEditProfileSetting
= (PRT_PROFILE_SETTING
) malloc(sizeof(RT_PROFILE_SETTING
));
789 memset(m_pEditProfileSetting
, 0x00, sizeof(RT_PROFILE_SETTING
));
790 previous
->Next
= m_pEditProfileSetting
;
791 m_pEditProfileSetting
->Next
= NULL
;
792 strcpy((char *)m_pEditProfileSetting
->Profile
, qstr
.data());
796 QMessageBox::warning(this, "Warning", "Duplicate profile name.!");
802 m_pEditProfileSetting
= m_pProfileSetting
;
803 strcpy((char *)m_pEditProfileSetting
->Profile
, qstr
.data());
804 m_pEditProfileSetting
->Next
= NULL
;
808 { //Edit Profile, check does it Duplicate profile name?
809 ptr
= m_pProfileSetting
;
812 if( (qstr
.compare((const char *)ptr
->Profile
) == 0) && (ptr
!= m_pEditProfileSetting
))
822 if (m_type
== PROFILE_ADD
)
824 Item
= new QListViewItem(m_ProfileListView
, 0);
825 qstr
= LineEdit_ProfileName
->text();
826 Item
->setText(0, qstr
);
827 Item
->setPixmap(0, uic_load_pixmap_AddProfileDlg("uncheck16.xpm"));
831 Item
= m_ProfileListView
->findItem((const char *) m_pEditProfileSetting
->Profile
, 0);
832 strcpy((char *)m_pEditProfileSetting
->Profile
, qstr
.data());
833 Item
->setText(0, qstr
);
837 qstr
= ComboBox_SSID
->currentText();
838 m_pEditProfileSetting
->SsidLen
= qstr
.length() <= 32 ? qstr
.length() : 32;
839 memcpy((char *)m_pEditProfileSetting
->SSID
, qstr
.data(), m_pEditProfileSetting
->SsidLen
);
840 m_pEditProfileSetting
->SSID
[m_pEditProfileSetting
->SsidLen
] = 0x00;
841 Item
->setText(1, (char *)m_pEditProfileSetting
->SSID
);
844 if(Config_GetNetworkType() == Ndis802_11IBSS
)
846 qstr
= Config_ComboBox_Channel
->currentText();
847 m_pEditProfileSetting
->Channel
= qstr
.toUInt();
850 m_pEditProfileSetting
->Channel
= 0; // 0: Auto.
852 Item
->setText(2, (Config_ComboBox_NetworkType
->currentItem()==0 ? Config_ComboBox_Channel
->currentText():"Auto"));
855 AuthMode
= Security_GetAuthticationMode();
856 if (AuthMode
== Ndis802_11AuthModeOpen
)
857 Item
->setText(3, "OPEN");
858 else if (AuthMode
== Ndis802_11AuthModeShared
)
859 Item
->setText(3, "SHARED");
860 else if (AuthMode
== Ndis802_11AuthModeWPAPSK
)
861 Item
->setText(3, "WPAPSK");
862 else if (AuthMode
== Ndis802_11AuthModeWPANone
)
863 Item
->setText(3, "WPA-None");
865 Item
->setText(3, "Unknown");
868 EncryType
= Security_GetEncryptType();
869 if (EncryType
== Ndis802_11WEPEnabled
)
870 Item
->setText(4, "WEP");
871 else if (EncryType
== Ndis802_11WEPDisabled
)
872 Item
->setText(4, "NONE");
873 else if (EncryType
== Ndis802_11Encryption2Enabled
)
874 Item
->setText(4, "TKIP");
875 else if (EncryType
== Ndis802_11Encryption3Enabled
)
876 Item
->setText(4, "AES");
879 m_pEditProfileSetting
->NetworkType
= Config_GetNetworkType();
880 Item
->setText(5, strAryNetworkType
[Config_ComboBox_NetworkType
->currentItem()]);
883 m_pEditProfileSetting
->Fragment
= Config_SpinBox_Fragment
->value();
885 m_pEditProfileSetting
->RTS
= Config_SpinBox_RTS
->value();
887 switch ( Config_ButtonGroup_PowerSaveing
->id(Config_ButtonGroup_PowerSaveing
->selected()) )
890 m_pEditProfileSetting
->PSmode
= Ndis802_11PowerModeMAX_PSP
;
894 m_pEditProfileSetting
->PSmode
= Ndis802_11PowerModeCAM
;
899 if (Config_ComboBox_Preamble
->currentItem() == 0)
901 m_pEditProfileSetting
->PreamType
= Rt802_11PreambleAuto
;
905 m_pEditProfileSetting
->PreamType
= Rt802_11PreambleLong
;
909 m_pEditProfileSetting
->RTSCheck
= Config_CheckBox_RTS
->isChecked();
912 m_pEditProfileSetting
->FragmentCheck
= Config_CheckBox_Fragment
->isChecked();
913 m_ProfileListView
->setCurrentItem(Item
);
915 m_pEditProfileSetting
->Authentication
= Security_GetAuthticationMode();
916 m_pEditProfileSetting
->Encryption
= Security_GetEncryptType();
917 m_pEditProfileSetting
->KeyDefaultId
= Security_GetDefaultKeyId();
918 m_pEditProfileSetting
->Key1Type
= Security_GetWepKeyType(0);
919 m_pEditProfileSetting
->Key2Type
= Security_GetWepKeyType(1);
920 m_pEditProfileSetting
->Key3Type
= Security_GetWepKeyType(2);
921 m_pEditProfileSetting
->Key4Type
= Security_GetWepKeyType(3);
922 strcpy(m_pEditProfileSetting
->Key1
, Security_GetWepKeyString(0));
923 strcpy(m_pEditProfileSetting
->Key2
, Security_GetWepKeyString(1));
924 strcpy(m_pEditProfileSetting
->Key3
, Security_GetWepKeyString(2));
925 strcpy(m_pEditProfileSetting
->Key4
, Security_GetWepKeyString(3));
926 strcpy(m_pEditProfileSetting
->WpaPsk
, Security_GetPSKString());
928 m_IsAddToProfile
= TRUE
;
932 void AddProfileDlg::Config_OnSelectSSID(int id
)
934 PNDIS_WLAN_BSSID_EX pBssid
;
935 NDIS_802_11_AUTHENTICATION_MODE AuthenticationMode
= Ndis802_11AuthModeOpen
;
936 NDIS_802_11_ENCRYPTION_STATUS EncryptType
= Ndis802_11WEPDisabled
;
938 char strSSID
[NDIS_802_11_LENGTH_SSID
+ 1];
946 pBssid
= m_pBssidList
->Bssid
;
947 for(i
= 0; i
< (id
-1); i
++)
949 if (i
>= m_pBssidList
->NumberOfItems
)
951 pBssid
= (PNDIS_WLAN_BSSID_EX
)((char *)pBssid
+ pBssid
->Length
);
954 memset(strSSID
, 0x00, NDIS_802_11_LENGTH_SSID
+ 1);
955 memcpy(strSSID
, pBssid
->Ssid
.Ssid
, pBssid
->Ssid
.SsidLength
);
958 EncryptType
= Ndis802_11WEPEnabled
;
960 EncryptType
= Ndis802_11WEPDisabled
;
962 if ((pBssid
->Length
> sizeof(NDIS_WLAN_BSSID
)) && (pBssid
->IELength
> sizeof(NDIS_802_11_FIXED_IEs
)))
965 PNDIS_802_11_FIXED_IEs pFixIE
= (PNDIS_802_11_FIXED_IEs
)pBssid
->IEs
;
966 PNDIS_802_11_VARIABLE_IEs pVarIE
= (PNDIS_802_11_VARIABLE_IEs
)((char*)pFixIE
+ sizeof(NDIS_802_11_FIXED_IEs
));
967 lIELoc
+= sizeof(NDIS_802_11_FIXED_IEs
);
968 while (pBssid
->IELength
> (lIELoc
+ sizeof(NDIS_802_11_VARIABLE_IEs
)))
970 if ((pVarIE
->ElementID
== 221) && (pVarIE
->Length
>= 16))
972 ULONG
* pOUI
= (ULONG
*)((char*)pVarIE
+ 2);
973 if(*pOUI
!= WPA_OUI_TYPE
)
976 WORD
* pdPairKeyCount
;
978 WORD
* pdAuthenKeyCount
;
979 plGroupKey
= (ULONG
*)((char*)pVarIE
+ 8);
981 ULONG lGroupKey
= *plGroupKey
& 0x00ffffff;
982 if (lGroupKey
== WPA_OUI
)
984 lGroupKey
= (*plGroupKey
& 0xff000000) >> 0x18;
986 EncryptType
= Ndis802_11Encryption2Enabled
;
987 else if (lGroupKey
== 3)
988 EncryptType
= Ndis802_11Encryption3Enabled
;
989 else if (lGroupKey
== 4)
990 EncryptType
= Ndis802_11Encryption3Enabled
;
995 pdPairKeyCount
= (WORD
*)((char*)plGroupKey
+ 4);
996 pdAuthenKeyCount
= (WORD
*)((char*)pdPairKeyCount
+ 2 + 4 * (*pdPairKeyCount
));
997 if (*pdAuthenKeyCount
> 0)
999 plAuthenKey
= (ULONG
*)((char*)pdAuthenKeyCount
+ 2);
1001 ULONG lAuthenKey
= *plAuthenKey
& 0x00ffffff;
1002 if (lAuthenKey
== WPA_OUI
)
1004 lAuthenKey
= (*plAuthenKey
& 0xff000000) >> 0x18;
1005 if (lAuthenKey
== 1)
1006 AuthenticationMode
= Ndis802_11AuthModeWPA
;
1007 else if (lAuthenKey
== 2)
1009 if (pBssid
->InfrastructureMode
)
1010 AuthenticationMode
= Ndis802_11AuthModeWPAPSK
;
1012 AuthenticationMode
= Ndis802_11AuthModeWPANone
;
1018 lIELoc
+= pVarIE
->Length
;
1019 pVarIE
= (PNDIS_802_11_VARIABLE_IEs
)((char*)pVarIE
+ pVarIE
->Length
);
1021 if(pVarIE
->Length
<= 0)
1026 Security_SetAuthModeAndEncryType(pBssid
->InfrastructureMode
, AuthenticationMode
, EncryptType
);
1028 if (pBssid
->InfrastructureMode
== Ndis802_11IBSS
)
1030 if (pBssid
->Configuration
.DSConfig
== 2484000)
1032 else if (pBssid
->Configuration
.DSConfig
>= 2412000 && pBssid
->Configuration
.DSConfig
< 2484000)
1033 nChannel
= (int)((pBssid
->Configuration
.DSConfig
- 2412000) / 5000) + 1;
1035 sprintf(tmp
, "%d", nChannel
);
1036 Config_ComboBox_Channel
->setCurrentText( tmp
);
1040 void AddProfileDlg::Config_OnSelectNetworkType(int index
)
1044 current
= Security_ComboBox_AuthType
->currentItem();
1047 Security_ComboBox_AuthType
->clear();
1048 Security_ComboBox_AuthType
->insertItem("OPEN");
1049 Security_ComboBox_AuthType
->insertItem("SHARED");
1050 Security_ComboBox_AuthType
->insertItem("WPA-None");
1052 Config_TextLabel_Channel
->show();
1053 Config_ComboBox_Channel
->show();
1055 Config_RadioButton_CAM
->setEnabled( FALSE
);
1056 Config_RadioButton_PSMode
->setEnabled( FALSE
);
1058 Config_ComboBox_Preamble
->setEnabled( TRUE
);
1062 Security_ComboBox_AuthType
->clear();
1063 Security_ComboBox_AuthType
->insertItem("OPEN");
1064 Security_ComboBox_AuthType
->insertItem("SHARED");
1065 Security_ComboBox_AuthType
->insertItem("WPAPSK");
1067 Config_TextLabel_Channel
->hide();
1068 Config_ComboBox_Channel
->hide();
1070 Config_RadioButton_CAM
->setEnabled( TRUE
);
1071 Config_RadioButton_PSMode
->setEnabled( TRUE
);
1073 Config_ComboBox_Preamble
->setEnabled( FALSE
);
1075 Security_ComboBox_AuthType
->setCurrentItem( current
);
1078 void AddProfileDlg::Config_OnEnableRTS(bool flag
)
1082 Config_Slider_RTS
->setEnabled( TRUE
);
1083 Config_SpinBox_RTS
->setEnabled( TRUE
);
1087 Config_Slider_RTS
->setEnabled( FALSE
);
1088 Config_Slider_RTS
->setValue( 2312 );
1089 Config_SpinBox_RTS
->setEnabled( FALSE
);
1090 Config_SpinBox_RTS
->setValue( 2312 );
1095 void AddProfileDlg::Config_OnEnableFragment(bool flag
)
1099 Config_Slider_Fragment
->setEnabled( TRUE
);
1100 Config_SpinBox_Fragment
->setEnabled( TRUE
);
1104 Config_Slider_Fragment
->setEnabled( FALSE
);
1105 Config_Slider_Fragment
->setValue( 2312 );
1106 Config_SpinBox_Fragment
->setEnabled( FALSE
);
1107 Config_SpinBox_Fragment
->setValue( 2312 );
1111 void AddProfileDlg::Config_OnRTSSliderChanged(int value
)
1113 Config_SpinBox_RTS
->setValue( value
);
1116 void AddProfileDlg::Config_OnFragmentSliderChanged(int value
)
1118 Config_SpinBox_Fragment
->setValue( value
);
1121 void AddProfileDlg::Config_OnRTSSpinBoxChanged(int value
)
1123 Config_Slider_RTS
->setValue( value
);
1126 void AddProfileDlg::Config_OnFragmentSpinBoxChanged(int value
)
1128 Config_Slider_Fragment
->setValue( value
);
1131 void AddProfileDlg::Config_SetCurrentSSID(QString text
)
1133 ComboBox_SSID
->setEditText(text
);
1136 NDIS_802_11_NETWORK_INFRASTRUCTURE
AddProfileDlg::Config_GetNetworkType()
1138 NDIS_802_11_NETWORK_INFRASTRUCTURE Type
= Ndis802_11Infrastructure
;
1140 if (Config_ComboBox_NetworkType
->currentItem() == 0)
1141 Type
= Ndis802_11IBSS
;
1142 else if (Config_ComboBox_NetworkType
->currentItem() == 1)
1143 Type
= Ndis802_11Infrastructure
;
1148 void AddProfileDlg::Security_OnSelectAuthenType(int id
)
1152 textAuthen
= Security_ComboBox_AuthType
->text(id
);
1153 if ((textAuthen
.compare("OPEN") == 0) || (textAuthen
.compare("SHARED") == 0))
1155 Security_LineEdit_PSK
->setEnabled( FALSE
);
1157 Security_ComboBox_Encrypt
->clear();
1158 Security_ComboBox_Encrypt
->insertItem("NONE");
1159 Security_ComboBox_Encrypt
->insertItem("WEP");
1160 Security_ComboBox_Encrypt
->setCurrentItem( 1 );
1162 Security_RadioButton_Key1
->setEnabled( TRUE
);
1163 Security_RadioButton_Key2
->setEnabled( TRUE
);
1164 Security_RadioButton_Key3
->setEnabled( TRUE
);
1165 Security_RadioButton_Key4
->setEnabled( TRUE
);
1167 Security_ComboBox_KeyType1
->setEnabled( TRUE
);
1168 Security_ComboBox_KeyType2
->setEnabled( TRUE
);
1169 Security_ComboBox_KeyType3
->setEnabled( TRUE
);
1170 Security_ComboBox_KeyType4
->setEnabled( TRUE
);
1172 Security_LineEdit_Key1Hex
->setEnabled( TRUE
);
1173 Security_LineEdit_Key1Ascii
->setEnabled( TRUE
);
1174 Security_LineEdit_Key2Hex
->setEnabled( TRUE
);
1175 Security_LineEdit_Key2Ascii
->setEnabled( TRUE
);
1176 Security_LineEdit_Key3Hex
->setEnabled( TRUE
);
1177 Security_LineEdit_Key3Ascii
->setEnabled( TRUE
);
1178 Security_LineEdit_Key4Hex
->setEnabled( TRUE
);
1179 Security_LineEdit_Key4Ascii
->setEnabled( TRUE
);
1182 else if ((textAuthen
.compare("WPAPSK") == 0) || (textAuthen
.compare("WPA-None") == 0))
1184 Security_LineEdit_PSK
->setEnabled( TRUE
);
1186 Security_ComboBox_Encrypt
->clear();
1187 Security_ComboBox_Encrypt
->insertItem("TKIP");
1188 Security_ComboBox_Encrypt
->insertItem("AES");
1189 Security_ComboBox_Encrypt
->setCurrentItem( 0 );
1191 Security_RadioButton_Key1
->setEnabled( FALSE
);
1192 Security_RadioButton_Key2
->setEnabled( FALSE
);
1193 Security_RadioButton_Key3
->setEnabled( FALSE
);
1194 Security_RadioButton_Key4
->setEnabled( FALSE
);
1196 Security_ComboBox_KeyType1
->setEnabled( FALSE
);
1197 Security_ComboBox_KeyType2
->setEnabled( FALSE
);
1198 Security_ComboBox_KeyType3
->setEnabled( FALSE
);
1199 Security_ComboBox_KeyType4
->setEnabled( FALSE
);
1201 Security_LineEdit_Key1Hex
->setEnabled( FALSE
);
1202 Security_LineEdit_Key1Ascii
->setEnabled( FALSE
);
1203 Security_LineEdit_Key2Hex
->setEnabled( FALSE
);
1204 Security_LineEdit_Key2Ascii
->setEnabled( FALSE
);
1205 Security_LineEdit_Key3Hex
->setEnabled( FALSE
);
1206 Security_LineEdit_Key3Ascii
->setEnabled( FALSE
);
1207 Security_LineEdit_Key4Hex
->setEnabled( FALSE
);
1208 Security_LineEdit_Key4Ascii
->setEnabled( FALSE
);
1212 void AddProfileDlg::Security_OnSelectEncryptType(int id
)
1217 textEncry
= Security_ComboBox_Encrypt
->text(id
);
1218 textAuthen
= Security_ComboBox_AuthType
->currentText();
1219 if ((textAuthen
.compare("OPEN") == 0) || (textAuthen
.compare("SHARED") == 0))
1221 if (textEncry
.compare("NONE") == 0)
1223 Security_RadioButton_Key1
->setEnabled( FALSE
);
1224 Security_RadioButton_Key2
->setEnabled( FALSE
);
1225 Security_RadioButton_Key3
->setEnabled( FALSE
);
1226 Security_RadioButton_Key4
->setEnabled( FALSE
);
1228 Security_ComboBox_KeyType1
->setEnabled( FALSE
);
1229 Security_ComboBox_KeyType2
->setEnabled( FALSE
);
1230 Security_ComboBox_KeyType3
->setEnabled( FALSE
);
1231 Security_ComboBox_KeyType4
->setEnabled( FALSE
);
1233 Security_LineEdit_Key1Hex
->setEnabled( FALSE
);
1234 Security_LineEdit_Key1Ascii
->setEnabled( FALSE
);
1235 Security_LineEdit_Key2Hex
->setEnabled( FALSE
);
1236 Security_LineEdit_Key2Ascii
->setEnabled( FALSE
);
1237 Security_LineEdit_Key3Hex
->setEnabled( FALSE
);
1238 Security_LineEdit_Key3Ascii
->setEnabled( FALSE
);
1239 Security_LineEdit_Key4Hex
->setEnabled( FALSE
);
1240 Security_LineEdit_Key4Ascii
->setEnabled( FALSE
);
1242 Security_ComboBox_AuthType
->setCurrentItem(0);
1246 Security_RadioButton_Key1
->setEnabled( TRUE
);
1247 Security_RadioButton_Key2
->setEnabled( TRUE
);
1248 Security_RadioButton_Key3
->setEnabled( TRUE
);
1249 Security_RadioButton_Key4
->setEnabled( TRUE
);
1251 Security_ComboBox_KeyType1
->setEnabled( TRUE
);
1252 Security_ComboBox_KeyType2
->setEnabled( TRUE
);
1253 Security_ComboBox_KeyType3
->setEnabled( TRUE
);
1254 Security_ComboBox_KeyType4
->setEnabled( TRUE
);
1256 Security_LineEdit_Key1Hex
->setEnabled( TRUE
);
1257 Security_LineEdit_Key1Ascii
->setEnabled( TRUE
);
1258 Security_LineEdit_Key2Hex
->setEnabled( TRUE
);
1259 Security_LineEdit_Key2Ascii
->setEnabled( TRUE
);
1260 Security_LineEdit_Key3Hex
->setEnabled( TRUE
);
1261 Security_LineEdit_Key3Ascii
->setEnabled( TRUE
);
1262 Security_LineEdit_Key4Hex
->setEnabled( TRUE
);
1263 Security_LineEdit_Key4Ascii
->setEnabled( TRUE
);
1268 void AddProfileDlg::Security_OnSelectKey1Type(int id
)
1272 Security_LineEdit_Key1Hex
->show();
1273 Security_LineEdit_Key1Ascii
->hide();
1277 Security_LineEdit_Key1Hex
->hide();
1278 Security_LineEdit_Key1Ascii
->show();
1282 void AddProfileDlg::Security_OnSelectKey2Type(int id
)
1286 Security_LineEdit_Key2Hex
->show();
1287 Security_LineEdit_Key2Ascii
->hide();
1291 Security_LineEdit_Key2Hex
->hide();
1292 Security_LineEdit_Key2Ascii
->show();
1296 void AddProfileDlg::Security_OnSelectKey3Type(int id
)
1300 Security_LineEdit_Key3Hex
->show();
1301 Security_LineEdit_Key3Ascii
->hide();
1305 Security_LineEdit_Key3Hex
->hide();
1306 Security_LineEdit_Key3Ascii
->show();
1310 void AddProfileDlg::Security_OnSelectKey4Type(int id
)
1314 Security_LineEdit_Key4Hex
->show();
1315 Security_LineEdit_Key4Ascii
->hide();
1319 Security_LineEdit_Key4Hex
->hide();
1320 Security_LineEdit_Key4Ascii
->show();
1324 int AddProfileDlg::Security_GetWepKeyType(int index
)
1331 num
= Security_ComboBox_KeyType2
->currentItem();
1334 num
= Security_ComboBox_KeyType3
->currentItem();
1337 num
= Security_ComboBox_KeyType4
->currentItem();
1341 num
= Security_ComboBox_KeyType1
->currentItem();
1348 QString
AddProfileDlg::Security_GetWepKeyString(int index
)
1353 if ( Security_GetWepKeyType(index
) == 0) //Hex
1354 return (Security_LineEdit_Key2Hex
->text());
1356 return (Security_LineEdit_Key2Ascii
->text());
1359 if ( Security_GetWepKeyType(index
) == 0) //Hex
1360 return (Security_LineEdit_Key3Hex
->text());
1362 return (Security_LineEdit_Key3Ascii
->text());
1365 if ( Security_GetWepKeyType(index
) == 0) //Hex
1366 return (Security_LineEdit_Key4Hex
->text());
1368 return (Security_LineEdit_Key4Ascii
->text());
1372 if ( Security_GetWepKeyType(index
) == 0) //Hex
1373 return (Security_LineEdit_Key1Hex
->text());
1375 return (Security_LineEdit_Key1Ascii
->text());
1380 QString
AddProfileDlg::Security_GetPSKString()
1382 return (Security_LineEdit_PSK
->text());
1385 NDIS_802_11_AUTHENTICATION_MODE
AddProfileDlg::Security_GetAuthticationMode()
1388 NDIS_802_11_AUTHENTICATION_MODE mode
= Ndis802_11AuthModeOpen
;
1390 qstr
= Security_ComboBox_AuthType
->currentText();
1391 if (qstr
.compare("OPEN") == 0)
1392 mode
= Ndis802_11AuthModeOpen
;
1393 else if (qstr
.compare("SHARED") == 0)
1394 mode
= Ndis802_11AuthModeShared
;
1395 else if (qstr
.compare("WPAPSK") == 0)
1396 mode
= Ndis802_11AuthModeWPAPSK
;
1397 else if (qstr
.compare("WPA-None") == 0)
1398 mode
= Ndis802_11AuthModeWPANone
;
1403 NDIS_802_11_ENCRYPTION_STATUS
AddProfileDlg::Security_GetEncryptType()
1406 NDIS_802_11_ENCRYPTION_STATUS type
= Ndis802_11WEPDisabled
;
1408 qstr
= Security_ComboBox_Encrypt
->currentText();
1409 if (qstr
.compare("NONE") == 0)
1410 type
= Ndis802_11WEPDisabled
;
1411 else if (qstr
.compare("WEP") == 0)
1412 type
= Ndis802_11WEPEnabled
;
1413 else if (qstr
.compare("TKIP") == 0)
1414 type
= Ndis802_11Encryption2Enabled
;
1415 else if (qstr
.compare("AES") == 0)
1416 type
= Ndis802_11Encryption3Enabled
;
1421 void AddProfileDlg::Security_SetAuthModeAndEncryType(NDIS_802_11_NETWORK_INFRASTRUCTURE NetworkType
, NDIS_802_11_AUTHENTICATION_MODE mode
, NDIS_802_11_ENCRYPTION_STATUS type
)
1423 if (NetworkType
== Ndis802_11IBSS
)
1425 Security_ComboBox_AuthType
->clear();
1426 Security_ComboBox_AuthType
->insertItem("OPEN");
1427 Security_ComboBox_AuthType
->insertItem("SHARED");
1428 Security_ComboBox_AuthType
->insertItem("WPA-None");
1430 Config_TextLabel_Channel
->show();
1431 Config_ComboBox_Channel
->show();
1433 Config_RadioButton_CAM
->setEnabled( FALSE
);
1434 Config_RadioButton_PSMode
->setEnabled( FALSE
);
1436 Config_ComboBox_Preamble
->setEnabled( TRUE
);
1438 Config_ComboBox_NetworkType
->setCurrentItem( 0 ); //Adhoc
1442 Security_ComboBox_AuthType
->clear();
1443 Security_ComboBox_AuthType
->insertItem("OPEN");
1444 Security_ComboBox_AuthType
->insertItem("SHARED");
1445 Security_ComboBox_AuthType
->insertItem("WPAPSK");
1447 Config_TextLabel_Channel
->hide();
1448 Config_ComboBox_Channel
->hide();
1450 Config_RadioButton_CAM
->setEnabled( TRUE
);
1451 Config_RadioButton_PSMode
->setEnabled( TRUE
);
1453 Config_ComboBox_Preamble
->setEnabled( FALSE
);
1455 Config_ComboBox_NetworkType
->setCurrentItem( 1 ); //Infrastructure
1458 if (mode
== Ndis802_11AuthModeOpen
)
1459 Security_ComboBox_AuthType
->setCurrentItem( 0 ); //OPEN
1460 else if (mode
== Ndis802_11AuthModeShared
)
1461 Security_ComboBox_AuthType
->setCurrentItem( 1 ); //SHARED
1462 else if ((mode
== Ndis802_11AuthModeWPAPSK
) || (mode
== Ndis802_11AuthModeWPANone
))
1463 Security_ComboBox_AuthType
->setCurrentItem( 2 ); //WPAPSK or WPA-None
1465 if ((mode
== Ndis802_11AuthModeOpen
) || (mode
== Ndis802_11AuthModeShared
))
1467 Security_LineEdit_PSK
->setEnabled( FALSE
);
1469 Security_ComboBox_Encrypt
->clear();
1470 Security_ComboBox_Encrypt
->insertItem("NONE");
1471 Security_ComboBox_Encrypt
->insertItem("WEP");
1473 if (type
== Ndis802_11WEPEnabled
)
1475 Security_ComboBox_Encrypt
->setCurrentItem( 1 );
1477 Security_RadioButton_Key1
->setEnabled( TRUE
);
1478 Security_RadioButton_Key2
->setEnabled( TRUE
);
1479 Security_RadioButton_Key3
->setEnabled( TRUE
);
1480 Security_RadioButton_Key4
->setEnabled( TRUE
);
1482 Security_ComboBox_KeyType1
->setEnabled( TRUE
);
1483 Security_ComboBox_KeyType2
->setEnabled( TRUE
);
1484 Security_ComboBox_KeyType3
->setEnabled( TRUE
);
1485 Security_ComboBox_KeyType4
->setEnabled( TRUE
);
1487 Security_LineEdit_Key1Hex
->setEnabled( TRUE
);
1488 Security_LineEdit_Key1Ascii
->setEnabled( TRUE
);
1489 Security_LineEdit_Key2Hex
->setEnabled( TRUE
);
1490 Security_LineEdit_Key2Ascii
->setEnabled( TRUE
);
1491 Security_LineEdit_Key3Hex
->setEnabled( TRUE
);
1492 Security_LineEdit_Key3Ascii
->setEnabled( TRUE
);
1493 Security_LineEdit_Key4Hex
->setEnabled( TRUE
);
1494 Security_LineEdit_Key4Ascii
->setEnabled( TRUE
);
1498 Security_ComboBox_Encrypt
->setCurrentItem( 0 );
1500 Security_RadioButton_Key1
->setEnabled( FALSE
);
1501 Security_RadioButton_Key2
->setEnabled( FALSE
);
1502 Security_RadioButton_Key3
->setEnabled( FALSE
);
1503 Security_RadioButton_Key4
->setEnabled( FALSE
);
1505 Security_ComboBox_KeyType1
->setEnabled( FALSE
);
1506 Security_ComboBox_KeyType2
->setEnabled( FALSE
);
1507 Security_ComboBox_KeyType3
->setEnabled( FALSE
);
1508 Security_ComboBox_KeyType4
->setEnabled( FALSE
);
1510 Security_LineEdit_Key1Hex
->setEnabled( FALSE
);
1511 Security_LineEdit_Key1Ascii
->setEnabled( FALSE
);
1512 Security_LineEdit_Key2Hex
->setEnabled( FALSE
);
1513 Security_LineEdit_Key2Ascii
->setEnabled( FALSE
);
1514 Security_LineEdit_Key3Hex
->setEnabled( FALSE
);
1515 Security_LineEdit_Key3Ascii
->setEnabled( FALSE
);
1516 Security_LineEdit_Key4Hex
->setEnabled( FALSE
);
1517 Security_LineEdit_Key4Ascii
->setEnabled( FALSE
);
1520 else if (mode
== Ndis802_11AuthModeWPAPSK
)
1522 Security_LineEdit_PSK
->setEnabled( TRUE
);
1524 Security_ComboBox_Encrypt
->clear();
1525 Security_ComboBox_Encrypt
->insertItem("TKIP");
1526 Security_ComboBox_Encrypt
->insertItem("AES");
1528 if (type
== Ndis802_11Encryption2Enabled
)
1529 Security_ComboBox_Encrypt
->setCurrentItem( 0 );
1530 else if(type
== Ndis802_11Encryption3Enabled
)
1531 Security_ComboBox_Encrypt
->setCurrentItem( 1 );
1533 Security_RadioButton_Key1
->setEnabled( FALSE
);
1534 Security_RadioButton_Key2
->setEnabled( FALSE
);
1535 Security_RadioButton_Key3
->setEnabled( FALSE
);
1536 Security_RadioButton_Key4
->setEnabled( FALSE
);
1538 Security_ComboBox_KeyType1
->setEnabled( FALSE
);
1539 Security_ComboBox_KeyType2
->setEnabled( FALSE
);
1540 Security_ComboBox_KeyType3
->setEnabled( FALSE
);
1541 Security_ComboBox_KeyType4
->setEnabled( FALSE
);
1543 Security_LineEdit_Key1Hex
->setEnabled( FALSE
);
1544 Security_LineEdit_Key1Ascii
->setEnabled( FALSE
);
1545 Security_LineEdit_Key2Hex
->setEnabled( FALSE
);
1546 Security_LineEdit_Key2Ascii
->setEnabled( FALSE
);
1547 Security_LineEdit_Key3Hex
->setEnabled( FALSE
);
1548 Security_LineEdit_Key3Ascii
->setEnabled( FALSE
);
1549 Security_LineEdit_Key4Hex
->setEnabled( FALSE
);
1550 Security_LineEdit_Key4Ascii
->setEnabled( FALSE
);
1554 int AddProfileDlg::Security_GetDefaultKeyId()
1558 keyId
= Security_ButtonGroup_Key
->id(Security_ButtonGroup_Key
->selected());
1563 void AddProfileDlg::Security_SetDefaultKeyId(int keyId
)
1565 Security_ButtonGroup_Key
->setButton(keyId
);
1568 void AddProfileDlg::Security_SetKeyTypeAndKeyString(int keyIndex
, int keyType
, char *keyString
)
1573 if (keyType
== 0) //Hex
1575 Security_ComboBox_KeyType1
->setCurrentItem( 0 );
1576 Security_LineEdit_Key1Hex
->setText(keyString
);
1577 Security_LineEdit_Key1Hex
->show();
1578 Security_LineEdit_Key1Ascii
->hide();
1582 Security_ComboBox_KeyType1
->setCurrentItem( 1 );
1583 Security_LineEdit_Key1Ascii
->setText(keyString
);
1584 Security_LineEdit_Key1Ascii
->show();
1585 Security_LineEdit_Key1Hex
->hide();
1589 if (keyType
== 0) //Hex
1591 Security_ComboBox_KeyType2
->setCurrentItem( 0 );
1592 Security_LineEdit_Key2Hex
->setText(keyString
);
1593 Security_LineEdit_Key2Hex
->show();
1594 Security_LineEdit_Key2Ascii
->hide();
1598 Security_ComboBox_KeyType2
->setCurrentItem( 1 );
1599 Security_LineEdit_Key2Ascii
->setText(keyString
);
1600 Security_LineEdit_Key2Ascii
->show();
1601 Security_LineEdit_Key2Hex
->hide();
1605 if (keyType
== 0) //Hex
1607 Security_ComboBox_KeyType3
->setCurrentItem( 0 );
1608 Security_LineEdit_Key3Hex
->setText(keyString
);
1609 Security_LineEdit_Key3Hex
->show();
1610 Security_LineEdit_Key3Ascii
->hide();
1614 Security_ComboBox_KeyType3
->setCurrentItem( 1 );
1615 Security_LineEdit_Key3Ascii
->setText(keyString
);
1616 Security_LineEdit_Key3Ascii
->show();
1617 Security_LineEdit_Key3Hex
->hide();
1621 if (keyType
== 0) //Hex
1623 Security_ComboBox_KeyType4
->setCurrentItem( 0 );
1624 Security_LineEdit_Key4Hex
->setText(keyString
);
1625 Security_LineEdit_Key4Hex
->show();
1626 Security_LineEdit_Key4Ascii
->hide();
1630 Security_ComboBox_KeyType4
->setCurrentItem( 1 );
1631 Security_LineEdit_Key4Ascii
->setText(keyString
);
1632 Security_LineEdit_Key4Ascii
->show();
1633 Security_LineEdit_Key4Hex
->hide();