2005-01-20 23:22:22 +00:00
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
2004-05-17 22:15:10 +00:00
//
2005-01-20 23:22:22 +00:00
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
2004-04-10 09:11:03 +00:00
//
2005-01-20 23:22:22 +00:00
// This software 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 Lesser General Public License for more details.
2004-05-17 22:15:10 +00:00
//
2005-01-20 23:22:22 +00:00
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2004-04-10 09:11:03 +00:00
2004-04-11 04:37:10 +00:00
# if defined(__GNUG__) && !defined(__APPLE__)
# pragma implementation "MainFrame.h"
# endif
2004-04-10 09:11:03 +00:00
# include "stdwx.h"
2005-06-28 22:22:29 +00:00
# include "hyperlink.h"
2004-04-10 20:25:27 +00:00
# include "BOINCGUIApp.h"
# include "MainFrame.h"
2004-07-13 05:56:03 +00:00
# include "Events.h"
2004-09-21 01:30:29 +00:00
# include "BOINCBaseView.h"
# include "ViewProjects.h"
2005-04-21 06:04:26 +00:00
# include "ViewWork.h"
# include "ViewTransfers.h"
# include "ViewMessages.h"
# include "ViewStatistics.h"
# include "ViewResources.h"
2004-04-10 20:25:27 +00:00
# include "DlgAbout.h"
2004-04-11 04:12:44 +00:00
# include "DlgOptions.h"
2005-03-31 23:54:12 +00:00
# include "DlgAttachProject.h"
2005-06-17 04:53:35 +00:00
# include "DlgAccountManagerSignup.h"
# include "DlgAccountManagerStatus.h"
2005-06-29 05:21:47 +00:00
# include "DlgDialupCredentials.h"
2005-03-30 09:24:31 +00:00
# include "DlgSelectComputer.h"
2004-04-10 09:11:03 +00:00
2004-04-11 04:12:44 +00:00
# include "res/BOINCGUIApp.xpm"
2004-10-28 07:03:06 +00:00
# include "res/connect.xpm"
# include "res/disconnect.xpm"
2004-04-10 09:11:03 +00:00
2004-04-13 00:33:40 +00:00
2005-04-07 07:04:50 +00:00
enum STATUSBARFIELDS {
2004-10-28 22:51:38 +00:00
STATUS_TEXT ,
STATUS_CONNECTION_STATUS
} ;
2005-03-10 05:07:01 +00:00
IMPLEMENT_DYNAMIC_CLASS ( CStatusBar , wxStatusBar )
BEGIN_EVENT_TABLE ( CStatusBar , wxStatusBar )
EVT_SIZE ( CStatusBar : : OnSize )
END_EVENT_TABLE ( )
2005-04-07 07:04:50 +00:00
CStatusBar : : CStatusBar ( ) {
2005-03-10 05:07:01 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CStatusBar::CStatusBar - Default Constructor Function Begin " ) ) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CStatusBar::CStatusBar - Default Constructor Function End " ) ) ;
}
2005-04-07 07:04:50 +00:00
CStatusBar : : CStatusBar ( wxWindow * parent ) :
wxStatusBar ( parent , ID_STATUSBAR , wxST_SIZEGRIP , _T ( " statusBar " ) )
2005-03-10 05:07:01 +00:00
{
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CStatusBar::CStatusBar - Function Begin " ) ) ;
2005-04-10 19:01:23 +00:00
const int widths [ ] = { - 1 , 200 , 20 } ;
2005-03-10 05:07:01 +00:00
SetFieldsCount ( WXSIZEOF ( widths ) , widths ) ;
m_pbmpConnected = new wxStaticBitmap ( this , - 1 , wxIcon ( connect_xpm ) ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pbmpConnected ) ;
2005-03-10 05:07:01 +00:00
m_pbmpConnected - > Hide ( ) ;
2005-04-07 07:04:50 +00:00
m_ptxtConnected = new wxStaticText ( this , - 1 , _ ( " Connected " ) , wxPoint ( 0 , 0 ) , wxDefaultSize , wxALIGN_LEFT ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_ptxtConnected ) ;
2005-03-10 05:07:01 +00:00
m_ptxtConnected - > Hide ( ) ;
m_pbmpDisconnect = new wxStaticBitmap ( this , - 1 , wxIcon ( disconnect_xpm ) ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pbmpDisconnect ) ;
2005-03-10 05:07:01 +00:00
m_pbmpDisconnect - > Hide ( ) ;
2005-04-07 07:04:50 +00:00
m_ptxtDisconnect = new wxStaticText ( this , - 1 , _ ( " Disconnected " ) , wxPoint ( 0 , 0 ) , wxDefaultSize , wxALIGN_LEFT ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_ptxtDisconnect ) ;
2005-03-10 05:07:01 +00:00
m_ptxtDisconnect - > Hide ( ) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CStatusBar::CStatusBar - Function End " ) ) ;
}
CStatusBar : : ~ CStatusBar ( )
{
}
2005-04-07 07:04:50 +00:00
void CStatusBar : : OnSize ( wxSizeEvent & event ) {
2005-03-10 05:07:01 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CStatusBar::OnSize - Function Begin " ) ) ;
2005-04-07 07:04:50 +00:00
if ( IsShown ( ) ) {
2005-03-10 05:07:01 +00:00
wxRect rect ;
wxSize size ;
GetFieldRect ( STATUS_CONNECTION_STATUS , rect ) ;
2005-04-07 07:04:50 +00:00
if ( m_pbmpConnected ) {
2005-03-10 05:07:01 +00:00
size = m_pbmpConnected - > GetSize ( ) ;
m_pbmpConnected - > Move ( rect . x + 1 ,
rect . y + ( rect . height - size . y ) / 2 ) ;
}
2005-04-07 07:04:50 +00:00
if ( m_ptxtConnected ) {
2005-03-10 05:07:01 +00:00
m_ptxtConnected - > Move ( ( rect . x + size . x ) + 2 ,
( rect . y + ( rect . height - size . y ) / 2 ) + 1 ) ;
}
2005-04-07 07:04:50 +00:00
if ( m_pbmpDisconnect ) {
2005-03-10 05:07:01 +00:00
size = m_pbmpConnected - > GetSize ( ) ;
m_pbmpDisconnect - > Move ( rect . x + 1 ,
rect . y + ( rect . height - size . y ) / 2 ) ;
}
2005-04-07 07:04:50 +00:00
if ( m_ptxtDisconnect ) {
2005-03-10 05:07:01 +00:00
m_ptxtDisconnect - > Move ( ( rect . x + size . x ) + 2 ,
( rect . y + ( rect . height - size . y ) / 2 ) + 1 ) ;
}
}
event . Skip ( ) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CStatusBar::OnSize - Function End " ) ) ;
}
2005-06-17 04:53:35 +00:00
DEFINE_EVENT_TYPE ( wxEVT_MAINFRAME_ALERT )
2005-04-08 16:58:55 +00:00
DEFINE_EVENT_TYPE ( wxEVT_MAINFRAME_CONNECT )
DEFINE_EVENT_TYPE ( wxEVT_MAINFRAME_INITIALIZED )
DEFINE_EVENT_TYPE ( wxEVT_MAINFRAME_REFRESHVIEW )
2005-04-08 04:23:37 +00:00
2004-04-10 09:11:03 +00:00
IMPLEMENT_DYNAMIC_CLASS ( CMainFrame , wxFrame )
BEGIN_EVENT_TABLE ( CMainFrame , wxFrame )
2004-10-24 07:38:38 +00:00
EVT_MENU ( ID_HIDE , CMainFrame : : OnHide )
EVT_MENU_RANGE ( ID_ACTIVITYRUNALWAYS , ID_ACTIVITYSUSPEND , CMainFrame : : OnActivitySelection )
EVT_MENU_RANGE ( ID_NETWORKRUNALWAYS , ID_NETWORKSUSPEND , CMainFrame : : OnNetworkSelection )
2004-10-27 23:19:50 +00:00
EVT_MENU ( ID_RUNBENCHMARKS , CMainFrame : : OnRunBenchmarks )
2004-10-28 07:03:06 +00:00
EVT_MENU ( ID_SELECTCOMPUTER , CMainFrame : : OnSelectComputer )
2004-09-24 02:01:53 +00:00
EVT_MENU ( wxID_EXIT , CMainFrame : : OnExit )
2005-06-17 04:53:35 +00:00
EVT_MENU ( ID_TOOLSMANAGEACCOUNTS , CMainFrame : : OnToolsManageAccounts )
2004-09-24 02:01:53 +00:00
EVT_MENU ( ID_TOOLSOPTIONS , CMainFrame : : OnToolsOptions )
2005-06-21 17:27:39 +00:00
EVT_HELP ( ID_FRAME , CMainFrame : : OnHelp )
2005-06-17 04:53:35 +00:00
EVT_MENU ( ID_HELPBOINCMANAGER , CMainFrame : : OnHelpBOINCManager )
2005-05-05 06:07:14 +00:00
EVT_MENU ( ID_HELPBOINC , CMainFrame : : OnHelpBOINCWebsite )
EVT_MENU ( wxID_ABOUT , CMainFrame : : OnHelpAbout )
2004-10-24 07:38:38 +00:00
EVT_CLOSE ( CMainFrame : : OnClose )
2005-06-17 04:53:35 +00:00
EVT_MAINFRAME_ALERT ( CMainFrame : : OnAlert )
2005-04-08 04:23:37 +00:00
EVT_MAINFRAME_CONNECT ( CMainFrame : : OnConnect )
EVT_MAINFRAME_INITIALIZED ( CMainFrame : : OnInitialized )
EVT_MAINFRAME_REFRESH ( CMainFrame : : OnRefreshView )
2005-03-07 23:52:28 +00:00
EVT_TIMER ( ID_REFRESHSTATETIMER , CMainFrame : : OnRefreshState )
2004-12-10 20:46:43 +00:00
EVT_TIMER ( ID_FRAMERENDERTIMER , CMainFrame : : OnFrameRender )
EVT_TIMER ( ID_FRAMELISTRENDERTIMER , CMainFrame : : OnListPanelRender )
2005-04-10 02:24:08 +00:00
EVT_TIMER ( ID_DOCUMENTPOLLTIMER , CMainFrame : : OnDocumentPoll )
2004-10-21 14:29:59 +00:00
EVT_NOTEBOOK_PAGE_CHANGED ( ID_FRAMENOTEBOOK , CMainFrame : : OnNotebookSelectionChanged )
2004-05-21 06:27:15 +00:00
END_EVENT_TABLE ( )
2004-04-10 09:11:03 +00:00
2004-10-23 07:13:18 +00:00
2005-04-07 07:04:50 +00:00
CMainFrame : : CMainFrame ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CMainFrame - Default Constructor Function Begin " ) ) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CMainFrame - Default Constructor Function End " ) ) ;
2004-04-10 09:11:03 +00:00
}
CMainFrame : : CMainFrame ( wxString strTitle ) :
2005-04-08 06:24:58 +00:00
wxFrame ( ( wxFrame * ) NULL , ID_FRAME , strTitle , wxDefaultPosition , wxDefaultSize ,
2004-04-10 09:11:03 +00:00
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE )
{
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CMainFrame - Function Begin " ) ) ;
2004-12-03 22:06:39 +00:00
2004-04-10 09:11:03 +00:00
m_pMenubar = NULL ;
m_pNotebook = NULL ;
m_pStatusbar = NULL ;
2005-06-29 05:21:47 +00:00
// Configuration Settings
2005-03-10 05:07:01 +00:00
m_iSelectedLanguage = 0 ;
2005-06-24 10:49:42 +00:00
m_iReminderFrequency = 0 ;
2004-10-28 22:51:38 +00:00
2005-06-29 05:21:47 +00:00
m_iNetworkConnectionType = ID_NETWORKAUTODETECT ;
m_strNetworkDialupConnectionName = wxEmptyString ;
m_bNetworkDialupPromptCredentials = false ;
// Working Variables
2004-10-28 22:51:38 +00:00
m_strBaseTitle = strTitle ;
2004-04-10 09:11:03 +00:00
2005-03-30 09:24:31 +00:00
m_aSelectedComputerMRU . Clear ( ) ;
2004-05-21 06:27:15 +00:00
2005-06-29 05:21:47 +00:00
// Initialize Application
2004-04-10 09:11:03 +00:00
SetIcon ( wxICON ( APP_ICON ) ) ;
wxCHECK_RET ( CreateMenu ( ) , _T ( " Failed to create menu bar. " ) ) ;
wxCHECK_RET ( CreateNotebook ( ) , _T ( " Failed to create notebook. " ) ) ;
wxCHECK_RET ( CreateStatusbar ( ) , _T ( " Failed to create status bar. " ) ) ;
2004-05-21 06:27:15 +00:00
2005-06-28 15:55:59 +00:00
RestoreState ( ) ;
SetStatusBarPane ( 0 ) ;
2005-06-28 22:22:29 +00:00
# ifdef __WXMSW__
2005-07-08 06:30:25 +00:00
// Prefetch and Load Wininet.dll so that any calls to
// wxDialUpManager->IsAlwaysOnline happen quicker.
m_WININET . Load ( wxT ( " WININET " ) ) ;
2005-06-24 10:49:42 +00:00
m_pDialupManager = wxDialUpManager : : Create ( ) ;
2005-06-28 15:55:59 +00:00
wxASSERT ( m_pDialupManager - > IsOk ( ) ) ;
2005-06-28 22:22:29 +00:00
# endif
2004-05-21 06:27:15 +00:00
2005-03-07 23:52:28 +00:00
m_pRefreshStateTimer = new wxTimer ( this , ID_REFRESHSTATETIMER ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pRefreshStateTimer ) ;
2005-03-07 23:52:28 +00:00
2004-10-28 22:51:38 +00:00
m_pFrameRenderTimer = new wxTimer ( this , ID_FRAMERENDERTIMER ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pFrameRenderTimer ) ;
2004-10-28 22:51:38 +00:00
2004-09-25 21:33:24 +00:00
m_pFrameListPanelRenderTimer = new wxTimer ( this , ID_FRAMELISTRENDERTIMER ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pFrameListPanelRenderTimer ) ;
2004-09-25 21:33:24 +00:00
2005-04-10 02:24:08 +00:00
m_pDocumentPollTimer = new wxTimer ( this , ID_DOCUMENTPOLLTIMER ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pDocumentPollTimer ) ;
2005-04-10 02:24:08 +00:00
2005-06-28 15:55:59 +00:00
m_pRefreshStateTimer - > Start ( 300000 ) ; // Send event every 5 minutes
2004-10-28 22:51:38 +00:00
m_pFrameRenderTimer - > Start ( 1000 ) ; // Send event every 1 second
2004-10-19 18:14:40 +00:00
m_pFrameListPanelRenderTimer - > Start ( 5000 ) ; // Send event every 5 seconds
2005-04-10 02:24:08 +00:00
m_pDocumentPollTimer - > Start ( 250 ) ; // Send event every 250 milliseconds
2004-05-21 06:27:15 +00:00
2005-03-10 04:20:36 +00:00
2005-05-24 21:46:20 +00:00
// Limit the number of times the UI can update itself to two times a second
// NOTE: Linux and Mac were updating several times a second and eating
// CPU time
wxUpdateUIEvent : : SetUpdateInterval ( 500 ) ;
2005-05-24 21:26:49 +00:00
// The second half of the initialization process picks up in the OnFrameRender()
// routine since the menus' and status bars' are drawn in the frameworks
// on idle routines, on idle events are sent in between the end of the
// constructor and the first call to OnFrameRender
//
// Look for the 'if (!bAlreadyRunOnce) {' statement
2005-04-08 04:23:37 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CMainFrame - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
}
2005-04-10 19:01:23 +00:00
CMainFrame : : ~ CMainFrame ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::~CMainFrame - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2005-04-10 19:01:23 +00:00
wxASSERT ( m_pRefreshStateTimer ) ;
wxASSERT ( m_pFrameRenderTimer ) ;
wxASSERT ( m_pFrameListPanelRenderTimer ) ;
wxASSERT ( m_pDocumentPollTimer ) ;
wxASSERT ( m_pMenubar ) ;
wxASSERT ( m_pNotebook ) ;
wxASSERT ( m_pStatusbar ) ;
2005-06-28 22:22:29 +00:00
# ifdef __WXMSW__
2005-06-24 10:49:42 +00:00
wxASSERT ( m_pDialupManager ) ;
2005-06-28 22:22:29 +00:00
# endif
2004-05-21 06:27:15 +00:00
2004-05-22 01:36:36 +00:00
SaveState ( ) ;
2005-03-10 05:07:01 +00:00
if ( m_pRefreshStateTimer ) {
m_pRefreshStateTimer - > Stop ( ) ;
delete m_pRefreshStateTimer ;
}
2004-05-22 01:36:36 +00:00
2004-10-28 22:51:38 +00:00
if ( m_pFrameRenderTimer ) {
m_pFrameRenderTimer - > Stop ( ) ;
delete m_pFrameRenderTimer ;
}
2004-09-25 21:33:24 +00:00
if ( m_pFrameListPanelRenderTimer ) {
m_pFrameListPanelRenderTimer - > Stop ( ) ;
delete m_pFrameListPanelRenderTimer ;
2004-05-21 06:27:15 +00:00
}
2004-04-10 09:11:03 +00:00
2005-04-10 02:24:08 +00:00
if ( m_pDocumentPollTimer ) {
m_pDocumentPollTimer - > Stop ( ) ;
delete m_pDocumentPollTimer ;
}
2004-04-10 09:11:03 +00:00
if ( m_pStatusbar )
wxCHECK_RET ( DeleteStatusbar ( ) , _T ( " Failed to delete status bar. " ) ) ;
2004-05-21 06:27:15 +00:00
if ( m_pNotebook )
wxCHECK_RET ( DeleteNotebook ( ) , _T ( " Failed to delete notebook. " ) ) ;
if ( m_pMenubar )
wxCHECK_RET ( DeleteMenu ( ) , _T ( " Failed to delete menu bar. " ) ) ;
2004-12-03 20:30:24 +00:00
2005-06-28 22:22:29 +00:00
# ifdef __WXMSW__
2005-06-24 10:49:42 +00:00
if ( m_pDialupManager )
delete m_pDialupManager ;
2005-06-28 22:22:29 +00:00
# endif
2005-06-24 10:49:42 +00:00
2005-04-08 22:23:53 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::~CMainFrame - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : CreateMenu ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateMenu - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2005-03-11 22:10:56 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2005-03-11 22:10:56 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2004-04-10 09:11:03 +00:00
// File menu
wxMenu * menuFile = new wxMenu ;
2004-10-24 07:38:38 +00:00
menuFile - > Append (
ID_HIDE ,
_ ( " &Hide " ) ,
_ ( " Hides the main BOINC Manager window " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-24 07:38:38 +00:00
menuFile - > AppendSeparator ( ) ;
menuFile - > AppendRadioItem (
ID_ACTIVITYRUNALWAYS ,
_ ( " &Run always " ) ,
2004-11-22 19:17:13 +00:00
_ ( " Does work regardless of preferences " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-24 07:38:38 +00:00
menuFile - > AppendRadioItem (
ID_ACTIVITYRUNBASEDONPREPERENCES ,
_ ( " Run based on &preferences " ) ,
2004-11-22 19:17:13 +00:00
_ ( " Does work according to your preferences " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-24 07:38:38 +00:00
menuFile - > AppendRadioItem (
ID_ACTIVITYSUSPEND ,
_ ( " &Suspend " ) ,
2004-11-22 19:17:13 +00:00
_ ( " Stops work regardless of preferences " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-24 07:38:38 +00:00
menuFile - > AppendSeparator ( ) ;
2005-06-29 05:54:12 +00:00
menuFile - > AppendRadioItem (
ID_NETWORKRUNALWAYS ,
_ ( " &Network activity always available " ) ,
_ ( " Does network activity regardless of preferences " )
) ;
menuFile - > AppendRadioItem (
ID_NETWORKRUNBASEDONPREPERENCES ,
_ ( " Network activity based on &preferences " ) ,
_ ( " Does network activity according to your preferences " )
) ;
menuFile - > AppendRadioItem (
2004-10-24 07:38:38 +00:00
ID_NETWORKSUSPEND ,
2005-06-29 05:54:12 +00:00
_ ( " &Network activity suspended " ) ,
2004-11-22 19:17:13 +00:00
_ ( " Stops BOINC network activity " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-24 07:38:38 +00:00
menuFile - > AppendSeparator ( ) ;
2004-10-27 23:19:50 +00:00
menuFile - > Append (
ID_RUNBENCHMARKS ,
_ ( " Run &Benchmarks " ) ,
2004-11-22 19:17:13 +00:00
_ ( " Runs BOINC CPU benchmarks " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-27 23:19:50 +00:00
menuFile - > AppendSeparator ( ) ;
2004-10-28 07:03:06 +00:00
menuFile - > Append (
ID_SELECTCOMPUTER ,
_ ( " Select Computer... " ) ,
2004-11-22 19:17:13 +00:00
_ ( " Connect to another computer running BOINC " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-28 07:03:06 +00:00
menuFile - > AppendSeparator ( ) ;
2004-10-09 03:05:01 +00:00
menuFile - > Append (
wxID_EXIT ,
_ ( " E&xit " ) ,
_ ( " Exit the BOINC Manager " )
2005-04-10 19:01:23 +00:00
) ;
2004-04-10 09:11:03 +00:00
// Tools menu
wxMenu * menuTools = new wxMenu ;
2005-06-17 04:53:35 +00:00
menuTools - > Append (
ID_TOOLSMANAGEACCOUNTS ,
_ ( " &Manage Accounts " ) ,
_ ( " Connect to an account manager website and update all of your accounts " )
) ;
2005-03-11 22:10:56 +00:00
2005-06-17 04:53:35 +00:00
menuTools - > AppendSeparator ( ) ;
2005-03-11 22:10:56 +00:00
2005-04-07 07:04:50 +00:00
menuTools - > Append (
2004-10-09 03:05:01 +00:00
ID_TOOLSOPTIONS ,
_ ( " &Options " ) ,
_ ( " Configure GUI options and proxy settings " )
2005-04-10 19:01:23 +00:00
) ;
2004-04-10 09:11:03 +00:00
// Help menu
wxMenu * menuHelp = new wxMenu ;
2005-05-05 06:07:14 +00:00
menuHelp - > Append (
ID_HELPBOINCMANAGER ,
_ ( " &BOINC Manager \t F1 " ) ,
_ ( " Show information about the BOINC Manager " )
) ;
menuHelp - > Append (
ID_HELPBOINC ,
_ ( " BOINC &Website " ) ,
_ ( " Show information about BOINC and BOINC Manager " )
) ;
menuHelp - > AppendSeparator ( ) ;
2005-04-08 16:58:55 +00:00
menuHelp - > Append (
2004-10-09 03:05:01 +00:00
wxID_ABOUT ,
2004-10-24 05:40:12 +00:00
_ ( " &About BOINC Manager... " ) ,
2005-05-05 06:07:14 +00:00
_ ( " Licensing and copyright information. " )
2005-04-10 19:01:23 +00:00
) ;
2004-04-10 09:11:03 +00:00
// construct menu
m_pMenubar = new wxMenuBar ;
2004-10-09 03:05:01 +00:00
m_pMenubar - > Append (
menuFile ,
_ ( " &File " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-09 03:05:01 +00:00
m_pMenubar - > Append (
menuTools ,
_ ( " &Tools " )
2005-04-10 19:01:23 +00:00
) ;
2004-10-09 03:05:01 +00:00
m_pMenubar - > Append (
menuHelp ,
_ ( " &Help " )
2005-04-10 19:01:23 +00:00
) ;
2004-04-10 09:11:03 +00:00
SetMenuBar ( m_pMenubar ) ;
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateMenu - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : CreateNotebook ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateNotebook - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-04-10 09:11:03 +00:00
// create frame panel
wxPanel * pPanel = new wxPanel ( this , - 1 , wxDefaultPosition , wxDefaultSize ,
wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER ) ;
2004-12-15 23:08:18 +00:00
pPanel - > SetAutoLayout ( TRUE ) ;
2004-04-10 09:11:03 +00:00
// initialize notebook
2004-10-21 14:29:59 +00:00
m_pNotebook = new wxNotebook ( pPanel , ID_FRAMENOTEBOOK , wxDefaultPosition , wxDefaultSize ,
2004-04-10 09:11:03 +00:00
wxNB_FIXEDWIDTH | wxCLIP_CHILDREN ) ;
// layout frame panel
wxBoxSizer * pPanelSizer = new wxBoxSizer ( wxVERTICAL ) ;
2004-09-21 01:30:29 +00:00
2004-04-10 09:11:03 +00:00
pPanelSizer - > Add ( new wxStaticLine ( pPanel , - 1 ) , 0 , wxEXPAND ) ;
2005-04-04 06:02:36 +00:00
pPanelSizer - > Add ( 0 , 5 ) ;
2005-04-26 04:20:35 +00:00
pPanelSizer - > Add ( m_pNotebook , 1 , wxEXPAND ) ;
2004-09-21 01:30:29 +00:00
2004-12-15 22:50:21 +00:00
// create the various notebook pages
2005-04-07 07:04:50 +00:00
CreateNotebookPage ( new CViewProjects ( m_pNotebook ) ) ;
2005-04-21 06:04:26 +00:00
CreateNotebookPage ( new CViewWork ( m_pNotebook ) ) ;
CreateNotebookPage ( new CViewTransfers ( m_pNotebook ) ) ;
CreateNotebookPage ( new CViewMessages ( m_pNotebook ) ) ;
CreateNotebookPage ( new CViewStatistics ( m_pNotebook ) ) ;
CreateNotebookPage ( new CViewResources ( m_pNotebook ) ) ;
2004-04-10 09:11:03 +00:00
2004-12-15 22:11:14 +00:00
2005-04-27 06:32:40 +00:00
pPanel - > SetSizer ( pPanelSizer ) ;
pPanel - > Layout ( ) ;
2004-12-15 22:11:14 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateNotebook - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
return true ;
}
2004-05-27 06:17:58 +00:00
template < class T >
2005-04-07 07:04:50 +00:00
bool CMainFrame : : CreateNotebookPage ( T pwndNewNotebookPage ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateNotebookPage - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-04-13 00:33:40 +00:00
wxImageList * pImageList ;
2005-04-10 19:01:23 +00:00
int iImageIndex = 0 ;
2004-04-13 00:33:40 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pwndNewNotebookPage ) ;
wxASSERT ( m_pNotebook ) ;
2004-09-21 01:30:29 +00:00
wxASSERT ( wxDynamicCast ( pwndNewNotebookPage , CBOINCBaseView ) ) ;
2004-04-10 09:11:03 +00:00
2004-04-13 00:33:40 +00:00
pImageList = m_pNotebook - > GetImageList ( ) ;
if ( ! pImageList ) {
pImageList = new wxImageList ( 16 , 16 , true , 0 ) ;
wxASSERT ( pImageList ! = NULL ) ;
2004-04-13 02:06:27 +00:00
m_pNotebook - > SetImageList ( pImageList ) ;
2004-04-13 00:33:40 +00:00
}
2004-05-27 06:17:58 +00:00
iImageIndex = pImageList - > Add ( wxBitmap ( pwndNewNotebookPage - > GetViewIcon ( ) ) , wxColour ( 255 , 0 , 255 ) ) ;
m_pNotebook - > AddPage ( pwndNewNotebookPage , pwndNewNotebookPage - > GetViewName ( ) , TRUE , iImageIndex ) ;
2004-04-10 09:11:03 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateNotebookPage - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : CreateStatusbar ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateStatusbar - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-04-10 09:11:03 +00:00
if ( m_pStatusbar )
return true ;
2005-04-07 07:04:50 +00:00
m_pStatusbar = new CStatusBar ( this ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pStatusbar ) ;
2004-05-21 06:27:15 +00:00
2004-04-10 09:11:03 +00:00
SetStatusBar ( m_pStatusbar ) ;
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::CreateStatusbar - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : DeleteMenu ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::DeleteMenu - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::DeleteMenu - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : DeleteNotebook ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::DeleteNotebook - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-04-13 00:33:40 +00:00
wxImageList * pImageList ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pNotebook ) ;
2004-04-13 02:18:03 +00:00
2004-04-13 00:33:40 +00:00
pImageList = m_pNotebook - > GetImageList ( ) ;
2004-05-21 06:27:15 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pImageList ) ;
2004-05-21 06:27:15 +00:00
2004-04-13 00:33:40 +00:00
if ( pImageList )
delete pImageList ;
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::DeleteNotebook - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : DeleteStatusbar ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::DeleteStatusbar - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-04-10 09:11:03 +00:00
if ( ! m_pStatusbar )
return true ;
2004-05-21 06:27:15 +00:00
SetStatusBar ( NULL ) ;
2004-04-10 09:11:03 +00:00
delete m_pStatusbar ;
m_pStatusbar = NULL ;
2004-10-28 22:51:38 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::DeleteStatusbar - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : SaveState ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::SaveState - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-05 02:55:26 +00:00
wxString strBaseConfigLocation = wxString ( wxT ( " / " ) ) ;
2004-05-27 06:17:58 +00:00
wxConfigBase * pConfig = wxConfigBase : : Get ( FALSE ) ;
2004-05-29 00:09:41 +00:00
wxWindow * pwndNotebookPage = NULL ;
2004-10-26 01:59:44 +00:00
CBOINCBaseView * pView = NULL ;
wxString strConfigLocation = wxEmptyString ;
wxString strPreviousLocation = wxEmptyString ;
2005-03-30 09:24:31 +00:00
wxString strBuffer = wxEmptyString ;
2005-04-08 16:58:55 +00:00
int iIndex = 0 ;
int iItemCount = 0 ;
2004-05-27 06:17:58 +00:00
2005-04-08 16:58:55 +00:00
wxASSERT ( pConfig ) ;
wxASSERT ( m_pNotebook ) ;
2004-05-27 06:17:58 +00:00
2005-06-24 10:49:42 +00:00
// An odd case happens every once and awhile where wxWidgets looses
// the pointer to the config object, or it is cleaned up before
// the window has finished it's cleanup duty. If we detect a NULL
// pointer, return false.
if ( ! pConfig ) return false ;
2004-05-27 06:17:58 +00:00
//
// Save Frame State
//
pConfig - > SetPath ( strBaseConfigLocation ) ;
2005-02-07 04:47:18 +00:00
pConfig - > Write ( wxT ( " Language " ) , m_iSelectedLanguage ) ;
2005-06-24 10:49:42 +00:00
pConfig - > Write ( wxT ( " ReminderFrequency " ) , m_iReminderFrequency ) ;
2005-02-07 04:47:18 +00:00
2005-06-29 05:21:47 +00:00
pConfig - > Write ( wxT ( " NetworkConnectionType " ) , m_iNetworkConnectionType ) ;
pConfig - > Write ( wxT ( " NetworkDialupConnectionName " ) , m_strNetworkDialupConnectionName ) ;
pConfig - > Write ( wxT ( " NetworkDialupPromptCredentials " ) , m_bNetworkDialupPromptCredentials ) ;
2004-10-05 02:55:26 +00:00
pConfig - > Write ( wxT ( " CurrentPage " ) , m_pNotebook - > GetSelection ( ) ) ;
2005-02-07 04:47:18 +00:00
pConfig - > Write ( wxT ( " WindowIconized " ) , IsIconized ( ) ) ;
2005-03-09 07:46:39 +00:00
# if defined(__WXMSW__) || defined(__WXMAC__)
2005-02-07 04:47:18 +00:00
pConfig - > Write ( wxT ( " WindowMaximized " ) , IsMaximized ( ) ) ;
2005-03-09 07:46:39 +00:00
# endif
2005-04-07 07:04:50 +00:00
if ( ! IsIconized ( ) & & ! IsMaximized ( ) ) {
2005-02-07 04:47:18 +00:00
pConfig - > Write ( wxT ( " Width " ) , GetSize ( ) . GetWidth ( ) ) ;
pConfig - > Write ( wxT ( " Height " ) , GetSize ( ) . GetHeight ( ) ) ;
2005-03-26 13:45:21 +00:00
# ifdef __WXMAC__
pConfig - > Write ( wxT ( " XPos " ) , GetPosition ( ) . x ) ;
pConfig - > Write ( wxT ( " YPos " ) , GetPosition ( ) . y ) ;
# endif
2005-02-07 04:47:18 +00:00
}
2004-05-27 06:17:58 +00:00
//
// Save Page(s) State
//
2004-05-29 00:09:41 +00:00
// Convert to a zero based index
2005-03-30 09:24:31 +00:00
iItemCount = m_pNotebook - > GetPageCount ( ) - 1 ;
2004-05-27 06:17:58 +00:00
2005-04-07 07:04:50 +00:00
for ( iIndex = 0 ; iIndex < = iItemCount ; iIndex + + ) {
2004-05-27 06:17:58 +00:00
pwndNotebookPage = m_pNotebook - > GetPage ( iIndex ) ;
2004-09-21 01:30:29 +00:00
wxASSERT ( wxDynamicCast ( pwndNotebookPage , CBOINCBaseView ) ) ;
2004-10-26 01:59:44 +00:00
pView = wxDynamicCast ( pwndNotebookPage , CBOINCBaseView ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pView ) ;
2004-05-27 06:17:58 +00:00
2004-10-26 01:59:44 +00:00
strPreviousLocation = pConfig - > GetPath ( ) ;
strConfigLocation = strPreviousLocation + pView - > GetViewName ( ) ;
2004-05-27 06:17:58 +00:00
2004-10-26 01:59:44 +00:00
pConfig - > SetPath ( strConfigLocation ) ;
2005-04-07 07:04:50 +00:00
pView - > FireOnSaveState ( pConfig ) ;
2004-10-26 01:59:44 +00:00
pConfig - > SetPath ( strPreviousLocation ) ;
}
2004-05-27 06:17:58 +00:00
2005-03-30 09:24:31 +00:00
//
// Save Computer MRU list
//
strPreviousLocation = pConfig - > GetPath ( ) ;
strConfigLocation = strPreviousLocation + wxT ( " ComputerMRU " ) ;
pConfig - > SetPath ( strConfigLocation ) ;
iItemCount = m_aSelectedComputerMRU . GetCount ( ) - 1 ;
2005-04-07 07:04:50 +00:00
for ( iIndex = 0 ; iIndex < = iItemCount ; iIndex + + ) {
2005-03-30 09:24:31 +00:00
strBuffer . Printf ( wxT ( " %d " ) , iIndex ) ;
pConfig - > Write (
strBuffer ,
m_aSelectedComputerMRU . Item ( iIndex )
2005-04-10 19:01:23 +00:00
) ;
2005-03-30 09:24:31 +00:00
}
pConfig - > SetPath ( strPreviousLocation ) ;
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::SaveState - Function End " ) ) ;
2004-05-27 06:17:58 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
bool CMainFrame : : RestoreState ( ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::RestoreState - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-05 02:55:26 +00:00
wxString strBaseConfigLocation = wxString ( wxT ( " / " ) ) ;
2004-05-27 06:17:58 +00:00
wxConfigBase * pConfig = wxConfigBase : : Get ( FALSE ) ;
2004-05-29 00:09:41 +00:00
wxWindow * pwndNotebookPage = NULL ;
2004-10-26 01:59:44 +00:00
CBOINCBaseView * pView = NULL ;
wxString strConfigLocation = wxEmptyString ;
wxString strPreviousLocation = wxEmptyString ;
2005-03-30 09:24:31 +00:00
wxString strBuffer = wxEmptyString ;
wxString strValue = wxEmptyString ;
long iIndex = 0 ;
long iPageCount = 0 ;
bool bKeepEnumerating = false ;
2005-02-07 04:47:18 +00:00
bool bWindowIconized = false ;
2005-03-09 07:46:39 +00:00
# if defined(__WXMSW__) || defined(__WXMAC__)
2005-02-07 04:47:18 +00:00
bool bWindowMaximized = false ;
2005-03-09 07:46:39 +00:00
# endif
2005-03-26 13:45:21 +00:00
# ifdef __WXMAC__
2005-03-30 09:24:31 +00:00
long iTop = 0 ;
long iLeft = 0 ;
2005-03-26 13:45:21 +00:00
# endif
2005-03-30 09:24:31 +00:00
long iHeight = 0 ;
long iWidth = 0 ;
2004-05-27 06:17:58 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pConfig ) ;
wxASSERT ( m_pNotebook ) ;
2004-05-27 06:17:58 +00:00
2005-06-24 10:49:42 +00:00
// An odd case happens every once and awhile where wxWidgets looses
// the pointer to the config object, or it is cleaned up before
// the window has finished it's cleanup duty. If we detect a NULL
// pointer, return false.
if ( ! pConfig ) return false ;
2004-05-27 06:17:58 +00:00
//
// Restore Frame State
//
2005-04-10 19:01:23 +00:00
int iCurrentPage ;
2004-05-27 06:17:58 +00:00
pConfig - > SetPath ( strBaseConfigLocation ) ;
2005-02-07 04:47:18 +00:00
pConfig - > Read ( wxT ( " Language " ) , & m_iSelectedLanguage , 0L ) ;
2005-06-24 10:49:42 +00:00
pConfig - > Read ( wxT ( " ReminderFrequency " ) , & m_iReminderFrequency , 60L ) ;
2005-02-07 04:47:18 +00:00
2005-06-29 05:21:47 +00:00
pConfig - > Read ( wxT ( " NetworkConnectionType " ) , & m_iNetworkConnectionType , ID_NETWORKAUTODETECT ) ;
pConfig - > Read ( wxT ( " NetworkDialupConnectionName " ) , & m_strNetworkDialupConnectionName , wxEmptyString ) ;
pConfig - > Read ( wxT ( " NetworkDialupPromptCredentials " ) , & m_bNetworkDialupPromptCredentials , false ) ;
2005-02-07 04:47:18 +00:00
2004-10-05 02:55:26 +00:00
pConfig - > Read ( wxT ( " CurrentPage " ) , & iCurrentPage , 1 ) ;
2005-04-21 19:10:10 +00:00
m_pNotebook - > SetSelection ( iCurrentPage ) ;
2004-05-27 06:17:58 +00:00
2005-02-07 04:47:18 +00:00
pConfig - > Read ( wxT ( " WindowIconized " ) , & bWindowIconized , false ) ;
2005-03-09 07:46:39 +00:00
# if defined(__WXMSW__) || defined(__WXMAC__)
2005-02-07 04:47:18 +00:00
pConfig - > Read ( wxT ( " WindowMaximized " ) , & bWindowMaximized , false ) ;
2005-03-09 07:46:39 +00:00
# endif
2004-10-26 18:49:50 +00:00
pConfig - > Read ( wxT ( " Width " ) , & iWidth , 800 ) ;
pConfig - > Read ( wxT ( " Height " ) , & iHeight , 600 ) ;
2005-02-07 04:47:18 +00:00
2005-03-26 13:45:21 +00:00
# ifdef __WXMAC__
pConfig - > Read ( wxT ( " YPos " ) , & iTop , 30 ) ;
pConfig - > Read ( wxT ( " XPos " ) , & iLeft , 30 ) ;
2005-03-30 09:56:55 +00:00
// If the user has changed the arrangement of multiple
// displays, make sure the window title bar is still on-screen.
Rect titleRect = { iTop , iLeft , iTop + 22 , iLeft + iWidth } ;
InsetRect ( & titleRect , 5 , 5 ) ; // Make sure at least a 5X5 piece visible
RgnHandle displayRgn = NewRgn ( ) ;
CopyRgn ( GetGrayRgn ( ) , displayRgn ) ; // Region encompassing all displays
Rect menuRect = ( ( * * GetMainDevice ( ) ) ) . gdRect ;
menuRect . bottom = GetMBarHeight ( ) + menuRect . top ;
RgnHandle menuRgn = NewRgn ( ) ;
RectRgn ( menuRgn , & menuRect ) ; // Region hidden by menu bar
DiffRgn ( displayRgn , menuRgn , displayRgn ) ; // Subtract menu bar retion
if ( ! RectInRgn ( & titleRect , displayRgn ) )
iTop = iLeft = 30 ;
DisposeRgn ( menuRgn ) ;
DisposeRgn ( displayRgn ) ;
2005-05-07 12:37:01 +00:00
SetSize ( iLeft , iTop , iWidth , iHeight ) ;
# else // ! __WXMAC__
SetSize ( - 1 , - 1 , iWidth , iHeight ) ;
Iconize ( bWindowIconized ) ;
# endif
# ifdef __WXMSW__
Maximize ( bWindowMaximized ) ;
2005-03-26 13:45:21 +00:00
# endif
2004-05-27 06:17:58 +00:00
//
// Restore Page(s) State
//
2004-05-29 00:09:41 +00:00
// Convert to a zero based index
2004-05-27 06:17:58 +00:00
iPageCount = m_pNotebook - > GetPageCount ( ) - 1 ;
2005-04-07 07:04:50 +00:00
for ( iIndex = 0 ; iIndex < = iPageCount ; iIndex + + ) {
2004-05-27 06:17:58 +00:00
pwndNotebookPage = m_pNotebook - > GetPage ( iIndex ) ;
2004-09-21 01:30:29 +00:00
wxASSERT ( wxDynamicCast ( pwndNotebookPage , CBOINCBaseView ) ) ;
2004-10-26 01:59:44 +00:00
pView = wxDynamicCast ( pwndNotebookPage , CBOINCBaseView ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pView ) ;
2004-05-27 06:17:58 +00:00
2004-10-26 01:59:44 +00:00
strPreviousLocation = pConfig - > GetPath ( ) ;
strConfigLocation = strPreviousLocation + pView - > GetViewName ( ) ;
2004-05-21 06:27:15 +00:00
2004-10-26 01:59:44 +00:00
pConfig - > SetPath ( strConfigLocation ) ;
2005-04-07 07:04:50 +00:00
pView - > FireOnRestoreState ( pConfig ) ;
2004-10-26 01:59:44 +00:00
pConfig - > SetPath ( strPreviousLocation ) ;
2004-05-21 06:27:15 +00:00
2004-10-26 01:59:44 +00:00
}
2004-05-27 06:17:58 +00:00
2005-03-30 09:24:31 +00:00
//
// Restore Computer MRU list
//
strPreviousLocation = pConfig - > GetPath ( ) ;
strConfigLocation = strPreviousLocation + wxT ( " ComputerMRU " ) ;
pConfig - > SetPath ( strConfigLocation ) ;
m_aSelectedComputerMRU . Clear ( ) ;
bKeepEnumerating = pConfig - > GetFirstEntry ( strBuffer , iIndex ) ;
2005-04-07 07:04:50 +00:00
while ( bKeepEnumerating ) {
2005-03-30 09:24:31 +00:00
pConfig - > Read ( strBuffer , & strValue ) ;
m_aSelectedComputerMRU . Add ( strValue ) ;
bKeepEnumerating = pConfig - > GetNextEntry ( strBuffer , iIndex ) ;
}
pConfig - > SetPath ( strPreviousLocation ) ;
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::RestoreState - Function End " ) ) ;
2004-05-27 06:17:58 +00:00
return true ;
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnHide ( wxCommandEvent & WXUNUSED ( event ) ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHide - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-24 07:38:38 +00:00
Hide ( ) ;
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHide - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnActivitySelection ( wxCommandEvent & event ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnActivitySelection - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-24 07:38:38 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2004-10-24 07:38:38 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-07 07:04:50 +00:00
switch ( event . GetId ( ) ) {
case ID_ACTIVITYRUNALWAYS :
2005-05-29 07:12:00 +00:00
pDoc - > SetActivityRunMode ( RUN_MODE_ALWAYS ) ;
2005-04-07 07:04:50 +00:00
break ;
case ID_ACTIVITYSUSPEND :
2005-05-29 07:12:00 +00:00
pDoc - > SetActivityRunMode ( RUN_MODE_NEVER ) ;
2005-04-07 07:04:50 +00:00
break ;
case ID_ACTIVITYRUNBASEDONPREPERENCES :
2005-05-29 07:12:00 +00:00
pDoc - > SetActivityRunMode ( RUN_MODE_AUTO ) ;
2005-04-07 07:04:50 +00:00
break ;
2004-10-24 07:38:38 +00:00
}
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnActivitySelection - Function End " ) ) ;
2004-10-24 07:38:38 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnNetworkSelection ( wxCommandEvent & event ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnNetworkSelection - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-24 07:38:38 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2004-10-24 07:38:38 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-07 07:04:50 +00:00
switch ( event . GetId ( ) ) {
2005-06-29 05:54:12 +00:00
case ID_NETWORKRUNALWAYS :
pDoc - > SetNetworkRunMode ( RUN_MODE_ALWAYS ) ;
break ;
case ID_NETWORKSUSPEND :
pDoc - > SetNetworkRunMode ( RUN_MODE_NEVER ) ;
break ;
case ID_NETWORKRUNBASEDONPREPERENCES :
pDoc - > SetNetworkRunMode ( RUN_MODE_AUTO ) ;
break ;
2004-10-23 23:40:11 +00:00
}
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnNetworkSelection - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
}
2004-10-24 07:38:38 +00:00
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnRunBenchmarks ( wxCommandEvent & WXUNUSED ( event ) ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnRunBenchmarks - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-27 23:19:50 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pNotebook ) ;
wxASSERT ( pDoc ) ;
2004-10-27 23:19:50 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-07 07:04:50 +00:00
m_pNotebook - > SetSelection ( ID_LIST_MESSAGESVIEW - ID_LIST_BASE ) ;
2004-10-27 23:19:50 +00:00
pDoc - > RunBenchmarks ( ) ;
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnRunBenchmarks - Function End " ) ) ;
2004-10-27 23:19:50 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnSelectComputer ( wxCommandEvent & WXUNUSED ( event ) ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnSelectComputer - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2005-03-30 09:24:31 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
CDlgSelectComputer * pDlg = new CDlgSelectComputer ( this ) ;
long lAnswer = 0 ;
2005-04-04 18:55:42 +00:00
size_t lIndex = 0 ;
2005-03-30 09:24:31 +00:00
long lRetVal = - 1 ;
wxArrayString aComputerNames ;
2004-10-28 07:03:06 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2004-10-28 07:03:06 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pDlg ) ;
2004-10-28 07:03:06 +00:00
2005-03-30 09:24:31 +00:00
// Lets copy the template store in the system state
aComputerNames = m_aSelectedComputerMRU ;
// Lets populate the combo control with the MRU list
pDlg - > m_ComputerNameCtrl - > Clear ( ) ;
2005-04-07 07:04:50 +00:00
for ( lIndex = 0 ; lIndex < aComputerNames . Count ( ) ; lIndex + + ) {
pDlg - > m_ComputerNameCtrl - > Append ( aComputerNames . Item ( lIndex ) ) ;
2005-03-30 09:24:31 +00:00
}
lAnswer = pDlg - > ShowModal ( ) ;
2005-04-07 07:04:50 +00:00
if ( wxID_OK = = lAnswer ) {
2005-04-08 17:59:52 +00:00
lRetVal = pDoc - > Connect (
pDlg - > m_ComputerNameCtrl - > GetValue ( ) ,
pDlg - > m_ComputerPasswordCtrl - > GetValue ( ) ,
TRUE
) ;
2005-04-10 18:36:12 +00:00
if ( lRetVal ) {
2005-06-24 10:49:42 +00:00
ShowAlert (
2005-04-10 18:36:12 +00:00
_ ( " Connection failed. " ) ,
_ ( " Connection failed. " ) ,
2005-03-30 09:24:31 +00:00
wxICON_ERROR
2005-04-08 16:58:55 +00:00
) ;
2005-03-31 23:54:12 +00:00
}
2005-03-30 09:24:31 +00:00
// Insert a copy of the current combo box value to the head of the
// computer names string array
2005-04-07 07:04:50 +00:00
aComputerNames . Insert ( pDlg - > m_ComputerNameCtrl - > GetValue ( ) , 0 ) ;
2005-03-30 09:24:31 +00:00
// Loops through the computer names and remove any duplicates that
// might exist with the new head value
2005-04-07 07:04:50 +00:00
for ( lIndex = 1 ; lIndex < aComputerNames . Count ( ) ; lIndex + + ) {
if ( aComputerNames . Item ( lIndex ) = = aComputerNames . Item ( 0 ) )
2005-04-26 04:20:35 +00:00
aComputerNames . RemoveAt ( lIndex ) ;
2005-03-30 09:24:31 +00:00
}
// Store the modified computer name MRU list back to the system state
m_aSelectedComputerMRU = aComputerNames ;
}
if ( pDlg )
pDlg - > Destroy ( ) ;
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnSelectComputer - Function End " ) ) ;
2004-10-28 07:03:06 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnExit ( wxCommandEvent & WXUNUSED ( event ) ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnExit - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-24 07:38:38 +00:00
Close ( true ) ;
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnExit - Function End " ) ) ;
2004-10-24 07:38:38 +00:00
}
2004-04-10 09:11:03 +00:00
2005-06-17 04:53:35 +00:00
void CMainFrame : : OnToolsManageAccounts ( wxCommandEvent & WXUNUSED ( event ) )
2005-03-11 22:10:56 +00:00
{
2005-06-17 04:53:35 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnToolsManageAccounts - Function Begin " ) ) ;
2005-03-11 22:10:56 +00:00
2005-06-20 01:45:13 +00:00
int iAnswer = 0 ;
wxString strTitle = wxEmptyString ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-06-17 04:53:35 +00:00
CDlgAccountManagerSignup * pDlgSignup = new CDlgAccountManagerSignup ( this ) ;
CDlgAccountManagerStatus * pDlgStatus = new CDlgAccountManagerStatus ( this ) ;
2005-03-11 22:10:56 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2005-03-11 22:10:56 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-06-17 04:53:35 +00:00
wxASSERT ( pDlgSignup ) ;
wxASSERT ( pDlgStatus ) ;
2005-03-11 22:10:56 +00:00
2005-06-21 08:22:18 +00:00
ACCT_MGR_INFO ami ;
pDoc - > rpc . acct_mgr_info ( ami ) ;
if ( ami . acct_mgr_url . size ( ) ) {
2005-06-20 01:45:13 +00:00
strTitle = pDlgSignup - > GetTitle ( ) ;
2005-06-28 23:56:56 +00:00
strTitle + = wxT ( " - " ) + wxString ( ami . acct_mgr_name . c_str ( ) ) ;
char buf [ 256 ] ;
sprintf ( buf , " Name: %s " , ami . acct_mgr_name . c_str ( ) ) ;
pDlgStatus - > SetAcctManagerName ( wxT ( buf ) ) ;
sprintf ( buf , " URL: %s " , ami . acct_mgr_url . c_str ( ) ) ;
pDlgStatus - > SetAcctManagerURL ( wxT ( buf ) ) ;
2005-06-20 01:45:13 +00:00
pDlgStatus - > SetTitle ( strTitle ) ;
2005-06-17 04:53:35 +00:00
iAnswer = pDlgStatus - > ShowModal ( ) ;
} else {
2005-06-21 08:22:18 +00:00
if ( ami . login_name . empty ( ) ) {
2005-06-20 01:45:13 +00:00
iAnswer = ID_CHANGE ;
2005-03-11 22:10:56 +00:00
}
}
2005-06-20 01:45:13 +00:00
if ( ID_CHANGE = = iAnswer ) {
strTitle = pDlgSignup - > GetTitle ( ) ;
2005-06-21 08:22:18 +00:00
if ( ! ami . acct_mgr_name . empty ( ) ) {
strTitle + = wxT ( " - " ) + wxString ( ami . acct_mgr_name . c_str ( ) ) ;
} else if ( ! ami . acct_mgr_url . empty ( ) ) {
strTitle + = wxT ( " - " ) + wxString ( ami . acct_mgr_url . c_str ( ) ) ;
2005-06-20 01:45:13 +00:00
}
pDlgSignup - > SetTitle ( strTitle ) ;
2005-06-21 08:22:18 +00:00
pDlgSignup - > m_strAcctManagerURL = ami . acct_mgr_url . c_str ( ) ;
pDlgSignup - > m_strAcctManagerUsername = ami . login_name . c_str ( ) ;
pDlgSignup - > m_strAcctManagerPassword = ami . password . c_str ( ) ;
2005-06-20 01:45:13 +00:00
iAnswer = pDlgSignup - > ShowModal ( ) ;
if ( wxID_OK = = iAnswer ) {
2005-06-21 08:22:18 +00:00
ami . acct_mgr_url = pDlgSignup - > m_strAcctManagerURL ;
ami . login_name = pDlgSignup - > m_strAcctManagerUsername . c_str ( ) ;
ami . password = pDlgSignup - > m_strAcctManagerPassword . c_str ( ) ;
2005-06-20 01:45:13 +00:00
}
}
if ( wxID_CANCEL ! = iAnswer ) {
2005-06-21 08:22:18 +00:00
pDoc - > rpc . acct_mgr_rpc (
ami . acct_mgr_url . c_str ( ) ,
ami . login_name . c_str ( ) ,
ami . password . c_str ( )
) ;
2005-06-20 01:45:13 +00:00
}
2005-03-11 22:10:56 +00:00
2005-06-17 04:53:35 +00:00
if ( pDlgSignup )
pDlgSignup - > Destroy ( ) ;
if ( pDlgStatus )
pDlgStatus - > Destroy ( ) ;
2005-03-11 22:10:56 +00:00
2005-06-17 04:53:35 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnToolsManageAccounts - Function End " ) ) ;
2005-03-11 22:10:56 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnToolsOptions ( wxCommandEvent & WXUNUSED ( event ) ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnToolsOptions - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-10-25 00:56:16 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
CDlgOptions * pDlg = new CDlgOptions ( this ) ;
2005-06-24 10:49:42 +00:00
int iAnswer = 0 ;
int iBuffer = 0 ;
2004-10-27 03:17:40 +00:00
wxString strBuffer = wxEmptyString ;
2005-06-28 15:55:59 +00:00
wxArrayString astrDialupConnections ;
2005-06-29 05:21:47 +00:00
bool bRetrievedProxyConfiguration = false ;
2004-10-25 00:56:16 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2004-10-25 00:56:16 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pDlg ) ;
2005-06-28 22:22:29 +00:00
# ifdef __WXMSW__
2005-06-28 15:55:59 +00:00
wxASSERT ( m_pDialupManager ) ;
2005-06-28 22:22:29 +00:00
# endif
2004-04-11 04:12:44 +00:00
2005-06-28 15:55:59 +00:00
// General Tab
pDlg - > m_LanguageSelectionCtrl - > Append ( wxGetApp ( ) . GetSupportedLanguages ( ) ) ;
2005-06-29 05:21:47 +00:00
2005-06-28 15:55:59 +00:00
pDlg - > m_LanguageSelectionCtrl - > SetSelection ( m_iSelectedLanguage ) ;
2005-06-29 05:21:47 +00:00
pDlg - > m_ReminderFrequencyCtrl - > SetValue ( m_iReminderFrequency ) ;
2005-06-28 15:55:59 +00:00
# ifdef __WXMSW__
// Connection Tab
m_pDialupManager - > GetISPNames ( astrDialupConnections ) ;
2005-06-29 05:21:47 +00:00
2005-06-28 15:55:59 +00:00
pDlg - > m_DialupConnectionsCtrl - > Append ( astrDialupConnections ) ;
2005-06-29 05:21:47 +00:00
pDlg - > SetDefaultConnectionType ( m_iNetworkConnectionType ) ;
pDlg - > SetDefaultDialupConnection ( m_strNetworkDialupConnectionName ) ;
pDlg - > SetDefaultDialupPromptCredentials ( m_bNetworkDialupPromptCredentials ) ;
2005-06-28 15:55:59 +00:00
# endif
// Proxy Tabs
2005-06-29 05:21:47 +00:00
bRetrievedProxyConfiguration = ( 0 = = pDoc - > GetProxyConfiguration ( ) ) ;
if ( ! bRetrievedProxyConfiguration ) {
// We were unable to get the proxy configuration, so disable
// the controls
pDlg - > m_EnableHTTPProxyCtrl - > Enable ( false ) ;
pDlg - > m_EnableSOCKSProxyCtrl - > Enable ( false ) ;
} else {
pDlg - > m_EnableHTTPProxyCtrl - > Enable ( true ) ;
pDlg - > m_EnableSOCKSProxyCtrl - > Enable ( true ) ;
}
2005-06-28 22:22:29 +00:00
pDlg - > m_EnableHTTPProxyCtrl - > SetValue ( pDoc - > proxy_info . use_http_proxy ) ;
pDlg - > m_HTTPAddressCtrl - > SetValue ( pDoc - > proxy_info . http_server_name . c_str ( ) ) ;
pDlg - > m_HTTPUsernameCtrl - > SetValue ( pDoc - > proxy_info . http_user_name . c_str ( ) ) ;
pDlg - > m_HTTPPasswordCtrl - > SetValue ( pDoc - > proxy_info . http_user_passwd . c_str ( ) ) ;
strBuffer . Printf ( wxT ( " %d " ) , pDoc - > proxy_info . http_server_port ) ;
pDlg - > m_HTTPPortCtrl - > SetValue ( strBuffer ) ;
pDlg - > m_EnableSOCKSProxyCtrl - > SetValue ( pDoc - > proxy_info . use_socks_proxy ) ;
pDlg - > m_SOCKSAddressCtrl - > SetValue ( pDoc - > proxy_info . socks_server_name . c_str ( ) ) ;
pDlg - > m_SOCKSUsernameCtrl - > SetValue ( pDoc - > proxy_info . socks5_user_name . c_str ( ) ) ;
pDlg - > m_SOCKSPasswordCtrl - > SetValue ( pDoc - > proxy_info . socks5_user_passwd . c_str ( ) ) ;
strBuffer . Printf ( wxT ( " %d " ) , pDoc - > proxy_info . socks_server_port ) ;
pDlg - > m_SOCKSPortCtrl - > SetValue ( strBuffer ) ;
2004-10-26 01:59:44 +00:00
2004-10-25 00:56:16 +00:00
iAnswer = pDlg - > ShowModal ( ) ;
2005-04-07 07:04:50 +00:00
if ( wxID_OK = = iAnswer ) {
2005-06-28 22:22:29 +00:00
// General Tab
if ( m_iSelectedLanguage ! = pDlg - > m_LanguageSelectionCtrl - > GetSelection ( ) ) {
ShowAlert (
_ ( " The BOINC Managers default language has been changed, in order for this change to take affect you must restart the manager. " ) ,
_ ( " Language Selection... " ) ,
wxICON_INFORMATION
) ;
}
m_iSelectedLanguage = pDlg - > m_LanguageSelectionCtrl - > GetSelection ( ) ;
2005-06-29 05:21:47 +00:00
m_iReminderFrequency = pDlg - > m_ReminderFrequencyCtrl - > GetValue ( ) ;
2005-06-28 22:22:29 +00:00
2005-06-29 05:21:47 +00:00
# ifdef __WXMSW__
// Connection Tab
m_iNetworkConnectionType = pDlg - > GetDefaultConnectionType ( ) ;
m_strNetworkDialupConnectionName = pDlg - > GetDefaultDialupConnection ( ) ;
m_bNetworkDialupPromptCredentials = pDlg - > GetDefaultDialupPromptCredentials ( ) ;
# endif
2005-06-28 22:22:29 +00:00
// Proxy Tabs
2005-06-29 05:21:47 +00:00
if ( bRetrievedProxyConfiguration ) {
pDoc - > proxy_info . use_http_proxy = pDlg - > m_EnableHTTPProxyCtrl - > GetValue ( ) ;
pDoc - > proxy_info . http_server_name = pDlg - > m_HTTPAddressCtrl - > GetValue ( ) . c_str ( ) ;
pDoc - > proxy_info . http_user_name = pDlg - > m_HTTPUsernameCtrl - > GetValue ( ) . c_str ( ) ;
pDoc - > proxy_info . http_user_passwd = pDlg - > m_HTTPPasswordCtrl - > GetValue ( ) . c_str ( ) ;
strBuffer = pDlg - > m_HTTPPortCtrl - > GetValue ( ) ;
strBuffer . ToLong ( ( long * ) & iBuffer ) ;
pDoc - > proxy_info . http_server_port = iBuffer ;
pDoc - > proxy_info . use_socks_proxy = pDlg - > m_EnableSOCKSProxyCtrl - > GetValue ( ) ;
pDoc - > proxy_info . socks_server_name = pDlg - > m_SOCKSAddressCtrl - > GetValue ( ) . c_str ( ) ;
pDoc - > proxy_info . socks5_user_name = pDlg - > m_SOCKSUsernameCtrl - > GetValue ( ) . c_str ( ) ;
pDoc - > proxy_info . socks5_user_passwd = pDlg - > m_SOCKSPasswordCtrl - > GetValue ( ) . c_str ( ) ;
strBuffer = pDlg - > m_SOCKSPortCtrl - > GetValue ( ) ;
strBuffer . ToLong ( ( long * ) & iBuffer ) ;
pDoc - > proxy_info . socks_server_port = iBuffer ;
pDoc - > SetProxyConfiguration ( ) ;
}
2004-10-25 00:56:16 +00:00
}
2004-04-11 04:12:44 +00:00
if ( pDlg )
2004-05-29 00:09:41 +00:00
pDlg - > Destroy ( ) ;
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnToolsOptions - Function End " ) ) ;
2004-04-11 04:12:44 +00:00
}
2005-06-21 17:21:16 +00:00
void CMainFrame : : OnHelp ( wxHelpEvent & event ) {
2005-05-05 06:07:14 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpBOINCManager - Function Begin " ) ) ;
if ( IsShown ( ) ) {
if ( ID_FRAME = = event . GetId ( ) ) {
ExecuteBrowserLink ( wxT ( " http://boinc.berkeley.edu/manager.php " ) ) ;
} else {
event . Skip ( ) ;
}
}
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpBOINCManager - Function End " ) ) ;
}
2005-06-17 04:53:35 +00:00
void CMainFrame : : OnHelpBOINCManager ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpBOINCManager - Function Begin " ) ) ;
if ( IsShown ( ) ) {
ExecuteBrowserLink ( wxT ( " http://boinc.berkeley.edu/manager.php " ) ) ;
}
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpBOINCManager - Function End " ) ) ;
}
2005-05-05 06:07:14 +00:00
void CMainFrame : : OnHelpBOINCWebsite ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpBOINCWebsite - Function Begin " ) ) ;
if ( IsShown ( ) ) {
ExecuteBrowserLink ( wxT ( " http://boinc.berkeley.edu " ) ) ;
}
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpBOINCWebsite - Function End " ) ) ;
}
void CMainFrame : : OnHelpAbout ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpAbout - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2004-05-21 06:27:15 +00:00
CDlgAbout * pDlg = new CDlgAbout ( this ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pDlg ) ;
2004-05-21 06:27:15 +00:00
pDlg - > ShowModal ( ) ;
if ( pDlg )
2004-05-29 00:09:41 +00:00
pDlg - > Destroy ( ) ;
2004-12-03 20:30:24 +00:00
2005-05-05 06:07:14 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnHelpAbout - Function End " ) ) ;
2004-04-10 09:11:03 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnClose ( wxCloseEvent & event ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnClose - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2005-03-30 09:56:55 +00:00
# if defined(__WXMSW__) || defined(__WXMAC__)
2005-04-07 07:04:50 +00:00
if ( ! event . CanVeto ( ) )
2004-10-24 07:38:38 +00:00
Destroy ( ) ;
else
Hide ( ) ;
2005-02-21 17:36:19 +00:00
# else
event . Skip ( ) ;
# endif
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnClose - Function End " ) ) ;
2004-10-24 07:38:38 +00:00
}
2005-06-17 04:53:35 +00:00
void CMainFrame : : OnAlert ( CMainFrameAlertEvent & event ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnAlert - Function Begin " ) ) ;
2005-06-24 10:49:42 +00:00
# ifdef __WXMSW__
2005-07-07 22:26:49 +00:00
if ( IsShown ( ) & & ! event . m_notification_only ) {
: : wxMessageBox ( event . m_message , event . m_title , event . m_style , this ) ;
2005-06-24 10:49:42 +00:00
} else {
// If the main window is hidden or minimzed use the system tray ballon
// to notify the user instead. This keeps dialogs from interfering
// with people typing email messages or any other activity where they
// do not want keyboard focus changed to another window while typing.
CTaskBarIcon * taskbar = wxGetApp ( ) . GetTaskBarIcon ( ) ;
unsigned int icon_type ;
wxASSERT ( taskbar ) ;
2005-07-07 22:26:49 +00:00
if ( wxICON_ERROR & event . m_style ) {
2005-06-24 10:49:42 +00:00
icon_type = NIIF_ERROR ;
2005-07-07 22:26:49 +00:00
} else if ( wxICON_WARNING & event . m_style ) {
2005-06-24 10:49:42 +00:00
icon_type = NIIF_WARNING ;
2005-07-07 22:26:49 +00:00
} else if ( wxICON_INFORMATION & event . m_style ) {
2005-06-24 10:49:42 +00:00
icon_type = NIIF_INFO ;
} else {
icon_type = NIIF_NONE ;
}
taskbar - > SetBalloon (
taskbar - > m_iconTaskBarIcon ,
2005-07-07 22:26:49 +00:00
event . m_title ,
event . m_message ,
2005-06-24 10:49:42 +00:00
5000 ,
icon_type
) ;
}
# else
2005-07-07 22:26:49 +00:00
: : wxMessageBox ( event . m_message , event . m_title , event . m_style , this ) ;
2005-06-24 10:49:42 +00:00
# endif
2005-06-17 04:53:35 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnAlert - Function End " ) ) ;
}
2005-04-08 16:58:55 +00:00
void CMainFrame : : OnConnect ( CMainFrameEvent & ) {
2005-04-08 04:23:37 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnConnect - Function Begin " ) ) ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
CDlgAttachProject * pDlg = new CDlgAttachProject ( this ) ;
2005-04-10 19:01:23 +00:00
int iAnswer = 0 ;
2005-04-08 04:23:37 +00:00
long lProjectCount = 0 ;
2004-12-03 20:30:24 +00:00
2005-04-08 16:58:55 +00:00
wxASSERT ( m_pNotebook ) ;
wxASSERT ( pDoc ) ;
2005-04-08 04:23:37 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-08 16:58:55 +00:00
wxASSERT ( pDlg ) ;
2004-09-25 21:33:24 +00:00
2005-04-08 04:23:37 +00:00
// Only present the attach to project dialog if no projects are currently
// detected.
lProjectCount = pDoc - > GetProjectCount ( ) ;
if ( 0 = = lProjectCount ) {
2004-10-21 14:29:59 +00:00
2005-04-08 04:23:37 +00:00
iAnswer = pDlg - > ShowModal ( ) ;
if ( wxID_OK = = iAnswer ) {
pDoc - > ProjectAttach (
pDlg - > GetProjectAddress ( ) ,
pDlg - > GetProjectAccountKey ( )
) ;
}
2004-10-26 01:59:44 +00:00
2005-04-08 04:23:37 +00:00
m_pNotebook - > SetSelection ( ID_LIST_MESSAGESVIEW - ID_LIST_BASE ) ;
2004-09-25 21:33:24 +00:00
}
2004-10-21 14:29:59 +00:00
2004-12-03 20:30:24 +00:00
2005-04-08 16:58:55 +00:00
if ( pDlg ) {
2005-04-08 04:23:37 +00:00
pDlg - > Destroy ( ) ;
2005-04-08 16:58:55 +00:00
}
2005-04-08 04:23:37 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnConnect - Function End " ) ) ;
}
2005-04-08 16:58:55 +00:00
void CMainFrame : : OnInitialized ( CMainFrameEvent & ) {
2005-04-15 20:49:23 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnInitialized - Function Begin " ) ) ;
2005-04-08 04:23:37 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-04-08 16:58:55 +00:00
wxASSERT ( pDoc ) ;
2005-04-08 04:23:37 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-05-24 21:26:49 +00:00
if ( ! pDoc - > IsConnected ( ) ) {
2005-04-10 02:24:08 +00:00
pDoc - > Connect ( wxEmptyString , wxEmptyString , TRUE ) ;
2005-05-24 21:26:49 +00:00
}
2005-04-08 04:23:37 +00:00
2005-04-15 20:49:23 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnInitialized - Function End " ) ) ;
2005-04-08 04:23:37 +00:00
}
2005-04-08 16:58:55 +00:00
void CMainFrame : : OnRefreshView ( CMainFrameEvent & ) {
2005-04-08 04:23:37 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnRefreshView - Function Begin " ) ) ;
static bool bAlreadyRunningLoop = false ;
if ( ! bAlreadyRunningLoop ) {
bAlreadyRunningLoop = true ;
if ( IsShown ( ) ) {
wxWindow * pwndNotebookPage = NULL ;
CBOINCBaseView * pView = NULL ;
wxTimerEvent timerEvent ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pNotebook ) ;
2005-04-08 04:23:37 +00:00
pwndNotebookPage = m_pNotebook - > GetPage ( m_pNotebook - > GetSelection ( ) ) ;
2005-04-08 16:58:55 +00:00
wxASSERT ( pwndNotebookPage ) ;
2005-04-08 04:23:37 +00:00
pView = wxDynamicCast ( pwndNotebookPage , CBOINCBaseView ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pView ) ;
2005-04-08 04:23:37 +00:00
2005-04-08 16:58:55 +00:00
pView - > FireOnListRender ( timerEvent ) ;
2005-04-08 04:23:37 +00:00
}
bAlreadyRunningLoop = false ;
}
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnRefreshView - Function End " ) ) ;
2004-09-25 21:33:24 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnRefreshState ( wxTimerEvent & event ) {
2005-03-07 23:52:28 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnRefreshState - Function Begin " ) ) ;
2005-03-12 01:09:24 +00:00
static bool bAlreadyRunningLoop = false ;
2005-03-07 23:52:28 +00:00
2005-04-07 07:04:50 +00:00
if ( ! bAlreadyRunningLoop ) {
2005-03-12 01:09:24 +00:00
bAlreadyRunningLoop = true ;
2005-03-31 23:54:12 +00:00
// Write a snapshot of the current state to the config
// module, on Win9x systems we don't always shutdown
// in a nice way, if we are terminated by the user
// we still want the UI state to have been stored
// for their next use
SaveState ( ) ;
2005-03-12 01:09:24 +00:00
bAlreadyRunningLoop = false ;
2005-03-07 23:52:28 +00:00
}
event . Skip ( ) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnRefreshState - Function End " ) ) ;
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnFrameRender ( wxTimerEvent & event ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnFrameRender - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2005-06-24 10:49:42 +00:00
static bool bAlreadyRunningLoop = false ;
static bool bAlreadyRunOnce = false ;
static wxString strCachedStatusText = wxEmptyString ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-03-07 23:52:28 +00:00
2005-04-07 07:04:50 +00:00
if ( ! bAlreadyRunningLoop ) {
2005-03-12 01:09:24 +00:00
bAlreadyRunningLoop = true ;
wxGetApp ( ) . UpdateSystemIdleDetection ( ) ;
2005-05-24 21:26:49 +00:00
if ( ! bAlreadyRunOnce ) {
// Complete any remaining initialization that has to happen after we are up
// and running
FireInitialize ( ) ;
bAlreadyRunOnce = true ;
}
2005-06-24 10:49:42 +00:00
# ifdef __WXMSW__
2005-07-08 06:30:25 +00:00
static wxDateTime dtLastDialupIsAlreadyOnlineCheck = wxDateTime ( ( time_t ) 0 ) ;
2005-06-24 10:49:42 +00:00
static wxDateTime dtLastDialupAlertSent = wxDateTime ( ( time_t ) 0 ) ;
static wxDateTime dtLastDialupRequest = wxDateTime ( ( time_t ) 0 ) ;
2005-07-01 06:30:06 +00:00
static wxDateTime dtFirstDialupDisconnectEvent = wxDateTime ( ( time_t ) 0 ) ;
2005-06-30 06:12:49 +00:00
static bool already_notified_update_all_projects = false ;
2005-07-01 06:30:06 +00:00
static bool connected_successfully = false ;
static bool reset_timers = false ;
static bool was_dialing = false ;
2005-07-08 06:30:25 +00:00
static bool is_already_online = true ;
2005-06-29 05:21:47 +00:00
bool should_check_connection = false ;
2005-07-01 06:30:06 +00:00
bool is_dialing = false ;
bool is_online = false ;
2005-06-24 10:49:42 +00:00
int want_network = 0 ;
int answer = 0 ;
2005-06-29 05:21:47 +00:00
wxString strConnectionName = wxEmptyString ;
wxString strConnectionUsername = wxEmptyString ;
wxString strConnectionPassword = wxEmptyString ;
2005-07-01 06:30:06 +00:00
wxString strBuffer = wxEmptyString ;
2005-07-08 06:30:25 +00:00
wxTimeSpan tsLastDialupIsAlreadyOnlineCheck ;
2005-06-24 10:49:42 +00:00
wxTimeSpan tsLastDialupAlertSent ;
wxTimeSpan tsLastDialupRequest ;
2005-07-01 06:30:06 +00:00
wxTimeSpan tsFirstDialupDisconnectEvent ;
2005-06-24 10:49:42 +00:00
2005-07-01 06:30:06 +00:00
wxASSERT ( m_pDialupManager - > IsOk ( ) ) ;
2005-06-29 05:21:47 +00:00
if ( m_pDialupManager & & pDoc ) {
2005-07-08 06:30:25 +00:00
// Update the always online flag every 60 seconds. This call is expensive
// on slow machines.
tsLastDialupIsAlreadyOnlineCheck = wxDateTime : : Now ( ) - dtLastDialupIsAlreadyOnlineCheck ;
if ( tsLastDialupIsAlreadyOnlineCheck . GetSeconds ( ) > 60 ) {
dtLastDialupIsAlreadyOnlineCheck = wxDateTime : : Now ( ) ;
is_already_online = m_pDialupManager - > IsAlwaysOnline ( ) ;
}
2005-06-29 05:21:47 +00:00
// Are we configured to detect a network or told one already exists?
if ( ID_NETWORKLAN ! = m_iNetworkConnectionType ) {
if ( ID_NETWORKDIALUP = = m_iNetworkConnectionType ) {
should_check_connection = true ;
}
if ( ID_NETWORKAUTODETECT = = m_iNetworkConnectionType ) {
2005-07-08 06:30:25 +00:00
if ( ! is_already_online ) {
2005-06-29 05:21:47 +00:00
should_check_connection = true ;
2005-07-01 06:30:06 +00:00
}
2005-06-29 05:21:47 +00:00
}
}
2005-07-01 06:30:06 +00:00
if ( should_check_connection ) {
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
// cache the various states
is_dialing = m_pDialupManager - > IsDialing ( ) ;
is_online = m_pDialupManager - > IsOnline ( ) ;
pDoc - > rpc . network_query ( want_network ) ;
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Dialup Flags " ) ) ;
wxLogTrace ( wxT ( " Function Status " ) ,
wxT ( " CMainFrame::OnFrameRender - -- is_online = '%d', is_dialing = '%d', was_dialing = '%d', want_network = '%d' " ) ,
is_online , is_dialing , was_dialing , want_network
) ;
wxLogTrace ( wxT ( " Function Status " ) ,
wxT ( " CMainFrame::OnFrameRender - -- reset_timers = '%d', already_notified_update_all_projects = '%d', connected_successfully = '%d' " ) ,
reset_timers , already_notified_update_all_projects , connected_successfully
) ;
// If we have received any connection event, then we should reset the
// dtLastDialupAlertSent and dtLastDialupRequest variables
// so that if we are disconnected without completing the user will
// be notifed in a prompt fashion.
if ( reset_timers ) {
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Resetting dial-up notification timers " ) ) ;
reset_timers = false ;
dtLastDialupAlertSent = wxDateTime ( ( time_t ) 0 ) ;
dtLastDialupRequest = wxDateTime ( ( time_t ) 0 ) ;
}
if ( ! is_online & & ! is_dialing & & ! was_dialing & & want_network )
{
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Internet connection needed " ) ) ;
if ( ! IsShown ( ) ) {
// BOINC Manager is hidden and displaying a dialog might interupt what they
// are doing.
tsLastDialupAlertSent = wxDateTime : : Now ( ) - dtLastDialupAlertSent ;
if ( tsLastDialupAlertSent . GetSeconds ( ) > = ( m_iReminderFrequency * 60 ) ) {
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Manager not shown, notify instead " ) ) ;
dtLastDialupAlertSent = wxDateTime : : Now ( ) ;
ShowAlert (
_ ( " BOINC Manager - Network Status " ) ,
_ ( " BOINC needs a connection to the Internet to perform some maintenance, open the BOINC Manager to connect up and perform the needed work. " ) ,
wxICON_INFORMATION ,
true
) ;
2005-06-30 06:12:49 +00:00
}
2005-07-01 06:30:06 +00:00
} else {
// BOINC Manager is visable and can process user input.
tsLastDialupRequest = wxDateTime : : Now ( ) - dtLastDialupRequest ;
if ( tsLastDialupRequest . GetSeconds ( ) > = ( m_iReminderFrequency * 60 ) ) {
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Begin connection process " ) ) ;
dtLastDialupRequest = wxDateTime : : Now ( ) ;
2005-06-30 06:12:49 +00:00
2005-07-01 06:30:06 +00:00
if ( pDoc - > state . global_prefs . confirm_before_connecting ) {
answer = : : wxMessageBox (
_ ( " BOINC needs to connect to the network. \n May it do so now? " ) ,
_ ( " BOINC Manager - Network Status " ) ,
wxYES_NO | wxICON_QUESTION ,
this
) ;
} else {
2005-06-24 10:49:42 +00:00
ShowAlert (
_ ( " BOINC Manager - Network Status " ) ,
2005-07-01 06:30:06 +00:00
_ ( " BOINC is connecting to the internet. " ) ,
2005-06-24 10:49:42 +00:00
wxICON_INFORMATION ,
true
) ;
2005-07-01 06:30:06 +00:00
answer = wxYES ;
2005-06-24 10:49:42 +00:00
}
2005-06-29 05:21:47 +00:00
2005-07-01 06:30:06 +00:00
// Are we allow to connect?
if ( wxYES = = answer ) {
if ( m_strNetworkDialupConnectionName . size ( ) )
strConnectionName = m_strNetworkDialupConnectionName ;
2005-06-29 05:21:47 +00:00
2005-07-01 06:30:06 +00:00
if ( m_bNetworkDialupPromptCredentials ) {
CDlgDialupCredentials * pDlgDialupCredentials = new CDlgDialupCredentials ( this ) ;
2005-06-29 05:21:47 +00:00
2005-07-01 06:30:06 +00:00
answer = pDlgDialupCredentials - > ShowModal ( ) ;
if ( wxID_OK = = answer ) {
strConnectionUsername = pDlgDialupCredentials - > GetUsername ( ) ;
strConnectionPassword = pDlgDialupCredentials - > GetPassword ( ) ;
2005-06-29 05:21:47 +00:00
}
2005-07-01 06:30:06 +00:00
if ( pDlgDialupCredentials ) {
pDlgDialupCredentials - > Destroy ( ) ;
}
2005-06-29 18:41:09 +00:00
}
2005-07-01 06:30:06 +00:00
already_notified_update_all_projects = false ;
connected_successfully = false ;
m_pDialupManager - > Dial ( strConnectionName , strConnectionUsername , strConnectionPassword , true ) ;
2005-06-24 10:49:42 +00:00
}
}
2005-07-01 06:30:06 +00:00
}
} else if ( ! is_dialing & & ! was_dialing ) {
2005-07-06 10:25:20 +00:00
if ( is_online & & want_network & & connected_successfully & & ! already_notified_update_all_projects ) {
2005-07-01 06:30:06 +00:00
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Connection Detected, notifing user of update to all projects " ) ) ;
already_notified_update_all_projects = true ;
// We are already online but BOINC for some reason is in a state
// where it belives it has some pending work to do, so give it
// a nudge
ShowAlert (
_ ( " BOINC Manager - Network Status " ) ,
2005-07-07 03:20:57 +00:00
_ ( " BOINC has detected it is now connected to the internet. Updating all projects and retrying all transfers. " ) ,
2005-07-01 06:30:06 +00:00
wxICON_INFORMATION ,
true
) ;
// Sleep for a couple of seconds to let the network interface finish
// initializing.
: : wxSleep ( 2 ) ;
// Signal BOINC to update all projects and transfers.
pDoc - > rpc . network_available ( ) ;
} else if ( is_online & & ! want_network & & connected_successfully ) {
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Connection Detected, Don't need the network, We successfully connected. " ) ) ;
// Should we disconnect now? The first time we see the disconnect event
// we should ignore it and wait for 5 seconds to see if it is really
// safe to disconnect.
if ( wxDateTime ( ( time_t ) 0 ) = = dtFirstDialupDisconnectEvent ) {
dtFirstDialupDisconnectEvent = wxDateTime : : Now ( ) ;
}
tsFirstDialupDisconnectEvent = wxDateTime : : Now ( ) - dtFirstDialupDisconnectEvent ;
if ( tsFirstDialupDisconnectEvent . GetSeconds ( ) > = 5 ) {
if ( pDoc - > state . global_prefs . hangup_if_dialed ) {
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - Connection Detected, Don't need the network, Hanging up. " ) ) ;
if ( m_pDialupManager - > HangUp ( ) ) {
ShowAlert (
_ ( " BOINC Manager - Network Status " ) ,
_ ( " BOINC has successfully disconnected from the internet. " ) ,
wxICON_INFORMATION ,
true
) ;
2005-06-24 10:49:42 +00:00
2005-07-01 06:30:06 +00:00
connected_successfully = false ;
} else {
ShowAlert (
_ ( " BOINC Manager - Network Status " ) ,
_ ( " BOINC failed to disconnected from the internet. " ) ,
wxICON_ERROR
) ;
2005-06-29 18:41:09 +00:00
}
2005-06-24 10:49:42 +00:00
}
}
}
2005-07-01 06:30:06 +00:00
} else if ( ! is_dialing & & was_dialing ) {
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - We were dialing and now we are not, detect success or failure of the connection. " ) ) ;
was_dialing = false ;
reset_timers = true ;
if ( is_online ) {
ShowAlert (
_ ( " BOINC Manager - Network Status " ) ,
_ ( " BOINC has successfully connected to the internet. " ) ,
wxICON_INFORMATION ,
true
) ;
connected_successfully = true ;
} else {
ShowAlert (
_ ( " BOINC Manager - Network Status " ) ,
_ ( " BOINC failed to connect to the internet. " ) ,
wxICON_ERROR ,
true
) ;
connected_successfully = false ;
}
} else if ( is_dialing & & ! was_dialing ) {
wxLogTrace ( wxT ( " Function Status " ) , wxT ( " CMainFrame::OnFrameRender - We are now dialing, where before we were not. " ) ) ;
was_dialing = true ;
2005-06-24 10:49:42 +00:00
}
}
}
# endif
2005-04-07 07:04:50 +00:00
if ( IsShown ( ) ) {
2005-04-27 06:55:28 +00:00
if ( pDoc ) {
2005-03-12 01:09:24 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-03-09 19:15:20 +00:00
2005-03-12 01:09:24 +00:00
// Update the menu bar
2005-06-24 10:49:42 +00:00
wxMenuBar * pMenuBar = GetMenuBar ( ) ;
2005-04-10 19:01:23 +00:00
int iActivityMode = - 1 ;
int iNetworkMode = - 1 ;
2005-03-09 19:15:20 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pMenuBar ) ;
2005-03-12 01:09:24 +00:00
wxASSERT ( wxDynamicCast ( pMenuBar , wxMenuBar ) ) ;
2005-03-09 19:15:20 +00:00
2005-06-29 05:54:12 +00:00
pMenuBar - > Check ( ID_ACTIVITYRUNALWAYS , false ) ;
pMenuBar - > Check ( ID_ACTIVITYSUSPEND , false ) ;
pMenuBar - > Check ( ID_ACTIVITYRUNBASEDONPREPERENCES , false ) ;
2005-04-08 16:58:55 +00:00
if ( ( pDoc - > IsConnected ( ) ) & & ( 0 = = pDoc - > GetActivityRunMode ( iActivityMode ) ) ) {
2005-05-29 07:12:00 +00:00
if ( iActivityMode = = RUN_MODE_ALWAYS )
2005-04-07 07:04:50 +00:00
pMenuBar - > Check ( ID_ACTIVITYRUNALWAYS , true ) ;
2005-05-29 07:12:00 +00:00
if ( iActivityMode = = RUN_MODE_NEVER )
2005-04-07 07:04:50 +00:00
pMenuBar - > Check ( ID_ACTIVITYSUSPEND , true ) ;
2005-05-29 07:12:00 +00:00
if ( iActivityMode = = RUN_MODE_AUTO )
2005-04-07 07:04:50 +00:00
pMenuBar - > Check ( ID_ACTIVITYRUNBASEDONPREPERENCES , true ) ;
2005-03-12 01:09:24 +00:00
}
2005-03-09 19:15:20 +00:00
2005-06-29 05:54:12 +00:00
pMenuBar - > Check ( ID_NETWORKRUNALWAYS , false ) ;
pMenuBar - > Check ( ID_NETWORKSUSPEND , false ) ;
pMenuBar - > Check ( ID_NETWORKRUNBASEDONPREPERENCES , false ) ;
2005-04-08 16:58:55 +00:00
if ( ( pDoc - > IsConnected ( ) ) & & ( 0 = = pDoc - > GetNetworkRunMode ( iNetworkMode ) ) ) {
2005-05-29 07:12:00 +00:00
if ( RUN_MODE_ALWAYS = = iNetworkMode )
2005-04-07 07:04:50 +00:00
pMenuBar - > Check ( ID_NETWORKRUNALWAYS , true ) ;
2005-05-29 07:12:00 +00:00
if ( RUN_MODE_NEVER = = iNetworkMode )
2005-04-07 07:04:50 +00:00
pMenuBar - > Check ( ID_NETWORKSUSPEND , true ) ;
2005-05-29 07:12:00 +00:00
if ( RUN_MODE_AUTO = = iNetworkMode )
2005-04-07 07:04:50 +00:00
pMenuBar - > Check ( ID_NETWORKRUNBASEDONPREPERENCES , true ) ;
2005-03-12 01:09:24 +00:00
}
2005-03-09 19:15:20 +00:00
2005-03-12 01:09:24 +00:00
// Update the statusbar
wxASSERT ( wxDynamicCast ( m_pStatusbar , CStatusBar ) ) ;
2005-04-07 07:04:50 +00:00
if ( pDoc - > IsConnected ( ) | | pDoc - > IsReconnecting ( ) ) {
2005-03-12 01:09:24 +00:00
m_pStatusbar - > m_pbmpConnected - > Show ( ) ;
m_pStatusbar - > m_ptxtConnected - > Show ( ) ;
m_pStatusbar - > m_pbmpDisconnect - > Hide ( ) ;
m_pStatusbar - > m_ptxtDisconnect - > Hide ( ) ;
wxString strBuffer = wxEmptyString ;
2005-04-06 23:28:49 +00:00
wxString strComputerName = wxEmptyString ;
2005-03-12 01:09:24 +00:00
wxString strStatusText = wxEmptyString ;
wxString strTitle = m_strBaseTitle ;
wxString strLocale = setlocale ( LC_NUMERIC , NULL ) ;
2005-04-07 07:04:50 +00:00
if ( pDoc - > IsReconnecting ( ) )
pDoc - > GetConnectingComputerName ( strComputerName ) ;
2005-04-06 23:28:49 +00:00
else
2005-04-07 07:04:50 +00:00
pDoc - > GetConnectedComputerName ( strComputerName ) ;
2005-04-06 23:28:49 +00:00
2005-04-07 07:04:50 +00:00
if ( strComputerName . empty ( ) ) {
2005-03-12 01:09:24 +00:00
strTitle + = wxT ( " - (localhost) " ) ;
2005-04-06 23:28:49 +00:00
strComputerName + = wxT ( " localhost " ) ;
2005-04-07 07:04:50 +00:00
} else {
2005-04-06 23:28:49 +00:00
strStatusText + = strComputerName ;
2005-03-12 01:09:24 +00:00
}
2005-04-07 07:04:50 +00:00
if ( pDoc - > IsReconnecting ( ) ) {
2005-04-06 23:28:49 +00:00
strTitle . Printf ( _ ( " %s - (%s) " ) , m_strBaseTitle . c_str ( ) , strComputerName . c_str ( ) ) ;
strStatusText . Printf ( _ ( " Connecting to %s " ) , strComputerName . c_str ( ) ) ;
2005-04-07 07:04:50 +00:00
} else {
2005-04-06 23:28:49 +00:00
strTitle . Printf ( _ ( " %s - (%s) " ) , m_strBaseTitle . c_str ( ) , strComputerName . c_str ( ) ) ;
2005-04-08 22:52:40 +00:00
strStatusText . Printf ( _ ( " Connected to %s " ) , strComputerName . c_str ( ) ) ;
2005-04-06 23:28:49 +00:00
}
2005-03-12 01:09:24 +00:00
2005-04-07 07:04:50 +00:00
SetTitle ( strTitle ) ;
2005-05-25 03:36:16 +00:00
// The Mac takes a huge performance hit changing the text of a floating
// window, so don't change the text unless we really have too.
if ( strStatusText ! = strCachedStatusText ) {
strCachedStatusText = strStatusText ;
m_pStatusbar - > m_ptxtConnected - > SetLabel ( strStatusText ) ;
}
2005-04-07 07:04:50 +00:00
} else {
2005-03-12 01:09:24 +00:00
m_pStatusbar - > m_pbmpConnected - > Hide ( ) ;
m_pStatusbar - > m_ptxtConnected - > Hide ( ) ;
m_pStatusbar - > m_pbmpDisconnect - > Show ( ) ;
m_pStatusbar - > m_ptxtDisconnect - > Show ( ) ;
2005-04-08 04:23:37 +00:00
SetTitle ( m_strBaseTitle ) ;
2005-01-10 20:24:09 +00:00
}
2004-10-28 22:51:38 +00:00
}
}
2005-03-12 01:09:24 +00:00
bAlreadyRunningLoop = false ;
2004-10-28 22:51:38 +00:00
}
event . Skip ( ) ;
2004-12-03 20:30:24 +00:00
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnFrameRender - Function End " ) ) ;
2004-10-28 22:51:38 +00:00
}
2004-09-25 21:33:24 +00:00
2005-04-08 16:58:55 +00:00
void CMainFrame : : OnListPanelRender ( wxTimerEvent & ) {
2004-12-04 00:43:39 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnListPanelRender - Function Begin " ) ) ;
2004-12-03 20:30:24 +00:00
2005-06-11 00:30:11 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2005-06-22 10:51:34 +00:00
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
FireRefreshView ( ) ;
2005-06-11 00:30:11 +00:00
pDoc - > CachedMessageUpdate ( ) ;
2005-03-12 01:09:24 +00:00
2005-04-08 04:23:37 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnListPanelRender - Function End " ) ) ;
}
2004-05-21 06:27:15 +00:00
2005-04-15 19:33:47 +00:00
void CMainFrame : : OnDocumentPoll ( wxTimerEvent & /*event*/ ) {
2005-04-10 02:24:08 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
pDoc - > OnPoll ( ) ;
}
2005-04-08 04:23:37 +00:00
void CMainFrame : : OnNotebookSelectionChanged ( wxNotebookEvent & event ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnNotebookSelectionChanged - Function Begin " ) ) ;
2004-10-21 14:29:59 +00:00
2005-04-08 04:23:37 +00:00
if ( ( - 1 ! = event . GetSelection ( ) ) & & IsShown ( ) ) {
wxWindow * pwndNotebookPage = NULL ;
CBOINCBaseView * pView = NULL ;
wxTimerEvent timerEvent ;
2005-03-12 01:09:24 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pNotebook ) ;
2005-03-12 01:09:24 +00:00
2005-04-08 04:23:37 +00:00
pwndNotebookPage = m_pNotebook - > GetPage ( event . GetSelection ( ) ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pwndNotebookPage ) ;
2004-10-26 01:59:44 +00:00
2005-04-08 04:23:37 +00:00
pView = wxDynamicCast ( pwndNotebookPage , CBOINCBaseView ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pView ) ;
2005-04-08 04:23:37 +00:00
2005-04-23 07:21:00 +00:00
FireRefreshView ( ) ;
2004-05-27 06:17:58 +00:00
}
2004-10-21 14:29:59 +00:00
event . Skip ( ) ;
2004-12-03 20:30:24 +00:00
2005-04-08 04:23:37 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnNotebookSelectionChanged - Function End " ) ) ;
}
2005-04-08 16:58:55 +00:00
void CMainFrame : : UpdateStatusText ( const wxChar * szStatus ) {
2005-04-08 06:24:58 +00:00
wxString strStatus = szStatus ;
2005-04-08 16:58:55 +00:00
m_pStatusbar - > SetStatusText ( strStatus ) ;
: : wxSleep ( 0 ) ;
2005-04-08 06:24:58 +00:00
}
2005-05-24 21:26:49 +00:00
void CMainFrame : : FireInitialize ( ) {
CMainFrameEvent event ( wxEVT_MAINFRAME_INITIALIZED , this ) ;
AddPendingEvent ( event ) ;
}
2005-06-17 04:53:35 +00:00
void CMainFrame : : FireRefreshView ( ) {
CMainFrameEvent event ( wxEVT_MAINFRAME_REFRESHVIEW , this ) ;
AddPendingEvent ( event ) ;
}
2005-04-08 16:58:55 +00:00
void CMainFrame : : FireConnect ( ) {
2005-04-08 04:23:37 +00:00
CMainFrameEvent event ( wxEVT_MAINFRAME_CONNECT , this ) ;
2005-04-08 16:58:55 +00:00
AddPendingEvent ( event ) ;
2005-04-08 04:23:37 +00:00
}
2005-06-24 10:49:42 +00:00
void CMainFrame : : ShowAlert ( const wxString title , const wxString message , const int style , const bool notification_only ) {
CMainFrameAlertEvent event ( wxEVT_MAINFRAME_ALERT , this , title , message , style , notification_only ) ;
2005-04-08 21:18:30 +00:00
AddPendingEvent ( event ) ;
}
2005-04-08 06:24:58 +00:00
void CMainFrame : : ExecuteBrowserLink ( const wxString & strLink ) {
2005-06-28 22:22:29 +00:00
wxHyperLink : : ExecuteLink ( strLink ) ;
2005-04-08 06:24:58 +00:00
}
2005-07-06 05:16:53 +00:00
# ifdef __WXMAC__
bool CMainFrame : : Show ( bool show ) {
ProcessSerialNumber psn ;
GetCurrentProcess ( & psn ) ;
if ( show ) {
SetFrontProcess ( & psn ) ; // Shows process if hidden
} else
if ( IsProcessVisible ( & psn ) )
ShowHideProcess ( & psn , false ) ;
return wxFrame : : Show ( show ) ;
}
# endif // __WXMAC__
2005-04-08 06:24:58 +00:00
2005-01-02 18:29:53 +00:00
const char * BOINC_RCSID_d881a56dc5 = " $Id$ " ;