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-06-29 05:21:47 +00:00
# include "DlgDialupCredentials.h"
2005-03-30 09:24:31 +00:00
# include "DlgSelectComputer.h"
2005-10-03 23:14:39 +00:00
# include "wizardex.h"
# include "BOINCWizards.h"
# include "BOINCBaseWizard.h"
# include "WizardAttachProject.h"
# include "WizardAccountManager.h"
2004-04-10 09:11:03 +00:00
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 )
2005-07-22 06:56:34 +00:00
EVT_MENU ( ID_FILERUNBENCHMARKS , CMainFrame : : OnRunBenchmarks )
EVT_MENU ( ID_FILESELECTCOMPUTER , CMainFrame : : OnSelectComputer )
2004-09-24 02:01:53 +00:00
EVT_MENU ( wxID_EXIT , CMainFrame : : OnExit )
2005-10-05 19:01:28 +00:00
EVT_MENU_RANGE ( ID_FILEACTIVITYRUNALWAYS , ID_FILEACTIVITYSUSPEND , CMainFrame : : OnActivitySelection )
EVT_MENU_RANGE ( ID_FILENETWORKRUNALWAYS , ID_FILENETWORKSUSPEND , CMainFrame : : OnNetworkSelection )
2005-09-06 08:58:56 +00:00
EVT_MENU ( ID_PROJECTSATTACHACCOUNTMANAGER , CMainFrame : : OnProjectsAttachToAccountManager )
EVT_MENU ( ID_PROJECTSATTACHPROJECT , CMainFrame : : OnProjectsAttachToProject )
2005-10-05 19:01:28 +00:00
EVT_MENU ( ID_COMMADSRETRYCOMMUNICATIONS , CMainFrame : : OnCommandsRetryCommunications )
2005-09-06 08:58:56 +00:00
EVT_MENU ( ID_OPTIONSOPTIONS , CMainFrame : : OnOptionsOptions )
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
}
2005-12-28 12:33:18 +00:00
CMainFrame : : CMainFrame ( wxString title , wxIcon * icon ) :
wxFrame ( ( wxFrame * ) NULL , ID_FRAME , title , 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
2005-12-28 12:33:18 +00:00
m_strBaseTitle = title ;
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
2005-12-28 12:33:18 +00:00
SetIcon ( * icon ) ;
2004-04-10 09:11:03 +00:00
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-10-21 02:16:11 +00:00
if ( m_RASAPI32 . Load ( wxT ( " RASAPI32 " ) ) ) {
m_pDialupManager = wxDialUpManager : : Create ( ) ;
wxASSERT ( m_pDialupManager - > IsOk ( ) ) ;
} else {
m_pDialupManager = NULL ;
}
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-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 ) ;
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
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 ( ) {
2005-12-28 12:33:18 +00:00
wxString strMenuName ;
wxString strMenuDescription ;
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
2004-04-10 09:11:03 +00:00
// File menu
wxMenu * menuFile = new wxMenu ;
2004-10-24 07:38:38 +00:00
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strMenuDescription . Printf (
_ ( " Connect to another computer running %s " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2004-10-24 07:38:38 +00:00
menuFile - > Append (
2005-09-06 08:58:56 +00:00
ID_FILESELECTCOMPUTER ,
2005-09-22 08:46:51 +00:00
_ ( " Select computer... " ) ,
2005-12-28 12:33:18 +00:00
strMenuDescription
2005-04-10 19:01:23 +00:00
) ;
2004-10-24 07:38:38 +00:00
2005-12-28 12:33:18 +00:00
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strMenuDescription . Printf (
_ ( " Exit the %s " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
2005-09-06 08:58:56 +00:00
menuFile - > Append (
wxID_EXIT ,
_ ( " E&xit " ) ,
2005-12-28 12:33:18 +00:00
strMenuDescription
2005-09-06 08:58:56 +00:00
) ;
2005-12-28 12:33:18 +00:00
// Commands menu
2005-09-06 08:58:56 +00:00
wxMenu * menuCommands = new wxMenu ;
menuCommands - > AppendRadioItem (
2005-07-22 06:56:34 +00:00
ID_FILEACTIVITYRUNALWAYS ,
2004-10-24 07:38:38 +00:00
_ ( " &Run always " ) ,
2004-11-22 19:17:13 +00:00
_ ( " Does work regardless of preferences " )
2005-04-10 19:01:23 +00:00
) ;
2005-09-06 08:58:56 +00:00
menuCommands - > AppendRadioItem (
2005-07-22 06:56:34 +00:00
ID_FILEACTIVITYRUNBASEDONPREPERENCES ,
2004-10-24 07:38:38 +00:00
_ ( " 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
) ;
2005-09-06 08:58:56 +00:00
menuCommands - > AppendRadioItem (
2005-07-22 06:56:34 +00:00
ID_FILEACTIVITYSUSPEND ,
2004-10-24 07:38:38 +00:00
_ ( " &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
2005-09-06 08:58:56 +00:00
menuCommands - > AppendSeparator ( ) ;
2004-10-24 07:38:38 +00:00
2005-09-06 08:58:56 +00:00
menuCommands - > AppendRadioItem (
2005-07-22 06:56:34 +00:00
ID_FILENETWORKRUNALWAYS ,
2005-06-29 05:54:12 +00:00
_ ( " &Network activity always available " ) ,
_ ( " Does network activity regardless of preferences " )
) ;
2005-09-06 08:58:56 +00:00
menuCommands - > AppendRadioItem (
2005-07-22 06:56:34 +00:00
ID_FILENETWORKRUNBASEDONPREPERENCES ,
2005-06-29 05:54:12 +00:00
_ ( " Network activity based on &preferences " ) ,
_ ( " Does network activity according to your preferences " )
) ;
2005-09-06 08:58:56 +00:00
menuCommands - > AppendRadioItem (
2005-07-22 06:56:34 +00:00
ID_FILENETWORKSUSPEND ,
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
2005-09-06 08:58:56 +00:00
menuCommands - > AppendSeparator ( ) ;
2004-10-24 07:38:38 +00:00
2005-10-05 19:01:28 +00:00
menuCommands - > Append (
ID_COMMADSRETRYCOMMUNICATIONS ,
2005-10-05 23:45:06 +00:00
_ ( " Retry &communications " ) ,
2005-10-05 19:01:28 +00:00
_ ( " Report completed work, get latest credit, "
" get latest preferences, and possibly get more work. " )
) ;
2005-09-06 08:58:56 +00:00
menuCommands - > Append (
2005-07-22 06:56:34 +00:00
ID_FILERUNBENCHMARKS ,
2005-09-22 08:46:51 +00:00
_ ( " 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
2005-09-06 08:58:56 +00:00
// Projects menu
wxMenu * menuProjects = new wxMenu ;
menuProjects - > Append (
ID_PROJECTSATTACHPROJECT ,
2005-11-07 10:44:37 +00:00
_ ( " Attach to &project " ) ,
2005-09-06 08:58:56 +00:00
_ ( " Attach to a project to begin processing work " )
2005-06-17 04:53:35 +00:00
) ;
2005-09-22 08:46:51 +00:00
menuProjects - > Append (
ID_PROJECTSATTACHACCOUNTMANAGER ,
_ ( " &Account manager " ) ,
_ ( " Attach to an account manager " )
) ;
2005-03-11 22:10:56 +00:00
2005-09-06 08:58:56 +00:00
// Options menu
wxMenu * menuOptions = new wxMenu ;
menuOptions - > Append (
ID_OPTIONSOPTIONS ,
2004-10-09 03:05:01 +00:00
_ ( " &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-12-28 12:33:18 +00:00
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strMenuName . Printf (
_ ( " &%s \t F1 " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strMenuDescription . Printf (
_ ( " Show information about the %s " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
2005-05-05 06:07:14 +00:00
menuHelp - > Append (
ID_HELPBOINCMANAGER ,
2005-12-28 12:33:18 +00:00
strMenuName ,
strMenuDescription
2005-05-05 06:07:14 +00:00
) ;
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strMenuName . Printf (
_ ( " %s &website " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( )
) ;
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strMenuDescription . Printf (
_ ( " Show information about BOINC and %s " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
2005-05-05 06:07:14 +00:00
menuHelp - > Append (
ID_HELPBOINC ,
2005-12-28 12:33:18 +00:00
strMenuName ,
strMenuDescription
2005-05-05 06:07:14 +00:00
) ;
menuHelp - > AppendSeparator ( ) ;
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strMenuName . Printf (
_ ( " &About %s... " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
2005-04-08 16:58:55 +00:00
menuHelp - > Append (
2004-10-09 03:05:01 +00:00
wxID_ABOUT ,
2005-12-28 12:33:18 +00:00
strMenuName ,
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 (
2005-09-06 08:58:56 +00:00
menuCommands ,
_ ( " &Commands " )
) ;
m_pMenubar - > Append (
menuProjects ,
_ ( " &Projects " )
) ;
m_pMenubar - > Append (
menuOptions ,
_ ( " &Options " )
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
2005-11-28 21:14:46 +00:00
pConfig - > Read ( wxT ( " CurrentPage " ) , & iCurrentPage , ( ID_LIST_WORKVIEW - ID_LIST_BASE ) ) ;
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 : : 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 ( ) ) {
2005-07-22 06:56:34 +00:00
case ID_FILEACTIVITYRUNALWAYS :
2005-05-29 07:12:00 +00:00
pDoc - > SetActivityRunMode ( RUN_MODE_ALWAYS ) ;
2005-04-07 07:04:50 +00:00
break ;
2005-07-22 06:56:34 +00:00
case ID_FILEACTIVITYSUSPEND :
2005-05-29 07:12:00 +00:00
pDoc - > SetActivityRunMode ( RUN_MODE_NEVER ) ;
2005-04-07 07:04:50 +00:00
break ;
2005-07-22 06:56:34 +00:00
case ID_FILEACTIVITYRUNBASEDONPREPERENCES :
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-07-22 06:56:34 +00:00
case ID_FILENETWORKRUNALWAYS :
2005-06-29 05:54:12 +00:00
pDoc - > SetNetworkRunMode ( RUN_MODE_ALWAYS ) ;
break ;
2005-07-22 06:56:34 +00:00
case ID_FILENETWORKSUSPEND :
2005-06-29 05:54:12 +00:00
pDoc - > SetNetworkRunMode ( RUN_MODE_NEVER ) ;
break ;
2005-07-22 06:56:34 +00:00
case ID_FILENETWORKRUNBASEDONPREPERENCES :
2005-06-29 05:54:12 +00:00
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-11-14 23:12:07 +00:00
// Make a null hostname be the same thing as localhost
if ( wxEmptyString = = pDlg - > m_ComputerNameCtrl - > GetValue ( ) ) {
2005-11-29 00:29:43 +00:00
lRetVal = pDoc - > Connect (
wxT ( " localhost " ) ,
wxEmptyString ,
TRUE ,
TRUE
) ;
} else {
// Connect up to the remote machine
lRetVal = pDoc - > Connect (
pDlg - > m_ComputerNameCtrl - > GetValue ( ) ,
pDlg - > m_ComputerPasswordCtrl - > GetValue ( ) ,
TRUE ,
FALSE
) ;
2005-11-14 23:12:07 +00:00
}
2005-04-10 18:36:12 +00:00
if ( lRetVal ) {
2005-11-27 01:28:56 +00:00
ShowConnectionFailedAlert ( ) ;
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-11-14 23:12:07 +00:00
if ( wxEmptyString ! = pDlg - > m_ComputerNameCtrl - > GetValue ( ) ) {
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-09-06 08:58:56 +00:00
void CMainFrame : : OnProjectsAttachToAccountManager ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnProjectsAttachToAccountManager - Function Begin " ) ) ;
2005-03-11 22:10:56 +00:00
2005-06-20 01:45:13 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
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-09-28 01:06:35 +00:00
2005-11-02 08:02:16 +00:00
# ifdef __WXMAC__
if ( ! Mac_Authorize ( ) )
return ;
# endif
2005-11-26 11:17:48 +00:00
if ( pDoc - > IsConnected ( ) ) {
m_pRefreshStateTimer - > Stop ( ) ;
m_pFrameRenderTimer - > Stop ( ) ;
m_pFrameListPanelRenderTimer - > Stop ( ) ;
m_pDocumentPollTimer - > Stop ( ) ;
2005-12-19 13:30:01 +00:00
CWizardAccountManager * pWizard = new CWizardAccountManager ( this ) ;
2005-09-06 08:58:56 +00:00
2005-12-19 13:30:01 +00:00
pWizard - > Run ( ) ;
2005-11-26 11:17:48 +00:00
2005-12-19 13:30:01 +00:00
if ( pWizard )
pWizard - > Destroy ( ) ;
2005-11-26 11:17:48 +00:00
2005-12-19 13:30:01 +00:00
FireRefreshView ( ) ;
2005-03-11 22:10:56 +00:00
2005-11-26 11:17:48 +00:00
m_pRefreshStateTimer - > Start ( ) ;
m_pFrameRenderTimer - > Start ( ) ;
m_pFrameListPanelRenderTimer - > Start ( ) ;
m_pDocumentPollTimer - > Start ( ) ;
} else {
ShowNotCurrentlyConnectedAlert ( ) ;
}
2005-03-11 22:10:56 +00:00
2005-09-06 08:58:56 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnProjectsAttachToAccountManager - Function End " ) ) ;
}
void CMainFrame : : OnProjectsAttachToProject ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnProjectsAttachToProject - Function Begin " ) ) ;
2005-11-26 11:17:48 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-11-02 08:02:16 +00:00
# ifdef __WXMAC__
if ( ! Mac_Authorize ( ) )
return ;
# endif
2005-11-26 11:17:48 +00:00
if ( pDoc - > IsConnected ( ) ) {
UpdateStatusText ( _ ( " Attaching to project... " ) ) ;
2005-09-06 08:58:56 +00:00
2005-11-26 11:17:48 +00:00
m_pRefreshStateTimer - > Stop ( ) ;
m_pFrameRenderTimer - > Stop ( ) ;
m_pFrameListPanelRenderTimer - > Stop ( ) ;
m_pDocumentPollTimer - > Stop ( ) ;
2005-09-06 08:58:56 +00:00
2005-11-26 11:17:48 +00:00
CWizardAttachProject * pWizard = new CWizardAttachProject ( this ) ;
2005-09-06 08:58:56 +00:00
2005-11-26 11:17:48 +00:00
wxString strName = wxEmptyString ;
wxString strURL = wxEmptyString ;
pWizard - > Run ( strName , strURL , false ) ;
2005-09-06 08:58:56 +00:00
2005-11-26 11:17:48 +00:00
if ( pWizard )
pWizard - > Destroy ( ) ;
2005-09-06 08:58:56 +00:00
2005-11-26 11:17:48 +00:00
m_pRefreshStateTimer - > Start ( ) ;
m_pFrameRenderTimer - > Start ( ) ;
m_pFrameListPanelRenderTimer - > Start ( ) ;
m_pDocumentPollTimer - > Start ( ) ;
2005-09-06 08:58:56 +00:00
2005-11-26 11:17:48 +00:00
UpdateStatusText ( wxT ( " " ) ) ;
2005-09-06 08:58:56 +00:00
2005-11-26 11:17:48 +00:00
FireRefreshView ( ) ;
} else {
ShowNotCurrentlyConnectedAlert ( ) ;
}
2005-09-06 08:58:56 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnProjectsAttachToProject - Function End " ) ) ;
2005-03-11 22:10:56 +00:00
}
2005-10-05 19:01:28 +00:00
void CMainFrame : : OnCommandsRetryCommunications ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnCommandsRetryCommunications - Function Begin " ) ) ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
UpdateStatusText ( _ ( " Retrying communications for project(s)... " ) ) ;
pDoc - > rpc . network_available ( ) ;
UpdateStatusText ( wxT ( " " ) ) ;
FireRefreshView ( ) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnCommandsRetryCommunications - Function End " ) ) ;
}
2005-09-06 08:58:56 +00:00
void CMainFrame : : OnOptionsOptions ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnOptionsOptions - 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
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
2005-10-21 02:16:11 +00:00
if ( m_pDialupManager ) {
m_pDialupManager - > GetISPNames ( astrDialupConnections ) ;
2005-06-29 05:21:47 +00:00
2005-10-21 02:16:11 +00:00
pDlg - > m_DialupConnectionsCtrl - > Append ( astrDialupConnections ) ;
pDlg - > SetDefaultConnectionType ( m_iNetworkConnectionType ) ;
pDlg - > SetDefaultDialupConnection ( m_strNetworkDialupConnectionName ) ;
pDlg - > SetDefaultDialupPromptCredentials ( m_bNetworkDialupPromptCredentials ) ;
} else {
pDlg - > m_DialupConnectionsCtrl - > Append ( astrDialupConnections ) ;
pDlg - > SetDefaultConnectionType ( m_iNetworkConnectionType ) ;
pDlg - > SetDefaultDialupConnection ( m_strNetworkDialupConnectionName ) ;
pDlg - > SetDefaultDialupPromptCredentials ( m_bNetworkDialupPromptCredentials ) ;
pDlg - > m_NetworkAutomaticDetectionCtrl - > Disable ( ) ;
pDlg - > m_NetworkUseLANCtrl - > Disable ( ) ;
pDlg - > m_NetworkUseDialupCtrl - > Disable ( ) ;
pDlg - > m_DialupConnectionsCtrl - > Disable ( ) ;
pDlg - > m_DialupSetDefaultCtrl - > Disable ( ) ;
pDlg - > m_DialupClearDefaultCtrl - > Disable ( ) ;
pDlg - > m_DialupPromptCredentials - > Disable ( ) ;
}
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 ( ) ) {
2005-12-28 12:33:18 +00:00
wxString strDialogTitle ;
wxString strDialogMessage ;
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strDialogTitle . Printf (
_ ( " %s - Language Selection " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strDialogMessage . Printf (
_ ( " The %s's default language has been changed, in order for this "
" change to take affect you must restart the %s. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
2005-06-28 22:22:29 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-06-28 22:22:29 +00:00
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
2005-09-06 08:58:56 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::OnOptionsOptions - 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 ( ) ) {
2005-12-28 12:33:18 +00:00
wxString url = wxGetApp ( ) . GetBrand ( ) - > GetCompanyWebsite ( ) . c_str ( ) ;
url + = wxT ( " manager.php " ) ;
ExecuteBrowserLink ( url ) ;
2005-05-05 06:07:14 +00:00
} 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 ( ) ) {
2005-12-28 12:33:18 +00:00
wxString url = wxGetApp ( ) . GetBrand ( ) - > GetCompanyWebsite ( ) . c_str ( ) ;
url + = wxT ( " manager.php " ) ;
ExecuteBrowserLink ( url ) ;
2005-06-17 04:53:35 +00:00
}
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 ( ) ) {
2005-12-28 12:33:18 +00:00
wxString url = wxGetApp ( ) . GetBrand ( ) - > GetCompanyWebsite ( ) . c_str ( ) ;
ExecuteBrowserLink ( url ) ;
2005-05-05 06:07:14 +00:00
}
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-10-01 08:56:37 +00:00
# if defined(__WXMSW__) || defined(__WXMAC__)
2005-09-06 06:18:36 +00:00
if ( ! event . CanVeto ( ) ) {
2004-10-24 07:38:38 +00:00
Destroy ( ) ;
2005-09-06 06:18:36 +00:00
} else {
2004-10-24 07:38:38 +00:00
Hide ( ) ;
2005-09-06 06:18:36 +00:00
}
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-14 20:27:32 +00:00
CTaskBarIcon * pTaskbar = wxGetApp ( ) . GetTaskBarIcon ( ) ;
wxASSERT ( pTaskbar ) ;
if ( ( IsShown ( ) & & ! event . m_notification_only ) | | ( IsShown ( ) & & ! pTaskbar - > IsBalloonsSupported ( ) ) ) {
2005-10-10 18:24:04 +00:00
if ( ! event . m_notification_only ) {
2005-11-27 01:28:56 +00:00
int retval = 0 ;
retval = : : wxMessageBox ( event . m_message , event . m_title , event . m_style , this ) ;
if ( event . m_alert_event_type = = AlertProcessResponse ) {
event . ProcessResponse ( retval ) ;
}
2005-10-10 18:24:04 +00:00
}
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.
unsigned int icon_type ;
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 ;
}
2005-07-14 20:27:32 +00:00
pTaskbar - > SetBalloon (
pTaskbar - > 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 ( ) ;
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 ) ) ;
2004-09-25 21:33:24 +00:00
2005-09-27 09:55:54 +00:00
// Only present one of the wizards if no projects are currently
2005-04-08 04:23:37 +00:00
// detected.
2005-09-28 11:59:34 +00:00
if ( 0 > = pDoc - > GetProjectCount ( ) ) {
2005-08-25 22:00:39 +00:00
m_pRefreshStateTimer - > Stop ( ) ;
m_pFrameRenderTimer - > Stop ( ) ;
m_pFrameListPanelRenderTimer - > Stop ( ) ;
m_pDocumentPollTimer - > Stop ( ) ;
2004-10-21 14:29:59 +00:00
2005-09-28 11:59:34 +00:00
CWizardAttachProject * pAPWizard = NULL ;
CWizardAccountManager * pAMWizard = NULL ;
wxString strName = wxEmptyString ;
2005-09-27 09:55:54 +00:00
wxString strURL = wxEmptyString ;
ACCT_MGR_INFO ami ;
PROJECT_INIT_STATUS pis ;
2004-10-26 01:59:44 +00:00
2005-09-27 09:55:54 +00:00
pDoc - > rpc . acct_mgr_info ( ami ) ;
if ( ami . acct_mgr_url . size ( ) ) {
2005-09-28 11:59:34 +00:00
pAMWizard = new CWizardAccountManager ( this ) ;
2005-12-19 13:30:01 +00:00
pAMWizard - > Run ( ) ;
2005-09-27 09:55:54 +00:00
} else {
2005-09-28 11:59:34 +00:00
pAPWizard = new CWizardAttachProject ( this ) ;
2005-09-27 09:55:54 +00:00
pDoc - > rpc . get_project_init_status ( pis ) ;
2005-09-28 11:59:34 +00:00
strName = pis . name . c_str ( ) ;
2005-09-27 09:55:54 +00:00
strURL = pis . url . c_str ( ) ;
2005-09-29 00:50:19 +00:00
if ( pis . url . length ( ) & & pis . has_account_key ) {
pAPWizard - > Run ( strName , strURL , true ) ;
} else {
pAPWizard - > Run ( strName , strURL , false ) ;
2005-09-27 09:55:54 +00:00
}
}
if ( pAMWizard )
pAMWizard - > Destroy ( ) ;
if ( pAPWizard )
pAPWizard - > Destroy ( ) ;
2004-10-21 14:29:59 +00:00
2005-08-25 22:00:39 +00:00
m_pRefreshStateTimer - > Start ( ) ;
m_pFrameRenderTimer - > Start ( ) ;
m_pFrameListPanelRenderTimer - > Start ( ) ;
m_pDocumentPollTimer - > Start ( ) ;
2004-12-03 20:30:24 +00:00
2005-11-02 18:28:45 +00:00
m_pNotebook - > SetSelection ( ID_TASK_MESSAGESVIEW - ID_TASK_BASE ) ;
2005-04-08 16:58:55 +00:00
}
2005-08-25 22:00:39 +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-11-29 00:29:43 +00:00
pDoc - > Connect ( wxT ( " localhost " ) , wxEmptyString , TRUE , 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
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 ;
}
2004-09-25 21:33:24 +00:00
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnRefreshState ( wxTimerEvent & event ) {
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 ( ) ;
}
2005-04-07 07:04:50 +00:00
void CMainFrame : : OnFrameRender ( wxTimerEvent & event ) {
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-08-23 20:26:28 +00:00
if ( pDoc - > IsConnected ( ) ) {
static wxDateTime dtLastDialupIsAlreadyOnlineCheck = wxDateTime ( ( time_t ) 0 ) ;
static wxDateTime dtLastDialupAlertSent = wxDateTime ( ( time_t ) 0 ) ;
static wxDateTime dtLastDialupRequest = wxDateTime ( ( time_t ) 0 ) ;
static wxDateTime dtFirstDialupDisconnectEvent = wxDateTime ( ( time_t ) 0 ) ;
static bool already_notified_update_all_projects = false ;
static bool connected_successfully = false ;
static bool reset_timers = false ;
static bool was_dialing = false ;
static bool is_already_online = true ;
bool should_check_connection = false ;
bool is_dialing = false ;
bool is_online = false ;
int want_network = 0 ;
int answer = 0 ;
wxString strConnectionName = wxEmptyString ;
wxString strConnectionUsername = wxEmptyString ;
wxString strConnectionPassword = wxEmptyString ;
wxString strBuffer = wxEmptyString ;
wxTimeSpan tsLastDialupIsAlreadyOnlineCheck ;
wxTimeSpan tsLastDialupAlertSent ;
wxTimeSpan tsLastDialupRequest ;
wxTimeSpan tsFirstDialupDisconnectEvent ;
2005-12-28 12:33:18 +00:00
wxString strDialogTitle = wxEmptyString ;
wxString strDialogMessage = wxEmptyString ;
// Construct the default dialog title for dial-up messages
//
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strDialogTitle . Printf (
_ ( " %s - Network Status " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
2005-08-23 20:26:28 +00:00
if ( m_pDialupManager & & pDoc ) {
// 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
}
2005-08-23 20:26:28 +00:00
// Are we configured to detect a network or told one already exists?
if ( ID_NETWORKLAN ! = m_iNetworkConnectionType ) {
if ( ID_NETWORKDIALUP = = m_iNetworkConnectionType ) {
2005-06-29 05:21:47 +00:00
should_check_connection = true ;
2005-07-01 06:30:06 +00:00
}
2005-08-23 20:26:28 +00:00
if ( ID_NETWORKAUTODETECT = = m_iNetworkConnectionType ) {
if ( ! is_already_online ) {
should_check_connection = true ;
}
}
2005-06-29 05:21:47 +00:00
}
2005-07-01 06:30:06 +00:00
2005-08-23 20:26:28 +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
) ;
2005-10-10 17:29:07 +00:00
wxLogTrace ( wxT ( " Function Status " ) ,
wxT ( " CMainFrame::OnFrameRender - -- confirm_before_connecting = '%d', hangup_if_dialed = '%d' " ) ,
pDoc - > state . global_prefs . confirm_before_connecting , pDoc - > state . global_prefs . hangup_if_dialed
) ;
2005-08-23 20:26:28 +00:00
// 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 ) ;
}
2005-07-01 06:30:06 +00:00
2005-08-23 20:26:28 +00:00
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 " ) ) ;
2005-07-01 06:30:06 +00:00
2005-08-23 20:26:28 +00:00
dtLastDialupAlertSent = wxDateTime : : Now ( ) ;
2005-06-30 06:12:49 +00:00
2005-12-28 12:33:18 +00:00
// 1st %s is the project name
// i.e. 'BOINC', 'GridRepublic'
// 2st %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strDialogMessage . Printf (
_ ( " %s needs a connection to the Internet to perform some "
" maintenance, open the %s to connect up and "
" perform the needed work. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
2005-06-24 10:49:42 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-06-24 10:49:42 +00:00
wxICON_INFORMATION ,
true
) ;
}
2005-08-23 20:26:28 +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 " ) ) ;
2005-06-29 05:21:47 +00:00
2005-08-23 20:26:28 +00:00
dtLastDialupRequest = wxDateTime : : Now ( ) ;
2005-06-29 05:21:47 +00:00
2005-08-23 20:26:28 +00:00
if ( pDoc - > state . global_prefs . confirm_before_connecting ) {
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s needs to connect to the network. \n May it do so now? " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-08-23 20:26:28 +00:00
answer = : : wxMessageBox (
2005-12-28 12:33:18 +00:00
strDialogMessage ,
strDialogTitle ,
2005-08-23 20:26:28 +00:00
wxYES_NO | wxICON_QUESTION ,
this
) ;
} else {
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s is connecting to the internet. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-07-01 06:30:06 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-07-01 06:30:06 +00:00
wxICON_INFORMATION ,
true
) ;
2005-08-23 20:26:28 +00:00
answer = wxYES ;
}
// Are we allow to connect?
if ( wxYES = = answer ) {
if ( m_strNetworkDialupConnectionName . size ( ) )
strConnectionName = m_strNetworkDialupConnectionName ;
2005-06-24 10:49:42 +00:00
2005-08-23 20:26:28 +00:00
if ( m_bNetworkDialupPromptCredentials ) {
CDlgDialupCredentials * pDlgDialupCredentials = new CDlgDialupCredentials ( this ) ;
answer = pDlgDialupCredentials - > ShowModal ( ) ;
if ( wxID_OK = = answer ) {
strConnectionUsername = pDlgDialupCredentials - > GetUsername ( ) ;
strConnectionPassword = pDlgDialupCredentials - > GetPassword ( ) ;
}
if ( pDlgDialupCredentials ) {
pDlgDialupCredentials - > Destroy ( ) ;
}
}
already_notified_update_all_projects = false ;
2005-07-01 06:30:06 +00:00
connected_successfully = false ;
2005-08-23 20:26:28 +00:00
m_pDialupManager - > Dial ( strConnectionName , strConnectionUsername , strConnectionPassword , true ) ;
2005-06-29 18:41:09 +00:00
}
2005-06-24 10:49:42 +00:00
}
}
2005-08-23 20:26:28 +00:00
} else if ( ! is_dialing & & ! was_dialing ) {
if ( is_online & & want_network & & connected_successfully & & ! already_notified_update_all_projects ) {
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
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s has detected it is now connected to the internet. "
" Updating all projects and retrying all transfers. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-08-23 20:26:28 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-08-23 20:26:28 +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 ( ) ) {
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s has successfully disconnected from the internet. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-08-23 20:26:28 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-08-23 20:26:28 +00:00
wxICON_INFORMATION ,
true
) ;
connected_successfully = false ;
2005-12-28 12:33:18 +00:00
2005-08-23 20:26:28 +00:00
} else {
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s failed to disconnected from the internet. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-08-23 20:26:28 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-08-23 20:26:28 +00:00
wxICON_ERROR
) ;
2005-12-28 12:33:18 +00:00
2005-08-23 20:26:28 +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 ) {
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s has successfully connected to the internet. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-08-23 20:26:28 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-08-23 20:26:28 +00:00
wxICON_INFORMATION ,
true
) ;
connected_successfully = true ;
2005-12-28 12:33:18 +00:00
2005-08-23 20:26:28 +00:00
} else {
2005-12-28 12:33:18 +00:00
// %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s failed to connect to the internet. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-08-23 20:26:28 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-08-23 20:26:28 +00:00
wxICON_ERROR ,
true
) ;
connected_successfully = false ;
2005-12-28 12:33:18 +00:00
2005-08-23 20:26:28 +00:00
}
} 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-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILEACTIVITYRUNALWAYS , false ) ;
pMenuBar - > Check ( ID_FILEACTIVITYSUSPEND , false ) ;
pMenuBar - > Check ( ID_FILEACTIVITYRUNBASEDONPREPERENCES , 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-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILEACTIVITYRUNALWAYS , true ) ;
2005-05-29 07:12:00 +00:00
if ( iActivityMode = = RUN_MODE_NEVER )
2005-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILEACTIVITYSUSPEND , true ) ;
2005-05-29 07:12:00 +00:00
if ( iActivityMode = = RUN_MODE_AUTO )
2005-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILEACTIVITYRUNBASEDONPREPERENCES , true ) ;
2005-03-12 01:09:24 +00:00
}
2005-03-09 19:15:20 +00:00
2005-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILENETWORKRUNALWAYS , false ) ;
pMenuBar - > Check ( ID_FILENETWORKSUSPEND , false ) ;
pMenuBar - > Check ( ID_FILENETWORKRUNBASEDONPREPERENCES , 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-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILENETWORKRUNALWAYS , true ) ;
2005-05-29 07:12:00 +00:00
if ( RUN_MODE_NEVER = = iNetworkMode )
2005-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILENETWORKSUSPEND , true ) ;
2005-05-29 07:12:00 +00:00
if ( RUN_MODE_AUTO = = iNetworkMode )
2005-07-22 06:56:34 +00:00
pMenuBar - > Check ( ID_FILENETWORKRUNBASEDONPREPERENCES , 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-11-27 01:28:56 +00:00
if ( pDoc - > IsComputerNameLocal ( strComputerName ) ) {
2005-03-12 01:09:24 +00:00
strTitle + = 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-08-30 11:34:27 +00:00
// The Mac takes a huge performance hit redrawing this window,
2005-05-25 03:36:16 +00:00
// window, so don't change the text unless we really have too.
2005-08-30 11:34:27 +00:00
if ( GetTitle ( ) ! = strTitle )
SetTitle ( strTitle ) ;
2005-05-25 03:36:16 +00:00
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
2005-08-30 11:34:27 +00:00
if ( GetTitle ( ) ! = m_strBaseTitle )
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-09-25 21:33:24 +00:00
2005-04-08 16:58:55 +00:00
void CMainFrame : : OnListPanelRender ( wxTimerEvent & ) {
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-08-31 05:40:59 +00:00
SetFrameListPanelRenderTimerRate ( ) ; // Set to refresh every 5 or 60 seconds
2005-04-08 04:23:37 +00:00
}
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 ( ) ;
2005-08-31 05:40:59 +00:00
SetFrameListPanelRenderTimerRate ( ) ;
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-08-31 05:40:59 +00:00
void CMainFrame : : SetFrameListPanelRenderTimerRate ( ) {
static wxWindowID previousPane = - 1 ;
static int connectedCount = 0 ;
wxWindowID currentPane ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
wxASSERT ( m_pNotebook ) ;
wxASSERT ( m_pFrameListPanelRenderTimer ) ;
wxASSERT ( pDoc ) ;
2005-11-27 01:28:56 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-08-31 05:40:59 +00:00
// Keep timer at faster rate until we have been connected > 10 seconds
if ( ! pDoc - > IsConnected ( ) )
connectedCount = 0 ;
if ( connectedCount < 3 ) {
connectedCount + + ;
previousPane = - 1 ; // Ensure an update when connectedCount reaches 3
if ( m_pFrameListPanelRenderTimer - > IsRunning ( ) )
m_pFrameListPanelRenderTimer - > Stop ( ) ;
m_pFrameListPanelRenderTimer - > Start ( 5000 ) ; // Refresh every 5 seconds
return ;
}
currentPane = m_pNotebook - > GetSelection ( ) + ID_TASK_BASE ;
if ( currentPane = = previousPane )
return ;
previousPane = currentPane ;
if ( m_pFrameListPanelRenderTimer - > IsRunning ( ) )
m_pFrameListPanelRenderTimer - > Stop ( ) ;
switch ( currentPane ) {
case ID_TASK_STATISTICSVIEW :
m_pFrameListPanelRenderTimer - > Start ( 60000 ) ; // Refresh every 1 minute
break ;
default :
m_pFrameListPanelRenderTimer - > Start ( 5000 ) ; // Refresh every 5 seconds
break ;
}
}
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-12-28 12:33:18 +00:00
void CMainFrame : : ShowConnectionBadPasswordAlert ( ) {
wxString strDialogTitle = wxEmptyString ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::ShowConnectionBadPasswordAlert - Function Begin " ) ) ;
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strDialogTitle . Printf (
_ ( " %s - Connection Error " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
ShowAlert (
strDialogTitle ,
_ ( " The password you have provided is incorrect, please try again. " ) ,
wxICON_ERROR
) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::ShowConnectionBadPasswordAlert - Function End " ) ) ;
}
2005-11-27 01:28:56 +00:00
void CMainFrame : : ShowConnectionFailedAlert ( ) {
2005-12-28 12:33:18 +00:00
wxString strDialogTitle = wxEmptyString ;
wxString strDialogMessage = wxEmptyString ;
2005-11-27 01:28:56 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::ShowConnectionFailedAlert - Function Begin " ) ) ;
2005-12-28 12:33:18 +00:00
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strDialogTitle . Printf (
_ ( " %s - Connection Failed " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
// 1st %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
// 2st %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s is not able to connect to a %s client. \n "
2005-11-27 01:28:56 +00:00
" Would you like to try to connect again? " ) ,
2005-12-28 12:33:18 +00:00
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
ShowAlert (
strDialogTitle ,
strDialogMessage ,
2005-11-27 01:28:56 +00:00
wxYES_NO | wxICON_QUESTION ,
false ,
AlertProcessResponse
) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::ShowConnectionFailedAlert - Function End " ) ) ;
}
2005-11-26 11:17:48 +00:00
void CMainFrame : : ShowNotCurrentlyConnectedAlert ( ) {
2005-12-28 12:33:18 +00:00
wxString strDialogTitle = wxEmptyString ;
wxString strDialogMessage = wxEmptyString ;
2005-11-26 11:17:48 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::ShowNotCurrentlyConnectedAlert - Function Begin " ) ) ;
2005-12-28 12:33:18 +00:00
// %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
strDialogTitle . Printf (
_ ( " %s - Connection Status " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( )
) ;
// 1st %s is the application name
// i.e. 'BOINC Manager', 'GridRepublic Manager'
// 2nd %s is the project name
// i.e. 'BOINC', 'GridRepublic'
// 3nd %s is the project name
// i.e. 'BOINC', 'GridRepublic'
strDialogMessage . Printf (
_ ( " %s is not currently connected to a %s client. \n "
" Please use the 'File \\ Select Computer...' menu option to connect up to a %s client. \n "
" To connect up to your local computer please use 'localhost' as the host name. " ) ,
wxGetApp ( ) . GetBrand ( ) - > GetApplicationName ( ) . c_str ( ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( ) ,
wxGetApp ( ) . GetBrand ( ) - > GetProjectName ( ) . c_str ( )
) ;
2005-11-26 11:17:48 +00:00
ShowAlert (
2005-12-28 12:33:18 +00:00
strDialogTitle ,
strDialogMessage ,
2005-11-26 11:17:48 +00:00
wxICON_ERROR
) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CMainFrame::ShowNotCurrentlyConnectedAlert - Function End " ) ) ;
}
2005-11-27 01:28:56 +00:00
void CMainFrame : : ShowAlert ( const wxString title , const wxString message , const int style , const bool notification_only , const MainFrameAlertEventType alert_event_type ) {
CMainFrameAlertEvent event ( wxEVT_MAINFRAME_ALERT , this , title , message , style , notification_only , alert_event_type ) ;
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-11-27 01:28:56 +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-11-27 01:28:56 +00:00
void CMainFrameAlertEvent : : ProcessResponse ( const int response ) const {
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
if ( ( AlertProcessResponse = = m_alert_event_type ) & & ( wxYES = = response ) ) {
pDoc - > Reconnect ( ) ;
}
}
2005-01-02 18:29:53 +00:00
const char * BOINC_RCSID_d881a56dc5 = " $Id$ " ;