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 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(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->IsCookieRequired() && !pWA->IsCredentialsDetected())) { 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->IsCookieRequired() && !pWA->IsCredentialsDetected()) { 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->IsCookieRequired() && !pWA->IsCredentialsDetected()) { 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->GetCookieFailureURL() ); } 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 or LDAP ID:") ); } else { m_pAccountEmailAddressStaticCtrl->SetLabel( _("&Email address:") ); } m_pAccountEmailAddressCtrl->SetValue(m_strAccountEmailAddress); } if (pc.min_passwd_length) { wxString str2; str.Printf(_("minimum length %d"), pc.min_passwd_length); m_pAccountPasswordRequirmentsStaticCtrl->SetLabel( str2 ); } if (!IS_ACCOUNTMANAGERWIZARD()) { m_pAccountForgotPasswordCtrl->SetLabel( _("Forgot your password?") ); m_pAccountForgotPasswordCtrl->SetURL( wxString(pWA->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 web site") ); m_pAccountForgotPasswordCtrl->SetURL( wxString(pWA->GetProjectURL()) ); } if (pc.uses_username) { m_pAccountUsernameCtrl->SetFocus(); } else { m_pAccountEmailAddressCtrl->SetFocus(); } Fit(); }
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 retrieve 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->GetProjectURL().mb_str(); } if (!pWA->GetProjectAuthenticator().IsEmpty() || pWA->IsCredentialsCached() || pWA->IsCredentialsDetected() ) { if (!pWA->IsCredentialsCached() || pWA->IsCredentialsDetected()) { 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->GetAccountUsername().mb_str(); } else { ai->email_addr = (const char*)pWA->GetAccountEmailAddress().mb_str(); } ai->passwd = (const char*)pWA->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(); ai->ldap_auth = pWA->project_config.ldap_auth; 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); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_USER_INPUT); } 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); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_USER_INPUT); } } 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->IsCredentialsCached()) { pDoc->rpc.project_attach_from_file(); } else { std::string master_url; if (!pWA->project_config.master_url.empty()) { master_url = pWA->project_config.master_url; } else { master_url = (const char*)pWA->GetProjectURL().mb_str(); } pDoc->rpc.project_attach( master_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); #ifdef __WXMAC__ wxEventLoopBase * const modalLoop = wxEventLoopBase::GetActive(); modalLoop->YieldFor(wxEVT_CATEGORY_USER_INPUT); #else ::wxSafeYield(GetParent()); #endif } 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); } }