⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wxcasframe.cpp

📁 电驴的MAC源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// Prefs buttonvoidWxCasFrame::OnBarPrefs ( wxCommandEvent& WXUNUSED( event ) ){	WxCasPrefs dlg ( this );	dlg.ShowModal ();}// About buttonvoidWxCasFrame::OnBarAbout ( wxCommandEvent& WXUNUSED( event ) ){	wxMessageBox ( _	               ( "wxCas, aMule OnLine Signature Statistics\n\n"	                 "(c) 2004 ThePolish <thepolish@vipmail.ru>\n\n"	                 "Based on CAS by Pedro de Oliveira <falso@rdk.homeip.net>\n\n"	                 "Distributed under GPL" ),	               _( "About wxCas" ), wxOK | wxCENTRE | wxICON_INFORMATION );}// Refresh timervoidWxCasFrame::OnRefreshTimer ( wxTimerEvent& WXUNUSED( event ) ){	// Prefs	wxConfigBase * prefs = wxConfigBase::Get();	UpdateAll ();	// Generate stat image if asked in config	if ( ( bool )	        ( prefs->	          Read ( WxCasCte::ENABLE_AUTOSTATIMG_KEY,	                 WxCasCte::DEFAULT_AUTOSTATIMG_ISENABLED ) ) ) {		wxImage * statImage = GetStatImage ();		wxFileName fileName ( prefs->		                      Read ( WxCasCte::AUTOSTATIMG_DIR_KEY,		                             WxCasCte::DEFAULT_AUTOSTATIMG_PATH ),		                      WxCasCte::AMULESIG_IMG_NAME,		                      prefs->		                      Read ( WxCasCte::AUTOSTATIMG_TYPE_KEY,		                             WxCasCte::DEFAULT_AUTOSTATIMG_TYPE ).		                      Lower () );		if ( !statImage->SaveFile ( fileName.GetFullPath () ) ) {			wxLogError ( wxT( "No handler for this file type. File was not saved" ) );		}		delete statImage;	}}// Ftp update timervoidWxCasFrame::OnFtpUpdateTimer ( wxTimerEvent& WXUNUSED( event ) ){	// Prefs	wxConfigBase * prefs = wxConfigBase::Get();	// Image must be autogenerated to be uploaded	if ( ( bool ) ( prefs->Read ( WxCasCte::ENABLE_AUTOSTATIMG_KEY,	                              WxCasCte::DEFAULT_AUTOSTATIMG_ISENABLED ) ) &&	        ( bool ) ( prefs->Read ( WxCasCte::ENABLE_FTP_UPDATE_KEY,	                                 WxCasCte::DEFAULT_FTP_UPDATE_ISENABLED ) ) ) {		// Get image file		wxFileName fileName ( prefs->		                      Read ( WxCasCte::AUTOSTATIMG_DIR_KEY,		                             WxCasCte::DEFAULT_AUTOSTATIMG_PATH ),		                      WxCasCte::AMULESIG_IMG_NAME,		                      prefs->		                      Read ( WxCasCte::AUTOSTATIMG_TYPE_KEY,		                             WxCasCte::DEFAULT_AUTOSTATIMG_TYPE ).		                      Lower () );		// If img doenst exist, return		if ( ! fileName.FileExists( fileName.GetFullPath () ) ) {			wxLogError( wxT( "Image file " ) + fileName.GetFullPath () + wxT( " doesn't exist" ) );			return ;		}		// Connect to ftp		wxFTP ftp;		ftp.SetUser( prefs->Read ( WxCasCte::FTP_USER_KEY,		                           WxCasCte::DEFAULT_FTP_USER ) );		ftp.SetPassword( prefs->Read ( WxCasCte::FTP_PASSWD_KEY,		                               WxCasCte::DEFAULT_FTP_PASSWD ) );		if ( ! ftp.Connect( prefs->Read ( WxCasCte::FTP_URL_KEY,		                                  WxCasCte::DEFAULT_FTP_URL ) ) ) {			wxLogError( wxT( "Cannot connect to FTP server " ) + prefs->Read ( WxCasCte::FTP_URL_KEY,			            WxCasCte::DEFAULT_FTP_URL ) );			return ;		}		// Chdir		if ( ! ftp.ChDir( prefs->Read ( WxCasCte::FTP_PATH_KEY,		                                WxCasCte::DEFAULT_FTP_PATH ) ) ) {			wxLogError( wxT( "Cannot chdir to " ) + prefs->Read ( WxCasCte::FTP_PATH_KEY,			            WxCasCte::DEFAULT_FTP_PATH ) );			ftp.Close();			return ;		}		// Upload image		ftp.SetBinary();		wxFileInputStream in( fileName.GetFullPath () );		if ( in.Ok() ) {			wxOutputStream * out = ftp.GetOutputStream( fileName.GetFullName () );			if ( out ) {				out->Write( in );				delete out;			} else {				wxLogError( wxT( "Cannot open FTP upload stream" ) );			}		} else {			wxLogError( wxT( "Cannot open file stream to read image file" ) );		}		// Close connexion		ftp.Close();	}}// Reset wxcas session hitvoidWxCasFrame::OnHitButton ( wxCommandEvent& WXUNUSED( event ) ){	m_aMuleSig->ResetSessionMaxDL();	UpdateStatsPanel ();}// Reset wxcas absolute hitvoidWxCasFrame::OnAbsHitButton ( wxCommandEvent& WXUNUSED( event ) ){	m_aMuleSig->ResetAbsoluteMaxDL();	SaveAbsoluteHits();	UpdateStatsPanel ();}// Update all panels and frame, call Fit if neededvoidWxCasFrame::UpdateAll ( bool forceFitting ){	bool needFit = UpdateStatsPanel ();	if ( needFit || forceFitting ) {		// Fit stats pannel		m_mainPanel->Fit();		// Fit main frame		SetClientSize( m_mainPanel->GetSize() );	}}// Update stat panelboolWxCasFrame::UpdateStatsPanel (){	// Set labels	m_aMuleSig->Refresh ();#ifdef __LINUX__		// System monitoring on Linux	m_sysMonitor->Refresh ();#endif	wxString newline;	wxString status;	unsigned int newMaxLineCount = 0;	Freeze ();	// Stat line 1	newline = MakeStatLine_1();	m_statLine_1->SetLabel ( newline );	newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );	// aMule is stopped 	//if ( m_aMuleSig->GetRunTime () == 0 		// aMule is not running	if ( m_aMuleSig->GetUpStatus () == 0) {		status = _( "Oh Oh, aMule is not running..." );		newline = MakeStatLine_2();		m_statLine_2->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );	}	// aMule is running, ed2k and kad are connected	else if ( (m_aMuleSig->GetAmuleState () == 1 ) && (m_aMuleSig->GetKadState () == 1 || m_aMuleSig->GetKadState () == 2)) {		// Stat line 2		newline = MakeStatLine_2();		m_statLine_2->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 3		newline = MakeStatLine_3();		m_statLine_3->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 4		newline = MakeStatLine_4();		m_statLine_4->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 5		newline = MakeStatLine_5();		m_statLine_5->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 6		newline = MakeStatLine_6();		m_statLine_6->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 7		newline = MakeStatLine_7();		m_statLine_7->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Hits line 1		if ( m_aMuleSig->IsSessionMaxDlChanged() ) {			newline = MakeHitsLine_1();			m_hitLine->SetLabel ( newline );			newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		}		// Hits line 2		if ( m_aMuleSig->IsAbsoluteMaxDlChanged() ) {			newline = MakeHitsLine_2();			m_absHitLine->SetLabel ( newline );			newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );			// Save new records			SaveAbsoluteHits();		}#ifdef __LINUX__		// System monitoring on Linux		newline = MakeSysLine_1();		m_sysLine_1->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		newline = MakeSysLine_2();		m_sysLine_2->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );#endif		status = _( "aMule is running" );	}	// aMule is running, ed2k is off, but kad connected	else if ( (m_aMuleSig->GetAmuleState () == 0) && (m_aMuleSig->GetKadState () == 1 || m_aMuleSig->GetKadState () == 2 )) {		// Stat line 2		newline = MakeStatLine_2();		m_statLine_2->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 3		newline = MakeStatLine_3();		m_statLine_3->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 4		newline = MakeStatLine_4();		m_statLine_4->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 5		newline = MakeStatLine_5();		m_statLine_5->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 6		newline = MakeStatLine_6();		m_statLine_6->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 7		newline = MakeStatLine_7();		m_statLine_7->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Hits line 1		if ( m_aMuleSig->IsSessionMaxDlChanged() ) {			newline = MakeHitsLine_1();			m_hitLine->SetLabel ( newline );			newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		}		// Hits line 2		if ( m_aMuleSig->IsAbsoluteMaxDlChanged() ) {			newline = MakeHitsLine_2();			m_absHitLine->SetLabel ( newline );			newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );			// Save new records			SaveAbsoluteHits();		}#ifdef __LINUX__		// System monitoring on Linux		newline = MakeSysLine_1();		m_sysLine_1->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		newline = MakeSysLine_2();		m_sysLine_2->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );#endif		status = _( "aMule is running" );	}	else if ( (m_aMuleSig->GetAmuleState () == 1) && (m_aMuleSig->GetKadState () == 0)) {		// Stat line 2		newline = MakeStatLine_2();		m_statLine_2->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 3		newline = MakeStatLine_3();		m_statLine_3->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 4		newline = MakeStatLine_4();		m_statLine_4->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 5		newline = MakeStatLine_5();		m_statLine_5->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 6		newline = MakeStatLine_6();		m_statLine_6->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Stat line 7		newline = MakeStatLine_7();		m_statLine_7->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		// Hits line 1		if ( m_aMuleSig->IsSessionMaxDlChanged() ) {			newline = MakeHitsLine_1();			m_hitLine->SetLabel ( newline );			newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		}		// Hits line 2		if ( m_aMuleSig->IsAbsoluteMaxDlChanged() ) {			newline = MakeHitsLine_2();			m_absHitLine->SetLabel ( newline );			newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );			// Save new records			SaveAbsoluteHits();		}#ifdef __LINUX__		// System monitoring on Linux		newline = MakeSysLine_1();		m_sysLine_1->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );		newline = MakeSysLine_2();		m_sysLine_2->SetLabel ( newline );		newMaxLineCount = GetMaxUInt( newline.Length (), newMaxLineCount );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -