2008-08-06 18:36:30 +00:00
// This file is part of BOINC.
2005-09-26 11:29:28 +00:00
// http://boinc.berkeley.edu
2008-08-06 18:36:30 +00:00
// Copyright (C) 2008 University of California
2005-09-26 11:29:28 +00:00
//
2008-08-06 18:36:30 +00:00
// BOINC 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 3 of the License, or (at your option) any later version.
2005-09-26 11:29:28 +00:00
//
2008-08-06 18:36:30 +00:00
// BOINC is distributed in the hope that it will be useful,
2005-09-26 11:29:28 +00:00
// 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.
//
2008-08-06 18:36:30 +00:00
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
2005-09-26 11:29:28 +00:00
//
# if defined(__GNUG__) && !defined(__APPLE__)
# pragma implementation "WelcomePage.h"
# endif
# include "stdwx.h"
2006-10-20 15:00:14 +00:00
# include "diagnostics.h"
# include "util.h"
# include "mfile.h"
# include "miofile.h"
# include "parse.h"
# include "error_numbers.h"
2005-09-26 11:29:28 +00:00
# include "wizardex.h"
# include "error_numbers.h"
# include "BOINCGUIApp.h"
2006-10-20 15:00:14 +00:00
# include "SkinManager.h"
# include "MainDocument.h"
2005-09-26 11:29:28 +00:00
# include "BOINCWizards.h"
# include "BOINCBaseWizard.h"
2006-02-16 19:03:02 +00:00
# include "WizardAttachProject.h"
2005-09-26 11:29:28 +00:00
# include "WelcomePage.h"
////@begin XPM images
////@end XPM images
/*!
* CWelcomePage type definition
*/
IMPLEMENT_DYNAMIC_CLASS ( CWelcomePage , wxWizardPageEx )
/*!
* CWelcomePage event table definition
*/
BEGIN_EVENT_TABLE ( CWelcomePage , wxWizardPageEx )
////@begin CWelcomePage event table entries
EVT_WIZARDEX_PAGE_CHANGED ( - 1 , CWelcomePage : : OnPageChanged )
2009-06-19 06:42:36 +00:00
EVT_RADIOBUTTON ( ID_WELCOMESELECTWIZARDPROJECT , CWelcomePage : : OnWizardSelectionChanged )
EVT_RADIOBUTTON ( ID_WELCOMESELECTWIZARDACCOUNTMGR , CWelcomePage : : OnWizardSelectionChanged )
EVT_BUTTON ( ID_WELCOMECHANGEAPPS , CWelcomePage : : OnChangeApplications )
2005-09-26 11:29:28 +00:00
EVT_WIZARDEX_CANCEL ( - 1 , CWelcomePage : : OnCancel )
////@end CWelcomePage event table entries
END_EVENT_TABLE ( )
/*!
* CWelcomePage constructors
*/
CWelcomePage : : CWelcomePage ( )
{
}
CWelcomePage : : CWelcomePage ( CBOINCBaseWizard * parent )
{
Create ( parent ) ;
}
/*!
* WizardPage creator
*/
bool CWelcomePage : : Create ( CBOINCBaseWizard * parent )
{
////@begin CWelcomePage member initialisation
2006-01-27 00:34:53 +00:00
m_pTitleStaticCtrl = NULL ;
m_pDescriptionStaticCtrl = NULL ;
2009-06-19 06:42:36 +00:00
m_pAttachToProjectCtrl = NULL ;
m_pAttachToAccountManagerCtrl = NULL ;
2006-01-27 00:34:53 +00:00
m_pDirectionsStaticCtrl = NULL ;
2005-09-26 11:29:28 +00:00
////@end CWelcomePage member initialisation
////@begin CWelcomePage creation
2009-11-17 19:19:50 +00:00
wxWizardPageEx : : Create ( parent , ID_WELCOMEPAGE ) ;
2005-09-26 11:29:28 +00:00
CreateControls ( ) ;
GetSizer ( ) - > Fit ( this ) ;
////@end CWelcomePage creation
return TRUE ;
}
/*!
* Control creation for WizardPage
*/
void CWelcomePage : : CreateControls ( )
{
////@begin CWelcomePage content construction
CWelcomePage * itemWizardPage2 = this ;
wxBoxSizer * itemBoxSizer3 = new wxBoxSizer ( wxVERTICAL ) ;
itemWizardPage2 - > SetSizer ( itemBoxSizer3 ) ;
2006-01-27 00:34:53 +00:00
m_pTitleStaticCtrl = new wxStaticText ;
2010-05-07 16:14:54 +00:00
m_pTitleStaticCtrl - > Create ( itemWizardPage2 , wxID_STATIC , wxEmptyString , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-01-27 00:34:53 +00:00
m_pTitleStaticCtrl - > SetFont ( wxFont ( 12 , wxSWISS , wxNORMAL , wxBOLD , FALSE , _T ( " Verdana " ) ) ) ;
itemBoxSizer3 - > Add ( m_pTitleStaticCtrl , 0 , wxALIGN_LEFT | wxALL , 5 ) ;
2005-09-26 11:29:28 +00:00
2006-01-27 00:34:53 +00:00
m_pDescriptionStaticCtrl = new wxStaticText ;
m_pDescriptionStaticCtrl - > Create ( itemWizardPage2 , wxID_STATIC , wxEmptyString , wxDefaultPosition , wxDefaultSize , 0 ) ;
itemBoxSizer3 - > Add ( m_pDescriptionStaticCtrl , 0 , wxALIGN_LEFT | wxALL , 5 ) ;
2005-09-26 11:29:28 +00:00
itemBoxSizer3 - > Add ( 5 , 5 , 0 , wxALIGN_LEFT | wxALL , 5 ) ;
2009-05-13 12:42:05 +00:00
wxFlexGridSizer * itemFlexGridSizer62 = new wxFlexGridSizer ( 2 , 1 , 0 , 0 ) ;
itemFlexGridSizer62 - > AddGrowableCol ( 1 ) ;
itemBoxSizer3 - > Add ( itemFlexGridSizer62 , 0 , wxGROW | wxALL , 5 ) ;
2009-06-19 06:42:36 +00:00
m_pAttachToProjectCtrl = new wxRadioButton ;
m_pAttachToProjectCtrl - > Create ( itemWizardPage2 , ID_WELCOMESELECTWIZARDPROJECT , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxRB_GROUP ) ;
m_pAttachToProjectCtrl - > SetValue ( TRUE ) ;
itemFlexGridSizer62 - > Add ( m_pAttachToProjectCtrl , 0 , wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2009-05-13 12:42:05 +00:00
2009-06-19 06:42:36 +00:00
m_pAttachToAccountManagerCtrl = new wxRadioButton ;
m_pAttachToAccountManagerCtrl - > Create ( itemWizardPage2 , ID_WELCOMESELECTWIZARDACCOUNTMGR , wxEmptyString , wxDefaultPosition , wxDefaultSize , 0 ) ;
m_pAttachToAccountManagerCtrl - > SetValue ( FALSE ) ;
itemFlexGridSizer62 - > Add ( m_pAttachToAccountManagerCtrl , 0 , wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2005-09-26 11:29:28 +00:00
2006-01-27 00:34:53 +00:00
m_pDirectionsStaticCtrl = new wxStaticText ;
m_pDirectionsStaticCtrl - > Create ( itemWizardPage2 , wxID_STATIC , wxEmptyString , wxDefaultPosition , wxDefaultSize , 0 ) ;
itemBoxSizer3 - > Add ( m_pDirectionsStaticCtrl , 0 , wxALIGN_LEFT | wxALL , 5 ) ;
2005-09-26 11:29:28 +00:00
2009-06-19 06:42:36 +00:00
m_pChangeApplicationsCtrl = new wxButton ;
m_pChangeApplicationsCtrl - > Create ( itemWizardPage2 , ID_WELCOMECHANGEAPPS , wxEmptyString , wxDefaultPosition , wxDefaultSize , 0 ) ;
itemBoxSizer3 - > Add ( m_pChangeApplicationsCtrl , 0 , wxALIGN_CENTER , 5 ) ;
2008-10-14 23:07:40 +00:00
2007-03-09 23:44:34 +00:00
itemWizardPage2 - > SetSizer ( itemBoxSizer3 ) ;
2009-11-19 11:58:35 +00:00
# ifdef __WXMAC__
//Accessibility
HIViewRef buttonView = ( HIViewRef ) m_pAttachToProjectCtrl - > GetHandle ( ) ;
HIObjectRef theObject = ( HIObjectRef ) HIViewGetSuperview ( buttonView ) ;
HIObjectSetAccessibilityIgnored ( theObject , true ) ;
# endif
2005-09-26 11:29:28 +00:00
////@end CWelcomePage content construction
}
2006-01-25 11:58:02 +00:00
2008-10-14 23:07:40 +00:00
/*
2005-09-26 11:29:28 +00:00
* Gets the previous page .
*/
wxWizardPageEx * CWelcomePage : : GetPrev ( ) const
{
return NULL ;
}
/*!
* Gets the next page .
*/
wxWizardPageEx * CWelcomePage : : GetNext ( ) const
{
if ( CHECK_CLOSINGINPROGRESS ( ) ) {
// Cancel Event Detected
return PAGE_TRANSITION_NEXT ( ID_COMPLETIONERRORPAGE ) ;
} else if ( IS_ATTACHTOPROJECTWIZARD ( ) ) {
return PAGE_TRANSITION_NEXT ( ID_PROJECTINFOPAGE ) ;
2009-06-19 06:42:36 +00:00
} else if ( IS_ACCOUNTMANAGERUPDATEWIZARD ( ) ) {
2006-02-16 19:03:02 +00:00
return PAGE_TRANSITION_NEXT ( ID_ACCOUNTMANAGERPROCESSINGPAGE ) ;
2006-01-27 00:34:53 +00:00
} else if ( IS_ACCOUNTMANAGERWIZARD ( ) ) {
2005-09-26 11:29:28 +00:00
return PAGE_TRANSITION_NEXT ( ID_ACCOUNTMANAGERINFOPAGE ) ;
}
return NULL ;
}
/*!
* Should we show tooltips ?
*/
bool CWelcomePage : : ShowToolTips ( )
{
return TRUE ;
}
/*!
* Get bitmap resources
*/
2006-07-21 08:23:26 +00:00
wxBitmap CWelcomePage : : GetBitmapResource ( const wxString & WXUNUSED ( name ) )
2005-09-26 11:29:28 +00:00
{
// Bitmap retrieval
////@begin CWelcomePage bitmap retrieval
return wxNullBitmap ;
////@end CWelcomePage bitmap retrieval
}
/*!
* Get icon resources
*/
2006-07-21 08:23:26 +00:00
wxIcon CWelcomePage : : GetIconResource ( const wxString & WXUNUSED ( name ) )
2005-09-26 11:29:28 +00:00
{
// Icon retrieval
////@begin CWelcomePage icon retrieval
return wxNullIcon ;
////@end CWelcomePage icon retrieval
}
/*!
* wxEVT_WIZARD_PAGE_CHANGED event handler for ID_WELCOMEPAGE
*/
void CWelcomePage : : OnPageChanged ( wxWizardExEvent & event ) {
2006-01-27 00:34:53 +00:00
if ( event . GetDirection ( ) = = false ) return ;
2009-06-19 16:30:08 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CWelcomePage::OnPageChanged - Function Begin " ) ) ;
2006-01-27 00:34:53 +00:00
2007-08-02 20:03:21 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
ACCT_MGR_INFO ami ;
bool is_acct_mgr_detected = false ;
2009-06-19 06:42:36 +00:00
bool is_wcg_client = false ;
2007-08-02 20:03:21 +00:00
wxString strBuffer = wxEmptyString ;
2006-02-16 19:03:02 +00:00
2007-08-02 20:03:21 +00:00
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2006-01-27 00:34:53 +00:00
wxASSERT ( m_pTitleStaticCtrl ) ;
wxASSERT ( m_pDescriptionStaticCtrl ) ;
2009-06-19 06:42:36 +00:00
wxASSERT ( m_pAttachToProjectCtrl ) ;
wxASSERT ( m_pAttachToAccountManagerCtrl ) ;
2006-01-27 00:34:53 +00:00
wxASSERT ( m_pDirectionsStaticCtrl ) ;
2009-06-19 06:42:36 +00:00
wxASSERT ( m_pChangeApplicationsCtrl ) ;
2006-01-27 00:34:53 +00:00
2009-05-13 12:42:05 +00:00
2009-06-19 06:42:36 +00:00
# if defined (_WCG)
// Determine if we are the World Community Grid version of the client
// and connected to World Community Grid
2010-02-01 18:42:00 +00:00
std : : string wcgUrl = " http://www.worldcommunitygrid.org/ " ;
if ( pDoc - > state . lookup_project ( wcgUrl ) ) {
2009-06-19 06:42:36 +00:00
is_wcg_client = true ;
2009-05-13 12:42:05 +00:00
}
2009-06-19 06:42:36 +00:00
# endif
2009-05-13 12:42:05 +00:00
2009-06-03 04:01:29 +00:00
2009-06-19 06:42:36 +00:00
m_pTitleStaticCtrl - > SetLabel (
_ ( " Attach to project or account manager " )
) ;
2007-08-02 20:03:21 +00:00
2009-06-19 06:42:36 +00:00
pDoc - > rpc . acct_mgr_info ( ami ) ;
is_acct_mgr_detected = ami . acct_mgr_url . size ( ) ? true : false ;
2007-08-02 20:03:21 +00:00
2009-06-19 06:42:36 +00:00
if ( is_acct_mgr_detected ) {
2006-02-16 19:03:02 +00:00
strBuffer . Printf (
2009-06-19 06:42:36 +00:00
_ ( " If possible, add projects at the \n %s web site. \n \n Projects added via this wizard will not be \n listed on or managed via %s. " ) ,
wxString ( ami . acct_mgr_name . c_str ( ) , wxConvUTF8 ) . c_str ( ) ,
wxString ( ami . acct_mgr_name . c_str ( ) , wxConvUTF8 ) . c_str ( )
2006-02-16 19:03:02 +00:00
) ;
2009-06-19 06:42:36 +00:00
2006-02-16 19:03:02 +00:00
m_pDescriptionStaticCtrl - > SetLabel (
strBuffer
) ;
2009-06-19 06:42:36 +00:00
m_pAttachToAccountManagerCtrl - > Disable ( ) ;
2006-01-27 00:34:53 +00:00
} else {
2009-06-19 06:42:36 +00:00
if ( ! is_wcg_client ) {
m_pDescriptionStaticCtrl - > SetLabel (
2010-05-07 16:14:54 +00:00
_ ( " There are over 30 BOINC-based projects \n \
doing research in many areas of science , \ n \
and you can volunteer for as many of them as you like . \ n \
You can attach to a project directly , \ n \
or use an ' Account Manager ' web site to select projects . " )
2009-06-19 06:42:36 +00:00
) ;
} else {
m_pDescriptionStaticCtrl - > SetLabel (
2010-05-07 16:14:54 +00:00
_ ( " You have chosen to attach to a new BOINC project. Attaching to a new \n project means that you will be connecting your computer to a new organization. \n If this is what you wanted to do, please click on \n the 'Next' button below. \n \n Some projects like World Community Grid run multiple research applications. \n If you want to change which research applications are sent to your computer \n to run, visit the project's website and modify your \n preferences there. \n \n To change which research applications are sent to you from \n World Community Grid then please click on the following button: " )
2009-06-19 06:42:36 +00:00
) ;
m_pChangeApplicationsCtrl - > SetLabel (
_ ( " Change Research Applications at World Community Grid " )
) ;
}
m_pAttachToAccountManagerCtrl - > Enable ( ) ;
2006-01-27 00:34:53 +00:00
}
2009-06-19 06:42:36 +00:00
m_pAttachToProjectCtrl - > SetLabel (
_ ( " Attach to project " )
2006-01-27 00:34:53 +00:00
) ;
2009-06-19 06:42:36 +00:00
m_pAttachToAccountManagerCtrl - > SetLabel (
_ ( " Attach to account manager " )
2006-01-27 00:34:53 +00:00
) ;
2009-06-19 06:42:36 +00:00
if ( ! is_wcg_client ) {
2008-10-17 18:37:45 +00:00
m_pDirectionsStaticCtrl - > SetLabel (
_ ( " To continue, click Next. " )
) ;
2009-06-19 06:42:36 +00:00
m_pChangeApplicationsCtrl - > Hide ( ) ;
2008-10-17 18:37:45 +00:00
}
2006-01-27 00:34:53 +00:00
2006-01-27 08:11:29 +00:00
Fit ( ) ;
2007-03-09 23:44:34 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CWelcomePage::OnPageChanged - Function End " ) ) ;
2005-09-26 11:29:28 +00:00
}
2009-06-19 06:42:36 +00:00
2005-09-26 11:29:28 +00:00
/*!
2009-06-19 06:42:36 +00:00
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_WELCOMESELECTWIZARDPROJECT
* or ID_WELCOMESELECTWIZARDACCOUNTMGR
2005-09-26 11:29:28 +00:00
*/
2009-06-19 06:42:36 +00:00
void CWelcomePage : : OnWizardSelectionChanged ( wxCommandEvent & event ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CWelcomePage::OnWizardSelectionChanged - Function Begin " ) ) ;
2005-09-26 11:29:28 +00:00
2009-06-19 06:42:36 +00:00
CWizardAttachProject * pWAP = ( ( CWizardAttachProject * ) GetParent ( ) ) ;
2007-03-09 23:44:34 +00:00
2009-06-19 06:42:36 +00:00
wxASSERT ( pWAP ) ;
wxASSERT ( wxDynamicCast ( pWAP , CWizardAttachProject ) ) ;
2007-03-09 23:44:34 +00:00
2009-06-19 06:42:36 +00:00
if ( ID_WELCOMESELECTWIZARDPROJECT = = event . GetId ( ) ) {
pWAP - > IsAttachToProjectWizard = true ;
pWAP - > IsAccountManagerWizard = false ;
} else if ( ID_WELCOMESELECTWIZARDACCOUNTMGR = = event . GetId ( ) ) {
pWAP - > IsAttachToProjectWizard = false ;
pWAP - > IsAccountManagerWizard = true ;
}
2007-03-09 23:44:34 +00:00
2009-06-19 06:42:36 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CWelcomePage::OnWizardSelectionChanged - Function End " ) ) ;
2007-03-09 23:44:34 +00:00
}
2009-06-19 06:42:36 +00:00
2008-10-14 23:07:40 +00:00
/*!
2009-06-19 06:42:36 +00:00
* wxEVT_BUTTON event handler for ID_WELCOMECHANGEAPPS
2008-10-14 23:07:40 +00:00
*/
2009-06-19 06:42:36 +00:00
void CWelcomePage : : OnChangeApplications ( wxCommandEvent & /* event */ ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CWelcomePage::OnChangeApplications - Function Begin " ) ) ;
2008-10-17 18:37:45 +00:00
CWizardAttachProject * pWAP = ( ( CWizardAttachProject * ) GetParent ( ) ) ;
2008-10-14 23:07:40 +00:00
2009-06-19 06:42:36 +00:00
wxASSERT ( pWAP ) ;
wxASSERT ( wxDynamicCast ( pWAP , CWizardAttachProject ) ) ;
2009-05-13 12:42:05 +00:00
2009-12-19 05:16:41 +00:00
wxLaunchDefaultBrowser ( wxT ( " http://www.worldcommunitygrid.org/ms/viewMyProjects.do " ) ) ;
2009-06-19 06:42:36 +00:00
pWAP - > SimulateCancelButton ( ) ;
2009-05-13 12:42:05 +00:00
2009-06-19 06:42:36 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CWelcomePage::OnChangeApplications - Function End " ) ) ;
2009-05-13 12:42:05 +00:00
}
2009-06-19 06:42:36 +00:00
/*!
* wxEVT_WIZARD_CANCEL event handler for ID_WELCOMEPAGE
*/
void CWelcomePage : : OnCancel ( wxWizardExEvent & event ) {
PROCESS_CANCELEVENT ( event ) ;
}