📄 encryptionpage.cpp
字号:
/* EncryptionPage.cpp *//******************************************************************************************* Copyright 2002-2003 ATMEL Corporation. This file is part of ATMEL Wireless LAN Drivers. ATMEL Wireless LAN Drivers is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ATMEL Wireless LAN Drivers is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ATMEL Wireless LAN Drivers; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*******************************************************************************************/#include "EncryptionPage.h"#include "Decls.h"#include "ChoiceCtrl.h"#include "WinterModel.h"#include "WinterData.h"#include "Accessor.h"#include "WinterFrame.h"#include "WinterTimer.h"#include "HRStrings.h"#include "Device.h"#include "WinterSetup.h"#include "WinterDebug.h"#include <wx/busyinfo.h>BEGIN_EVENT_TABLE( CEncryptionPage, wxPanel ) EVT_BUTTON( ID_BT_ENCRYPTPAGE_SUBMIT, CEncryptionPage::OnBtEncryptPageSubmit ) EVT_RADIOBUTTON( ID_RB_SECONDBOX_ALNUM, CEncryptionPage::OnInputTypeSelect ) EVT_RADIOBUTTON( ID_RB_SECONDBOX_HEX, CEncryptionPage::OnInputTypeSelect ) EVT_IDLE( CEncryptionPage::OnIdle )END_EVENT_TABLE( )CEncryptionPage::CEncryptionPage( wxWindow *parent, int id, const wxPoint &pos, const wxSize &size, long style ) : CWinterPage( parent, id, pos ){ //EncryptionPage setup wxBoxSizer *sz_curline; int border = 4; wxSize page3_labelsize( 80, -1 ); wxSize page3_labelsize_2( 150, -1 ); wxSize page3_labelsize_3( 110, -1 ); int field = 6; int width = 20;//First Box Controls //ID_SB_FIRSTBOX, mStEncryption = new wxStaticText( this, ID_ST_FIRSTBOX_ENCRYPTION, _( "Encryption :" ), wxDefaultPosition, page3_labelsize_2 ); mChEncryption = new CAutoChoice( this, ID_CH_FIRSTBOX_ENCRYPTION );//Second Box Controls //ID_SB_SECONDBOX, mStKey[0] = new wxStaticText( this, ID_ST_SECONDBOX_KEY1, _( "Key #1 " ), wxDefaultPosition, page3_labelsize ); mTxKey[0] = new wxTextCtrl( this, ID_TX_SECONDBOX_KEY1, "", wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD | wxTE_PROCESS_TAB ); mStKey[1] = new wxStaticText( this, ID_ST_SECONDBOX_KEY2, _( "Key #2 " ), wxDefaultPosition, page3_labelsize ); mTxKey[1] = new wxTextCtrl( this, ID_TX_SECONDBOX_KEY2, "", wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD | wxTE_PROCESS_TAB ); mStKey[2] = new wxStaticText( this, ID_ST_SECONDBOX_KEY3, _( "Key #3 " ), wxDefaultPosition, page3_labelsize ); mTxKey[2] = new wxTextCtrl( this, ID_TX_SECONDBOX_KEY3, "", wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD | wxTE_PROCESS_TAB ); mStKey[3] = new wxStaticText( this, ID_ST_SECONDBOX_KEY4, _( "Key #4 " ), wxDefaultPosition, page3_labelsize ); mTxKey[3] = new wxTextCtrl( this, ID_TX_SECONDBOX_KEY4, "", wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD | wxTE_PROCESS_TAB ); mStKeyInputType = new wxStaticText( this, ID_ST_SECONDBOX_TYPE, _( "Key Input Type " ), wxDefaultPosition, page3_labelsize_3 ); mRbKeyInputTypeAlnum = new wxRadioButton(this, ID_RB_SECONDBOX_ALNUM, _("Alphanumeric"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); mRbKeyInputTypeHex = new wxRadioButton(this, ID_RB_SECONDBOX_HEX, _("Hexadecimal"), wxDefaultPosition, wxDefaultSize, 0 ); //Third Box Controls //ID_SB_THIRDBOX, mStWepKeyToUse = new wxStaticText( this, ID_ST_THIRDBOX_WEPKEYTOUSE, _( "WEP Key to use " ), wxDefaultPosition, page3_labelsize_2 ); mChWepkeyToUse = new CAutoChoice( this, ID_CH_THIRDBOX_WEPKEYTOUSE );#if 0 // Obsolete mStWepMode = new wxStaticText( this, ID_ST_THIRDBOX_WEPMODE, _( "WEP Mode " ), wxDefaultPosition, page3_labelsize_2 ); mChWepMode = new CAutoChoice( this, ID_CH_THIRDBOX_WEPMODE );#endif // 0 mStAuthType = new wxStaticText( this, ID_ST_THIRDBOX_AUTHENTICATIONTYPE, _( "Authentication Type " ), wxDefaultPosition, page3_labelsize_2 ); mChAuthType = new CAutoChoice( this, ID_CH_THIRDBOX_AUTHENTICATIONTYPE );//Encryption Page Controls mSubmit = new wxButton( this, ID_BT_ENCRYPTPAGE_SUBMIT, _( "&Submit" ), wxDefaultPosition, wxDefaultSize ); wxStaticBox *sb_firstbox = new wxStaticBox( this, ID_SB_FIRSTBOX, wxT( "" ) ); wxStaticBox *sb_secondbox = new wxStaticBox( this, ID_SB_SECONDBOX, wxT( "" ) ); wxStaticBox *sb_thirdbox = new wxStaticBox( this, ID_SB_THIRDBOX, wxT( "" ) ); //The first box group wxStaticBoxSizer *sz_firstbox = new wxStaticBoxSizer( sb_firstbox, wxVERTICAL ); //Encryption sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_firstbox->Add( 1, 10, 0, 1 ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStEncryption, 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mChEncryption, field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_firstbox->Add( sz_curline, 0, wxEXPAND | wxALL, border ); //The second box group wxStaticBoxSizer *sz_secondbox = new wxStaticBoxSizer( sb_secondbox, wxVERTICAL ); //key #i for(int i=0; i<4; i++) { sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStKey[i], 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mTxKey[i], field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_secondbox->Add( 1, 10, 0, 1 ); sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border ); } #if 0 //key #1 sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStKey[0], 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mTxKey[0], field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_secondbox->Add( 1, 10, 0, 1 ); sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border ); //key #2 sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStKey[1], 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mTxKey[1], field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border ); //key #3 sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStKey[2], 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mTxKey[2], field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border ); //key #4 sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStKey[3], 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mTxKey[3], field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );#endif //key input-type selector sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStKeyInputType, 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mRbKeyInputTypeAlnum, field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mRbKeyInputTypeHex, field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_secondbox->Add( 1, 10, 0, 1 ); sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border ); //The third box group wxStaticBoxSizer *sz_thirdbox = new wxStaticBoxSizer( sb_thirdbox, wxVERTICAL ); //wep key to use sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStWepKeyToUse, 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mChWepkeyToUse, field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_thirdbox->Add( 1, 10, 0, 1 ); sz_thirdbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );#if 0 // Obsolete //wep mode sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStWepMode, 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mChWepMode, field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_thirdbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );#endif // 0 //authentication type sz_curline = new wxBoxSizer( wxHORIZONTAL ); sz_curline->Add( 1, 10, 1, 0 ); sz_curline->Add( mStAuthType, 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( mChAuthType, field, wxALIGN_CENTER_VERTICAL, 0 ); sz_curline->Add( width, 10, 0, 0 ); sz_thirdbox->Add( sz_curline, 0, wxEXPAND | wxALL, border ); //encryption page sizer wxBoxSizer *sz_page_encryption = new wxBoxSizer( wxVERTICAL ); sz_page_encryption->Add( sz_firstbox, 2, wxEXPAND | wxALL, 5 ); sz_page_encryption->Add( sz_secondbox, 7, wxEXPAND | wxALL, 5 ); sz_page_encryption->Add( sz_thirdbox, 4, wxEXPAND | wxALL, 5 ); sz_page_encryption->Add( mSubmit, 0, wxALIGN_RIGHT | wxRIGHT, 5 ); sz_page_encryption->Add( 1, 10, 1, 0 ); SetSizer( sz_page_encryption ); SetAutoLayout( true );//////////////////////////////Encryption page choices setup mEncryptionChoice = new CEncryptionChoiceSP( this ); wxArrayString encryption_ret = mEncryptionChoice->ProvideStrings( ID_CH_FIRSTBOX_ENCRYPTION ); mChEncryption->SetStrings( encryption_ret ); wxArrayString wepkey_ret = mEncryptionChoice->ProvideStrings( ID_CH_THIRDBOX_WEPKEYTOUSE ); mChWepkeyToUse->SetStrings( wepkey_ret );#if 0 // Obsolete wxArrayString wepmode_ret = mEncryptionChoice->ProvideStrings( ID_CH_THIRDBOX_WEPMODE ); mChWepMode->SetStrings( wepmode_ret );#endif // 0 wxArrayString authentication_ret = mEncryptionChoice->ProvideStrings( ID_CH_THIRDBOX_AUTHENTICATIONTYPE ); mChAuthType->SetStrings( authentication_ret ); mLastKey = -1;}CEncryptionPage::~CEncryptionPage( ){ delete mEncryptionChoice;}void CEncryptionPage::OnBtEncryptPageSubmit( wxCommandEvent &event ){#if ( USE_BUSY_INFO == 1 )// Once again some more ifdef's! wxBusyInfo info( _( "Configuring device..." ) );#endif // USE_BUSY_INFO == 1 DEACTIVATE_TIMER( );#if ( USE_BUSY_INFO == 0 ) ::wxBeginBusyCursor( );#endif // USE_BUSY_INFO == 0 SubmitEncryptionPageData( );#if ( DELAY_AFTER_SUBMIT == 1 ) ::wxSleep( 1 );#endif // DELAY_AFTER_SUBMIT == 1 UpdateWinterPage( );#if ( USE_BUSY_INFO == 0 ) ::wxEndBusyCursor( );#endif // USE_BUSY_INFO == 0 ( ( wxNotebook * ) FindWindowById( ID_NB_MAINNOTEBOOK ) )->SetSelection( 0 ); ACTIVATE_TIMER( ); return;}void CEncryptionPage::SubmitEncryptionPageData( ){ TransferToModel( ); CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL ); CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE ); CWepInfoData *data = ( CWepInfoData * ) model->GetChild( MC_WEPINFODATA ); if( device == NULL ) { ::wxMessageBox( _( "No device." ), wxT( "Winter" ), wxICON_HAND, ( CWinterFrame * ) CAccessor::Access( AID_FRAME ) ); return; } if( device->SetWepInfo( data ) == false ) { ::wxMessageBox( _( "Failed to set encryption settings." ) ); return; } return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -