Ejemplo n.º 1
0
void CProjectsComponent::OnResume(wxCommandEvent& /*event*/) {
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function Begin"));

    CMainDocument* pDoc      = wxGetApp().GetDocument();
    CC_STATUS ccs;

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

    pDoc->GetCoreClientStatus(ccs);
    if ((RUN_MODE_NEVER == ccs.task_mode) && (0 >= ccs.task_mode_delay)) {
        pDoc->SetActivityRunMode(RUN_MODE_AUTO, 0);
    } else {
        pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
    }

    btnResume->Show(false);
    btnPause->Show(true);

    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function End"));
}
Ejemplo n.º 2
0
bool CSimpleTaskPanel::isRunning(RESULT* result) {
    bool outcome = false;

    // It must be scheduled to be running
    if ( result->scheduler_state == CPU_SCHED_SCHEDULED ) {
        // If either the project or task have been suspended, then it cannot be running
        if ( !result->suspended_via_gui && !result->project_suspended_via_gui ) {
            CC_STATUS status;
            CMainDocument*      pDoc = wxGetApp().GetDocument();
            wxASSERT(pDoc);
            
            pDoc->GetCoreClientStatus(status);
            // Make sure that the core client isn't global suspended for some reason
            if ( status.task_suspend_reason == 0 || status.task_suspend_reason == SUSPEND_REASON_CPU_THROTTLE ) {
                outcome = true;
            }
        }
    }

    return outcome;
}
Ejemplo n.º 3
0
void CBOINCBaseFrame::OnDocumentPoll(wxTimerEvent& WXUNUSED(event)) {
    static bool        bAlreadyRunOnce = false;
    CMainDocument*     pDoc = wxGetApp().GetDocument();

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

    // Timer events are handled while the RPC Wait dialog is shown
    // which may cause unintended recursion and repeatedly posting
    // the same RPC requests from timer routines.
    if (pDoc->WaitingForRPC()) return;

    if (!bAlreadyRunOnce && m_pDocumentPollTimer->IsRunning()) {
        // Complete any remaining initialization that has to happen after we are up
        //   and running
        FireInitialize();
        bAlreadyRunOnce = true;
    }

    pDoc->OnPoll();
}
Ejemplo n.º 4
0
void CSimpleTaskPopupButton::OnTaskAbort(wxCommandEvent& WXUNUSED(event)) {
    wxInt32  iAnswer        = 0;
    wxString strMessage     = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();

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

    if (!pDoc->IsUserAuthorized())  // Probably no longer relevant
        return;

    TaskSelectionData* selData = ((CSimpleTaskPanel*)GetParent())->GetTaskSelectionData();
    if (selData == NULL) return;

    RESULT* result = lookup_result(selData->project_url, selData->result_name);
    if (result) {
#if SELECTBYRESULTNAME
        wxString name = wxString(selData->result_name, wxConvUTF8, strlen(selData->result_name));
#else
        wxString name = ((CSimpleTaskPanel*)GetParent())->GetSelectedTaskString();
#endif
        strMessage.Printf(
           _("Are you sure you want to abort this task '%s'?\n(Progress: %.1lf%%, Status: %s)"), 
           name.c_str(), result->fraction_done * 100.0, result_description(result, false).c_str());

        iAnswer = wxGetApp().SafeMessageBox(
            strMessage,
            _("Abort task"),
            wxYES_NO | wxICON_QUESTION,
            this
        );

        if (wxYES != iAnswer) {
            return;
        }
        
        pDoc->WorkAbort(result->project_url, result->name);
    }
}
Ejemplo n.º 5
0
void CSimpleGUIPanel::OnSuspendResume(wxCommandEvent& /*event*/) {
    CMainDocument* pDoc      = wxGetApp().GetDocument();
    CC_STATUS ccs;

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

    if (m_bIsSuspended) {
        pDoc->GetCoreClientStatus(ccs);
        
        if ((RUN_MODE_NEVER == ccs.task_mode) && (0 >= ccs.task_mode_delay)) {
            pDoc->SetActivityRunMode(RUN_MODE_AUTO, 0);
        } else {
            pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
        }
    } else {
        pDoc->SetActivityRunMode(RUN_MODE_NEVER, 3600);
    }
    
    m_SuspendResumeButton->SetLabel(m_bIsSuspended ? m_sResumeString : m_sSuspendString);
    m_SuspendResumeButton->SetToolTip(m_bIsSuspended ? m_sResumeButtonToolTip : m_sSuspendButtonToolTip);
}
Ejemplo n.º 6
0
void CViewProjects::OnProjectNoNewWork( wxCommandEvent& WXUNUSED(event) ) {
    wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectNoNewWork - Function Begin"));

    CMainDocument*  pDoc   = wxGetApp().GetDocument();
    CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
    int row;

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    wxASSERT(pFrame);
    wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
    wxASSERT(m_pListPane);

    row = -1;
    while (1) {
        // Step through all selected items
        row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (row < 0) break;
        
        PROJECT* project = pDoc->project(m_iSortedIndexes[row]);
        if (project) {
            if (project->dont_request_more_work) {
                pFrame->UpdateStatusText(_("Telling project to allow additional task downloads..."));
                pDoc->ProjectAllowMoreWork(m_iSortedIndexes[row]);
                pFrame->UpdateStatusText(wxT(""));
            } else {
                pFrame->UpdateStatusText(_("Telling project to not fetch any additional tasks..."));
                pDoc->ProjectNoMoreWork(m_iSortedIndexes[row]);
                pFrame->UpdateStatusText(wxT(""));
            }
        }
    }
    
    m_bForceUpdateSelection = true;
    UpdateSelection();
    pFrame->FireRefreshView();

    wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectNoNewWork - Function End"));
}
Ejemplo n.º 7
0
void CViewWork::OnWorkSuspend( wxCommandEvent& WXUNUSED(event) ) {
    wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkSuspend - Function Begin"));

    CMainDocument* pDoc     = wxGetApp().GetDocument();
    CAdvancedFrame* pFrame  = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
    int row;

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    wxASSERT(pFrame);
    wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
    wxASSERT(m_pTaskPane);
    wxASSERT(m_pListPane);

    row = -1;
    while (1) {
        // Step through all selected items
        row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (row < 0) break;
        
        RESULT* result = pDoc->result(m_iSortedIndexes[row]);
        if (result) {
            if (result->suspended_via_gui) {
                pFrame->UpdateStatusText(_("Resuming task..."));
                pDoc->WorkResume(result->project_url, result->name);
            } else {
                pFrame->UpdateStatusText(_("Suspending task..."));
                pDoc->WorkSuspend(result->project_url, result->name);
            }
        }
    }

    pFrame->UpdateStatusText(wxT(""));
    
    UpdateSelection();
    pFrame->FireRefreshView();

    wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkSuspend - Function End"));
}
wxInt32 CViewTransfersGrid::FormatStatus(wxInt32 item, wxString& strBuffer) const {
    CMainDocument* doc = wxGetApp().GetDocument();
    FILE_TRANSFER* transfer = wxGetApp().GetDocument()->file_transfer(item);
    CC_STATUS      status;

    wxASSERT(doc);
    wxASSERT(wxDynamicCast(doc, CMainDocument));

    doc->GetCoreClientStatus(status);

    wxDateTime dtNextRequest((time_t)transfer->next_request_time);
    wxDateTime dtNow(wxDateTime::Now());

    if (transfer) {
        if      (dtNextRequest > dtNow) {
            wxTimeSpan tsNextRequest(dtNextRequest - dtNow);
            strBuffer = _("Retry in ") + tsNextRequest.Format();
        } else if (ERR_GIVEUP_DOWNLOAD == transfer->status) {
            strBuffer = _("Download failed");
        } else if (ERR_GIVEUP_UPLOAD == transfer->status) {
            strBuffer = _("Upload failed");
        } else {
            if (status.network_suspend_reason) {
                strBuffer = _("Suspended");
            } else {
                if (transfer->xfer_active) {
                    strBuffer = transfer->generated_locally? _("Uploading") : _("Downloading");
                } else {
                    strBuffer = transfer->generated_locally? _("Upload pending") : _("Download pending");
                }
            }
        }
    }

	strBuffer = wxT(" ") + strBuffer;

    return 0;
}
void CViewTransfersGrid::OnTransfersAbort( wxCommandEvent& WXUNUSED(event) ) {
    wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfersGrid::OnTransfersAbort - Function Begin"));

    wxInt32  iAnswer        = 0; 
    wxString strName        = wxEmptyString;
    wxString strMessage     = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    CAdvancedFrame* pFrame  = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    wxASSERT(pFrame);
    wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
    wxASSERT(m_pGridPane);

    if (!pDoc->IsUserAuthorized())
        return;

    pFrame->UpdateStatusText(_("Aborting transfer(s)..."));
	strMessage.Printf(
        _("Are you sure you want to abort this file(s) transfer ?\nNOTE: Aborting a transfer will invalidate a task and you\nwill not receive credit for it."));
    iAnswer = ::wxMessageBox(strMessage,_("Abort File Transfer(s)"),wxYES_NO | wxICON_QUESTION,this);
    if (wxYES == iAnswer) {
        wxArrayInt aRows = m_pGridPane->GetSelectedRows2();
        for(unsigned int i=0; i< aRows.Count();i++) {
            int row = aRows.Item(i);
            wxString fileName = m_pGridPane->GetCellValue(row,COLUMN_FILE).Trim(false);
            wxString projectURL = m_pGridPane->GetCellValue(row,COLUMN_HIDDEN_URL).Trim(false);
            pDoc->TransferAbort(fileName, projectURL);		
        }		
    }
    pFrame->UpdateStatusText(wxT(""));

    UpdateSelection();
    pFrame->FireRefreshView();

    wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfersGrid::OnTransfersAbort - Function End"));
}
Ejemplo n.º 10
0
/// Filter the messages based on the current filter settings.
/// This function stores the index of the last filtered message and won't touch
/// messages older than this if the function is called again. It will only check all
/// messages that are newer than the one remembered. This makes calling this function
/// as cheap as possible.
/// If you want this function to filter all the messages, for example because the
/// filter settings changed or the manager is now connected to a different client,
/// then you need to set m_maxFilteredIndex to zero and clear m_filteredIndexes
/// before calling this function.
void CViewMessages::FilterMessages() {
    CMainDocument* pDoc = wxGetApp().GetDocument();
    size_t end = pDoc->GetMessageCount();
    
    for (size_t index = m_maxFilteredIndex; index < end; ++index) {
        MESSAGE* msg = pDoc->message(index);
        if ((msg->project.empty()) || m_msgFilterData.IsProjectSelected(msg->project)) {            
            bool includeThisMsg = true;
            
            // Check if the message contains a debug flag:
            std::string::size_type start = msg->body.find('[');
            if (start != std::string::npos) {
                std::string::size_type end = msg->body.find(']', start);
                if (end != std::string::npos) {
                    std::string debugFlag = msg->body.substr(start + 1, end - start - 1);
                    if ((m_msgFilterData.IsDebugFlagValid(debugFlag))
                            && (!m_msgFilterData.IsDebugFlagSelected(debugFlag))) {
                        includeThisMsg = false;
                    }
                }
            }

            if (includeThisMsg) {
                // The message has passed all filters, thus add it to the list:
                m_filteredIndexes.push_back(index);
            }
        }
    }
    
    // Check if more messages passed the filters than should be shown and truncate the
    // list if necessary. The oldest messages (e.g. the ones added first) are removed first.
    if (m_filteredIndexes.size() > m_msgFilterData.GetNumVisibleMsg()) {
        m_filteredIndexes.erase(m_filteredIndexes.begin(),
                                m_filteredIndexes.end() - m_msgFilterData.GetNumVisibleMsg());
    }
    
    m_maxFilteredIndex = end;
}
Ejemplo n.º 11
0
void CSimpleProjectPanel::OnWizardAttach(wxCommandEvent& event) {
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardAttach - 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);

    pPanel->OnProjectsAttachToProject(event);
//    btnAddProj->Refresh();

    pPanel->SetDlgOpen(false);

    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardAttach - Function End"));
}
Ejemplo n.º 12
0
void CSimpleFrame::OnMenuOpening( wxMenuEvent &event) {
    wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnMenuOpening - Function Begin"));

    CMainDocument*     pDoc = wxGetApp().GetDocument();
    wxMenu* menuFile = NULL;
    wxMenu* menuHelp = NULL;
    
    wxASSERT(pDoc);
    
    bool isConnected = pDoc->IsConnected();
    wxMenu* menu = event.GetMenu();
    
    menu->FindItem(ID_CLOSEWINDOW, &menuFile);
    menu->FindItem(ID_HELPBOINC, &menuHelp);
    size_t numItems = menu->GetMenuItemCount();
    for (size_t pos = 0; pos < numItems; ++pos) {
        wxMenuItem * item = menu->FindItemByPosition(pos);
        if ((menu == menuFile) || (menu == menuHelp)) {
            // Always enable all items in File menu or Help menu:
            // ID_CLOSEWINDOW, wxID_EXIT, ID_HELPBOINC, ID_HELPBOINCMANAGER,
            // ID_HELPBOINCWEBSITE, wxID_ABOUT
            item->Enable(true);
        } else {
            // Disable other menu items if not connected to client
            item->Enable(isConnected);
        }
    }
    
    // wxID_EXIT and wxID_PREFERENCES are not in File menu on some platforms
    wxMenuItem* exitItem = menu->FindChildItem(wxID_EXIT, NULL);
    if (exitItem) {
        exitItem->Enable(true);
    }
    
    wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnMenuOpening - Function End"));
}
Ejemplo n.º 13
0
void CSimpleProjectPanel::UpdateProjectList() {
    CMainDocument* pDoc = wxGetApp().GetDocument();
    ProjectSelectionData* selData;
    PROJECT* project;
    char* ctrl_url;
    int i, j, oldProjectSelection, newProjectSelection;

    if ( pDoc->IsConnected() ) {
        int projCnt = pDoc->GetSimpleProjectCount();
        int ctrlCount = m_ProjectSelectionCtrl->GetCount();
        oldProjectSelection = m_ProjectSelectionCtrl->GetSelection();
        
        // If a new project has been added, figure out which one
        for(i=0; i<projCnt; i++) {
            project = pDoc->state.projects[i];
            bool found = false;
            for(j=0; j<ctrlCount; j++) {
                ctrl_url = ((ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(j))->project_url;
                if (!strcmp(project->master_url, ctrl_url)) {
                    found = true;
                    break;
                }
            }

            // if it isn't currently in the list then we have a new one!  lets add it
            if ( !found ) {
                wxString projname(project->project_name.c_str(), wxConvUTF8);
#if SORTPROJECTLIST
                int alphaOrder;
                for(j = 0; j < ctrlCount; ++j) {
                    alphaOrder = (m_ProjectSelectionCtrl->GetString(j)).CmpNoCase(projname);
                    if (alphaOrder > 0) {
                        break;  // Insert the new item here (sorted by item label)
                    }
                }
#endif
                selData = new ProjectSelectionData;
                strncpy(selData->project_url, project->master_url, sizeof(selData->project_url));
                selData->project_files_downloaded_time = project->project_files_downloaded_time;
                wxBitmap* projectBM = GetProjectSpecificBitmap(selData->project_url);
#if SORTPROJECTLIST
                if (j < ctrlCount) {
                    m_ProjectSelectionCtrl->Insert(projname, *projectBM, j, (void*)selData);
                    if (j <= oldProjectSelection) {
                        ++oldProjectSelection;
                        m_ProjectSelectionCtrl->SetSelection(oldProjectSelection);
                    }
                } else 
#endif
                {
                    m_ProjectSelectionCtrl->Append(projname, *projectBM, (void*)selData);
                }
                ctrlCount = m_ProjectSelectionCtrl->GetCount();
            }
        }
        
        newProjectSelection = oldProjectSelection;
        if ( projCnt < ctrlCount ) {
            project = NULL;
            // Check items in descending order so deletion won't change indexes of items yet to be checked
            for(j=ctrlCount-1; j>=0; --j) {
                ctrl_url = ((ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(j))->project_url;
                project = pDoc->state.lookup_project(ctrl_url);
                if ( project == NULL ) {
                    selData = (ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(j);
                    delete selData;
                    // Indicate to Delete() we have cleaned up the Selection Data
                    m_ProjectSelectionCtrl->SetClientData(j, NULL);
                    m_ProjectSelectionCtrl->Delete(j);
                    if (j == oldProjectSelection) {
                        int newCount = m_ProjectSelectionCtrl->GetCount();
                        if (newProjectSelection < newCount) {
                            // Select the next item if one exists
                            m_ProjectSelectionCtrl->SetSelection(newProjectSelection);
                        } else if (newCount > 0) {
                            // Select the previous item if one exists
                            newProjectSelection = newCount-1;
                            m_ProjectSelectionCtrl->SetSelection(newProjectSelection);
                        } else {
                            newProjectSelection = -1;
                            m_ProjectSelectionCtrl->SetSelection(wxNOT_FOUND);
                        }
                    }
                }
            }
        }
    
        // Check to see if we need to reload the project icon
        ctrlCount = m_ProjectSelectionCtrl->GetCount();
        for(j=0; j<ctrlCount; j++) {
            selData = (ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(j);
            ctrl_url = selData->project_url;
            project = pDoc->state.lookup_project(ctrl_url);
            if ( project->project_files_downloaded_time > selData->project_files_downloaded_time ) {
                wxBitmap* projectBM = GetProjectSpecificBitmap(ctrl_url);
                selData->project_files_downloaded_time = project->project_files_downloaded_time;
                m_ProjectSelectionCtrl->SetItemBitmap(j, *projectBM);
            }
        }
    }
}
Ejemplo n.º 14
0
void CSimpleProjectPanel::UpdateInterface() {
    int n, count = -1;
    bool b_needMenuRebuild = false;
    wxString str = wxEmptyString;
    wxString projName = wxEmptyString;
    CMainDocument* pDoc = wxGetApp().GetDocument();

    wxASSERT(pDoc);

    // Should we display the synchronize button instead of the
    //   attach to project button?
    if ( pDoc->IsConnected() ) {
        CC_STATUS       status;
        int             is_acct_mgr_detected = 0;

        pDoc->GetCoreClientStatus(status);

        if (pDoc->m_iAcct_mgr_info_rpc_result == 0) {
            // We use an integer rather than a bool to force action the first time
            is_acct_mgr_detected = pDoc->ami.acct_mgr_url.size() ? 1 : 0;
            
            if ((m_UsingAccountManager != is_acct_mgr_detected) || (!m_TaskAddProjectButton->IsEnabled())) {
                m_UsingAccountManager = is_acct_mgr_detected;
                if (is_acct_mgr_detected) {
                    m_TaskAddProjectButton->SetLabel(m_sSynchronizeString);
                    m_TaskAddProjectButton->Enable();
                    m_TaskAddProjectButton->SetToolTip(m_sSynchronizeToolTip);
                } else {
                    m_TaskAddProjectButton->SetLabel(m_sAddProjectString);
                    if (!status.disallow_attach) {
                        m_TaskAddProjectButton->Enable();
                        m_TaskAddProjectButton->SetToolTip(m_sAddProjectToolTip);
                   }
                }
                this->Layout();
            }
        } else {
            m_TaskAddProjectButton->Disable();
        }

        UpdateProjectList();
        
        count = m_ProjectSelectionCtrl->GetCount();
    }
    if (count > 0) {
        n = m_ProjectSelectionCtrl->GetSelection();
        if ((n < 0) || (n > count -1)) {
            m_ProjectSelectionCtrl->SetSelection(0);
            n = 0;
        }
        
        // Check to see if we need to rebuild the menu
        char* ctrl_url = ((ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(n))->project_url;
        if (strcmp(m_CurrentSelectedProjectURL, ctrl_url)) {
            b_needMenuRebuild = true;
            strncpy(m_CurrentSelectedProjectURL, ctrl_url, sizeof(m_CurrentSelectedProjectURL));
        }
        
        PROJECT* project = pDoc->state.lookup_project(ctrl_url);
        if ( project != NULL && project->last_rpc_time > m_Project_last_rpc_time ) {
            b_needMenuRebuild = true;
            m_Project_last_rpc_time = project->last_rpc_time;
        }
        
        if (b_needMenuRebuild) {
            m_ProjectWebSitesButton->RebuildMenu();
        }

        m_ProjectWebSitesButton->Enable();
        m_ProjectCommandsButton->Enable();
        
        if (m_fDisplayedCredit != project->user_total_credit) {
            str.Printf(wxT("%s: %s"),
                m_sTotalWorkDoneString.c_str(),
                format_number(project->user_total_credit, 0)
            );
            UpdateStaticText(&m_TotalCreditValue, str);
            m_TotalCreditValue->SetName(str);   // For accessibility on Windows
        }
        projName = m_ProjectSelectionCtrl->GetStringSelection();
        str.Printf(_("Pop up a menu of web sites for project %s"), projName.c_str());
        m_ProjectWebSitesButton->SetToolTip(str);
        str.Printf(_("Pop up a menu of commands to apply to project %s"), projName.c_str());
        m_ProjectCommandsButton->SetToolTip(str);
    } else {
        m_ProjectWebSitesButton->Disable();
        m_ProjectCommandsButton->Disable();
        m_CurrentSelectedProjectURL[0] = '\0';
        m_fDisplayedCredit = -1.0;
        UpdateStaticText(&m_TotalCreditValue, wxEmptyString);
        m_TotalCreditValue->SetName(wxEmptyString);   // For accessibility on Windows
        m_ProjectWebSitesButton->SetToolTip(wxEmptyString);
        m_ProjectCommandsButton->SetToolTip(wxEmptyString);
    }
}
Ejemplo n.º 15
0
void CBOINCClientManager::ShutdownBOINCCore() {
    wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::ShutdownBOINCCore - Function Begin"));

    CMainDocument*     pDoc = wxGetApp().GetDocument();
    wxInt32            iCount = 0;
    DWORD              dwExitCode = 0;
    bool               bClientQuit = false;
    std::string        strPassword;

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

    if (m_bBOINCStartedByManager) {
        if (!pDoc->IsLocalClient()) {
            RPC_CLIENT rpc;
            if (!rpc.init("localhost")) {
                try {
                    strPassword = read_gui_rpc_password();
                } catch (...) {
                    // Ignore any errors here and set an empty password.
                    // This will happen if the manager does not find the
                    // GUI-RPC-password file in its working directory.
                }
                rpc.authorize(strPassword.c_str());
                if (GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
                    if (STILL_ACTIVE == dwExitCode) {
                        rpc.quit();
                        for (iCount = 0; iCount <= 10; iCount++) {
                            if (!bClientQuit && GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
                                if (STILL_ACTIVE != dwExitCode) {
                                    wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - (localhost) Application Exit Detected"));
                                    bClientQuit = true;
                                    break;
                                }
                            }
                            wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - (localhost) Application Exit NOT Detected, Sleeping..."));
                            ::wxSleep(1);
                        }
                    }
                }
            }
            rpc.close();
        } else {
            if (GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
                if (STILL_ACTIVE == dwExitCode) {
                    pDoc->CoreClientQuit();
                    for (iCount = 0; iCount <= 10; iCount++) {
                        if (!bClientQuit && GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
                            if (STILL_ACTIVE != dwExitCode) {
                                wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - Application Exit Detected"));
                                bClientQuit = true;
                                break;
                            }
                        }
                        wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - Application Exit NOT Detected, Sleeping..."));
                        ::wxSleep(1);
                    }
                }
            }
        }

        if (!bClientQuit) {
            ::wxKill(m_lBOINCCoreProcessId);
        }
        m_lBOINCCoreProcessId = 0;
    }

    wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::ShutdownBOINCCore - Function End"));
}
Ejemplo n.º 16
0
void CViewWork::UpdateSelection() {
    int                 i, n, row;
    CTaskItemGroup*     pGroup = NULL;
    RESULT*             result = NULL;
    PROJECT*            project = NULL;
    CC_STATUS           status;
    CMainDocument*      pDoc = wxGetApp().GetDocument();
    std::string         first_project_url;
    wxString            strMachineName;
    bool                wasSuspended=false;
    bool                all_same_project=false;
    bool                enableShowGraphics = false;
    bool                enableShowVMConsole = false;
    bool                enableSuspendResume = false;
    bool                enableAbort = false;
    bool                enableProperties = false;

    wxASSERT(NULL != pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    wxASSERT(NULL != m_pTaskPane);

    CBOINCBaseView::PreUpdateSelection();

    pGroup = m_TaskGroups[0];
    
    n = m_pListPane->GetSelectedItemCount();
    if (n > 0) {
        enableShowGraphics = true;
        enableShowVMConsole = true;
        enableSuspendResume = true;
        enableAbort = true;
        
        pDoc->GetCoreClientStatus(status);
        if (status.task_suspend_reason & ~(SUSPEND_REASON_CPU_THROTTLE)) {
            enableShowGraphics = false;
            enableShowVMConsole = false;
        }

        pDoc->GetConnectedComputerName(strMachineName);
        if (!pDoc->IsComputerNameLocal(strMachineName)) {
            enableShowGraphics = false;
            enableShowVMConsole = false;
        }
    }

    if (pDoc->m_ActiveTasksOnly) {
        m_pTaskPane->UpdateTask(
            pGroup->m_Tasks[BTN_ACTIVE_ONLY],
            _("Show all tasks"),
            _("Show all tasks.")
        );
    } else {
        m_pTaskPane->UpdateTask(
            pGroup->m_Tasks[BTN_ACTIVE_ONLY],
            _("Show active tasks"),
            _("Show only active tasks.")
        );
    }

    row = -1;
    for (i=0; i<n; i++) {
        // Step through all selected items
        row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (row < 0) break;     // Should never happen
        
        result = pDoc->result(m_iSortedIndexes[row]);
        if (!result) continue;
        if (i == 0) {
            wasSuspended = result->suspended_via_gui;
            if (result->suspended_via_gui) {
                m_pTaskPane->UpdateTask(
                    pGroup->m_Tasks[BTN_SUSPEND],
                    _("Resume"),
                    _("Resume work for this task.")
                );
            } else {
                m_pTaskPane->UpdateTask(
                    pGroup->m_Tasks[BTN_SUSPEND],
                    _("Suspend"),
                    _("Suspend work for this task.")
                );
            }
        } else {
            if (wasSuspended != result->suspended_via_gui) {
                // Disable Suspend / Resume button if the multiple selection
                // has a mix of suspended and not suspended tasks
                enableSuspendResume = false;
            }
        }
        
        // Disable Show VM console if the selected task hasn't registered a remote
        // desktop connection
        //
        if (!strlen(result->remote_desktop_addr)) {
            enableShowVMConsole = false;
        }

        // Disable Show Graphics button if the selected task can't display graphics
        //
        if (!strlen(result->web_graphics_url) && !strlen(result->graphics_exec_path)) {
            enableShowGraphics = false;
        }

        if (result->suspended_via_gui ||
            result->project_suspended_via_gui || 
            (result->scheduler_state != CPU_SCHED_SCHEDULED)
        ) {
            enableShowGraphics = false;
        }
       
        // Disable Abort button if any selected task already aborted
        if (
            result->active_task_state == PROCESS_ABORT_PENDING ||
            result->active_task_state == PROCESS_ABORTED ||
            result->state == RESULT_ABORTED 
        ) {
            enableAbort = false;
        }

       if (i == 0) {
            first_project_url = result->project_url;
            all_same_project = true;
        } else {
            if (first_project_url != result->project_url) {
                all_same_project = false;
            }
        }
        
        if (n == 1) {
            enableProperties = true;
        }
    }

    // To minimize flicker, set each button only once to the final desired state
    pGroup->m_Tasks[BTN_GRAPHICS]->m_pButton->Enable(enableShowGraphics);
    if (enableShowVMConsole) {
        pGroup->m_Tasks[BTN_VMCONSOLE]->m_pButton->Enable();
        pGroup->m_Tasks[BTN_VMCONSOLE]->m_pButton->Show();
    } else {
        pGroup->m_Tasks[BTN_VMCONSOLE]->m_pButton->Disable();
        pGroup->m_Tasks[BTN_VMCONSOLE]->m_pButton->Hide();
    }
    pGroup->m_Tasks[BTN_SUSPEND]->m_pButton->Enable(enableSuspendResume);
    pGroup->m_Tasks[BTN_ABORT]->m_pButton->Enable(enableAbort);
    pGroup->m_Tasks[BTN_PROPERTIES]->m_pButton->Enable(enableProperties);

    if (all_same_project) {
        project = pDoc->state.lookup_project(result->project_url);
        UpdateWebsiteSelection(GRP_WEBSITES, project);
        if(m_TaskGroups.size()>1) {
            m_pTaskPane->EnableTaskGroupTasks(m_TaskGroups[1]);
        }
    } else {
        UpdateWebsiteSelection(GRP_WEBSITES, NULL);
        if(m_TaskGroups.size()>1) {
            m_pTaskPane->DisableTaskGroupTasks(m_TaskGroups[1]);
        }
    }

    CBOINCBaseView::PostUpdateSelection();
}
Ejemplo n.º 17
0
void CViewWork::OnWorkAbort( wxCommandEvent& WXUNUSED(event) ) {
    wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkAbort - Function Begin"));

    wxInt32  iAnswer        = 0;
    wxString strMessage     = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    CAdvancedFrame* pFrame  = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
    CWork* work;
    int row, n;

    wxASSERT(pDoc);
    wxASSERT(pFrame);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
    wxASSERT(m_pTaskPane);
    wxASSERT(m_pListPane);

    if (!pDoc->IsUserAuthorized())
        return;

    n = m_pListPane->GetSelectedItemCount();
    
    if (n == 1) {
        row = -1;
        row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (row < 0) return;
        if (GetWorkCacheAtIndex(work, m_iSortedIndexes[row])) {
            return;
        }
        strMessage.Printf(
           _("Are you sure you want to abort this task '%s'?\n(Progress: %s, Status: %s)"), 
           (work->m_strName).c_str(),
           (work->m_strProgress).c_str(),
           (work->m_strStatus).c_str()
        );
    } else {
        strMessage.Printf(_("Are you sure you want to abort these %d tasks?"), n);
    }

    iAnswer = wxGetApp().SafeMessageBox(
        strMessage,
        _("Abort task"),
        wxYES_NO | wxICON_QUESTION,
        this
    );

    if (wxYES != iAnswer) {
        return;
    }

    pFrame->UpdateStatusText(_("Aborting result..."));

    row = -1;
    while (1) {
        // Step through all selected items
        row = m_pListPane->GetNextItem(row, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (row < 0) break;
        
        RESULT* result = pDoc->result(m_iSortedIndexes[row]);
        if (result) {
            pDoc->WorkAbort(result->project_url, result->name);
        }
    }

    pFrame->UpdateStatusText(wxT(""));

    UpdateSelection();
    pFrame->FireRefreshView();

    wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkAbort - Function End"));
}
Ejemplo n.º 18
0
void CProjectsComponent::UpdateInterface()
{
	CMainDocument* pDoc = wxGetApp().GetDocument();

	// Check to see if error messages have been received
	if ( receivedErrorMessage ) {
		Freeze();
		if ( alertMessageDisplayed ) {
			btnAlertMessages->Show(false);
			btnMessages->Show(true);
			alertMessageDisplayed = false;
		} else {
			btnAlertMessages->Show(true);
			btnMessages->Show(false);
			alertMessageDisplayed = true;
		}
		Thaw();
	} else {
		if ( alertMessageDisplayed ) {
			Freeze();
			btnAlertMessages->Show(false);
			btnMessages->Show(true);
			alertMessageDisplayed = false;
			Thaw();
		}
	}

    // Should we display the synchronize button instead of the
    //   attach to project button?
	CC_STATUS       status;
    bool            is_acct_mgr_detected = false;

	pDoc->GetCoreClientStatus(status);

    is_acct_mgr_detected = pDoc->ami.acct_mgr_url.size() ? true : false;

    if (is_acct_mgr_detected) {
		btnAddProj->Show(false);
		btnSynchronize->Show(true);
	} else {
        if (!status.disallow_attach) {
		    btnAddProj->Show(true);
        }
		btnSynchronize->Show(false);
    }

    // Show resume or pause as appropriate
    if (RUN_MODE_NEVER == status.task_mode) {
		btnPause->Show(false);
		btnResume->Show(true);
	} else {
		btnPause->Show(true);
		btnResume->Show(false);
	}

    // Should we disable the attach to project button?
    if (status.disallow_attach || is_acct_mgr_detected) {
        btnAddProj->Show(false);
    } else {
        btnAddProj->Show(true);
    }

    // Should we only be able to see the simple gui?
    if (status.simple_gui_only) {
        btnAdvancedView->Show(false);
    } else {
        btnAdvancedView->Show(true);
    }

	// Check number of projects
	UpdateProjectArray();

	// Update stat icons
	for(int m = 0; m < (int)m_statProjects.size(); m++){
		StatImageLoader *i_statIcon = m_statProjects.at(m);
		i_statIcon->UpdateInterface();
	}
	
}
Ejemplo n.º 19
0
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);
    }
}
Ejemplo n.º 20
0
void CViewMessages::OnListRender (wxTimerEvent& event) {
    bool isConnected;
    static bool was_connected = false;
    static wxString strLastMachineName = wxEmptyString;
    wxString strNewMachineName = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    if (!m_bProcessingListRenderEvent) {
        m_bProcessingListRenderEvent = true;

        wxASSERT(m_pListPane);

        isConnected = pDoc->IsConnected();
        wxInt32 iRowCount = GetDocCount();
        if (0 >= iRowCount) {
            m_pListPane->DeleteAllItems();
        } else {
            // If connection status changed, adjust color of messages display
            if (was_connected != isConnected) {
                was_connected = isConnected;
                if (isConnected) {
                    m_pMessageInfoAttr->SetTextColour(*wxBLACK);
                    m_pMessageErrorAttr->SetTextColour(*wxRED);
                    m_pMessageInfoGrayAttr->SetTextColour(*wxBLACK);
                    m_pMessageErrorGrayAttr->SetTextColour(*wxRED);
                } else {
                    wxColourDatabase colorBase;
                    m_pMessageInfoAttr->SetTextColour(wxColour(128, 128, 128));
                    m_pMessageErrorAttr->SetTextColour(wxColour(255, 128, 128));
                    m_pMessageInfoGrayAttr->SetTextColour(wxColour(128, 128, 128));
                    m_pMessageErrorGrayAttr->SetTextColour(wxColour(255, 128, 128));
                }
                // Force a complete update
                m_pListPane->DeleteAllItems();
                m_pListPane->SetItemCount(iRowCount);
                m_iPreviousRowCount = 0;    // Force scrolling to bottom
            } else {
                // Connection status didn't change
                if (m_iPreviousRowCount != iRowCount) {
                    m_pListPane->SetItemCount(iRowCount);
                }
            }
        }

        if ((iRowCount>1) && (_EnsureLastItemVisible()) && (m_iPreviousRowCount != iRowCount)) {
            m_pListPane->EnsureVisible(iRowCount - 1);
        }

        if (isConnected) {
            pDoc->GetConnectedComputerName(strNewMachineName);
            if (strLastMachineName != strNewMachineName) {
                strLastMachineName = strNewMachineName;
                     if (iRowCount) {
                        m_pListPane->EnsureVisible(iRowCount - 1);
                    }
            }
        }

        if (m_iPreviousRowCount != iRowCount) {
            m_iPreviousRowCount = iRowCount;
        }

        m_bProcessingListRenderEvent = false;
    }

    event.Skip();
}
void CViewResources::OnListRender( wxTimerEvent& WXUNUSED(event) ) {
    CMainDocument* pDoc = wxGetApp().GetDocument();
    wxString diskspace;
	static double project_total=0.0;
	unsigned int i;

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

	//get data for BOINC projects disk usage
    pDoc->CachedDiskUsageUpdate();
    pDoc->CachedStateUpdate();
	bool refreshBOINC=false;
	if (pDoc->disk_usage.projects.size()>0) {
		m_BOINCwasEmpty=false;
		//check for changes worth a refresh
		if(pDoc->disk_usage.projects.size() != m_pieCtrlBOINC->m_Series.size()) {
			refreshBOINC=true;
		} else {
			for (i=0; i<pDoc->disk_usage.projects.size(); i++) {
				wxString oldValue;
				wxString newValue;
				FormatDiskSpace(pDoc->DiskUsageProject(i)->disk_usage, newValue);
				FormatDiskSpace(m_pieCtrlBOINC->m_Series.Item(i).GetValue(), oldValue);
				if(newValue.Cmp(oldValue)!=0) {
					refreshBOINC=true;
					break;
				}
			}
		}
		//only refresh when worthy changes
		if(refreshBOINC) {
			m_pieCtrlBOINC->m_Series.Clear();
            project_total = 0;
			for (i=0; i<pDoc->disk_usage.projects.size(); i++) {
				//update data for boinc projects pie chart
				PROJECT* project = pDoc->DiskUsageProject(i);
				wxString projectname;
				FormatProjectName(project, projectname);
				FormatDiskSpace(project->disk_usage, diskspace);
				double usage = project->disk_usage;
				project_total += usage;
				wxPiePart part;
                part.SetLabel(projectname + wxT(": ") + diskspace);
				part.SetValue(usage);
                unsigned char r=128+(rand()&127);
                unsigned char g=128+(rand()&127);
                unsigned char b=128+(rand()&127);
                part.SetColour(wxColour(r, g, b));
				m_pieCtrlBOINC->m_Series.Add(part);
			}
			m_pieCtrlBOINC->Refresh();
		}
	} else {
		if(!m_BOINCwasEmpty) {
            //paint an empty black pie
			m_pieCtrlBOINC->m_Series.Clear();
			wxPiePart part;
            part.SetLabel(_("not attached to any BOINC project: 0 bytes"));
			part.SetValue(1);
			part.SetColour(wxColour(0,0,0));
			m_pieCtrlBOINC->m_Series.Add(part);
			m_pieCtrlBOINC->Refresh();
			m_BOINCwasEmpty=true;
			refreshBOINC=true;
        }
	}

    //pDoc->disk_usage.d_allowed = 0;
	//data for pie chart 2 (total disk usage)
	//
	// good source of color palettes:
	// http://www.siteprocentral.com/cgi-bin/feed/feed.cgi
	//
	bool refreshTotal=false;
	double free = pDoc->disk_usage.d_free;
	double total = pDoc->disk_usage.d_total;
	if(m_pieCtrlTotal->m_Series.size()>0) {
		wxString oldFree;
		wxString newFree;
		FormatDiskSpace(free, newFree);
		FormatDiskSpace(m_pieCtrlTotal->m_Series.Item(0).GetValue(), oldFree);
		if(oldFree.Cmp(newFree)!=0) {
			refreshTotal=true;
		}
	} else {
		refreshTotal=true;
	}
	if(refreshBOINC || refreshTotal) {
		m_pieCtrlTotal->m_Series.Clear();
		wxPiePart part;

		// used by BOINC
        double boinc_total = project_total + pDoc->disk_usage.d_boinc;
        FormatDiskSpace(boinc_total, diskspace);
        part.SetLabel(_("used by BOINC: ") + diskspace);
		part.SetValue(boinc_total);
		part.SetColour(wxColour(0,0,0));
		m_pieCtrlTotal->m_Series.Add(part);

        if (pDoc->disk_usage.d_allowed > 0) {
            double avail = pDoc->disk_usage.d_allowed - boinc_total;
            if (avail > 0) {
                if (avail > free) avail = free;
		        FormatDiskSpace(avail, diskspace);
                part.SetLabel(_("free, available to BOINC: ") + diskspace);
		        part.SetValue(avail);
		        part.SetColour(wxColour(128, 128, 128));
		        m_pieCtrlTotal->m_Series.Add(part);
            } else {
                avail = 0;
            }
            double not_avail = free - avail;
            if (not_avail > 0) {
		        FormatDiskSpace(not_avail, diskspace);
                part.SetLabel(_("free, not available to BOINC: ") + diskspace);
		        part.SetValue(not_avail);
		        part.SetColour(wxColour(238,238,238));
		        m_pieCtrlTotal->m_Series.Add(part);
            }
        } else {
            // if d_allowed is zero, we must be talking to a pre-6.3 client.
            // Just show free space
            //
		    FormatDiskSpace(free, diskspace);
            part.SetLabel(_("free: ") + diskspace);
		    part.SetValue(free);
		    part.SetColour(wxColour(238,238,238));
		    m_pieCtrlTotal->m_Series.Add(part);
        }


		// used by others
        double used_by_others = total-boinc_total-free;
		FormatDiskSpace(used_by_others, diskspace);
        part.SetLabel(_("used by other programs: ") + diskspace);
		part.SetValue(used_by_others);
		part.SetColour(wxColour(192,192,192));
		m_pieCtrlTotal->m_Series.Add(part);
		m_pieCtrlTotal->Refresh();
	}
}
Ejemplo n.º 22
0
int CBOINCGUIApp::ConfirmExit() {
    CSkinAdvanced*  pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
    CMainDocument*  pDoc = wxGetApp().GetDocument();
    wxString        strConnectedCompter = wxEmptyString;
    bool            bWasVisible;
    int             retval = 0;

    wxASSERT(pDoc);
    wxASSERT(pSkinAdvanced);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
    
    pDoc->GetConnectedComputerName(strConnectedCompter);
    if (!pDoc->IsComputerNameLocal(strConnectedCompter)) {
        // Don't shut down remote clients on Manager exit
        return 1;
    }

    // Don't run confirmation dialog if logging out or shutting down Mac, 
    // or if emergency exit from AsyncRPCDlg
    if (s_bSkipExitConfirmation) return 1;

    // Don't run confirmation dialog if second instance of Manager 
    if (IsMgrMultipleInstance()) return 1;

    if (!m_iDisplayExitDialog) {
        // Mac: User doesn't want to display the dialog and just wants to use their previous value.
        // Win & Linux: User doesn't want to display the dialog and wants to shutdown the client.
        return 1;
    }

    bWasVisible = IsApplicationVisible();
    ShowApplication(true);

    CDlgExitMessage dlg(NULL);

    if (!pSkinAdvanced->GetExitMessage().IsEmpty()) {
        dlg.m_DialogExitMessage->SetLabel(pSkinAdvanced->GetExitMessage());
    }

#ifdef __WXMSW__
    if (m_iShutdownCoreClient) {
        dlg.m_DialogShutdownCoreClient->SetValue(TRUE);
    }
#endif

    if (m_iDisplayExitDialog) {
        dlg.m_DialogDisplay->SetValue(FALSE);
    }

    dlg.Fit();
    dlg.Centre();

    if (wxID_OK == dlg.ShowModal()) {
#ifdef __WXMAC__
        s_bSkipExitConfirmation = true;     // Don't ask twice (only affects Mac)
#else
        m_iShutdownCoreClient = dlg.m_DialogShutdownCoreClient->GetValue();
#endif
        m_iDisplayExitDialog = !dlg.m_DialogDisplay->GetValue();
        retval = true;

    }

    if (!bWasVisible) {
        ShowApplication(false);
    }

    return retval;       // User cancelled exit
}
Ejemplo n.º 23
0
void CSimpleTaskPanel::UpdatePanel(bool delayShow) {
    wxString s = wxEmptyString;
    wxString projName = wxEmptyString;
    TaskSelectionData *selData;
    CMainDocument*      pDoc = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    int                 workCount = pDoc->GetSimpleGUIWorkCount();

    // Workaround for Linux refresh problem
    static bool        wasDelayed = false;

#ifndef __WXMAC__
    Freeze();
#endif
    
    if ((workCount <= 0) || delayShow) {
        if ((workCount != m_oldWorkCount) || delayShow) {
            wasDelayed = true;
            m_myTasksLabel->Hide();
            m_TaskSelectionCtrl->Hide();
            m_TaskProjectLabel->Hide();
            m_TaskProjectName->Hide();
#if SELECTBYRESULTNAME
            m_TaskApplicationName->Hide();
#endif  // SELECTBYRESULTNAME
            m_SlideShowArea->Hide();
            m_ElapsedTimeValue->Hide();
            m_TimeRemainingValue->Hide();
            if (m_iPctDoneX10 >= 0) {
                m_iPctDoneX10 = -1;
                m_ProgressBar->Hide();
            }
            m_ProgressValueText->Hide();
            m_TaskCommandsButton->Hide();
            this->Layout();

#ifdef __WXMAC__
            m_ProgressRect = m_ProgressBar->GetRect();
            m_ProgressRect.Inflate(0, -2);
            m_ProgressRect.Offset(0, -2);
#endif
        }
        
        DisplayIdleState();
        
    } else {
        if ((m_oldWorkCount == 0) || wasDelayed) {
            wasDelayed = false;
            m_myTasksLabel->Show();
            m_TaskSelectionCtrl->Show();
            m_TaskProjectLabel->Show();
            m_TaskProjectName->Show();
#if SELECTBYRESULTNAME
            m_TaskApplicationName->Show();
#endif  // SELECTBYRESULTNAME
            m_SlideShowArea->Show();
            m_ElapsedTimeValue->Show();
            m_TimeRemainingValue->Show();
            m_ProgressBar->Show();
            m_ProgressValueText->Show();
            m_TaskCommandsButton->Show();
            this->Layout();
    
#ifdef __WXMAC__
            m_ProgressRect = m_ProgressBar->GetRect();
            m_ProgressRect.Inflate(0, -2);
            m_ProgressRect.Offset(0, -2);
#endif
        }

        UpdateTaskSelectionList(false);
        
        // We now have valid result pointers, so extract our data
        int count = m_TaskSelectionCtrl->GetCount();
        if (count <= 0) {
            m_CurrentTaskSelection = -1;
        } else {
            if ((m_CurrentTaskSelection < 0) || (m_CurrentTaskSelection > count -1)) {
                m_TaskSelectionCtrl->SetSelection(0);
                m_CurrentTaskSelection = 0;
                m_bStableTaskInfoChanged = true;
            }
            selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(m_CurrentTaskSelection);
            RESULT* result = selData->result;
            if (result) {
                if (m_bStableTaskInfoChanged) {
#if SELECTBYRESULTNAME
                    wxString str = wxEmptyString;
                    GetApplicationAndProjectNames(result, &s, &projName);
                    str.Printf(_("Application: %s"), s.c_str());
                    UpdateStaticText(&m_TaskApplicationName, str);
                    UpdateStaticText(&m_TaskProjectName, projName);
#else   // SELECTBYRESULTNAME
                    GetApplicationAndProjectNames(result, NULL, &projName);
#endif  // SELECTBYRESULTNAME
                    UpdateStaticText(&m_TaskProjectName, projName);
                    m_SlideShowArea->AdvanceSlideShow(false, true);
                    m_bStableTaskInfoChanged = false;
                }
                float f = result->elapsed_time;
                if (f == 0.) f = result->current_cpu_time;
//                f = result->final_elapsed_time;
                UpdateStaticText(&m_ElapsedTimeValue, GetElapsedTimeString(f));
                UpdateStaticText(&m_TimeRemainingValue, GetTimeRemainingString(result->estimated_cpu_time_remaining));
                int pctDoneX10 = result->fraction_done * 1000.0;
                if (m_iPctDoneX10 != pctDoneX10) {
                    int pctDone = pctDoneX10 / 10;
                    if (m_iPctDoneX10 != (pctDone * 10)) {
                        m_ProgressBar->SetValue(pctDone);
                    }
                    s.Printf(_("%.3f%%"), result->fraction_done*100);
                    m_iPctDoneX10 = pctDoneX10;
                    UpdateStaticText(&m_ProgressValueText, s);
                }
                UpdateStaticText(&m_StatusValueText, GetStatusString(result));
            } else {
                UpdateStaticText(&m_TaskProjectName, m_sNotAvailableString);
#if SELECTBYRESULTNAME
                UpdateStaticText(&m_TaskApplicationName, _("Application: Not available") );
#endif  // SELECTBYRESULTNAME
                UpdateStaticText(&m_ElapsedTimeValue, GetElapsedTimeString(-1.0));
                UpdateStaticText(&m_TimeRemainingValue, GetTimeRemainingString(-1.0));
                if (m_iPctDoneX10 >= 0) {
                    m_iPctDoneX10 = -1;
                    m_ProgressBar->Hide();
                }
                UpdateStaticText(&m_ProgressValueText, wxEmptyString);
                UpdateStaticText(&m_StatusValueText, GetStatusString(NULL));
            }
        }
    }
    m_oldWorkCount = workCount;

#ifndef __WXMAC__
    Thaw();
#endif
}
Ejemplo n.º 24
0
bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin CDlgEventLog member initialisation
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    m_iPreviousRowCount = 0;
    m_iTotalDocCount = 0;
    m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
    m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum - 1;

    m_iNumDeletedFilteredRows = 0;
    m_iTotalDeletedFilterRows = 0;
    
    if (!s_bIsFiltered) {
        s_strFilteredProjectName.clear();
    }
    m_iFilteredIndexes.Clear();
	m_bProcessingRefreshEvent = false;
    m_bWasConnected = false;
    m_bEventLogIsOpen = true;
////@end CDlgEventLog member initialisation

    CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
    wxPoint oTempPoint;
    wxSize  oTempSize;

    wxASSERT(pSkinAdvanced);
    wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));

    if ((pos == wxDefaultPosition) && (size == wxDefaultSize)) {
        // Get size and position from the previous configuration
        GetWindowDimensions( oTempPoint, oTempSize );

#ifdef __WXMSW__
        // Get the current display space for the current window
		int iDisplay = wxNOT_FOUND;
		if ( wxGetApp().GetFrame() != NULL )
            iDisplay = wxDisplay::GetFromWindow(wxGetApp().GetFrame());
		if ( iDisplay == wxNOT_FOUND )
            iDisplay = 0;
        wxDisplay *display = new wxDisplay(iDisplay);
        wxRect rDisplay = display->GetClientArea();

		// Check that the saved height and width is not larger than the displayable space.
		// If it is, then reduce the size.
        if ( oTempSize.GetWidth() > rDisplay.width ) oTempSize.SetWidth(rDisplay.width);
        if ( oTempSize.GetHeight() > rDisplay.height ) oTempSize.SetHeight(rDisplay.height);

        // Check if part of the display was going to be off the screen, if so, center the 
        // display on that axis
		if ( oTempPoint.x < rDisplay.x ) {
			oTempPoint.x = rDisplay.x;
		} else if ( oTempPoint.x + oTempSize.GetWidth() > rDisplay.x + rDisplay.width ) {
			oTempPoint.x = rDisplay.x + rDisplay.width - oTempSize.GetWidth();
		}

		if ( oTempPoint.y < rDisplay.y ) {
			oTempPoint.y = rDisplay.y;
		} else if ( oTempPoint.y + oTempSize.GetHeight() > rDisplay.y + rDisplay.height ) {
			oTempPoint.y = rDisplay.y + rDisplay.height - oTempSize.GetHeight();
		}

        delete display;
#endif
#ifdef __WXMAC__
        // If the user has changed the arrangement of multiple 
        // displays, make sure the window title bar is still on-screen.
    if (!IsWindowOnScreen(oTempPoint.x, oTempPoint.y, oTempSize.GetWidth(), oTempSize.GetHeight())) {
        oTempPoint.y = oTempPoint.x = 30;
    }
#endif  // ! __WXMAC__
    } else {
        oTempPoint = pos;
        oTempSize = size;
    }

    wxDialog::Create( parent, id, caption, oTempPoint, oTempSize, style );

    SetSizeHints(DLGEVENTLOG_MIN_WIDTH, DLGEVENTLOG_MIN_HEIGHT);
    SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);

    // Initialize Application Title
    wxString strCaption = caption;
    if (strCaption.IsEmpty()) {
        strCaption.Printf(_("%s - Event Log"), pSkinAdvanced->GetApplicationName().c_str());
    }
    SetTitle(strCaption);

    // Initialize Application Icon
    SetIcons(*pSkinAdvanced->GetApplicationIcon());

    CreateControls();

	// Create List Pane Items
    m_pList->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 109);
    m_pList->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 130);
    m_pList->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, 378);

    m_pMessageInfoAttr = new wxListItemAttr(
        wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
        wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
        wxNullFont
    );
    m_pMessageErrorAttr = new wxListItemAttr(
        *wxRED,
        wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
        wxNullFont
    );
#if EVENT_LOG_STRIPES
    m_pMessageInfoGrayAttr = new wxListItemAttr(
        wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
        wxColour(240, 240, 240),
        wxNullFont
    );
    m_pMessageErrorGrayAttr = new wxListItemAttr(*wxRED, wxColour(240, 240, 240), wxNullFont);
#else
    m_pMessageInfoGrayAttr = new wxListItemAttr(*m_pMessageInfoAttr);
    m_pMessageErrorGrayAttr = new wxListItemAttr(*m_pMessageErrorAttr);
#endif

    SetTextColor();
    RestoreState();
    OnRefresh();
    // Register that we had the Event Log open immediately
    SaveState();
    
    m_Shortcuts[0].Set(wxACCEL_CTRL|wxACCEL_SHIFT, (int)'F', ID_SGDIAGNOSTICLOGFLAGS);
    m_pAccelTable = new wxAcceleratorTable(1, m_Shortcuts);

    SetAcceleratorTable(*m_pAccelTable);

    return true;
}
Ejemplo n.º 25
0
void CProjectsComponent::MessagesViewed() {
	receivedErrorMessage = false;
	CMainDocument* pDoc = wxGetApp().GetDocument();
	lastMessageId = pDoc->GetMessageCount();
	checkForMessagesTimer->Start();
}
Ejemplo n.º 26
0
void CViewMessages::OnListRender (wxTimerEvent& event) {
    bool isConnected;
    static bool was_connected = false;
    static wxString strLastMachineName = wxEmptyString;
    wxString strNewMachineName = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    if (!m_bProcessingListRenderEvent) {
        m_bProcessingListRenderEvent = true;

        wxASSERT(m_pListPane);

        isConnected = pDoc->IsConnected();
        wxInt32 iDocCount = GetDocCount();
        if (0 >= iDocCount) {
            m_pListPane->DeleteAllItems();
        } else {
            // If connection status changed, adjust color of messages display
            if (was_connected != isConnected) {
                was_connected = isConnected;
                if (isConnected) {
                    m_pMessageInfoAttr->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
                    m_pMessageErrorAttr->SetTextColour(*wxRED);
                } else {
                    m_pMessageInfoAttr->SetTextColour(CBOINCListCtrl::GetBlendedColour(
                                wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
                                wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.5));
                    m_pMessageErrorAttr->SetTextColour(CBOINCListCtrl::GetBlendedColour(*wxRED,
                                wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.5));
                }
                m_pMessageInfoAttr->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
                m_pMessageErrorAttr->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
                // Force a complete update
                m_pListPane->DeleteAllItems();
                m_pListPane->SetItemCount(iDocCount);
           }
            
            if (m_iPreviousDocCount != iDocCount)
                m_pListPane->SetItemCount(iDocCount);
        }

        if ((iDocCount > 1) && (_EnsureLastItemVisible()) && (m_iPreviousDocCount != iDocCount)) {
            m_pListPane->EnsureVisible(iDocCount - 1);
        }

        if (isConnected) {
            pDoc->GetConnectedComputerName(strNewMachineName);
            if (strLastMachineName != strNewMachineName) {
                strLastMachineName = strNewMachineName;
                if (iDocCount > 1) {
                    m_pListPane->EnsureVisible(iDocCount - 1);
                }
            }
        }

        if (m_iPreviousDocCount != iDocCount) {
            m_iPreviousDocCount = iDocCount;
        }

        m_bProcessingListRenderEvent = false;
    }

    event.Skip();
}
Ejemplo n.º 27
0
// NOTE: this function is designed to be called only
// from CDlgEventLog::OnRefresh().  If you need to call it
// from other routines, it will need modification.
//
// Get the (possibly filtered) item count (i.e., the Row count) and
// make any needed adjustments if oldest items have been deleted.
wxInt32 CDlgEventLog::GetDocCount() {
    int i, j, numDeletedRows;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    m_iTotalDocCount = pDoc->GetMessageCount();

    numDeletedRows = pDoc->GetFirstMsgSeqNum() - m_iPreviousFirstMsgSeqNum;
    if ((numDeletedRows < 0) || (m_iPreviousFirstMsgSeqNum < 0)) {
        numDeletedRows = 0;
    }
    m_iNumDeletedFilteredRows = 0;

    if (s_bIsFiltered) {
        if (numDeletedRows > 0) {
            // Remove any deleted messages from our filtered list
            while (m_iFilteredIndexes.GetCount() > 0) {
                if (m_iFilteredIndexes[0] >= numDeletedRows) break;
                m_iFilteredIndexes.RemoveAt(0);
                m_iNumDeletedFilteredRows++;
                m_iTotalDeletedFilterRows++;
            }
            
            // Adjust the remaining indexes
            for (i = m_iFilteredIndexes.GetCount()-1; i >= 0; i--) {
                m_iFilteredIndexes[i] -= numDeletedRows;
            }
        }
        
        // Add indexes of new messages to filtered list as appropriate
        i = m_iTotalDocCount - (pDoc->GetLastMsgSeqNum() - m_iPreviousLastMsgSeqNum);
        if (i < 0) i = 0;
        for (; i < m_iTotalDocCount; i++) {
            MESSAGE* message = pDoc->message(i);
            if (message->project.empty() || (message->project == s_strFilteredProjectName)) {
                m_iFilteredIndexes.Add(i);
            }
        }
        m_iFilteredDocCount = (int)(m_iFilteredIndexes.GetCount());
    } else {
        m_iFilteredDocCount = m_iTotalDocCount;
        m_iNumDeletedFilteredRows = numDeletedRows;
    }

    if (numDeletedRows > 0) {
        // Adjust the selected row numbers
        wxArrayInt arrSelRows;
        
        i = -1;
        for (;;) {
            i = m_pList->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            if (i < 0) break;
            arrSelRows.Add(i);
        }
        int count = arrSelRows.Count();
        for (i=0; i<count; i++) {
            m_pList->SetItemState(arrSelRows[i], 0, wxLIST_STATE_SELECTED);
        }

        for (i=0; i<count; i++) {
            if ((j = arrSelRows[i] - m_iNumDeletedFilteredRows) >= 0) {
                m_pList->SetItemState(j, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
            }
        }
    }
    
    return s_bIsFiltered ? m_iFilteredDocCount : m_iTotalDocCount;
}
Ejemplo n.º 28
0
void CSimpleTaskPopupButton::OnTasksCommandButton(wxMouseEvent& /*event*/) {
    CMainDocument*      pDoc = wxGetApp().GetDocument();
    bool                enableShowGraphics = true;
    bool                enableAbort = true;
    CC_STATUS           status;
    wxString            strMachineName;
    
    wxASSERT(pDoc);
    
    TaskSelectionData* selData = ((CSimpleTaskPanel*)GetParent())->GetTaskSelectionData();
    if (selData == NULL) return;

    RESULT* result = lookup_result(selData->project_url, selData->result_name);

    if (!result) return;
    
    if (result->suspended_via_gui) {
        m_TaskSuspendedViaGUI = true;
        m_SuspendResumeMenuItem->SetItemLabel(_("Resume"));
        m_SuspendResumeMenuItem->SetHelp(_("Resume work for this task."));
    } else {
        m_TaskSuspendedViaGUI = false;
        m_SuspendResumeMenuItem->SetItemLabel(_("Suspend"));
        m_SuspendResumeMenuItem->SetHelp(_("Suspend work for this task."));
    }

    pDoc->GetCoreClientStatus(status);
    if (status.task_suspend_reason & ~(SUSPEND_REASON_CPU_THROTTLE)) {
        enableShowGraphics = false;
    }

    pDoc->GetConnectedComputerName(strMachineName);
    if (!pDoc->IsComputerNameLocal(strMachineName)) {
        enableShowGraphics = false;
    }

    // Disable Show Graphics button if selected task can't display graphics
    if (!strlen(result->web_graphics_url) && !strlen(result->graphics_exec_path)) {
        enableShowGraphics = false;
    }

    if (result->suspended_via_gui ||
        result->project_suspended_via_gui || 
        (result->scheduler_state != CPU_SCHED_SCHEDULED)
    ) {
        enableShowGraphics = false;
    }
    
    m_ShowGraphicsMenuItem->Enable(enableShowGraphics);
   
    // Disable Abort button if any selected task already aborted
    if (
        result->active_task_state == PROCESS_ABORT_PENDING ||
        result->active_task_state == PROCESS_ABORTED ||
        result->state == RESULT_ABORTED 
    ) {
        enableAbort = false;
    }

    m_AbortMenuItem->Enable(enableAbort);

#ifdef __WXMAC__
    // Disable tooltips on Mac while menus are popped up because they cover menus
    wxToolTip::Enable(false);
#endif

	PopupMenu(m_TaskCommandPopUpMenu);


#if TESTBIGICONPOPUP
/*** CAF *** FOR TESTING ONLY ***/
    static int i;
    wxString s;
    
    if (i > 9) i = 0;
    if ( i < 5) {
        s = (wxT("This is a very very very and extremely long label."));
    } else {
        s = (wxT("short."));
    }
        
    switch (i++) {
        case 0:
        case 5:
            UpdateStaticText(&m_TaskProjectName, s);
            break;
        case 1:
        case 6:
            UpdateStaticText(&m_TaskApplicationName, s);
            break;
        case 2:
        case 7:
            UpdateStaticText(&m_ElapsedTimeValue, s);
            break;
        case 3:
        case 8:
            UpdateStaticText(&m_TimeRemainingValue, s);
            break;
        case 4:
        case 9:
            UpdateStaticText(&m_StatusValueText, s);
            break;
    }

	m_ProgressBar->SetValue( i * 10 ); 
    int sel = i % 3;
//    m_TaskSelectionCtrl->SetStringSelection(tempArray[sel]);
    m_TaskSelectionCtrl->SetSelection(sel);
#endif
}
Ejemplo n.º 29
0
void CSimpleTaskPanel::UpdateTaskSelectionList(bool reskin) {
    wxLogTrace(wxT("Function Start/End"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Function Begin"));
    int i, j, count, newIcon;
    TaskSelectionData *selData;
    RESULT* result;
    RESULT* ctrlResult;
    PROJECT* project;
    std::vector<bool>is_alive;
    bool needRefresh = false;
    wxString resname;
    CMainDocument*      pDoc = wxGetApp().GetDocument();
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();

    static bool bAlreadyRunning = false;

    wxASSERT(pDoc);
    wxASSERT(pSkinSimple);
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
    
    if (bAlreadyRunning) {
        return;
    }
    bAlreadyRunning = true;
    
    count = m_TaskSelectionCtrl->GetCount();
    // Mark all inactive (this lets us loop only once)
    for (i=0; i<count; ++i) {
        is_alive.push_back(false);
    }
    
    // First update existing entries and add new ones
    for(i = 0; i < (int) pDoc->results.results.size(); i++) {
        bool found = false;
        
        result = pDoc->result(i);
        // only check tasks that are active
        if ( result == NULL || !result->active_task ) {
            continue;
        }

        resname = wxEmptyString;
#if SELECTBYRESULTNAME
        resname = wxString::FromUTF8(result->name);
#else   // SELECTBYRESULTNAME
        GetApplicationAndProjectNames(result, &resname, NULL);
#endif  // SELECTBYRESULTNAME
        
        // loop through the items already in Task Selection Control to find this result
        count = m_TaskSelectionCtrl->GetCount();
        for(j = 0; j < count; ++j) {
            selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(j);
            if (!strcmp(result->name, selData->result_name) && 
                !strcmp(result->project_url, selData->project_url)
            ) {
                selData->result = result;
                found = true;
                is_alive.at(j) = true;
                break; // skip out of this loop
            }
        }
        
        // if it isn't currently in the list then we have a new one!  lets add it
        if (!found) {
            int alphaOrder;
            for(j = 0; j < count; ++j) {
                alphaOrder = (m_TaskSelectionCtrl->GetString(j)).CmpNoCase(resname);
#if SORTTASKLIST
                if (alphaOrder > 0) {
                    break;  // Insert the new item here (sorted by item label)
                }
#endif
                // wxComboBox and wxBitmapComboBox have bugs on Windows when multiple 
                // entries have identical text, so add enough spaces to make each 
                // entry's text unique.
                if (alphaOrder == 0) {
                    resname.Append((const wxChar *)wxT(" "));
#if !SORTTASKLIST
                    j = -1;  // If not sorted, check new name from start for duplicate 
#endif
                }
            }
            
            selData = new TaskSelectionData;
            selData->result = result;
            strncpy(selData->result_name, result->name, sizeof(selData->result_name));
            strncpy(selData->project_url, result->project_url, sizeof(selData->project_url));
            selData->dotColor = -1;
            FindSlideShowFiles(selData);
            project = pDoc->state.lookup_project(result->project_url);
            if (project) {
                selData->project_files_downloaded_time = project->project_files_downloaded_time;
            } else {
                selData->project_files_downloaded_time = 0.0;
            }

#if SORTTASKLIST
            if (j < count) {
                std::vector<bool>::iterator iter = is_alive.begin();
                m_TaskSelectionCtrl->Insert(resname, wxNullBitmap, j, (void*)selData);
                is_alive.insert(iter+j, true);
                if (j <= m_CurrentTaskSelection) {
                    ++m_CurrentTaskSelection;
                    m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection);
                }
            } else 
#endif
            {
                m_TaskSelectionCtrl->Append(resname, wxNullBitmap, (void*)selData);
                is_alive.push_back(true);
            }
         ++count;
       }    // End if (!found)
    }       // End for (i) loop

    // Check items in descending order so deletion won't change indexes of items yet to be checked
    for(j = count-1; j >=0; --j) {
        if(!is_alive.at(j)) {
            wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Task '%d' no longer alive"), j);
            selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(j);
            wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - selData '%p' "), selData);
            wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - result_name '%s' "), selData->result_name);
            selData->slideShowFileNames.Clear();
            wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Deleting selData"));
            delete selData;
            wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Deleting control data"));
            // Indicate to Delete() we have cleaned up the Selection Data
            m_TaskSelectionCtrl->SetClientData(j, NULL);
            m_TaskSelectionCtrl->Delete(j);
            if (j == m_CurrentTaskSelection) {
                int newCount = m_TaskSelectionCtrl->GetCount();
                if (m_CurrentTaskSelection < newCount) {
                    // Select the next item if one exists
                    m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection);
                } else if (newCount > 0) {
                    // Select the previous item if one exists
                    m_CurrentTaskSelection = newCount-1;
                    m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection);
                } else {
                    m_CurrentTaskSelection = -1;
                    m_TaskSelectionCtrl->SetSelection(wxNOT_FOUND);
                }
                m_bStableTaskInfoChanged = true;
                needRefresh = true;
            } else if (j < m_CurrentTaskSelection) {
                --m_CurrentTaskSelection;
                m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection);
            }
        }
    }

    if ((m_CurrentTaskSelection >= 0) && !m_bStableTaskInfoChanged) {
        selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(m_CurrentTaskSelection);
        project = pDoc->state.lookup_project(selData->project_url);
        if ( project && (project->project_files_downloaded_time > selData->project_files_downloaded_time) ) {
            FindSlideShowFiles(selData);
            selData->project_files_downloaded_time = project->project_files_downloaded_time;
        }
    }

    count = m_TaskSelectionCtrl->GetCount();
    for(j = 0; j < count; ++j) {
        selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(j);
        ctrlResult = selData->result;
        if (Suspended() || ctrlResult->suspended_via_gui || ctrlResult->project_suspended_via_gui) {
            newIcon = suspendedIcon;
        } else if (isRunning(ctrlResult)) {
            newIcon = runningIcon;
        } else if (ctrlResult->scheduler_state == CPU_SCHED_PREEMPTED) {
            newIcon = waitingIcon;
        } else {
            newIcon = suspendedIcon;
        }

        if (reskin || (newIcon != selData->dotColor)) {
            switch (newIcon) {
            case runningIcon:
                m_TaskSelectionCtrl->SetItemBitmap(j, *pSkinSimple->GetWorkunitRunningImage()->GetBitmap());
                break;
            case waitingIcon:
                m_TaskSelectionCtrl->SetItemBitmap(j, *pSkinSimple->GetWorkunitWaitingImage()->GetBitmap());
                break;
            case suspendedIcon:
                m_TaskSelectionCtrl->SetItemBitmap(j, *pSkinSimple->GetWorkunitSuspendedImage()->GetBitmap());
                break;
            }
            selData->dotColor = newIcon;
            needRefresh = true;
        }
    }
    if (needRefresh) {
        m_TaskSelectionCtrl->Refresh();
    }

    bAlreadyRunning = false;

    wxLogTrace(wxT("Function Start/End"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Function End"));
}
Ejemplo n.º 30
0
/*!
 * called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event
 */
void CDlgEventLog::OnRefresh() {
    bool isConnected;
    static wxString strLastMachineName = wxEmptyString;
    wxString strNewMachineName = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    if (!IsShown()) return;

    if (!m_bProcessingRefreshEvent) {
        m_bProcessingRefreshEvent = true;
        wxASSERT(m_pList);

        wxInt32 iRowCount = GetDocCount();
        long topItem = m_pList->GetTopItem();
        
        if (0 >= iRowCount) {
            m_pList->DeleteAllItems();
            ResetMessageFiltering();
            m_iPreviousFirstMsgSeqNum = 0;
            m_iPreviousLastMsgSeqNum = 0;
        } else {
            // If connected computer changed, reset message filtering
            isConnected = wxGetApp().GetDocument()->IsConnected();
            if (isConnected) {
                pDoc->GetConnectedComputerName(strNewMachineName);
                if (strLastMachineName != strNewMachineName) {
                    strLastMachineName = strNewMachineName;
                    m_bWasConnected = false;
                    ResetMessageFiltering();
                    m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
                    m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum - 1;
                    iRowCount = m_iTotalDocCount;   // In case we had filtering set
                }
            }

            // If connection status changed, adjust color of messages display
            if (m_bWasConnected != isConnected) {
                m_bWasConnected = isConnected;
                SetTextColor();

                // Force a complete update
                m_pList->DeleteAllItems();
                m_pList->SetItemCount(iRowCount);
                m_iPreviousRowCount = 0;    // Force scrolling to bottom

            } else {
                // Connection status didn't change
                if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) {
                    if (m_iPreviousRowCount == iRowCount) {
                        m_pList->Refresh();
                    } else {
                        m_pList->SetItemCount(iRowCount);
                    }
                }
            }
        }

        if (iRowCount > 1) {
            if (s_bFilteringChanged) {
                m_pList->EnsureVisible(iRowCount - 1);
                s_bFilteringChanged = false;
            } else {
                if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) {
                    if (EnsureLastItemVisible()) {
                        m_pList->EnsureVisible(iRowCount - 1);
                    } else if (topItem > 0) {
                        int n = topItem - m_iNumDeletedFilteredRows;
                        if (n < 0) n = 0;
                        Freeze();   // Avoid flicker if selected rows are visible
                        m_pList->EnsureVisible(n);
                        Thaw();
                    }
                }
            }
        }

        m_iPreviousRowCount = iRowCount;
        if (m_iTotalDocCount > 0) {
            m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
            m_iPreviousLastMsgSeqNum = pDoc->GetLastMsgSeqNum();
        }
        
        UpdateButtons();

        m_bProcessingRefreshEvent = false;
    }
}