void CAccountManagerInfoPage::OnProjectSelected( wxCommandEvent& /*event*/ ) {
    int sel = m_pProjectListCtrl->GetSelection();
    if (sel == wxNOT_FOUND) {
        SetProjectURL(wxEmptyString);
        m_pProjectDetailsDescriptionCtrl->SetValue(wxEmptyString);
    } else {
        CAcctMgrListItem* pItem = (CAcctMgrListItem*)(m_pProjectListCtrl->GetClientData(sel));
        SetProjectURL(pItem->GetURL());
        m_pProjectDetailsDescriptionCtrl->SetValue(pItem->GetDescription());
    }
    TransferDataToWindow();
}
Exemple #2
0
bool CWizardAttach::SyncToAccountManager() {
    ACCT_MGR_INFO ami;
    CMainDocument* pDoc = wxGetApp().GetDocument();

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));

    IsAttachToProjectWizard = false;
    IsAccountManagerWizard = true;

    pDoc->rpc.acct_mgr_info(ami);

    if (ami.acct_mgr_url.size()) {
        SetProjectName(wxString(ami.acct_mgr_name.c_str(), wxConvUTF8));
        SetProjectURL(wxString(ami.acct_mgr_url.c_str(), wxConvUTF8));

        SetCredentialsCached(ami.have_credentials);
        SetCookieRequired(ami.cookie_required);
        SetCookieFailureURL(wxString(ami.cookie_failure_url.c_str(), wxConvUTF8));
        if (IsCredentialsCached()) {
            IsAccountManagerUpdateWizard = true;
        }
    }

    if (ami.acct_mgr_url.size() && !m_bCredentialsCached) {
        std::string login;
        std::string password_hash;
        std::string return_url;

        if (detect_account_manager_credentials(ami.acct_mgr_url, login, password_hash, return_url)) {
            wxString strLogin;
            wxString strPasswordHash;
            wxString strReturnURL;

            strLogin = wxURL::Unescape(wxString(login.c_str(), wxConvUTF8));
            strPasswordHash = wxURL::Unescape(wxString(password_hash.c_str(), wxConvUTF8));
            strReturnURL = wxURL::Unescape(wxString(return_url.c_str(), wxConvUTF8));

            SetCredentialsDetected(true);
            SetReturnURL(strReturnURL);
            SetAccountEmailAddress(strLogin);
            SetAccountUsername(strLogin);
            SetAccountPassword(
                wxString(_T("hash:")) + strPasswordHash
            );
        }
    }

    if (m_AccountManagerInfoPage || m_AccountManagerPropertiesPage) {
        IsAttachToProjectWizard = false;
        IsAccountManagerWizard = true;
        if (!ami.acct_mgr_url.size()) {
            return RunWizard(m_AccountManagerInfoPage);
        } else {
            return RunWizard(m_AccountManagerPropertiesPage);
        }
    }

    return FALSE;
}
Exemple #3
0
/*!
 * Runs the wizard.
 */
bool CWizardAttach::Run(
    wxString strProjectURL, bool bCredentialsCached
) {
    if (strProjectURL.Length()) {
        SetProjectURL(strProjectURL);
        SetCredentialsCached(bCredentialsCached);
    }

    // If credentials are not cached, then we should try one last place to look up the
    //   authenticator.  Some projects will set a "Setup" cookie off of their URL with a
    //   pretty short timeout.  Lets take a crack at detecting it.
    //
    if (!strProjectURL.IsEmpty() && !bCredentialsCached) {
        std::string url = std::string(strProjectURL.mb_str());
        std::string authenticator;

        if (detect_setup_authenticator(url, authenticator)) {
            SetCredentialsDetected(true);
            SetCloseWhenCompleted(true);
            SetProjectAuthenticator(wxString(authenticator.c_str(), wxConvUTF8));
        }
    }

    if (m_ProjectPropertiesPage || m_ProjectInfoPage) {
        IsAttachToProjectWizard = true;
        IsAccountManagerWizard = false;
        if (strProjectURL.Length()) {
            return RunWizard(m_ProjectPropertiesPage);
        } else {
            return RunWizard(m_ProjectInfoPage);
        }
    }

    return FALSE;
}
Exemple #4
0
bool CWizardAttach::RunSimpleProjectAttach(
    wxString strName, wxString strURL, wxString strAuthenticator, wxString strInstitution, wxString strDescription, wxString strKnown
) {
    SetProjectName(strName);
    SetProjectURL(strURL);
    SetProjectInstitution(strInstitution);
    SetProjectDescription(strDescription);
    if (strAuthenticator.size()) {
        SetProjectAuthenticator(strAuthenticator);
    }
    SetProjectKnown(strKnown.length() > 0);

    IsAttachToProjectWizard = true;
    IsAccountManagerWizard = false;
    return RunWizard(m_ProjectWelcomePage);
}
Exemple #5
0
/*!
 * Runs the wizard.
 */
bool CWizardAttach::Run(
        wxString strProjectName,
        wxString strProjectURL,
        wxString strProjectAuthenticator, 
        wxString strProjectInstitution,
        wxString strProjectDescription,
        wxString strProjectKnown,
        wxString strProjectSetupCookie,
        bool     bAccountKeyDetected,
        bool     bEmbedded
){
    SetProjectName(strProjectName);
    if (strProjectURL.size()) {
        SetProjectURL(strProjectURL);
        SetCredentialsCached(bAccountKeyDetected);
    }
    SetProjectInstitution(strProjectInstitution);
    SetProjectDescription(strProjectDescription);
    if (strProjectAuthenticator.size()) {
        SetProjectAuthenticator(strProjectAuthenticator);
    }
    if (strProjectSetupCookie.size()) {
        SetProjectSetupCookie(strProjectSetupCookie);
    }
    SetProjectKnown(strProjectKnown.length() > 0);

    if (strProjectURL.size() && strProjectAuthenticator.size() && !bAccountKeyDetected) {
        SetCredentialsDetected(true);
        SetCloseWhenCompleted(true);
    }

    if (m_ProjectPropertiesPage && m_ProjectInfoPage && m_ProjectWelcomePage) {
        IsAttachToProjectWizard = true;
        IsAccountManagerWizard = false;
        if (strProjectName.size() && strProjectURL.size() && (strProjectSetupCookie.size() == 0)) {
            return RunWizard(m_ProjectWelcomePage);
        } else if (strProjectURL.size() && (IsCredentialsCached() || IsCredentialsDetected() || strProjectSetupCookie.size())) {
            return RunWizard(m_ProjectPropertiesPage);
        } else {
            return RunWizard(m_ProjectInfoPage);
        }
    }

    return FALSE;
}
void CAccountManagerInfoPage::OnProjectItemChange( ProjectListCtrlEvent& event ) {
    SetProjectURL( event.GetURL() );
    SetProjectSupported( event.IsSupported() );
    TransferDataToWindow();
}
void CAccountManagerInfoPage::OnPageChanged( wxWizardExEvent& event ) {
    if (event.GetDirection() == false) return;
    wxLogTrace(wxT("Function Start/End"), wxT("CAccountManagerInfoPage::OnPageChanged - Function Begin"));

    unsigned int      i;
    ALL_PROJECTS_LIST pl;
    CMainDocument*    pDoc = wxGetApp().GetDocument();

    wxASSERT(m_pTitleStaticCtrl);
    wxASSERT(m_pDescriptionStaticCtrl);
    wxASSERT(m_pProjectDetailsStaticCtrl);
    wxASSERT(m_pProjectDetailsDescriptionCtrl);
    wxASSERT(m_pOpenWebSiteButton);
    wxASSERT(m_pProjectUrlStaticCtrl);
    wxASSERT(m_pProjectUrlCtrl);


    m_pTitleStaticCtrl->SetLabel(
        _("Choose an account manager")
    );
    m_pDescriptionStaticCtrl->SetLabel(
        _("To choose an account manager, click its name or \ntype its URL below.")
    );

    m_pProjectDetailsStaticCtrl->SetLabel(
        _("Account manager details:")
    );

    m_pProjectUrlStaticCtrl->SetLabel(
        _("Account manager &URL:")
    );

    m_pOpenWebSiteButton->SetLabel(
        _("Open web page")
    );

    m_pOpenWebSiteButton->SetToolTip( _("Visit this account manager's web site"));

    // Populate the list box with project information
    //
    if (!m_bAccountManagerListPopulated) {
        pDoc->rpc.get_all_projects_list(pl);
        for (i=0; i<pl.account_managers.size(); i++) {
            wxLogTrace(
                wxT("Function Status"),
                wxT("CAccountManagerInfoPage::OnPageChanged - Name: '%s', URL: '%s', Supported: '%d'"),
                wxString(pl.account_managers[i]->name.c_str(), wxConvUTF8).c_str(),
                wxString(pl.account_managers[i]->url.c_str(), wxConvUTF8).c_str(),
                true
            );

            CAcctMgrListItem* pItem = new CAcctMgrListItem();

            pItem->SetURL( pl.account_managers[i]->url.c_str() );
            pItem->SetName( pl.account_managers[i]->name.c_str() );
            pItem->SetImage( pl.account_managers[i]->image.c_str() );
            pItem->SetDescription( pl.account_managers[i]->description.c_str() );

            
            m_pProjectListCtrl->Append(
                wxString(pl.account_managers[i]->name.c_str(), wxConvUTF8),
                pItem
            );
        }

        // Pre select the first element
        if (m_pProjectListCtrl->GetCount()) {
            m_pProjectListCtrl->SetSelection(0);
            CAcctMgrListItem* pItem = (CAcctMgrListItem*)(m_pProjectListCtrl->GetClientData(0));
            SetProjectURL(pItem->GetURL());
            m_pProjectDetailsDescriptionCtrl->SetValue(pItem->GetDescription());
        }

        TransferDataToWindow();

        m_bAccountManagerListPopulated = true;
    }

    Layout();
    FitInside();
    m_pProjectListCtrl->SetFocus();

    wxLogTrace(wxT("Function Start/End"), wxT("CAccountManagerInfoPage::OnPageChanged - Function End"));
}