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 "ProjectPropertiesPage.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "network.h"
|
|
|
|
#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"
|
2006-01-23 08:47:05 +00:00
|
|
|
#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 "BOINCBaseWizard.h"
|
2010-08-02 16:01:09 +00:00
|
|
|
#include "WizardAttach.h"
|
2005-09-26 11:29:28 +00:00
|
|
|
#include "ProjectPropertiesPage.h"
|
|
|
|
#include "ProjectInfoPage.h"
|
2008-11-25 17:34:29 +00:00
|
|
|
#include "CompletionErrorPage.h"
|
2008-11-25 22:58:14 +00:00
|
|
|
#include "TermsOfUsePage.h"
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
#include "res/wizprogress01.xpm"
|
|
|
|
#include "res/wizprogress02.xpm"
|
|
|
|
#include "res/wizprogress03.xpm"
|
|
|
|
#include "res/wizprogress04.xpm"
|
|
|
|
#include "res/wizprogress05.xpm"
|
|
|
|
#include "res/wizprogress06.xpm"
|
|
|
|
#include "res/wizprogress07.xpm"
|
|
|
|
#include "res/wizprogress08.xpm"
|
|
|
|
#include "res/wizprogress09.xpm"
|
|
|
|
#include "res/wizprogress10.xpm"
|
|
|
|
#include "res/wizprogress11.xpm"
|
|
|
|
#include "res/wizprogress12.xpm"
|
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectPropertiesPage custom event definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_PROJECTPROPERTIES_STATECHANGE)
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectPropertiesPage type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CProjectPropertiesPage, wxWizardPageEx )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectPropertiesPage event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CProjectPropertiesPage, wxWizardPageEx )
|
|
|
|
|
|
|
|
EVT_PROJECTPROPERTIES_STATECHANGE( CProjectPropertiesPage::OnStateChange )
|
|
|
|
|
|
|
|
////@begin CProjectPropertiesPage event table entries
|
|
|
|
EVT_WIZARDEX_PAGE_CHANGED( -1, CProjectPropertiesPage::OnPageChanged )
|
|
|
|
EVT_WIZARDEX_CANCEL( -1, CProjectPropertiesPage::OnCancel )
|
|
|
|
|
|
|
|
////@end CProjectPropertiesPage event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectPropertiesPage constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
CProjectPropertiesPage::CProjectPropertiesPage( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CProjectPropertiesPage::CProjectPropertiesPage( CBOINCBaseWizard* parent )
|
|
|
|
{
|
|
|
|
Create( parent );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WizardPage creator
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectPropertiesPage::Create( CBOINCBaseWizard* parent )
|
|
|
|
{
|
|
|
|
////@begin CProjectPropertiesPage member initialisation
|
2006-01-27 00:34:53 +00:00
|
|
|
m_pTitleStaticCtrl = NULL;
|
|
|
|
m_pProgressIndicator = NULL;
|
2005-09-26 11:29:28 +00:00
|
|
|
////@end CProjectPropertiesPage member initialisation
|
|
|
|
|
|
|
|
m_bProjectPropertiesSucceeded = false;
|
|
|
|
m_bProjectPropertiesURLFailure = false;
|
2009-06-19 06:42:36 +00:00
|
|
|
m_bProjectPropertiesCommunicationFailure = false;
|
2005-09-26 11:29:28 +00:00
|
|
|
m_bProjectAccountCreationDisabled = false;
|
|
|
|
m_bProjectClientAccountCreationDisabled = false;
|
2009-07-28 05:53:51 +00:00
|
|
|
m_bNetworkConnectionNotDetected = false;
|
2008-11-25 17:34:29 +00:00
|
|
|
m_bServerReportedError = false;
|
2008-11-25 22:58:14 +00:00
|
|
|
m_bTermsOfUseRequired = true;
|
2005-09-26 11:29:28 +00:00
|
|
|
m_iBitmapIndex = 0;
|
|
|
|
m_iCurrentState = PROJPROP_INIT;
|
|
|
|
|
|
|
|
////@begin CProjectPropertiesPage creation
|
2009-11-17 19:19:50 +00:00
|
|
|
wxWizardPageEx::Create( parent, ID_PROJECTPROPERTIESPAGE );
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
CreateControls();
|
|
|
|
GetSizer()->Fit(this);
|
|
|
|
////@end CProjectPropertiesPage creation
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Control creation for WizardPage
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectPropertiesPage::CreateControls()
|
|
|
|
{
|
|
|
|
////@begin CProjectPropertiesPage content construction
|
|
|
|
CProjectPropertiesPage* itemWizardPage36 = this;
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
|
|
|
|
itemWizardPage36->SetSizer(itemBoxSizer37);
|
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
m_pTitleStaticCtrl = new wxStaticText;
|
|
|
|
m_pTitleStaticCtrl->Create( itemWizardPage36, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana")));
|
|
|
|
itemBoxSizer37->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
|
|
|
|
wxFlexGridSizer* itemFlexGridSizer40 = new wxFlexGridSizer(1, 3, 0, 0);
|
|
|
|
itemFlexGridSizer40->AddGrowableRow(0);
|
|
|
|
itemFlexGridSizer40->AddGrowableCol(0);
|
|
|
|
itemFlexGridSizer40->AddGrowableCol(1);
|
|
|
|
itemFlexGridSizer40->AddGrowableCol(2);
|
|
|
|
itemBoxSizer37->Add(itemFlexGridSizer40, 0, wxGROW|wxALL, 5);
|
|
|
|
|
2014-04-30 22:37:06 +00:00
|
|
|
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxALL, 5);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
wxBitmap itemBitmap41(GetBitmapResource(wxT("res/wizprogress01.xpm")));
|
|
|
|
m_pProgressIndicator = new wxStaticBitmap;
|
2014-09-11 08:47:58 +00:00
|
|
|
m_pProgressIndicator->Create( itemWizardPage36, ID_PROGRESSCTRL, itemBitmap41, wxDefaultPosition, wxSize(ADJUSTFORXDPI(184), ADJUSTFORYDPI(48)), 0 );
|
2006-01-27 00:34:53 +00:00
|
|
|
itemFlexGridSizer40->Add(m_pProgressIndicator, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2014-04-30 22:37:06 +00:00
|
|
|
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxALL, 5);
|
2005-09-26 11:29:28 +00:00
|
|
|
////@end CProjectPropertiesPage content construction
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Gets the previous page.
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxWizardPageEx* CProjectPropertiesPage::GetPrev() const
|
|
|
|
{
|
|
|
|
return PAGE_TRANSITION_BACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Gets the next page.
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxWizardPageEx* CProjectPropertiesPage::GetNext() const
|
|
|
|
{
|
|
|
|
if (CHECK_CLOSINGINPROGRESS()) {
|
|
|
|
// Cancel Event Detected
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
|
2008-11-25 22:58:14 +00:00
|
|
|
} else if (GetProjectPropertiesSucceeded() && GetTermsOfUseRequired()) {
|
|
|
|
// Terms of Use are required before requesting account information
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_TERMSOFUSEPAGE);
|
2009-06-19 16:30:08 +00:00
|
|
|
} else if (GetProjectPropertiesSucceeded() && GetCredentialsAlreadyAvailable()) {
|
|
|
|
// Credentials are already available, do whatever we need to do.
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_PROJECTPROCESSINGPAGE);
|
2005-09-26 11:29:28 +00:00
|
|
|
} else if (GetProjectPropertiesSucceeded()) {
|
|
|
|
// We were successful in retrieving the project properties
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_ACCOUNTINFOPAGE);
|
2009-07-29 05:27:18 +00:00
|
|
|
} else if (GetProjectPropertiesCommunicationFailure() && GetNetworkConnectionNotDetected()) {
|
2006-09-01 16:58:44 +00:00
|
|
|
// No Internet Connection
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_ERRPROXYINFOPAGE);
|
2006-08-31 21:29:44 +00:00
|
|
|
} else if (GetProjectPropertiesURLFailure()) {
|
2005-09-26 11:29:28 +00:00
|
|
|
// Not a BOINC based project
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_ERRNOTDETECTEDPAGE);
|
2008-11-25 17:34:29 +00:00
|
|
|
} else if (GetServerReportedError()) {
|
|
|
|
// Server reported an error, display the error
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
|
2005-09-26 11:29:28 +00:00
|
|
|
} else {
|
2006-03-21 00:42:55 +00:00
|
|
|
// The project must be down for maintenance
|
2005-09-26 11:29:28 +00:00
|
|
|
return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectPropertiesPage::ShowToolTips()
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CProjectPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
|
|
|
|
m_iBitmapIndex = 1;
|
|
|
|
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CProjectPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
|
|
|
|
m_iBitmapIndex += 1;
|
|
|
|
if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
|
|
|
|
|
|
|
|
wxString str;
|
|
|
|
str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
|
|
|
|
|
|
|
|
pBitmap->SetBitmap(GetBitmapResource(str));
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CProjectPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
|
|
|
|
m_iBitmapIndex = 12;
|
|
|
|
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap CProjectPropertiesPage::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
// TODO: Choose from multiple size images if provided, else resize the closest one
|
2005-09-26 11:29:28 +00:00
|
|
|
// Bitmap retrieval
|
|
|
|
if (name == wxT("res/wizprogress01.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress01_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress02.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress02_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress03.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress03_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress04.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress04_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress05.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress05_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress06.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress06_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress07.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress07_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress08.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress08_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress09.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress09_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress10.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress10_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress11.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress11_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress12.xpm"))
|
|
|
|
{
|
2014-09-11 08:47:58 +00:00
|
|
|
wxBitmap bitmap(GetScaledBitmapFromXPMData(wizprogress12_xpm));
|
2005-09-26 11:29:28 +00:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
return wxNullBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
wxIcon CProjectPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
|
2005-09-26 11:29:28 +00:00
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin CProjectPropertiesPage icon retrieval
|
|
|
|
return wxNullIcon;
|
|
|
|
////@end CProjectPropertiesPage icon retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
|
|
|
|
*/
|
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
void CProjectPropertiesPage::OnPageChanged( wxWizardExEvent& event ) {
|
2005-09-26 11:29:28 +00:00
|
|
|
if (event.GetDirection() == false) return;
|
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
wxASSERT(m_pTitleStaticCtrl);
|
|
|
|
wxASSERT(m_pProgressIndicator);
|
|
|
|
|
|
|
|
m_pTitleStaticCtrl->SetLabel(
|
|
|
|
_("Communicating with project\nPlease wait...")
|
|
|
|
);
|
|
|
|
|
2005-09-26 11:29:28 +00:00
|
|
|
SetProjectPropertiesSucceeded(false);
|
|
|
|
SetProjectPropertiesURLFailure(false);
|
2009-06-19 06:42:36 +00:00
|
|
|
SetProjectPropertiesCommunicationFailure(false);
|
2005-09-26 11:29:28 +00:00
|
|
|
SetProjectAccountCreationDisabled(false);
|
|
|
|
SetProjectClientAccountCreationDisabled(false);
|
2009-07-28 05:53:51 +00:00
|
|
|
SetNetworkConnectionNotDetected(false);
|
2005-09-26 11:29:28 +00:00
|
|
|
SetNextState(PROJPROP_INIT);
|
|
|
|
|
|
|
|
CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
|
|
|
|
AddPendingEvent(TransitionEvent);
|
2006-01-27 00:34:53 +00:00
|
|
|
|
|
|
|
Fit();
|
2005-09-26 11:29:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectPropertiesPage::OnCancel( wxWizardExEvent& event ) {
|
|
|
|
PROCESS_CANCELEVENT(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
|
|
|
|
*/
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
void CProjectPropertiesPage::OnStateChange( CProjectPropertiesPageEvent& WXUNUSED(event) )
|
2005-09-26 11:29:28 +00:00
|
|
|
{
|
2010-08-02 16:01:09 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CWizardAttach* pWAP = ((CWizardAttach*)GetParent());
|
|
|
|
PROJECT_CONFIG* pc = &pWAP->project_config;
|
2006-08-29 23:54:36 +00:00
|
|
|
CC_STATUS status;
|
2005-09-26 11:29:28 +00:00
|
|
|
wxDateTime dtStartExecutionTime;
|
|
|
|
wxDateTime dtCurrentExecutionTime;
|
|
|
|
wxTimeSpan tsExecutionTime;
|
2008-11-25 17:34:29 +00:00
|
|
|
wxString strBuffer = wxEmptyString;
|
2005-09-26 11:29:28 +00:00
|
|
|
bool bPostNewEvent = true;
|
|
|
|
int iReturnValue = 0;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
switch(GetCurrentState()) {
|
|
|
|
case PROJPROP_INIT:
|
2006-03-23 01:17:07 +00:00
|
|
|
pWAP->DisableNextButton();
|
|
|
|
pWAP->DisableBackButton();
|
2006-01-27 00:34:53 +00:00
|
|
|
StartProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
SetNextState(PROJPROP_RETRPROJECTPROPERTIES_BEGIN);
|
|
|
|
break;
|
|
|
|
case PROJPROP_RETRPROJECTPROPERTIES_BEGIN:
|
|
|
|
SetNextState(PROJPROP_RETRPROJECTPROPERTIES_EXECUTE);
|
|
|
|
break;
|
|
|
|
case PROJPROP_RETRPROJECTPROPERTIES_EXECUTE:
|
|
|
|
// Attempt to retrieve the project's account creation policies
|
|
|
|
|
|
|
|
// Wait until we are done processing the request.
|
|
|
|
dtStartExecutionTime = wxDateTime::Now();
|
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2005-09-29 00:50:19 +00:00
|
|
|
iReturnValue = 0;
|
2006-08-31 08:27:20 +00:00
|
|
|
pc->clear();
|
2009-06-14 05:04:02 +00:00
|
|
|
pc->error_num = ERR_RETRY;
|
|
|
|
while (
|
|
|
|
!iReturnValue &&
|
|
|
|
((ERR_IN_PROGRESS == pc->error_num) || (ERR_RETRY == pc->error_num)) &&
|
|
|
|
tsExecutionTime.GetSeconds() <= 60 &&
|
|
|
|
!CHECK_CLOSINGINPROGRESS()
|
|
|
|
) {
|
|
|
|
if (ERR_RETRY == pc->error_num) {
|
|
|
|
pDoc->rpc.get_project_config(
|
2015-01-12 20:08:36 +00:00
|
|
|
(const char*)pWAP->GetProjectURL().mb_str()
|
2009-06-14 05:04:02 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:29:28 +00:00
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
|
|
|
iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
|
2006-01-27 00:34:53 +00:00
|
|
|
IncrementProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
::wxMilliSleep(500);
|
2014-04-08 20:28:50 +00:00
|
|
|
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_USER_INPUT);
|
2005-09-26 11:29:28 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 22:10:27 +00:00
|
|
|
if (
|
|
|
|
!iReturnValue
|
|
|
|
&& (!pc->error_num || pc->error_num == ERR_ACCT_CREATION_DISABLED)
|
2020-04-12 22:26:31 +00:00
|
|
|
) {
|
|
|
|
if (pc->account_manager) {
|
|
|
|
// user tried to attach an account manager as a project
|
|
|
|
//
|
|
|
|
SetProjectPropertiesSucceeded(false);
|
|
|
|
SetServerReportedError(true);
|
|
|
|
strBuffer = pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
|
|
|
|
strBuffer += wxString(pc->name);
|
|
|
|
strBuffer += wxString(wxT(" is an account manager, not a project.\nSelect Tools / Use account manager.\n"));
|
|
|
|
pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
|
|
|
|
} else {
|
|
|
|
// We either successfully retrieved the project's
|
|
|
|
// account creation policies or we were able to talk
|
|
|
|
// to the web server and found out they do not support
|
|
|
|
// account creation through the wizard.
|
|
|
|
// In either case, claim success and set the correct flags
|
|
|
|
// to show the correct 'next' page.
|
|
|
|
//
|
|
|
|
SetProjectPropertiesSucceeded(true);
|
|
|
|
SetProjectAccountCreationDisabled(pc->account_creation_disabled);
|
|
|
|
SetProjectClientAccountCreationDisabled(pc->client_account_creation_disabled);
|
|
|
|
SetTermsOfUseRequired(!pc->terms_of_use.empty());
|
|
|
|
}
|
2005-09-26 11:29:28 +00:00
|
|
|
} else {
|
2009-07-28 04:06:14 +00:00
|
|
|
|
2005-09-26 11:29:28 +00:00
|
|
|
SetProjectPropertiesSucceeded(false);
|
2012-02-07 17:54:09 +00:00
|
|
|
SetProjectPropertiesURLFailure(pc->error_num == ERR_HTTP_PERMANENT);
|
2008-11-25 17:34:29 +00:00
|
|
|
|
2009-06-30 22:10:27 +00:00
|
|
|
bool comm_failure = !iReturnValue && (
|
2009-07-29 05:27:18 +00:00
|
|
|
(ERR_GETHOSTBYNAME == pc->error_num)
|
|
|
|
|| (ERR_CONNECT == pc->error_num)
|
2009-06-30 22:10:27 +00:00
|
|
|
|| (ERR_XML_PARSE == pc->error_num)
|
2009-07-28 04:06:14 +00:00
|
|
|
|| (ERR_PROJECT_DOWN == pc->error_num)
|
2009-06-30 22:10:27 +00:00
|
|
|
);
|
|
|
|
SetProjectPropertiesCommunicationFailure(comm_failure);
|
2008-11-25 17:34:29 +00:00
|
|
|
|
2009-06-30 22:10:27 +00:00
|
|
|
bool server_reported_error = !iReturnValue && (
|
2012-02-07 17:54:09 +00:00
|
|
|
(ERR_HTTP_PERMANENT != pc->error_num)
|
2009-06-30 22:10:27 +00:00
|
|
|
&& (ERR_GETHOSTBYNAME != pc->error_num)
|
|
|
|
&& (ERR_CONNECT != pc->error_num)
|
|
|
|
&& (ERR_XML_PARSE != pc->error_num)
|
|
|
|
&& (ERR_PROJECT_DOWN != pc->error_num)
|
|
|
|
);
|
|
|
|
SetServerReportedError(server_reported_error);
|
2009-07-28 04:06:14 +00:00
|
|
|
|
2009-06-30 22:10:27 +00:00
|
|
|
if (server_reported_error) {
|
2008-11-25 17:34:29 +00:00
|
|
|
strBuffer = pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
|
|
|
|
if (pc->error_msg.size()) {
|
|
|
|
strBuffer += wxString(pc->error_msg.c_str(), wxConvUTF8) + wxString(wxT("\n"));
|
|
|
|
}
|
|
|
|
pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
|
|
|
|
}
|
2005-09-26 11:29:28 +00:00
|
|
|
}
|
2009-06-19 18:48:36 +00:00
|
|
|
|
|
|
|
SetNextState(PROJPROP_DETERMINENETWORKSTATUS_BEGIN);
|
2005-09-26 11:29:28 +00:00
|
|
|
break;
|
|
|
|
case PROJPROP_DETERMINENETWORKSTATUS_BEGIN:
|
|
|
|
SetNextState(PROJPROP_DETERMINENETWORKSTATUS_EXECUTE);
|
|
|
|
break;
|
|
|
|
case PROJPROP_DETERMINENETWORKSTATUS_EXECUTE:
|
|
|
|
// Attempt to determine if we are even connected to a network
|
2006-08-29 23:54:36 +00:00
|
|
|
|
|
|
|
// Wait until we are done processing the request.
|
|
|
|
dtStartExecutionTime = wxDateTime::Now();
|
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
|
|
|
iReturnValue = 0;
|
|
|
|
status.network_status = NETWORK_STATUS_LOOKUP_PENDING;
|
|
|
|
while ((!iReturnValue && (NETWORK_STATUS_LOOKUP_PENDING == status.network_status)) &&
|
|
|
|
tsExecutionTime.GetSeconds() <= 60 &&
|
|
|
|
!CHECK_CLOSINGINPROGRESS()
|
|
|
|
)
|
|
|
|
{
|
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2007-05-31 18:02:53 +00:00
|
|
|
iReturnValue = pDoc->GetCoreClientStatus(status);
|
2006-08-29 23:54:36 +00:00
|
|
|
IncrementProgress(m_pProgressIndicator);
|
|
|
|
|
|
|
|
::wxMilliSleep(500);
|
2014-04-08 20:28:50 +00:00
|
|
|
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_USER_INPUT);
|
2006-08-29 23:54:36 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 05:53:51 +00:00
|
|
|
SetNetworkConnectionNotDetected(NETWORK_STATUS_WANT_CONNECTION == status.network_status);
|
2006-08-29 23:54:36 +00:00
|
|
|
|
2009-06-19 16:30:08 +00:00
|
|
|
SetNextState(PROJPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN);
|
|
|
|
break;
|
|
|
|
case PROJPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN:
|
|
|
|
SetNextState(PROJPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE);
|
|
|
|
break;
|
|
|
|
case PROJPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE:
|
|
|
|
// Determine if the account settings are already pre-populated.
|
|
|
|
// If so, advance to the Project Processing page.
|
2020-06-14 22:23:48 +00:00
|
|
|
SetCredentialsAlreadyAvailable(pWAP->IsCredentialsCached() || pWAP->IsCredentialsDetected());
|
2009-06-19 16:30:08 +00:00
|
|
|
|
|
|
|
SetNextState(PROJPROP_CLEANUP);
|
2005-09-26 11:29:28 +00:00
|
|
|
break;
|
|
|
|
case PROJPROP_CLEANUP:
|
2006-01-27 00:34:53 +00:00
|
|
|
FinishProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
SetNextState(PROJPROP_END);
|
|
|
|
break;
|
|
|
|
default:
|
2021-10-01 06:32:40 +00:00
|
|
|
// Allow a glimpse of what the result was before advancing to the next page.
|
2005-09-26 11:29:28 +00:00
|
|
|
wxSleep(1);
|
2006-03-23 01:17:07 +00:00
|
|
|
pWAP->EnableNextButton();
|
|
|
|
pWAP->EnableBackButton();
|
|
|
|
pWAP->SimulateNextButton();
|
2005-09-26 11:29:28 +00:00
|
|
|
bPostNewEvent = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Update();
|
|
|
|
|
|
|
|
if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
|
|
|
|
CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
|
|
|
|
AddPendingEvent(TransitionEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|