示例#1
0
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"));
}
示例#2
0
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"));
}