void CSimpleProjectPanel::OnWizardUpdate() { wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardUpdate - Function Begin")); CMainDocument* pDoc = wxGetApp().GetDocument(); CSimpleGUIPanel* pPanel = wxDynamicCast(GetParent(), CSimpleGUIPanel); wxASSERT(pDoc); wxASSERT(pPanel); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); if (!pDoc->IsUserAuthorized()) return; if (!pDoc->IsConnected()) return; pPanel->SetDlgOpen(true); CWizardAttach* pWizard = new CWizardAttach(this); pWizard->SyncToAccountManager(); if (pWizard) pWizard->Destroy(); // btnSynchronize->Refresh(); pPanel->SetDlgOpen(false); wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardUpdate - Function End")); }
void CSimpleFrame::OnProjectsAttachToProject(wxCommandEvent& WXUNUSED(event)) { wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnProjectsAttachToProject - Function Begin")); CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); if (!pDoc->IsUserAuthorized()) return; if (pDoc->IsConnected()) { CWizardAttach* pWizard = new CWizardAttach(this); wxString strURL = wxEmptyString; pWizard->Run(strURL, false); if (pWizard) pWizard->Destroy(); } else { ShowNotCurrentlyConnectedAlert(); } wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnProjectsAttachToProject - Function End")); }
void CTermsOfUsePage::OnPageChanging( wxWizardExEvent& event ) { CWizardAttach* pWA = ((CWizardAttach*)GetParent()); wxASSERT(pWA); wxASSERT(wxDynamicCast(pWA, CWizardAttach)); // If the user has left the terms of use disagree radio button // selected, then the next button is disabled and needs to be // re-enabled if the back button is pressed. pWA->EnableNextButton(); if (event.GetDirection() == false) return; if (!CHECK_CLOSINGINPROGRESS()) { // We are leaving this page. // Determine if the account settings are already pre-populated. // If so, advance to the Account Manager Processing page or the // Project Processing page. if ( pWA->m_bCredentialsCached || pWA->m_bCredentialsDetected) { SetCredentialsAlreadyAvailable(true); } else { SetCredentialsAlreadyAvailable(false); } } }
void CAccountManagerInfoPage::OnPageChanging( wxWizardExEvent& event ) { if (event.GetDirection() == false) return; CWizardAttach* pWA = ((CWizardAttach*)GetParent()); CAcctMgrListItem* pItem = (CAcctMgrListItem*)(m_pProjectListCtrl->GetClientData(m_pProjectListCtrl->GetSelection())); // Update authoritative data in CWizardAttach pWA->SetProjectURL(pItem->GetURL()); pWA->SetProjectName(pItem->GetName()); }
wxWizardPageEx* CProjectWelcomePage::GetNext() const { CWizardAttach* pWA = ((CWizardAttach*)GetParent()); wxASSERT(pWA); if (CHECK_CLOSINGINPROGRESS()) { // Cancel Event Detected return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE); } else if (pWA->GetProjectAuthenticator().IsEmpty()) { return PAGE_TRANSITION_NEXT(ID_ACCOUNTINFOPAGE); } else { return PAGE_TRANSITION_NEXT(ID_PROJECTPROCESSINGPAGE); } return NULL; }
void CAccountInfoPage::OnPageChanged( wxWizardExEvent& event ) { if (event.GetDirection() == false) return; CWizardAttach* pWA = ((CWizardAttach*)GetParent()); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); CSkinWizardATAM* pSkinWizardATAM = wxGetApp().GetSkinManager()->GetWizards()->GetWizardATAM(); PROJECT_CONFIG& pc = pWA->project_config; wxString strBaseConfigLocation = wxString(wxT("/Wizards")); wxConfigBase* pConfig = wxConfigBase::Get(FALSE); wxASSERT(pSkinAdvanced); wxASSERT(pSkinWizardATAM); wxASSERT(m_pTitleStaticCtrl); wxASSERT(m_pCookieDetectionFailedStaticCtrl); wxASSERT(m_pCookieDetectionFailedCtrl); wxASSERT(m_pAccountQuestionStaticCtrl); wxASSERT(m_pAccountInformationStaticCtrl); wxASSERT(m_pAccountCreateCtrl); wxASSERT(m_pAccountUseExistingCtrl); wxASSERT(m_pAccountEmailAddressStaticCtrl); wxASSERT(m_pAccountEmailAddressCtrl); wxASSERT(m_pAccountUsernameStaticCtrl); wxASSERT(m_pAccountUsernameCtrl); wxASSERT(m_pAccountPasswordStaticCtrl); wxASSERT(m_pAccountPasswordCtrl); wxASSERT(m_pAccountConfirmPasswordStaticCtrl); wxASSERT(m_pAccountConfirmPasswordCtrl); wxASSERT(m_pAccountPasswordRequirmentsStaticCtrl); wxASSERT(m_pAccountManagerLinkLabelStaticCtrl); wxASSERT(m_pAccountForgotPasswordCtrl); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); wxASSERT(wxDynamicCast(pSkinWizardATAM, CSkinWizardATAM)); // We are entering this page, so reterieve the previously used email // address and/or username. pConfig->SetPath(strBaseConfigLocation); m_strAccountEmailAddress = pConfig->Read(wxT("DefaultEmailAddress")); m_strAccountUsername = pConfig->Read(wxT("DefaultUsername")); // Setup the desired controls and default values. static bool bRunOnce = true; if (bRunOnce) { bRunOnce = false; if (!IS_ACCOUNTMANAGERWIZARD()) { m_pAccountCreateCtrl->SetValue(true); m_pAccountUseExistingCtrl->SetValue(false); } } if (IS_ACCOUNTMANAGERWIZARD()) { if (!(pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected)) { m_pCookieDetectionFailedStaticCtrl->Hide(); m_pCookieDetectionFailedCtrl->Hide(); } else { m_pCookieDetectionFailedStaticCtrl->Show(); m_pCookieDetectionFailedCtrl->Show(); } m_pAccountQuestionStaticCtrl->Hide(); m_pAccountCreateCtrl->SetValue(false); m_pAccountCreateCtrl->Hide(); m_pAccountUseExistingCtrl->SetValue(true); m_pAccountUseExistingCtrl->Hide(); m_pAccountConfirmPasswordStaticCtrl->Hide(); m_pAccountConfirmPasswordCtrl->Hide(); m_pAccountPasswordRequirmentsStaticCtrl->Hide(); if (pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected) { m_pAccountManagerLinkLabelStaticCtrl->Hide(); m_pAccountForgotPasswordCtrl->Hide(); } } else { m_pCookieDetectionFailedStaticCtrl->Hide(); m_pCookieDetectionFailedCtrl->Hide(); if (pc.account_creation_disabled || pc.client_account_creation_disabled) { m_pAccountCreateCtrl->SetValue(false); m_pAccountCreateCtrl->Hide(); m_pAccountUseExistingCtrl->SetValue(true); m_pAccountUseExistingCtrl->Hide(); } else { m_pAccountCreateCtrl->Show(); m_pAccountCreateCtrl->Enable(); m_pAccountUseExistingCtrl->Show(); } m_pAccountManagerLinkLabelStaticCtrl->Hide(); } wxString str; wxString name = wxString(pc.name.c_str(), wxConvUTF8); str.Printf(_("Identify your account at %s"), name.c_str()); m_pTitleStaticCtrl->SetLabel(str); if (!IS_ACCOUNTMANAGERWIZARD() && !IS_ACCOUNTMANAGERUPDATEWIZARD()) { if (pc.client_account_creation_disabled) { m_pAccountQuestionStaticCtrl->SetLabel( _("Please enter your account information\n(to create an account, visit the project's web site)") ); } else if (pc.account_creation_disabled) { m_pAccountQuestionStaticCtrl->SetLabel( _("This project is not currently accepting new accounts.\nYou can add it only if you already have an account.") ); } else { m_pAccountQuestionStaticCtrl->SetLabel( _("Are you already running this project?") ); } m_pAccountCreateCtrl->SetLabel( _("&No, new user") ); m_pAccountUseExistingCtrl->SetLabel( _("&Yes, existing user") ); } else { if (pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected) { m_pCookieDetectionFailedStaticCtrl->SetLabel( _("We were not able to set up your account information\nautomatically.\n\nPlease click on the 'Find login information' link\nbelow to find out what to put in the email address and\npassword fields.") ); m_pCookieDetectionFailedCtrl->SetLabel( _("Find login information") ); m_pCookieDetectionFailedCtrl->SetURL( pWA->m_strCookieFailureURL ); } if (pSkinAdvanced->IsBranded() && !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) { m_pAccountInformationStaticCtrl->SetLabel( pSkinWizardATAM->GetAccountInfoMessage() ); } } if (m_pAccountUseExistingCtrl->GetValue()) { m_pAccountConfirmPasswordStaticCtrl->Hide(); m_pAccountConfirmPasswordCtrl->Hide(); m_pAccountPasswordRequirmentsStaticCtrl->Hide(); m_pAccountPasswordStaticCtrl->SetLabel( _("&Password:"******"Choose a &password:"******"C&onfirm password:"******"Are you already running %s?"), pWA->GetProjectName().c_str() ); m_pAccountQuestionStaticCtrl->SetLabel(strQuestion); } if (pc.uses_username) { if (IS_ACCOUNTMANAGERWIZARD()) { if (pSkinAdvanced->IsBranded() && !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) { m_pAccountInformationStaticCtrl->SetLabel( pSkinWizardATAM->GetAccountInfoMessage() ); } } m_pAccountEmailAddressCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountEmailAddress) ); m_pAccountUsernameCtrl->SetValidator( wxTextValidator(wxFILTER_ASCII, &m_strAccountUsername) ); m_pAccountEmailAddressStaticCtrl->Hide(); m_pAccountEmailAddressCtrl->Hide(); m_pAccountUsernameStaticCtrl->Show(); m_pAccountUsernameCtrl->Show(); m_pAccountUsernameStaticCtrl->SetLabel( _("&Username:"******"&Email address:") ); m_pAccountEmailAddressCtrl->SetValue(m_strAccountEmailAddress); } if (pc.min_passwd_length) { wxString str; str.Printf(_("minimum length %d"), pc.min_passwd_length); m_pAccountPasswordRequirmentsStaticCtrl->SetLabel( str ); } if (!IS_ACCOUNTMANAGERWIZARD()) { m_pAccountForgotPasswordCtrl->SetLabel( _("Forgot your password?") ); m_pAccountForgotPasswordCtrl->SetURL( wxString(pWA->m_ProjectInfoPage->GetProjectURL() + _T("get_passwd.php")) ); } else { m_pAccountManagerLinkLabelStaticCtrl->SetLabel( _("If you have not yet registered with this account manager,\nplease do so before proceeding. Click on the link below\nto register or to retrieve a forgotten password." ) ); m_pAccountForgotPasswordCtrl->SetLabel( _("Account manager website") ); m_pAccountForgotPasswordCtrl->SetURL( wxString(pWA->m_AccountManagerInfoPage->GetProjectURL()) ); } if (pc.uses_username) { m_pAccountUsernameCtrl->SetFocus(); } else { m_pAccountEmailAddressCtrl->SetFocus(); } Fit(); }
void CProjectPropertiesPage::OnStateChange( CProjectPropertiesPageEvent& WXUNUSED(event) ) { CMainDocument* pDoc = wxGetApp().GetDocument(); CWizardAttach* pWAP = ((CWizardAttach*)GetParent()); PROJECT_CONFIG* pc = &pWAP->project_config; CC_STATUS status; wxDateTime dtStartExecutionTime; wxDateTime dtCurrentExecutionTime; wxTimeSpan tsExecutionTime; wxString strBuffer = wxEmptyString; bool bPostNewEvent = true; int iReturnValue = 0; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); switch(GetCurrentState()) { case PROJPROP_INIT: pWAP->DisableNextButton(); pWAP->DisableBackButton(); StartProgress(m_pProgressIndicator); 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; iReturnValue = 0; pc->clear(); 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( (const char*)pWAP->m_ProjectInfoPage->GetProjectURL().mb_str() ); } dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; iReturnValue = pDoc->rpc.get_project_config_poll(*pc); IncrementProgress(m_pProgressIndicator); ::wxMilliSleep(500); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_USER_INPUT); } if ( !iReturnValue && (!pc->error_num || pc->error_num == ERR_ACCT_CREATION_DISABLED) ) { // 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()); } else { SetProjectPropertiesSucceeded(false); SetProjectPropertiesURLFailure(pc->error_num == ERR_HTTP_PERMANENT); bool comm_failure = !iReturnValue && ( (ERR_GETHOSTBYNAME == pc->error_num) || (ERR_CONNECT == pc->error_num) || (ERR_XML_PARSE == pc->error_num) || (ERR_PROJECT_DOWN == pc->error_num) ); SetProjectPropertiesCommunicationFailure(comm_failure); bool server_reported_error = !iReturnValue && ( (ERR_HTTP_PERMANENT != pc->error_num) && (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); if (server_reported_error) { 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); } } SetNextState(PROJPROP_DETERMINENETWORKSTATUS_BEGIN); 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 // 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; iReturnValue = pDoc->GetCoreClientStatus(status); IncrementProgress(m_pProgressIndicator); ::wxMilliSleep(500); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_USER_INPUT); } SetNetworkConnectionNotDetected(NETWORK_STATUS_WANT_CONNECTION == status.network_status); 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. SetCredentialsAlreadyAvailable(pWAP->m_bCredentialsCached || pWAP->m_bCredentialsDetected); SetNextState(PROJPROP_CLEANUP); break; case PROJPROP_CLEANUP: FinishProgress(m_pProgressIndicator); SetNextState(PROJPROP_END); break; default: // Allow a glimps of what the result was before advancing to the next page. wxSleep(1); pWAP->EnableNextButton(); pWAP->EnableBackButton(); pWAP->SimulateNextButton(); bPostNewEvent = false; break; } Update(); if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) { CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this); AddPendingEvent(TransitionEvent); } }
void CProjectProcessingPage::OnStateChange( CProjectProcessingPageEvent& WXUNUSED(event) ) { CMainDocument* pDoc = wxGetApp().GetDocument(); CWizardAttach* pWA = ((CWizardAttach*)GetParent()); ACCOUNT_IN* ai = &pWA->account_in; ACCOUNT_OUT* ao = &pWA->account_out; unsigned int i; PROJECT_ATTACH_REPLY reply; wxString strBuffer = wxEmptyString; wxDateTime dtStartExecutionTime; wxDateTime dtCurrentExecutionTime; wxTimeSpan tsExecutionTime; bool bPostNewEvent = true; int retval = 0; bool creating_account = false; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); switch(GetCurrentState()) { case ATTACHPROJECT_INIT: pWA->DisableNextButton(); pWA->DisableBackButton(); StartProgress(m_pProgressIndicator); SetNextState(ATTACHPROJECT_ACCOUNTQUERY_BEGIN); break; case ATTACHPROJECT_ACCOUNTQUERY_BEGIN: SetNextState(ATTACHPROJECT_ACCOUNTQUERY_EXECUTE); break; case ATTACHPROJECT_ACCOUNTQUERY_EXECUTE: // Attempt to create the account or reterieve the authenticator. ai->clear(); ao->clear(); // 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()) { ai->url = pWA->project_config.master_url; } else { ai->url = (const char*)pWA->m_ProjectInfoPage->GetProjectURL().mb_str(); } if (!pWA->GetProjectAuthenticator().IsEmpty() || pWA->m_bCredentialsCached || pWA->m_bCredentialsDetected ) { if (!pWA->m_bCredentialsCached || pWA->m_bCredentialsDetected) { ao->authenticator = (const char*)pWA->GetProjectAuthenticator().mb_str(); } SetProjectCommunicationsSucceeded(true); } else { // Setup initial values for both the create and lookup API 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(); } ai->passwd = (const char*)pWA->m_AccountInfoPage->GetAccountPassword().mb_str(); ai->user_name = (const char*)::wxGetUserName().mb_str(); if (ai->user_name.empty()) { ai->user_name = (const char*)::wxGetUserId().mb_str(); } //ai->team_name = (const char*)pWA->GetTeamName().mb_str(); if (pWA->m_AccountInfoPage->m_pAccountCreateCtrl->GetValue()) { creating_account = true; // Wait until we are done processing the request. dtStartExecutionTime = wxDateTime::Now(); dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; retval = 0; ao->error_num = ERR_RETRY; while ( !retval && ((ERR_IN_PROGRESS == ao->error_num) || (ERR_RETRY == ao->error_num)) && tsExecutionTime.GetSeconds() <= 60 && !CHECK_CLOSINGINPROGRESS() ) { if (ERR_RETRY == ao->error_num) { pDoc->rpc.create_account(*ai); } dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; retval = pDoc->rpc.create_account_poll(*ao); IncrementProgress(m_pProgressIndicator); ::wxMilliSleep(500); ::wxSafeYield(GetParent()); } if ((!retval) && !ao->error_num) { pWA->SetAccountCreatedSuccessfully(true); } } else { creating_account = false; // Wait until we are done processing the request. dtStartExecutionTime = wxDateTime::Now(); dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; retval = 0; ao->error_num = ERR_RETRY; while ( !retval && ((ERR_IN_PROGRESS == ao->error_num) || (ERR_RETRY == ao->error_num)) && tsExecutionTime.GetSeconds() <= 60 && !CHECK_CLOSINGINPROGRESS() ) { if (ERR_RETRY == ao->error_num) { retval = pDoc->rpc.lookup_account(*ai); if (retval) { // REPORT ERROR } } dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; retval = pDoc->rpc.lookup_account_poll(*ao); IncrementProgress(m_pProgressIndicator); ::wxMilliSleep(500); ::wxSafeYield(GetParent()); } } if ((!retval) && !ao->error_num) { SetProjectCommunicationsSucceeded(true); } else { SetProjectCommunicationsSucceeded(false); if ((ao->error_num == ERR_DB_NOT_UNIQUE) || (ao->error_num == ERR_NONUNIQUE_EMAIL) || (ao->error_num == ERR_BAD_PASSWD && creating_account) ) { SetProjectAccountAlreadyExists(true); } else { SetProjectAccountAlreadyExists(false); } if ((ERR_NOT_FOUND == ao->error_num) || (ao->error_num == ERR_DB_NOT_FOUND) || (ERR_BAD_EMAIL_ADDR == ao->error_num) || (ERR_BAD_PASSWD == ao->error_num) ) { SetProjectAccountNotFound(true); } else { SetProjectAccountNotFound(false); } strBuffer = pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel(); if ((HTTP_STATUS_NOT_FOUND == ao->error_num)) { strBuffer += _("Required files not found on the server."); } else if ((HTTP_STATUS_INTERNAL_SERVER_ERROR == ao->error_num)) { strBuffer += _("An internal server error has occurred."); } else { if (ao->error_msg.size()) { strBuffer += wxString(ao->error_msg.c_str(), wxConvUTF8) + wxString(wxT("\n")); } } pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer); } } SetNextState(ATTACHPROJECT_ATTACHPROJECT_BEGIN); break; case ATTACHPROJECT_ATTACHPROJECT_BEGIN: SetNextState(ATTACHPROJECT_ATTACHPROJECT_EXECUTE); break; case ATTACHPROJECT_ATTACHPROJECT_EXECUTE: if (GetProjectCommunicationsSucceeded()) { // Wait until we are done processing the request. dtStartExecutionTime = wxDateTime::Now(); dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; retval = 0; reply.error_num = ERR_RETRY; while ( !retval && ((ERR_IN_PROGRESS == reply.error_num) || (ERR_RETRY == reply.error_num)) && tsExecutionTime.GetSeconds() <= 60 && !CHECK_CLOSINGINPROGRESS() ) { if (ERR_RETRY == reply.error_num) { if (pWA->m_bCredentialsCached) { pDoc->rpc.project_attach_from_file(); } else { pDoc->rpc.project_attach( ai->url.c_str(), ao->authenticator.c_str(), pWA->project_config.name.c_str() ); } } dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; retval = pDoc->rpc.project_attach_poll(reply); IncrementProgress(m_pProgressIndicator); ::wxMilliSleep(500); ::wxSafeYield(GetParent()); } if (!retval && !reply.error_num) { SetProjectAttachSucceeded(true); pWA->SetAttachedToProjectSuccessfully(true); pWA->SetProjectURL(wxString(ai->url.c_str(), wxConvUTF8)); pWA->SetProjectAuthenticator(wxString(ao->authenticator.c_str(), wxConvUTF8)); } else { SetProjectAttachSucceeded(false); strBuffer = pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel(); if ((HTTP_STATUS_INTERNAL_SERVER_ERROR == reply.error_num)) { strBuffer += _("An internal server error has occurred."); } else { for (i=0; i<reply.messages.size(); i++) { strBuffer += wxString(reply.messages[i].c_str(), wxConvUTF8) + wxString(wxT("\n")); } } pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer); } } else { SetProjectAttachSucceeded(false); } SetNextState(ATTACHPROJECT_CLEANUP); break; case ATTACHPROJECT_CLEANUP: FinishProgress(m_pProgressIndicator); SetNextState(ATTACHPROJECT_END); break; default: // Allow a glimps of what the result was before advancing to the next page. wxSleep(1); pWA->EnableNextButton(); pWA->EnableBackButton(); pWA->SimulateNextButton(); bPostNewEvent = false; break; } Update(); if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) { CProjectProcessingPageEvent TransitionEvent(wxEVT_PROJECTPROCESSING_STATECHANGE, this); AddPendingEvent(TransitionEvent); } }
void CAccountInfoPage::OnPageChanging( wxWizardExEvent& event ) { if (event.GetDirection() == false) return; CWizardAttach* pWA = ((CWizardAttach*)GetParent()); PROJECT_CONFIG& pc = pWA->project_config; wxString strTitle; wxString strMessage = wxT(""); bool bDisplayError = false; wxString strBaseConfigLocation = wxString(wxT("/Wizards")); wxConfigBase* pConfig = wxConfigBase::Get(FALSE); if (!CHECK_CLOSINGINPROGRESS()) { // We are leaving this page, so store the email address for future // use. pConfig->SetPath(strBaseConfigLocation); pConfig->Write(wxT("DefaultEmailAddress"), m_strAccountEmailAddress); pConfig->Write(wxT("DefaultUsername"), m_strAccountUsername); pConfig->Flush(); // Construct potiental dialog title if (IS_ATTACHTOPROJECTWIZARD()) { strTitle = _("Add project"); } else if (IS_ACCOUNTMANAGERWIZARD() && IS_ACCOUNTMANAGERUPDATEWIZARD()) { strTitle = _("Update account manager"); } else if (IS_ACCOUNTMANAGERWIZARD()) { strTitle = _("Use account manager"); } // Verify minimum username length if (!m_pAccountUseExistingCtrl->GetValue()) { if (!(m_pAccountPasswordCtrl->GetValue().Length() > 0)) { if (pc.uses_username) { strMessage.Printf(_("Please enter a user name.")); } else { strMessage.Printf(_("Please enter an email address.")); } bDisplayError = true; } } // Verify minimum password length if (!m_pAccountUseExistingCtrl->GetValue()) { if (m_pAccountPasswordCtrl->GetValue().Length() < (size_t)pc.min_passwd_length) { strMessage.Printf( _("Please enter a password of at least %d characters."), pc.min_passwd_length ); bDisplayError = true; } } // Verify that the password and confirmation password math. if (!IS_ACCOUNTMANAGERWIZARD() && m_pAccountCreateCtrl->GetValue()) { if (m_pAccountPasswordCtrl->GetValue() != m_pAccountConfirmPasswordCtrl->GetValue()) { strMessage = _("The password and confirmation password do not match. Please type them again."); bDisplayError = true; } } if (bDisplayError) { wxGetApp().SafeMessageBox( strMessage, strTitle, wxICON_ERROR | wxOK, this ); event.Veto(); } else { // Update authoritative data in CWizardAttach pWA->SetAccountEmailAddress(m_strAccountEmailAddress); pWA->SetAccountUsername(m_strAccountUsername); pWA->SetAccountPassword(m_pAccountPasswordCtrl->GetValue()); } } }
void CSimpleFrame::OnConnect(CFrameEvent& WXUNUSED(event)) { wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnConnect - Function Begin")); CMainDocument* pDoc = wxGetApp().GetDocument(); CWizardAttach* pWizard = NULL; wxString strComputer = wxEmptyString; wxString strName = wxEmptyString; wxString strURL = wxEmptyString; wxString strTeamName = wxEmptyString; std::string strProjectName; std::string strProjectURL; std::string strProjectAuthenticator; std::string strProjectInstitution; std::string strProjectDescription; std::string strProjectKnown; bool bCachedCredentials = false; ACCT_MGR_INFO ami; PROJECT_INIT_STATUS pis; CC_STATUS status; int wasShown = 0; int wasVisible = 0; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); pDoc->ForceCacheUpdate(); pDoc->GetCoreClientStatus(status, true); // If we are connected to the localhost, run a really quick screensaver // test to trigger a firewall popup. pDoc->GetConnectedComputerName(strComputer); if (pDoc->IsComputerNameLocal(strComputer)) { wxGetApp().StartBOINCScreensaverTest(); wxGetApp().StartBOINCDefaultScreensaverTest(); } pDoc->rpc.get_project_init_status(pis); pDoc->rpc.acct_mgr_info(ami); if (detect_simple_account_credentials( strProjectName, strProjectURL, strProjectAuthenticator, strProjectInstitution, strProjectDescription, strProjectKnown ) ){ if (!pDoc->project((char*)strProjectURL.c_str())) { wasShown = IsShown(); Show(); wasVisible = wxGetApp().IsApplicationVisible(); if (!wasVisible) { wxGetApp().ShowApplication(true); } pWizard = new CWizardAttach(this); pWizard->RunSimpleProjectAttach( wxURI::Unescape(strProjectName), wxURI::Unescape(strProjectURL), wxURI::Unescape(strProjectAuthenticator), wxURI::Unescape(strProjectInstitution), wxURI::Unescape(strProjectDescription), wxURI::Unescape(strProjectKnown) ); } } else if (ami.acct_mgr_url.size() && ami.have_credentials) { // Fall through // // There isn't a need to bring up the attach wizard, the account manager will // take care of ataching to projects when it completes the RPCs // } else if (ami.acct_mgr_url.size() && !ami.have_credentials) { wasShown = IsShown(); Show(); wasVisible = wxGetApp().IsApplicationVisible(); if (!wasVisible) { wxGetApp().ShowApplication(true); } pWizard = new CWizardAttach(this); if (pWizard->SyncToAccountManager()) { // _GRIDREPUBLIC, _PROGRESSTHRUPROCESSORS and _CHARITYENGINE // are defined for those branded builds on Windows only #if defined(_GRIDREPUBLIC) || defined(_PROGRESSTHRUPROCESSORS) || defined(_CHARITYENGINE) || defined(__WXMAC__) #ifdef __WXMAC__ // For GridRepublic, Charity Engine or ProgressThruProcessors, // the Mac installer put a branding file in our data directory long iBrandID = 0; // 0 is unbranded (default) BOINC FILE *f = boinc_fopen("/Library/Application Support/BOINC Data/Branding", "r"); if (f) { fscanf(f, "BrandId=%ld\n", &iBrandID); fclose(f); } if ((iBrandID > 0) && (iBrandID < 4)) #endif { // If successful, hide the main window if we showed it if (!wasVisible) { wxGetApp().ShowApplication(false); } #ifndef __WXMAC__ // See comment in CBOINCGUIApp::OnFinishInit() if (!wasShown) { Hide(); } #endif } #endif } } else if ((pis.url.size() || (0 >= pDoc->GetSimpleProjectCount())) && !status.disallow_attach) { Show(); wxGetApp().ShowApplication(true); strURL = wxString(pis.url.c_str(), wxConvUTF8); bCachedCredentials = pis.url.length() && pis.has_account_key; pWizard = new CWizardAttach(this); pWizard->Run(strURL, bCachedCredentials); } if (pWizard) { pWizard->Destroy(); m_pBackgroundPanel->UpdateProjectView(); } wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnConnect - Function End")); }
void CProjectWelcomePage::OnPageChanged( wxWizardExEvent& event ) { if (event.GetDirection() == false) return; wxLogTrace(wxT("Function Start/End"), wxT("CProjectWelcomePage::OnPageChanged - Function Begin")); CWizardAttach* pWA = ((CWizardAttach*)GetParent()); wxString buf; buf.Printf(_("Welcome to %s."), pWA->GetProjectName().c_str()); title_ctrl->SetLabel(buf); intro_ctrl->SetLabel(_("You have volunteered to compute for this project:")); project_name1_ctrl->SetLabel(_("Name:")); project_name2_ctrl->SetLabel(pWA->GetProjectName()); if (!pWA->GetProjectInstitution().IsEmpty()) { project_inst1_ctrl->SetLabel(_("Home:")); project_inst2_ctrl->SetLabel(pWA->GetProjectInstitution()); } if (!pWA->GetProjectDescription().IsEmpty()) { project_desc1_ctrl->SetLabel(_("Description:")); project_desc2_ctrl->SetLabel(pWA->GetProjectDescription()); } project_url1_ctrl->SetLabel(_("URL:")); project_url2_ctrl->SetLabel(pWA->GetProjectURL()); if (!pWA->GetProjectUserName().IsEmpty()) { user_name1_ctrl->SetLabel(_("User:"******"WARNING: This project is not registered with BOINC. Make sure you trust it before continuing.")); } continue_ctrl->SetLabel( _("To continue, click Next.") ); Layout(); wxLogTrace(wxT("Function Start/End"), wxT("CProjectWelcomePage::OnPageChanged - Function End")); }
void CAccountManagerProcessingPage::OnStateChange( CAccountManagerProcessingPageEvent& WXUNUSED(event) ) { CMainDocument* pDoc = wxGetApp().GetDocument(); CWizardAttach* pWA = ((CWizardAttach*)GetParent()); wxDateTime dtStartExecutionTime; wxDateTime dtCurrentExecutionTime; wxTimeSpan tsExecutionTime; ACCT_MGR_RPC_REPLY reply; wxString strBuffer = wxEmptyString; std::string url = ""; std::string username = ""; std::string password = ""; bool bPostNewEvent = true; int iReturnValue = 0; unsigned int i; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); switch(GetCurrentState()) { case ATTACHACCTMGR_INIT: pWA->DisableNextButton(); pWA->DisableBackButton(); StartProgress(m_pProgressIndicator); SetNextState(ATTACHACCTMGR_ATTACHACCTMGR_BEGIN); break; case ATTACHACCTMGR_ATTACHACCTMGR_BEGIN: SetNextState(ATTACHACCTMGR_ATTACHACCTMGR_EXECUTE); break; case ATTACHACCTMGR_ATTACHACCTMGR_EXECUTE: // Attempt to attach to the account manager. // Newer versions of the server-side software contain the correct // master url in the get_project_config response. If it is available // use it instead of what the user typed in. if (!pWA->project_config.master_url.empty()) { url = pWA->project_config.master_url; } else { url = (const char*)pWA->m_AccountManagerInfoPage->GetProjectURL().mb_str(); } if (pWA->project_config.uses_username) { username = (const char*)pWA->m_AccountInfoPage->GetAccountUsername().mb_str(); } else { username = (const char*)pWA->m_AccountInfoPage->GetAccountEmailAddress().mb_str(); } password = (const char*)pWA->m_AccountInfoPage->GetAccountPassword().mb_str(); // Wait until we are done processing the request. dtStartExecutionTime = wxDateTime::Now(); dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; iReturnValue = 0; reply.error_num = ERR_RETRY; while ( !iReturnValue && ((ERR_IN_PROGRESS == reply.error_num) || (ERR_RETRY == reply.error_num)) && (tsExecutionTime.GetSeconds() <= 60) && !CHECK_CLOSINGINPROGRESS() ) { if (ERR_RETRY == reply.error_num) { pDoc->rpc.acct_mgr_rpc( url.c_str(), username.c_str(), password.c_str(), pWA->m_bCredentialsCached ); } dtCurrentExecutionTime = wxDateTime::Now(); tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime; iReturnValue = pDoc->rpc.acct_mgr_rpc_poll(reply); IncrementProgress(m_pProgressIndicator); ::wxMilliSleep(500); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_USER_INPUT); } if (!iReturnValue && !reply.error_num) { SetProjectAttachSucceeded(true); pWA->SetAttachedToProjectSuccessfully(true); } else { SetProjectAttachSucceeded(false); if ((ERR_NOT_FOUND == reply.error_num) || (ERR_DB_NOT_FOUND == reply.error_num) || (ERR_BAD_EMAIL_ADDR == reply.error_num) || (ERR_BAD_PASSWD == reply.error_num) ) { // For any logon error, make sure we do not attempt to use cached credentials // on any follow-ups. pWA->m_bCredentialsCached = false; SetProjectAccountNotFound(true); } else { SetProjectAccountNotFound(false); } strBuffer = pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel(); if ((HTTP_STATUS_INTERNAL_SERVER_ERROR == reply.error_num)) { strBuffer += _("An internal server error has occurred.\n"); } else { for (i=0; i<reply.messages.size(); i++) { strBuffer += wxString(reply.messages[i].c_str(), wxConvUTF8) + wxString(wxT("\n")); } } pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer); } SetNextState(ATTACHACCTMGR_CLEANUP); break; case ATTACHACCTMGR_CLEANUP: FinishProgress(m_pProgressIndicator); SetNextState(ATTACHACCTMGR_END); break; default: // Allow a glimps of what the result was before advancing to the next page. wxSleep(1); pWA->EnableNextButton(); pWA->EnableBackButton(); pWA->SimulateNextButton(); bPostNewEvent = false; break; } Update(); if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) { CAccountManagerProcessingPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROCESSING_STATECHANGE, this); AddPendingEvent(TransitionEvent); } }