// Either appName argument or projName argument may be NULL void CSimpleTaskPanel::GetApplicationAndProjectNames(RESULT* result, wxString* appName, wxString* projName) { CMainDocument* pDoc = wxGetApp().GetDocument(); RESULT* state_result = NULL; wxString strAppBuffer = wxEmptyString; wxString strGPUBuffer = wxEmptyString; wxString pct_done_str = wxEmptyString; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); state_result = pDoc->state.lookup_result(result->project_url, result->name); if (!state_result) { pDoc->ForceCacheUpdate(); state_result = pDoc->state.lookup_result(result->project_url, result->name); } if (!state_result) return; if (appName != NULL) { WORKUNIT* wup = state_result->wup; if (!wup) return; APP* app = wup->app; if (!app) return; APP_VERSION* avp = state_result->avp; if (!avp) return; if (strlen(app->user_friendly_name)) { strAppBuffer = wxString(state_result->app->user_friendly_name, wxConvUTF8); } else { strAppBuffer = wxString(state_result->avp->app_name, wxConvUTF8); } if (avp->ncudas) { strGPUBuffer = wxString(" (NVIDIA GPU)", wxConvUTF8); } if (avp->natis) { strGPUBuffer = wxString(" (ATI GPU)", wxConvUTF8); } appName->Printf( wxT("%s%s%s"), state_result->project->anonymous_platform?_("Local: "):wxT(""), strAppBuffer.c_str(), strGPUBuffer.c_str() ); } if (projName != NULL) { *projName = wxString(state_result->project->project_name.c_str(), wxConvUTF8 ); if (projName->IsEmpty()) { *projName = _("Not Available"); } } }
wxString CDlgItemProperties::FormatApplicationName(RESULT* result ) { wxString strBuffer = wxEmptyString; CMainDocument* pDoc = wxGetApp().GetDocument(); RESULT* state_result = NULL; wxString strAppBuffer = wxEmptyString; wxString strClassBuffer = wxEmptyString; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); if (result) { state_result = pDoc->state.lookup_result(result->project_url, result->name); if (!state_result) { pDoc->ForceCacheUpdate(); state_result = pDoc->state.lookup_result(result->project_url, result->name); } wxASSERT(state_result); if (!state_result) return strBuffer; WORKUNIT* wup = state_result->wup; if (!wup) return strBuffer; APP* app = wup->app; if (!app) return strBuffer; APP_VERSION* avp = state_result->avp; if (!avp) return strBuffer; if (strlen(app->user_friendly_name)) { strAppBuffer = wxString(state_result->app->user_friendly_name, wxConvUTF8); } else { strAppBuffer = wxString(state_result->avp->app_name, wxConvUTF8); } if (strlen(avp->plan_class)) { strClassBuffer.Printf( wxT(" (%s)"), wxString(avp->plan_class, wxConvUTF8).c_str() ); } strBuffer.Printf( wxT("%s%s %d.%02d %s"), state_result->project->anonymous_platform?_("Local: "):wxT(""), strAppBuffer.c_str(), state_result->avp->version_num / 100, state_result->avp->version_num % 100, strClassBuffer.c_str() ); } return strBuffer; }
void CViewWork::GetDocApplicationName(wxInt32 item, wxString& strBuffer) const { CMainDocument* pDoc = wxGetApp().GetDocument(); RESULT* result = wxGetApp().GetDocument()->result(item); RESULT* state_result = NULL; wxString strAppBuffer = wxEmptyString; wxString strClassBuffer = wxEmptyString; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); if (result) { state_result = pDoc->state.lookup_result(result->project_url, result->name); if (!state_result) { pDoc->ForceCacheUpdate(); state_result = pDoc->state.lookup_result(result->project_url, result->name); } if (!state_result) return; WORKUNIT* wup = state_result->wup; if (!wup) return; APP* app = wup->app; if (!app) return; APP_VERSION* avp = state_result->avp; if (!avp) return; if (strlen(app->user_friendly_name)) { strAppBuffer = HtmlEntityDecode(wxString(state_result->app->user_friendly_name, wxConvUTF8)); } else { strAppBuffer = HtmlEntityDecode(wxString(state_result->avp->app_name, wxConvUTF8)); } if (strlen(avp->plan_class)) { strClassBuffer.Printf( wxT(" (%s)"), wxString(avp->plan_class, wxConvUTF8).c_str() ); } strBuffer.Printf( wxT(" %s%s %d.%02d %s"), state_result->project->anonymous_platform?_("Local: "):wxT(""), strAppBuffer.c_str(), state_result->avp->version_num / 100, state_result->avp->version_num % 100, strClassBuffer.c_str() ); } }
void CSimpleTaskPanel::FindSlideShowFiles(TaskSelectionData *selData) { RESULT* state_result; char urlDirectory[1024]; char fileName[1024]; char resolvedFileName[1024]; int j; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); selData->slideShowFileNames.Clear(); state_result = pDoc->state.lookup_result(selData->result->project_url, selData->result->name); if (!state_result) { pDoc->ForceCacheUpdate(); state_result = pDoc->state.lookup_result(selData->result->project_url, selData->result->name); } if (state_result) { url_to_project_dir(state_result->project->master_url, urlDirectory); for(j=0; j<99; ++j) { sprintf(fileName, "%s/slideshow_%s_%02d", urlDirectory, state_result->app->name, j); if(boinc_resolve_filename(fileName, resolvedFileName, sizeof(resolvedFileName)) == 0) { if (boinc_file_exists(resolvedFileName)) { selData->slideShowFileNames.Add(wxString(resolvedFileName,wxConvUTF8)); } } else { break; } } if ( selData->slideShowFileNames.size() == 0 ) { for(j=0; j<99; ++j) { sprintf(fileName, "%s/slideshow_%02d", urlDirectory, j); if(boinc_resolve_filename(fileName, resolvedFileName, sizeof(resolvedFileName)) == 0) { if (boinc_file_exists(resolvedFileName)) { selData->slideShowFileNames.Add(wxString(resolvedFileName,wxConvUTF8)); } } else { break; } } } } selData->lastSlideShown = -1; }
void CViewWork::GetDocProjectName(wxInt32 item, wxString& strBuffer) const { CMainDocument* doc = wxGetApp().GetDocument(); RESULT* result = wxGetApp().GetDocument()->result(item); PROJECT* state_project = NULL; std::string project_name; wxASSERT(doc); wxASSERT(wxDynamicCast(doc, CMainDocument)); if (result) { // TODO: should we get the name directly with result->project->get_name(project_name) ? state_project = doc->state.lookup_project(result->project_url); if (state_project) { state_project->get_name(project_name); strBuffer = HtmlEntityDecode(wxString(project_name.c_str(), wxConvUTF8)); } else { doc->ForceCacheUpdate(); } } }
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")); }