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 "ProjectProcessingPage.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 "BOINCBaseWizard.h"
|
2010-08-02 16:01:09 +00:00
|
|
|
#include "WizardAttach.h"
|
2005-09-26 11:29:28 +00:00
|
|
|
#include "ProjectProcessingPage.h"
|
|
|
|
#include "ProjectInfoPage.h"
|
|
|
|
#include "AccountInfoPage.h"
|
2005-09-28 11:59:34 +00:00
|
|
|
#include "CompletionErrorPage.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_PROJECTPROCESSING_STATECHANGE)
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectProcessingPage type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CProjectProcessingPage, wxWizardPageEx )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectProcessingPage event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CProjectProcessingPage, wxWizardPageEx )
|
|
|
|
|
|
|
|
EVT_PROJECTPROCESSING_STATECHANGE( CProjectProcessingPage::OnStateChange )
|
|
|
|
|
|
|
|
////@begin CProjectProcessingPage event table entries
|
|
|
|
EVT_WIZARDEX_PAGE_CHANGED( -1, CProjectProcessingPage::OnPageChanged )
|
|
|
|
EVT_WIZARDEX_CANCEL( -1, CProjectProcessingPage::OnCancel )
|
|
|
|
|
|
|
|
////@end CProjectProcessingPage event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectProcessingPage constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
CProjectProcessingPage::CProjectProcessingPage( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CProjectProcessingPage::CProjectProcessingPage( CBOINCBaseWizard* parent )
|
|
|
|
{
|
|
|
|
Create( parent );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectPropertiesPage creator
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectProcessingPage::Create( CBOINCBaseWizard* parent )
|
|
|
|
{
|
|
|
|
|
|
|
|
////@begin CProjectProcessingPage 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 CProjectProcessingPage member initialisation
|
|
|
|
|
2011-08-27 18:07:28 +00:00
|
|
|
m_bProjectCommunicationsSucceeded = false;
|
2005-09-26 11:29:28 +00:00
|
|
|
m_bProjectUnavailable = false;
|
2005-09-29 00:50:19 +00:00
|
|
|
m_bProjectAccountNotFound = false;
|
2005-09-26 11:29:28 +00:00
|
|
|
m_bProjectAccountAlreadyExists = false;
|
|
|
|
m_iBitmapIndex = 0;
|
|
|
|
m_iCurrentState = ATTACHPROJECT_INIT;
|
|
|
|
|
|
|
|
////@begin CProjectProcessingPage creation
|
2009-11-17 19:19:50 +00:00
|
|
|
wxWizardPageEx::Create( parent, ID_PROJECTPROCESSINGPAGE );
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
CreateControls();
|
|
|
|
GetSizer()->Fit(this);
|
|
|
|
////@end CProjectProcessingPage creation
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Control creation for CProjectPropertiesPage
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectProcessingPage::CreateControls()
|
|
|
|
{
|
|
|
|
////@begin CProjectProcessingPage content construction
|
2006-01-27 00:34:53 +00:00
|
|
|
CProjectProcessingPage* itemWizardPage36 = this;
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
|
|
|
|
itemWizardPage36->SetSizer(itemBoxSizer37);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
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
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
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);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|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;
|
|
|
|
m_pProgressIndicator->Create( itemWizardPage36, ID_PROGRESSCTRL, itemBitmap41, wxDefaultPosition, wxSize(184, 48), 0 );
|
|
|
|
itemFlexGridSizer40->Add(m_pProgressIndicator, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
|
2005-09-26 11:29:28 +00:00
|
|
|
////@end CProjectProcessingPage content construction
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Gets the previous page.
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxWizardPageEx* CProjectProcessingPage::GetPrev() const
|
|
|
|
{
|
|
|
|
return PAGE_TRANSITION_BACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Gets the next page.
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxWizardPageEx* CProjectProcessingPage::GetNext() const
|
|
|
|
{
|
|
|
|
if (CHECK_CLOSINGINPROGRESS()) {
|
|
|
|
// Cancel Event Detected
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
|
|
|
|
} else if (GetProjectAttachSucceeded()) {
|
|
|
|
// We were successful in creating or retrieving an account
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_COMPLETIONPAGE);
|
2011-08-27 18:07:28 +00:00
|
|
|
} else if (!GetProjectCommunicationsSucceeded() && GetProjectAccountAlreadyExists()) {
|
2005-09-26 11:29:28 +00:00
|
|
|
// The requested account already exists
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_ERRALREADYEXISTSPAGE);
|
2011-08-27 18:07:28 +00:00
|
|
|
} else if (!GetProjectCommunicationsSucceeded() && GetProjectAccountNotFound()) {
|
2005-09-26 11:29:28 +00:00
|
|
|
// The requested account does not exist or the password is bad
|
|
|
|
return PAGE_TRANSITION_NEXT(ID_ERRNOTFOUNDPAGE);
|
|
|
|
} else {
|
2008-11-25 17:34:29 +00:00
|
|
|
// An error must have occurred
|
2005-09-28 11:59:34 +00:00
|
|
|
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
|
2005-09-26 11:29:28 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectProcessingPage::ShowToolTips()
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CProjectProcessingPage::StartProgress(wxStaticBitmap* pBitmap) {
|
|
|
|
m_iBitmapIndex = 1;
|
|
|
|
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CProjectProcessingPage::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 CProjectProcessingPage::FinishProgress(wxStaticBitmap* pBitmap) {
|
|
|
|
m_iBitmapIndex = 12;
|
|
|
|
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap CProjectProcessingPage::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
if (name == wxT("res/wizprogress01.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress01_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress02.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress02_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress03.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress03_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress04.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress04_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress05.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress05_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress06.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress06_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress07.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress07_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress08.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress08_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress09.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress09_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress10.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress10_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress11.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress11_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
else if (name == wxT("res/wizprogress12.xpm"))
|
|
|
|
{
|
|
|
|
wxBitmap bitmap(wizprogress12_xpm);
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
return wxNullBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
wxIcon CProjectProcessingPage::GetIconResource( const wxString& WXUNUSED(name) )
|
2005-09-26 11:29:28 +00:00
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin CProjectProcessingPage icon retrieval
|
|
|
|
return wxNullIcon;
|
|
|
|
////@end CProjectProcessingPage icon retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_WIZARD_PAGE_CHANGED event handler for ID_ATTACHPROJECTPAGE
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectProcessingPage::OnPageChanged( wxWizardExEvent& event ) {
|
|
|
|
if (event.GetDirection() == false) return;
|
2006-01-27 00:34:53 +00:00
|
|
|
|
|
|
|
wxASSERT(m_pTitleStaticCtrl);
|
|
|
|
wxASSERT(m_pProgressIndicator);
|
|
|
|
|
|
|
|
m_pTitleStaticCtrl->SetLabel(
|
2009-11-01 00:34:12 +00:00
|
|
|
_("Communicating with project.")
|
2006-01-27 00:34:53 +00:00
|
|
|
);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2011-08-27 18:07:28 +00:00
|
|
|
SetProjectCommunicationsSucceeded(false);
|
2005-09-26 11:29:28 +00:00
|
|
|
SetProjectUnavailable(false);
|
|
|
|
SetProjectAccountAlreadyExists(false);
|
|
|
|
SetNextState(ATTACHPROJECT_INIT);
|
|
|
|
|
|
|
|
CProjectProcessingPageEvent TransitionEvent(wxEVT_PROJECTPROCESSING_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_ACCOUNTCREATIONPAGE
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectProcessingPage::OnCancel( wxWizardExEvent& event ) {
|
|
|
|
PROCESS_CANCELEVENT(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_ACCOUNTCREATION_STATECHANGE event handler for ID_ACCOUNTCREATIONPAGE
|
|
|
|
*/
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
void CProjectProcessingPage::OnStateChange( CProjectProcessingPageEvent& WXUNUSED(event) )
|
2005-09-26 11:29:28 +00:00
|
|
|
{
|
2010-08-02 16:01:09 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CWizardAttach* pWA = ((CWizardAttach*)GetParent());
|
|
|
|
ACCOUNT_IN* ai = &pWA->account_in;
|
|
|
|
ACCOUNT_OUT* ao = &pWA->account_out;
|
2005-09-30 19:00:53 +00:00
|
|
|
unsigned int i;
|
|
|
|
PROJECT_ATTACH_REPLY reply;
|
|
|
|
wxString strBuffer = wxEmptyString;
|
2005-09-26 11:29:28 +00:00
|
|
|
wxDateTime dtStartExecutionTime;
|
|
|
|
wxDateTime dtCurrentExecutionTime;
|
|
|
|
wxTimeSpan tsExecutionTime;
|
|
|
|
bool bPostNewEvent = true;
|
2011-08-27 18:32:47 +00:00
|
|
|
int retval = 0;
|
2007-01-15 21:22:23 +00:00
|
|
|
bool creating_account = false;
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
switch(GetCurrentState()) {
|
|
|
|
case ATTACHPROJECT_INIT:
|
2010-08-02 16:01:09 +00:00
|
|
|
pWA->DisableNextButton();
|
|
|
|
pWA->DisableBackButton();
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
StartProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
SetNextState(ATTACHPROJECT_ACCOUNTQUERY_BEGIN);
|
|
|
|
break;
|
|
|
|
case ATTACHPROJECT_ACCOUNTQUERY_BEGIN:
|
|
|
|
SetNextState(ATTACHPROJECT_ACCOUNTQUERY_EXECUTE);
|
|
|
|
break;
|
|
|
|
case ATTACHPROJECT_ACCOUNTQUERY_EXECUTE:
|
2014-02-20 07:54:52 +00:00
|
|
|
// Attempt to create the account or retrieve the authenticator.
|
2005-09-26 11:29:28 +00:00
|
|
|
ai->clear();
|
|
|
|
ao->clear();
|
|
|
|
|
client/manager/server: use HTTPS for web RPCs if possible
The web RPCs done by the client during project attach
(lookup_account, create_account)
have an email address and password hash in their request.
Network sniffers could potentially see these,
so we should use HTTPS for these RPCs if possible.
However, not all BOINC projects have SSL-enabled web servers.
So I did the following:
- Change get_project_config.php to return an additional
<web_rpc_url_base> element.
This is SECURE_URL_BASE (if specified in the project's
project.inc config file) or, if not, the master URL.
- This new element is parsed into the PROJECT_CONFIG structure.
- In calls to create_account and lookup_account,
the Manager uses PROJECT_CONFIG::web_rpc_url_base
if it's available, else the master URL.
So, the new Manager/client uses HTTPS for RPCs to projects
that have updated their get_project_config.php,
and specify a SECURE_URL_BASE with https:// prefix.
Android note: I added code to parse the new config element,
but didn't change the higher-level code;
Joachim will need to do this.
2014-01-28 21:25:59 +00:00
|
|
|
// use the web RPC URL in the get_project_config response
|
|
|
|
// if present, otherwise use what the user typed
|
|
|
|
//
|
|
|
|
if (!pWA->project_config.web_rpc_url_base.empty()) {
|
|
|
|
ai->url = pWA->project_config.web_rpc_url_base;
|
|
|
|
} else if (!pWA->project_config.master_url.empty()) {
|
2010-08-02 16:01:09 +00:00
|
|
|
ai->url = pWA->project_config.master_url;
|
2009-03-05 21:36:35 +00:00
|
|
|
} else {
|
2010-08-02 16:01:09 +00:00
|
|
|
ai->url = (const char*)pWA->m_ProjectInfoPage->GetProjectURL().mb_str();
|
2009-03-05 21:36:35 +00:00
|
|
|
}
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2010-08-02 16:01:09 +00:00
|
|
|
if (!pWA->GetProjectAuthenticator().IsEmpty() ||
|
|
|
|
pWA->m_bCredentialsCached ||
|
|
|
|
pWA->m_bCredentialsDetected
|
2005-09-28 11:59:34 +00:00
|
|
|
) {
|
2010-08-02 16:01:09 +00:00
|
|
|
if (!pWA->m_bCredentialsCached || pWA->m_bCredentialsDetected) {
|
|
|
|
ao->authenticator = (const char*)pWA->GetProjectAuthenticator().mb_str();
|
2005-09-28 11:59:34 +00:00
|
|
|
}
|
2011-08-27 18:07:28 +00:00
|
|
|
SetProjectCommunicationsSucceeded(true);
|
2005-09-26 11:29:28 +00:00
|
|
|
} else {
|
2006-02-02 08:33:23 +00:00
|
|
|
// Setup initial values for both the create and lookup API
|
2010-08-19 00:22:25 +00:00
|
|
|
|
|
|
|
if (pWA->project_config.uses_username) {
|
|
|
|
ai->email_addr = (const char*)pWA->m_AccountInfoPage->GetAccountUsername().mb_str();
|
|
|
|
} else {
|
|
|
|
ai->email_addr = (const char*)pWA->m_AccountInfoPage->GetAccountEmailAddress().mb_str();
|
|
|
|
}
|
2010-08-02 16:01:09 +00:00
|
|
|
ai->passwd = (const char*)pWA->m_AccountInfoPage->GetAccountPassword().mb_str();
|
2006-03-23 01:17:07 +00:00
|
|
|
ai->user_name = (const char*)::wxGetUserName().mb_str();
|
2007-10-24 07:53:29 +00:00
|
|
|
if (ai->user_name.empty()) {
|
|
|
|
ai->user_name = (const char*)::wxGetUserId().mb_str();
|
|
|
|
}
|
2010-08-02 16:01:09 +00:00
|
|
|
//ai->team_name = (const char*)pWA->GetTeamName().mb_str();
|
2006-02-02 08:33:23 +00:00
|
|
|
|
2010-08-02 16:01:09 +00:00
|
|
|
if (pWA->m_AccountInfoPage->m_pAccountCreateCtrl->GetValue()) {
|
2007-01-15 21:22:23 +00:00
|
|
|
creating_account = true;
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
// Wait until we are done processing the request.
|
|
|
|
dtStartExecutionTime = wxDateTime::Now();
|
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2011-08-27 18:32:47 +00:00
|
|
|
retval = 0;
|
2009-06-14 05:04:02 +00:00
|
|
|
ao->error_num = ERR_RETRY;
|
2006-02-23 21:16:12 +00:00
|
|
|
while (
|
2011-08-27 18:32:47 +00:00
|
|
|
!retval &&
|
2009-06-14 05:04:02 +00:00
|
|
|
((ERR_IN_PROGRESS == ao->error_num) || (ERR_RETRY == ao->error_num)) &&
|
2005-09-26 11:29:28 +00:00
|
|
|
tsExecutionTime.GetSeconds() <= 60 &&
|
2006-02-23 21:16:12 +00:00
|
|
|
!CHECK_CLOSINGINPROGRESS()
|
2009-06-14 05:04:02 +00:00
|
|
|
) {
|
2009-07-23 22:47:48 +00:00
|
|
|
if (ERR_RETRY == ao->error_num) {
|
2009-06-14 05:04:02 +00:00
|
|
|
pDoc->rpc.create_account(*ai);
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:29:28 +00:00
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2011-08-27 18:32:47 +00:00
|
|
|
retval = pDoc->rpc.create_account_poll(*ao);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
IncrementProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
::wxMilliSleep(500);
|
|
|
|
::wxSafeYield(GetParent());
|
|
|
|
}
|
|
|
|
|
2011-08-27 18:32:47 +00:00
|
|
|
if ((!retval) && !ao->error_num) {
|
2010-08-02 16:01:09 +00:00
|
|
|
pWA->SetAccountCreatedSuccessfully(true);
|
2005-09-26 11:29:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
2009-06-14 05:04:02 +00:00
|
|
|
creating_account = false;
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
// Wait until we are done processing the request.
|
|
|
|
dtStartExecutionTime = wxDateTime::Now();
|
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2011-08-27 18:32:47 +00:00
|
|
|
retval = 0;
|
2009-06-14 05:04:02 +00:00
|
|
|
ao->error_num = ERR_RETRY;
|
2006-02-23 21:16:12 +00:00
|
|
|
while (
|
2011-08-27 18:32:47 +00:00
|
|
|
!retval &&
|
2009-06-14 05:04:02 +00:00
|
|
|
((ERR_IN_PROGRESS == ao->error_num) || (ERR_RETRY == ao->error_num)) &&
|
2005-09-26 11:29:28 +00:00
|
|
|
tsExecutionTime.GetSeconds() <= 60 &&
|
|
|
|
!CHECK_CLOSINGINPROGRESS()
|
2009-06-14 05:04:02 +00:00
|
|
|
) {
|
2009-07-23 22:47:48 +00:00
|
|
|
if (ERR_RETRY == ao->error_num) {
|
2011-08-27 18:32:47 +00:00
|
|
|
retval = pDoc->rpc.lookup_account(*ai);
|
|
|
|
if (retval) {
|
|
|
|
// REPORT ERROR
|
|
|
|
}
|
2009-06-14 05:04:02 +00:00
|
|
|
}
|
|
|
|
|
2005-09-26 11:29:28 +00:00
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2011-08-27 18:32:47 +00:00
|
|
|
retval = pDoc->rpc.lookup_account_poll(*ao);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
IncrementProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
::wxMilliSleep(500);
|
|
|
|
::wxSafeYield(GetParent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 18:32:47 +00:00
|
|
|
|
|
|
|
if ((!retval) && !ao->error_num) {
|
2011-08-27 18:07:28 +00:00
|
|
|
SetProjectCommunicationsSucceeded(true);
|
2005-09-26 11:29:28 +00:00
|
|
|
} else {
|
2011-08-27 18:07:28 +00:00
|
|
|
SetProjectCommunicationsSucceeded(false);
|
2006-02-01 12:18:10 +00:00
|
|
|
|
2007-01-15 21:22:23 +00:00
|
|
|
if ((ao->error_num == ERR_DB_NOT_UNIQUE)
|
|
|
|
|| (ao->error_num == ERR_NONUNIQUE_EMAIL)
|
|
|
|
|| (ao->error_num == ERR_BAD_PASSWD && creating_account)
|
|
|
|
) {
|
2005-09-26 11:29:28 +00:00
|
|
|
SetProjectAccountAlreadyExists(true);
|
|
|
|
} else {
|
|
|
|
SetProjectAccountAlreadyExists(false);
|
|
|
|
}
|
2006-02-01 12:18:10 +00:00
|
|
|
|
|
|
|
if ((ERR_NOT_FOUND == ao->error_num) ||
|
2006-09-08 22:28:10 +00:00
|
|
|
(ao->error_num == ERR_DB_NOT_FOUND) ||
|
2006-02-01 12:18:10 +00:00
|
|
|
(ERR_BAD_EMAIL_ADDR == ao->error_num) ||
|
2009-06-19 06:42:36 +00:00
|
|
|
(ERR_BAD_PASSWD == ao->error_num)
|
|
|
|
) {
|
2005-09-26 11:29:28 +00:00
|
|
|
SetProjectAccountNotFound(true);
|
|
|
|
} else {
|
|
|
|
SetProjectAccountNotFound(false);
|
|
|
|
}
|
2006-02-01 12:18:10 +00:00
|
|
|
|
2010-08-02 16:01:09 +00:00
|
|
|
strBuffer = pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
|
2009-06-19 06:42:36 +00:00
|
|
|
if ((HTTP_STATUS_NOT_FOUND == ao->error_num)) {
|
2006-02-23 08:24:19 +00:00
|
|
|
strBuffer +=
|
2009-11-01 00:34:12 +00:00
|
|
|
_("Required files not found on the server.");
|
2009-06-19 06:42:36 +00:00
|
|
|
} else if ((HTTP_STATUS_INTERNAL_SERVER_ERROR == ao->error_num)) {
|
2006-02-23 08:24:19 +00:00
|
|
|
strBuffer +=
|
2009-11-01 00:34:12 +00:00
|
|
|
_("An internal server error has occurred.");
|
2006-02-23 08:24:19 +00:00
|
|
|
} else {
|
2006-09-08 22:28:10 +00:00
|
|
|
if (ao->error_msg.size()) {
|
|
|
|
strBuffer += wxString(ao->error_msg.c_str(), wxConvUTF8) + wxString(wxT("\n"));
|
2006-02-22 01:32:20 +00:00
|
|
|
}
|
2005-09-30 19:00:53 +00:00
|
|
|
}
|
2010-08-02 16:01:09 +00:00
|
|
|
pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
|
2005-09-26 11:29:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SetNextState(ATTACHPROJECT_ATTACHPROJECT_BEGIN);
|
|
|
|
break;
|
|
|
|
case ATTACHPROJECT_ATTACHPROJECT_BEGIN:
|
|
|
|
SetNextState(ATTACHPROJECT_ATTACHPROJECT_EXECUTE);
|
|
|
|
break;
|
|
|
|
case ATTACHPROJECT_ATTACHPROJECT_EXECUTE:
|
2011-08-27 18:07:28 +00:00
|
|
|
if (GetProjectCommunicationsSucceeded()) {
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
// Wait until we are done processing the request.
|
|
|
|
dtStartExecutionTime = wxDateTime::Now();
|
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2011-08-27 18:32:47 +00:00
|
|
|
retval = 0;
|
2009-06-14 05:04:02 +00:00
|
|
|
reply.error_num = ERR_RETRY;
|
|
|
|
while (
|
2011-08-27 18:32:47 +00:00
|
|
|
!retval &&
|
2009-06-14 05:04:02 +00:00
|
|
|
((ERR_IN_PROGRESS == reply.error_num) || (ERR_RETRY == reply.error_num)) &&
|
2005-09-26 11:29:28 +00:00
|
|
|
tsExecutionTime.GetSeconds() <= 60 &&
|
|
|
|
!CHECK_CLOSINGINPROGRESS()
|
2009-06-14 05:04:02 +00:00
|
|
|
) {
|
|
|
|
if (ERR_RETRY == reply.error_num) {
|
2010-08-02 16:01:09 +00:00
|
|
|
if (pWA->m_bCredentialsCached) {
|
2009-06-14 05:04:02 +00:00
|
|
|
pDoc->rpc.project_attach_from_file();
|
|
|
|
} else {
|
2014-02-20 08:20:59 +00:00
|
|
|
std::string master_url;
|
2014-02-20 07:54:52 +00:00
|
|
|
if (!pWA->project_config.master_url.empty()) {
|
|
|
|
master_url = pWA->project_config.master_url;
|
|
|
|
} else {
|
|
|
|
master_url = (const char*)pWA->m_ProjectInfoPage->GetProjectURL().mb_str();
|
|
|
|
}
|
2009-06-14 05:04:02 +00:00
|
|
|
pDoc->rpc.project_attach(
|
2014-02-20 07:54:52 +00:00
|
|
|
master_url.c_str(),
|
2009-06-14 05:04:02 +00:00
|
|
|
ao->authenticator.c_str(),
|
2010-08-02 16:01:09 +00:00
|
|
|
pWA->project_config.name.c_str()
|
2009-06-14 05:04:02 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:29:28 +00:00
|
|
|
dtCurrentExecutionTime = wxDateTime::Now();
|
|
|
|
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
|
2011-08-27 18:32:47 +00:00
|
|
|
retval = pDoc->rpc.project_attach_poll(reply);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
2006-01-27 00:34:53 +00:00
|
|
|
IncrementProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
|
|
|
|
::wxMilliSleep(500);
|
|
|
|
::wxSafeYield(GetParent());
|
|
|
|
}
|
|
|
|
|
2011-08-27 18:32:47 +00:00
|
|
|
if (!retval && !reply.error_num) {
|
2005-09-26 11:29:28 +00:00
|
|
|
SetProjectAttachSucceeded(true);
|
2010-08-02 16:01:09 +00:00
|
|
|
pWA->SetAttachedToProjectSuccessfully(true);
|
|
|
|
pWA->SetProjectURL(wxString(ai->url.c_str(), wxConvUTF8));
|
|
|
|
pWA->SetProjectAuthenticator(wxString(ao->authenticator.c_str(), wxConvUTF8));
|
2005-09-26 11:29:28 +00:00
|
|
|
} else {
|
|
|
|
SetProjectAttachSucceeded(false);
|
2006-02-23 08:24:19 +00:00
|
|
|
|
2010-08-02 16:01:09 +00:00
|
|
|
strBuffer = pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
|
2009-06-19 06:42:36 +00:00
|
|
|
if ((HTTP_STATUS_INTERNAL_SERVER_ERROR == reply.error_num)) {
|
2006-02-23 08:24:19 +00:00
|
|
|
strBuffer +=
|
2009-11-01 00:34:12 +00:00
|
|
|
_("An internal server error has occurred.");
|
2005-09-30 19:00:53 +00:00
|
|
|
} else {
|
|
|
|
for (i=0; i<reply.messages.size(); i++) {
|
2006-03-23 01:17:07 +00:00
|
|
|
strBuffer += wxString(reply.messages[i].c_str(), wxConvUTF8) + wxString(wxT("\n"));
|
2005-09-30 19:00:53 +00:00
|
|
|
}
|
2005-09-28 11:59:34 +00:00
|
|
|
}
|
2012-10-16 19:56:34 +00:00
|
|
|
pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
|
2005-09-26 11:29:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SetProjectAttachSucceeded(false);
|
|
|
|
}
|
|
|
|
SetNextState(ATTACHPROJECT_CLEANUP);
|
|
|
|
break;
|
|
|
|
case ATTACHPROJECT_CLEANUP:
|
2006-01-27 00:34:53 +00:00
|
|
|
FinishProgress(m_pProgressIndicator);
|
2005-09-26 11:29:28 +00:00
|
|
|
SetNextState(ATTACHPROJECT_END);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Allow a glimps of what the result was before advancing to the next page.
|
|
|
|
wxSleep(1);
|
2010-08-02 16:01:09 +00:00
|
|
|
pWA->EnableNextButton();
|
|
|
|
pWA->EnableBackButton();
|
|
|
|
pWA->SimulateNextButton();
|
2005-09-26 11:29:28 +00:00
|
|
|
bPostNewEvent = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Update();
|
|
|
|
|
|
|
|
if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
|
|
|
|
CProjectProcessingPageEvent TransitionEvent(wxEVT_PROJECTPROCESSING_STATECHANGE, this);
|
|
|
|
AddPendingEvent(TransitionEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|