📄 winterapp.cpp
字号:
/* WinterApp.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 "WinterApp.h"#include "WinterFrame.h"#include "Accessor.h"#include "WinterModel.h"#include "WinterLang.h"#include "WinterConfig.h"#include "WinterPage.h"#include "ProfilesPage.h"#include "Decls.h"#include "Device.h"#include "HRStrings.h"#include "WinterSetup.h"#include "WinterDebug.h"#ifdef OS_SOLARIS#include "Solaris.h"#endif // OS_SOLARIS#ifdef OS_LINUX#include "Linux.h"#include "OSHeaders.h"#endif // OS_LINUX#ifdef OS_VIRTUAL#include "VDevice.h"#endif // OS_VIRTUALIMPLEMENT_APP( CWinterApp );CWinterApp::CWinterApp( ){}CWinterApp::~CWinterApp( ){}// TODO: In the future, create separate application classes for each platform.bool CWinterApp::OnInit( ){ CWinterConfig *config = ( CWinterConfig * ) CAccessor::Access( AID_CONFIG ); config->Load( );#if ( USE_LOCALE == 1 ) int lang_code = CWinterSupportedLanguages::GetWxCode( config->GetLangName( ) ); mLocale = new wxLocale( ); if( lang_code != -1 ) { mLocale->Init( lang_code ); mLocale->AddCatalog( wxT( "winter" ) ); }#endif // USE_LOCALE == 1#if ( CHECK_SINGLE_INSTANCE == 1 ) // Suppress the stupid 'Deleted stale lock file' message box by // temporarily disabling logging. wxLogNull *log_null = new wxLogNull( ); mInstanceChecker = new wxSingleInstanceChecker( ); mInstanceChecker->Create( wxT( "Winter" ) ); delete log_null; if( mInstanceChecker->IsAnotherRunning( ) == true ) { ::wxMessageBox( _( "There is another instance of winter running." ), wxT( "Winter" ), wxICON_HAND ); return false; }#endif // CHECK_SINGLE_INSTANCE == 1// Implementation for Solaris#ifdef OS_SOLARIS CVnetDeviceManager *manager = ( CVnetDeviceManager * ) CAccessor::Access( AID_DEVICEMANAGER ); wxString str_device = wxT( "vnet0" ); if( argc != 1 ) { if( wxString( argv[ 1 ] ) == wxT( "-iface" ) ) { if( argc >= 3 ) { str_device = wxString( argv[ 2 ] ); } } } wxString str_pathdevice = wxT( "/dev/" ) + str_device; if( manager->AddDevice( new CVnetDeviceSolaris( str_device ) ) == false ) { ::wxMessageBox( _( "The device " ) + str_pathdevice + _( " could not be opened." ), _( "Error" ), wxICON_HAND ); return false; }#endif // OS_SOLARIS// Implementation for Linux#ifdef OS_LINUX // debug : CVnetDeviceManager *manager = ( CVnetDeviceManager * ) CAccessor::Access( AID_DEVICEMANAGER ); if( manager->Detect( ) == false ) { ::wxMessageBox( _( "Device detection failed." ), wxT( "Winter" ), wxICON_HAND ); return false; }#endif // OS_LINUX// Implementation for virtual device#ifdef OS_VIRTUAL CVnetDeviceManager *manager = ( CVnetDeviceManager * ) CAccessor::Access( AID_DEVICEMANAGER ); manager->AddDevice( new CVnetDeviceVirtual( ) );#endif // OS_VIRTUAL CVnetDeviceManager *the_manager = ( CVnetDeviceManager * ) CAccessor::Access( AID_DEVICEMANAGER ); if( the_manager->GetDeviceCount( ) == 0 ) { ::wxMessageBox( _( "No devices found." ), wxT( "Winter" ), wxICON_HAND ); return false; } CWinterFrame *frame = new CWinterFrame( NULL, -1, _( "Wireless LAN configuration INTERface" ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxSTAY_ON_TOP ); // The following line is required so that the controls are updated prior to showing the frame. // SendIdleEvents( frame ); SetTopWindow( frame ); CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER ); pmanager->LoadFile( ); frame->UpdateProfileList( ); frame->UpdateIFaceList( ); frame->UpdateAllPages( ); frame->Show( true ); ApplyStartupOptions( ); return true;}int CWinterApp::OnExit( ){ // delete ( CWinterTimer * ) CAccessor::Access( AID_TIMER ); delete ( CVnetDeviceManager * ) CAccessor::Access( AID_DEVICEMANAGER ); CWinterProfileManager *manager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER ); if( manager->SaveFile( ) == false ) { ::wxMessageBox( _( "Failed to write rc file." ), _( "Error" ), wxICON_HAND ); } CWinterConfig *config = ( CWinterConfig * ) CAccessor::Access( AID_CONFIG ); config->Save( ); delete config; delete manager; delete mLocale; delete ( CWinterStringsProvider * ) CAccessor::Access( AID_STRINGSPROVIDER );#if ( CHECK_SINGLE_INSTANCE == 1 ) delete mInstanceChecker;#endif // CHECK_SINGLE_INSTANCE == 1 return wxApp::OnExit( );}void CWinterApp::ApplyStartupOptions( ){ CWinterConfig *config = ( CWinterConfig * ) CAccessor::Access( AID_CONFIG ); CWinterProfileManager *pmanager = ( CWinterProfileManager * ) CAccessor::Access( AID_PROFILEMANAGER ); CProfilesPage *prof_page = ( CProfilesPage * ) GetTopWindow( )->FindWindowById( ID_PN_PROFILESPAGE ); CAutoChoice *ch_profiles = ( ( CAutoChoice *) GetTopWindow( )->FindWindowById( ID_CH_MAINPANEL_PROFILES ) ); // IFACE SELECT CAutoChoice *ch_ifaces = ((CAutoChoice*)GetTopWindow()->FindWindowById(ID_CH_WHICHDEVICE)); if(ch_ifaces->GetSelection() < 0) ch_ifaces->SetSelection(0); wxString profile_name = config->GetStartupProfile( ); CWinterProfile *profile = pmanager->GetProfile( profile_name ); if( profile != NULL ) { prof_page->ActivateProfile( profile ); ch_profiles->SetStringSelection( profile_name ); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -