//all messageboxes need to be modal, updater closes immeadiately when receiving the UpdateFinished event void UpdaterClass::OnDownloadEvent( wxCommandEvent& event ) { int code = event.GetInt(); if ( code != 0) customMessageBox(SL_MAIN_ICON, _("There was an error downloading for the latest version.\nPlease try again later.\nIf the problem persists, please use Help->Report Bug to report this bug."), _("Error")); else { if (!PostMinGW44( m_newexe ) ) { customMessageBox(SL_MAIN_ICON, _("Automatic update failed\n\nyou will be redirected to a web page with instructions and the download link will be opened in your browser."), _("Updater error.") ); OpenWebBrowser( _T("http://projects.springlobby.info/wiki/springlobby/Install#Windows-Binary") ); OpenWebBrowser( GetDownloadUrl( m_latest_version ) ); } if ( !UpdateExe( m_newexe , false ) ) { customMessageBox(SL_MAIN_ICON, wxFormat( _("There was an error while trying to replace the current executable version.\n Please manually copy springlobby.exe from: %s\n to: %s\n") ) % m_newexe % m_currentexe, _("Error") ); } else { bool locale_ok = UpdateLocale( m_newexe, false ); if ( locale_ok ) { customMessageBox(SL_MAIN_ICON, IdentityString( _("Update complete. \nPlease restart %s now.") ), _("Success")); } else { customMessageBox(SL_MAIN_ICON, IdentityString( _("Binary updated successfully. \nSome translation files could not be updated.\nPlease report this in #springlobby. \nPlease restart %s now.") ), _("Partial success") ); } wxRmdir( m_newexe ); } } GetGlobalEventSender( GlobalEvents::UpdateFinished ).SendEvent( 0 ); }
//! @brief Initializes the logging functions. ///initializes logging in an hidden stream and std::cout/gui messages wxLogWindow* InitializeLoggingTargets( wxWindow* parent, bool console, const wxString& logfilepath, bool showgui, int verbosity, wxLogChain* logChain ) { wxLogWindow* loggerwin = NULL; if ( console ) { #if wxUSE_STD_IOSTREAM ///std::cout logging logChain = new wxLogChain( new wxLogStream( &std::cout ) ); #else ///std::cerr logging logChain = new wxLogChain( new wxLogStderr( 0 ) ); #endif } if (showgui) { ///gui window logging loggerwin = new wxLogWindow(parent, IdentityString( _("%s error console") ), showgui ); logChain = new wxLogChain( loggerwin ); } if (!console && !showgui) { new wxLogNull(); //memleak but disables logging as no log target exists //FIXME: there should be a cleaner way (like just not showing message boxes) } if (!logfilepath.empty()) { FILE* logfile = fopen(C_STRING(logfilepath), "w"); // even if it returns null, wxLogStderr will switch to stderr logging, so it's fine logChain = new wxLogChain( new wxLogStderr( logfile ) ); } #if wxUSE_DEBUGREPORT && defined(ENABLE_DEBUG_REPORT) && wxUSE_STD_IOSTREAM ///hidden stream logging for crash reports wxLog *loggercrash = new wxLogStream( &CrashReport::instance().crashlog ); logChain = new wxLogChain( loggercrash ); // logCrashChain->SetLogLevel( wxLOG_Trace ); // logCrashChain->SetVerbose( true ); #endif if (logChain!=NULL) { switch (verbosity) { case 0: case 1: logChain->SetLogLevel( wxLOG_FatalError ); break; case 2: logChain->SetLogLevel( wxLOG_Error ); break; case 3: logChain->SetLogLevel( wxLOG_Warning ); break; case 4: logChain->SetLogLevel( wxLOG_Message ); break; case 5: logChain->SetLogLevel( wxLOG_Trace ); logChain->SetVerbose( true ); break; default://meaning loglevel < 0 or > 5 , == 0 is handled seperately logChain->SetLogLevel( wxLOG_Warning ); break; } } return loggerwin; }
OptionsDialog::OptionsDialog( wxWindow* parent ) : wxDialog( parent, -1, IdentityString(_("%s Preferences") ), wxDefaultPosition, wxSize( 700,430 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX ), WindowAttributesPickle( _T("preferences"), this, wxSize( 700,430 ) ) { m_options = new MainOptionsTab( this ); m_main_sizer = new wxBoxSizer( wxVERTICAL ); m_main_sizer->Add( m_options, 1, wxEXPAND | wxALL, 0 ); SetSizer( m_main_sizer ); Layout(); }
wxString slConfig::GlobalConfigPath() const { #ifdef __WXMSW__ wxString p (wxFileName::GetPathSeparator()); wxString global_config_path = wxFormat( _T("%s%s%s.global.conf") ) % GetExecutableFolder() % p % ::GetAppName( true ); #else wxString global_config_path = IdentityString( _T("/etc/default/%s.conf"), true ); #endif //__WXMSW__ return global_config_path; }
void SpringOptionsTab::OnApply( wxCommandEvent& /*unused*/ ) { sett().SetSpringBinary( sett().GetCurrentUsedSpringIndex(), m_exec_edit->GetValue() ); sett().SetUnitSync( sett().GetCurrentUsedSpringIndex(), m_sync_edit->GetValue() ); sett().SetSearchSpringOnlyInSLPath( m_dontsearch_chkbox->IsChecked() ); sett().SetOldSpringLaunchMethod( m_oldlaunch_chkbox->IsChecked() ); if ( sett().IsFirstRun() ) return; UiEvents::ScopedStatusMessage( _("Reloading unitsync"), 0 ); sett().RefreshSpringVersionList(); if ( !usync().LoadUnitSyncLib( sett().GetCurrentUsedUnitSync() ) ) { wxLogWarning( _T( "Cannot load UnitSync" ) ); customMessageBox( SL_MAIN_ICON, IdentityString( _( "%s is unable to load your UnitSync library.\n\nYou might want to take another look at your unitsync setting." ) ), _( "Spring error" ), wxOK ); } }
//! @brief Initializes the logging functions. ///initializes logging in an hidden stream and std::cout/gui messages wxLogWindow* InitializeLoggingTargets( wxFrame* parent, bool console, const wxString& logfilepath, bool showgui, bool /*logcrash*/, int verbosity, wxLogChain* logChain ) { wxLogWindow* loggerwin = 0; #if wxUSE_STD_IOSTREAM if ( console && verbosity != 0 ) { ///std::cout logging logChain = new wxLogChain( new wxLogStream( &std::cout ) ); } #else if ( console && verbosity != 0 ) { ///std::cerr logging logChain = new wxLogChain( new wxLogStderr( 0 ) ); } #endif if ( logfilepath.size() != 0 && verbosity != 0 ) { FILE* logfile = fopen(C_STRING(logfilepath), "w"); // even if it returns null, wxLogStderr will switch to stderr logging, so it's fine logChain = new wxLogChain( new wxLogStderr( logfile ) ); } if ( showgui && verbosity != 0 ) { ///gui window logging loggerwin = new wxLogWindow( (wxWindow*) parent, IdentityString( _("%s error console") ), showgui ); logChain = new wxLogChain( loggerwin ); } #if wxUSE_DEBUGREPORT && defined(ENABLE_DEBUG_REPORT) && wxUSE_STD_IOSTREAM ///hidden stream logging for crash reports wxLog *loggercrash = new wxLogStream( &CrashReport::instance().crashlog ); logChain = new wxLogChain( loggercrash ); // logCrashChain->SetLogLevel( wxLOG_Trace ); // logCrashChain->SetVerbose( true ); #endif if ( !( console || showgui ) || verbosity == 0 ){ new wxLogNull; return loggerwin; } if ( logChain ) { switch (verbosity) { case 1: logChain->SetLogLevel( wxLOG_FatalError ); break; case 2: logChain->SetLogLevel( wxLOG_Error ); break; case 3: logChain->SetLogLevel( wxLOG_Warning ); break; case 4: logChain->SetLogLevel( wxLOG_Message ); break; case 5: logChain->SetLogLevel( wxLOG_Trace ); logChain->SetVerbose( true ); break; default://meaning loglevel < 0 or > 5 , == 0 is handled seperately logChain->SetLogLevel( wxLOG_Warning ); break; } } return loggerwin; }