diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 816c8a607b..f7964c6602 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -178,7 +178,6 @@ wxInt32 CMainDocument::CachedProjectStatusUpdate() project_status.clear(); } - m_fProjectTotalResourceShare = 0.0; for (i=0; i < (long)project_status.projects.size(); i++) { m_fProjectTotalResourceShare += project_status.projects.at( i )->resource_share; @@ -195,7 +194,7 @@ wxInt32 CMainDocument::GetProjectCount() CachedStateUpdate(); CachedProjectStatusUpdate(); - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) iCount = project_status.projects.size(); return iCount; @@ -206,7 +205,7 @@ wxInt32 CMainDocument::GetProjectProjectName( wxInt32 iIndex, wxString& strBuffe { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -220,7 +219,7 @@ wxInt32 CMainDocument::GetProjectProjectURL( wxInt32 iIndex, wxString& strBuffer { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -234,7 +233,7 @@ wxInt32 CMainDocument::GetProjectAccountName( wxInt32 iIndex, wxString& strBuffe { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -248,7 +247,7 @@ wxInt32 CMainDocument::GetProjectTeamName( wxInt32 iIndex, wxString& strBuffer ) { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -262,7 +261,7 @@ wxInt32 CMainDocument::GetProjectTotalCredit( wxInt32 iIndex, float& fBuffer ) { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -276,7 +275,7 @@ wxInt32 CMainDocument::GetProjectAvgCredit( wxInt32 iIndex, float& fBuffer ) { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -290,7 +289,7 @@ wxInt32 CMainDocument::GetProjectResourceShare( wxInt32 iIndex, float& fBuffer ) { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -311,7 +310,7 @@ wxInt32 CMainDocument::GetProjectMinRPCTime( wxInt32 iIndex, wxInt32& iBuffer ) { PROJECT* pProject = NULL; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -415,7 +414,7 @@ bool CMainDocument::IsProjectSuspended( wxInt32 iIndex ) PROJECT* pProject = NULL; bool bRetVal = false; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -430,7 +429,7 @@ bool CMainDocument::IsProjectRPCPending( wxInt32 iIndex ) PROJECT* pProject = NULL; bool bRetVal = false; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -451,7 +450,7 @@ wxInt32 CMainDocument::ProjectDetach( wxInt32 iIndex ) PROJECT* pProject = NULL; wxInt32 iRetVal = -1; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -466,7 +465,7 @@ wxInt32 CMainDocument::ProjectUpdate( wxInt32 iIndex ) PROJECT* pProject = NULL; wxInt32 iRetVal = -1; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -481,7 +480,7 @@ wxInt32 CMainDocument::ProjectReset( wxInt32 iIndex ) PROJECT* pProject = NULL; wxInt32 iRetVal = -1; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -497,7 +496,7 @@ wxInt32 CMainDocument::ProjectSuspend( wxInt32 iIndex ) PROJECT* pStateProject = NULL; wxInt32 iRetVal = -1; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -522,7 +521,7 @@ wxInt32 CMainDocument::ProjectResume( wxInt32 iIndex ) PROJECT* pStateProject = NULL; wxInt32 iRetVal = -1; - if ( project_status.projects.size() != 0 ) + if ( !project_status.projects.empty() ) pProject = project_status.projects.at( iIndex ); if ( NULL != pProject ) @@ -552,7 +551,6 @@ wxInt32 CMainDocument::CachedResultsStatusUpdate() results.clear(); } - return retval; } @@ -564,7 +562,7 @@ wxInt32 CMainDocument::GetWorkCount() CachedStateUpdate(); CachedResultsStatusUpdate(); - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) iCount = results.results.size(); return iCount; @@ -577,7 +575,7 @@ wxInt32 CMainDocument::GetWorkProjectName( wxInt32 iIndex, wxString& strBuffer ) RESULT* pStateResult = NULL; PROJECT* pProject = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -601,7 +599,7 @@ wxInt32 CMainDocument::GetWorkProjectURL( wxInt32 iIndex, wxString& strBuffer ) { RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -618,7 +616,7 @@ wxInt32 CMainDocument::GetWorkApplicationName( wxInt32 iIndex, wxString& strBuff WORKUNIT* pWorkunit = NULL; APP_VERSION* pAppVersion = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -649,7 +647,7 @@ wxInt32 CMainDocument::GetWorkApplicationVersion( wxInt32 iIndex, wxInt32& iBuff WORKUNIT* pWorkunit = NULL; APP_VERSION* pAppVersion = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -677,7 +675,7 @@ wxInt32 CMainDocument::GetWorkName( wxInt32 iIndex, wxString& strBuffer ) { RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -691,7 +689,7 @@ wxInt32 CMainDocument::GetWorkCurrentCPUTime( wxInt32 iIndex, float& fBuffer ) { RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -705,7 +703,7 @@ wxInt32 CMainDocument::GetWorkEstimatedCPUTime( wxInt32 iIndex, float& fBuffer ) { RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -719,7 +717,7 @@ wxInt32 CMainDocument::GetWorkFinalCPUTime( wxInt32 iIndex, float& fBuffer ) { RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -733,7 +731,7 @@ wxInt32 CMainDocument::GetWorkFractionDone( wxInt32 iIndex, float& fBuffer ) { RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -747,7 +745,7 @@ wxInt32 CMainDocument::GetWorkReportDeadline( wxInt32 iIndex, wxInt32& iBuffer ) { RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -762,7 +760,7 @@ wxInt32 CMainDocument::GetWorkState( wxInt32 iIndex ) wxInt32 iBuffer = 0; RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -777,7 +775,7 @@ wxInt32 CMainDocument::GetWorkSchedulerState( wxInt32 iIndex ) wxInt32 iBuffer = 0; RESULT* pResult = NULL; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -792,7 +790,7 @@ bool CMainDocument::IsWorkAcknowledged( wxInt32 iIndex ) RESULT* pResult = NULL; bool bRetVal = false; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -807,7 +805,7 @@ bool CMainDocument::IsWorkActive( wxInt32 iIndex ) RESULT* pResult = NULL; bool bRetVal = false; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -822,7 +820,7 @@ bool CMainDocument::IsWorkReadyToReport( wxInt32 iIndex ) RESULT* pResult = NULL; bool bRetVal = false; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -837,7 +835,7 @@ bool CMainDocument::IsWorkSuspended( wxInt32 iIndex ) RESULT* pResult = NULL; bool bRetVal = false; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -853,7 +851,7 @@ wxInt32 CMainDocument::WorkSuspend( wxInt32 iIndex ) RESULT* pStateResult = NULL; wxInt32 iRetVal = 0; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -880,7 +878,7 @@ wxInt32 CMainDocument::WorkResume( wxInt32 iIndex ) RESULT* pStateResult = NULL; wxInt32 iRetVal = 0; - if ( results.results.size() != 0 ) + if ( !results.results.empty() ) pResult = results.results.at( iIndex ); if ( NULL != pResult ) @@ -901,27 +899,46 @@ wxInt32 CMainDocument::WorkResume( wxInt32 iIndex ) } -wxInt32 CMainDocument::WorkShowGraphics( wxString& strProjectURL, wxString& strResultName, bool bFullScreen ) +wxInt32 CMainDocument::WorkShowGraphics( wxInt32 iIndex, bool bFullScreen ) { - return rpc.show_graphics( (char*)strProjectURL.c_str(), (char*)strResultName.c_str(), bFullScreen ); + RESULT* pResult = NULL; + wxInt32 iRetVal = 0; + + if ( !results.results.empty() ) + pResult = results.results.at( iIndex ); + + if ( NULL != pResult ) + iRetVal = rpc.show_graphics( pResult->project_url.c_str(), pResult->name.c_str(), bFullScreen ); + + return iRetVal; } -wxInt32 CMainDocument::WorkAbort( wxString& strProjectURL, wxString& strResultName ) +wxInt32 CMainDocument::WorkAbort( wxInt32 iIndex ) { - PROJECT p; - RESULT r; - p.master_url = strProjectURL; - r.name = strResultName; - r.project = &p; - return rpc.result_op(r, wxT("abort")); + RESULT* pResult = NULL; + RESULT* pStateResult = NULL; + wxInt32 iRetVal = 0; + + if ( !results.results.empty() ) + pResult = results.results.at( iIndex ); + + if ( NULL != pResult ) + { + pStateResult = state.lookup_result( pResult->project_url, pResult->name ); + if ( NULL != pStateResult ) + { + iRetVal = rpc.result_op( (*pStateResult), wxT("abort") ); + } + } + + return iRetVal; } wxInt32 CMainDocument::CachedMessageUpdate() { wxInt32 retval = 0; - //wxInt32 i = 0; retval = rpc.get_messages( m_iMessageSequenceNumber, messages ); if (retval) @@ -944,7 +961,7 @@ wxInt32 CMainDocument::GetMessageCount() CachedStateUpdate(); CachedMessageUpdate(); - if ( messages.messages.size() != 0 ) + if ( !messages.messages.empty() ) iCount = messages.messages.size(); return iCount; @@ -955,7 +972,7 @@ wxInt32 CMainDocument::GetMessageProjectName( wxInt32 iIndex, wxString& strBuffe { MESSAGE* pMessage = NULL; - if ( messages.messages.size() != 0 ) + if ( !messages.messages.empty() ) pMessage = messages.messages.at( iIndex ); if ( NULL != pMessage ) @@ -969,7 +986,7 @@ wxInt32 CMainDocument::GetMessageTime( wxInt32 iIndex, wxDateTime& dtBuffer ) { MESSAGE* pMessage = NULL; - if ( messages.messages.size() != 0 ) + if ( !messages.messages.empty() ) pMessage = messages.messages.at( iIndex ); if ( NULL != pMessage ) @@ -986,7 +1003,7 @@ wxInt32 CMainDocument::GetMessagePriority( wxInt32 iIndex, wxInt32& iBuffer ) { MESSAGE* pMessage = NULL; - if ( messages.messages.size() != 0 ) + if ( !messages.messages.empty() ) pMessage = messages.messages.at( iIndex ); if ( NULL != pMessage ) @@ -1000,7 +1017,7 @@ wxInt32 CMainDocument::GetMessageMessage( wxInt32 iIndex, wxString& strBuffer ) { MESSAGE* pMessage = NULL; - if ( messages.messages.size() != 0 ) + if ( !messages.messages.empty() ) pMessage = messages.messages.at( iIndex ); if ( NULL != pMessage ) @@ -1027,49 +1044,125 @@ wxInt32 CMainDocument::CachedFileTransfersUpdate() wxInt32 CMainDocument::GetTransferCount() { + wxInt32 iCount = 0; + CachedStateUpdate(); - return 0; + CachedFileTransfersUpdate(); + + if ( !ft.file_transfers.empty() ) + iCount = ft.file_transfers.size(); + + return iCount; } wxInt32 CMainDocument::GetTransferProjectName( wxInt32 iIndex, wxString& strBuffer ) { + FILE_TRANSFER* pFT = NULL; + PROJECT* pProject = NULL; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + { + pProject = state.lookup_project( pFT->project_url ); + if ( NULL != pProject ) + { + strBuffer = pProject->project_name.c_str(); + } + } + return 0; } wxInt32 CMainDocument::GetTransferFileName( wxInt32 iIndex, wxString& strBuffer ) { + FILE_TRANSFER* pFT = NULL; + PROJECT* pProject = NULL; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + strBuffer = pFT->name.c_str(); + return 0; } -wxInt32 CMainDocument::GetTransferProgress( wxInt32 iIndex, wxString& strBuffer ) +wxInt32 CMainDocument::GetTransferFileSize( wxInt32 iIndex, float& fBuffer ) { + FILE_TRANSFER* pFT = NULL; + PROJECT* pProject = NULL; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + fBuffer = pFT->nbytes; + return 0; } -wxInt32 CMainDocument::GetTransferSize( wxInt32 iIndex, wxString& strBuffer ) +wxInt32 CMainDocument::GetTransferBytesXfered( wxInt32 iIndex, float& fBuffer ) { + FILE_TRANSFER* pFT = NULL; + PROJECT* pProject = NULL; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + fBuffer = pFT->bytes_xferred; + return 0; } -wxInt32 CMainDocument::GetTransferSpeed( wxInt32 iIndex, wxString& strBuffer ) +wxInt32 CMainDocument::GetTransferSpeed( wxInt32 iIndex, float& fBuffer ) { - return 0; -} + FILE_TRANSFER* pFT = NULL; + PROJECT* pProject = NULL; + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + fBuffer = pFT->xfer_speed; -wxInt32 CMainDocument::GetTransferStatus( wxInt32 iIndex, wxString& strBuffer ) -{ return 0; } wxInt32 CMainDocument::GetTransferTime( wxInt32 iIndex, wxString& strBuffer ) { + FILE_TRANSFER* pFT = NULL; + PROJECT* pProject = NULL; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + //if ( NULL != pFT ) + //fBuffer = pFT->; + return 0; } + +bool CMainDocument::IsTransferActive( wxInt32 iIndex ) +{ + FILE_TRANSFER* pFT = NULL; + bool bRetVal = false; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + bRetVal = pFT->pers_xfer_active; + + return bRetVal; +} + diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index 1485c039a1..96c2e10ba6 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -150,8 +150,8 @@ public: wxInt32 WorkSuspend( wxInt32 iIndex ); wxInt32 WorkResume( wxInt32 iIndex ); - wxInt32 WorkShowGraphics( wxString& strProjectURL, wxString& strResultName, bool bFullScreen ); - wxInt32 WorkAbort( wxString& strProjectURL, wxString& strResultName ); + wxInt32 WorkShowGraphics( wxInt32 iIndex, bool bFullScreen ); + wxInt32 WorkAbort( wxInt32 iIndex ); // @@ -186,13 +186,15 @@ public: wxInt32 GetTransferCount(); - wxInt32 GetTransferFileName( wxInt32 iIndex, wxString& strBuffer ); - wxInt32 GetTransferProgress( wxInt32 iIndex, wxString& strBuffer ); wxInt32 GetTransferProjectName( wxInt32 iIndex, wxString& strBuffer ); - wxInt32 GetTransferSize( wxInt32 iIndex, wxString& strBuffer ); - wxInt32 GetTransferSpeed( wxInt32 iIndex, wxString& strBuffer ); - wxInt32 GetTransferStatus( wxInt32 iIndex, wxString& strBuffer ); + wxInt32 GetTransferFileName( wxInt32 iIndex, wxString& strBuffer ); + wxInt32 GetTransferFileSize( wxInt32 iIndex, float& fBuffer ); + wxInt32 GetTransferBytesXfered( wxInt32 iIndex, float& fBuffer ); + wxInt32 GetTransferSpeed( wxInt32 iIndex, float& fBuffer ); wxInt32 GetTransferTime( wxInt32 iIndex, wxString& strBuffer ); + wxInt32 GetTransferStatus( wxInt32 iIndex, wxString& strBuffer ); + + bool IsTransferActive( wxInt32 iIndex ); }; diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index 8f48919fa6..70ebb21b60 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -241,7 +241,6 @@ void CViewProjects::OnListRender(wxTimerEvent &event) wxInt32 iColumnTotal = 0; wxString strDocumentText = wxEmptyString; wxString strListPaneText = wxEmptyString; - wxString strBuffer = wxEmptyString; bool bNeedRefreshData = false; wxListItem liItem; @@ -287,7 +286,7 @@ void CViewProjects::OnListRender(wxTimerEvent &event) m_pListPane->GetItem(liItem); strListPaneText = liItem.GetText(); - if ( !strBuffer.IsSameAs(strListPaneText) ) + if ( !strDocumentText.IsSameAs(strListPaneText) ) bNeedRefreshData = true; } diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index 99f02fdb5d..cb96a2beb8 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -179,15 +179,76 @@ void CViewTransfers::OnListRender(wxTimerEvent &event) } else { - m_pListPane->RefreshItems(m_iCacheFrom, m_iCacheTo); + if ( 1 <= m_iCacheTo ) + { + wxInt32 iRowIndex = 0; + wxInt32 iColumnIndex = 0; + wxInt32 iColumnTotal = 0; + wxString strDocumentText = wxEmptyString; + wxString strListPaneText = wxEmptyString; + bool bNeedRefreshData = false; + wxListItem liItem; + + liItem.SetMask(wxLIST_MASK_TEXT); + iColumnTotal = m_pListPane->GetColumnCount(); + + for ( iRowIndex = m_iCacheFrom; iRowIndex <= m_iCacheTo; iRowIndex++ ) + { + bNeedRefreshData = false; + liItem.SetId(iRowIndex); + + for ( iColumnIndex = 0; iColumnIndex < iColumnTotal; iColumnIndex++ ) + { + strDocumentText.Empty(); + strListPaneText.Empty(); + + switch(iColumnIndex) + { + case COLUMN_PROJECT: + FormatProjectName( iRowIndex, strDocumentText ); + break; + case COLUMN_FILE: + FormatFileName( iRowIndex, strDocumentText ); + break; + case COLUMN_PROGRESS: + FormatProgress( iRowIndex, strDocumentText ); + break; + case COLUMN_SIZE: + FormatSize( iRowIndex, strDocumentText ); + break; + case COLUMN_TIME: + FormatTime( iRowIndex, strDocumentText ); + break; + case COLUMN_SPEED: + FormatSpeed( iRowIndex, strDocumentText ); + break; + case COLUMN_STATUS: + FormatStatus( iRowIndex, strDocumentText ); + break; + } + + liItem.SetColumn(iColumnIndex); + m_pListPane->GetItem(liItem); + strListPaneText = liItem.GetText(); + + if ( !strDocumentText.IsSameAs(strListPaneText) ) + bNeedRefreshData = true; + } + + if ( bNeedRefreshData ) + { + m_pListPane->RefreshItem( iRowIndex ); + } + } + } } m_bProcessingListRenderEvent = false; } - else - { - event.Skip(); - } + + m_pListPane->Refresh(); + + event.Skip(); } @@ -223,7 +284,8 @@ wxString CViewTransfers::OnListGetItemText(long item, long column) const wxASSERT(NULL != pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - switch(column) { + switch(column) + { case COLUMN_PROJECT: if (item == m_iCacheFrom) pDoc->CachedStateLock(); FormatProjectName( item, strBuffer ); @@ -391,12 +453,97 @@ wxInt32 CViewTransfers::FormatFileName( wxInt32 item, wxString& strBuffer ) cons wxInt32 CViewTransfers::FormatProgress( wxInt32 item, wxString& strBuffer ) const { + float fBytesSent = 0; + float fFileSize = 0; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + strBuffer.Clear(); + + if ( pDoc->IsTransferActive(item) ) + pDoc->GetTransferBytesXfered( item, fBytesSent ); + else + pDoc->GetTransferFileSize( item, fBytesSent ); + + pDoc->GetTransferFileSize( item, fFileSize ); + + strBuffer.Printf(wxT("%.2f%%"), ( 100 * ( fBytesSent / fFileSize ) ) ); + return 0; } wxInt32 CViewTransfers::FormatSize( wxInt32 item, wxString& strBuffer ) const { + float fBytesSent = 0; + float fFileSize = 0; + double xTera = 1099511627776.0; + double xGiga = 1073741824.0; + double xMega = 1048576.0; + double xKilo = 1024.0; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + strBuffer.Clear(); + + if ( pDoc->IsTransferActive(item) ) + pDoc->GetTransferBytesXfered( item, fBytesSent ); + else + pDoc->GetTransferFileSize( item, fBytesSent ); + + pDoc->GetTransferFileSize( item, fFileSize ); + + if (fFileSize != 0) + { + if ( fFileSize >= xTera ) + { + strBuffer.Printf( wxT("%0.2f/%0.2f TB"), fBytesSent/xTera, fFileSize/xTera); + } + else if ( fFileSize >= xGiga ) + { + strBuffer.Printf( wxT("%0.2f/%0.2f GB"), fBytesSent/xGiga, fFileSize/xGiga); + } + else if ( fFileSize >= xMega ) + { + strBuffer.Printf( wxT("%0.2f/%0.2f MB"), fBytesSent/xMega, fFileSize/xMega); + } + else if ( fFileSize >= xKilo ) + { + strBuffer.Printf( wxT("%0.2f/%0.2f KB"), fBytesSent/xKilo, fFileSize/xKilo); + } + else + { + strBuffer.Printf( wxT("%0.0f/%0.0f bytes"), fBytesSent, fFileSize); + } + } + else + { + if ( fBytesSent >= xTera ) + { + strBuffer.Printf( wxT("%0.2f TB"), fBytesSent/xTera); + } + else if ( fBytesSent >= xGiga ) + { + strBuffer.Printf( wxT("%0.2f GB"), fBytesSent/xGiga); + } + else if ( fBytesSent >= xMega ) + { + strBuffer.Printf( wxT("%0.2f MB"), fBytesSent/xMega); + } + else if ( fBytesSent >= xKilo ) + { + strBuffer.Printf( wxT("%0.2f KB"), fBytesSent/xKilo); + } + else + { + strBuffer.Printf( wxT("%0.0f bytes"), fBytesSent); + } + } + return 0; } @@ -409,6 +556,22 @@ wxInt32 CViewTransfers::FormatTime( wxInt32 item, wxString& strBuffer ) const wxInt32 CViewTransfers::FormatSpeed( wxInt32 item, wxString& strBuffer ) const { + float fTransferSpeed = 0; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + strBuffer.Clear(); + + if ( pDoc->IsTransferActive(item) ) + { + pDoc->GetTransferSpeed( item, fTransferSpeed ); + strBuffer.Printf( wxT("%0.2f KBps"), ( fTransferSpeed / 1024 ) ); + } + else + strBuffer = wxT("0.00 KBps"); + return 0; } diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index f1db72b848..8db54bd165 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -202,7 +202,6 @@ void CViewWork::OnListRender(wxTimerEvent &event) wxInt32 iColumnTotal = 0; wxString strDocumentText = wxEmptyString; wxString strListPaneText = wxEmptyString; - wxString strBuffer = wxEmptyString; bool bNeedRefreshData = false; wxListItem liItem; @@ -222,28 +221,28 @@ void CViewWork::OnListRender(wxTimerEvent &event) switch(iColumnIndex) { case COLUMN_PROJECT: - FormatProjectName(iRowIndex, strBuffer); + FormatProjectName(iRowIndex, strDocumentText); break; case COLUMN_APPLICATION: - FormatApplicationName(iRowIndex, strBuffer); + FormatApplicationName(iRowIndex, strDocumentText); break; case COLUMN_NAME: - FormatName(iRowIndex, strBuffer); + FormatName(iRowIndex, strDocumentText); break; case COLUMN_CPUTIME: - FormatCPUTime(iRowIndex, strBuffer); + FormatCPUTime(iRowIndex, strDocumentText); break; case COLUMN_PROGRESS: - FormatProgress(iRowIndex, strBuffer); + FormatProgress(iRowIndex, strDocumentText); break; case COLUMN_TOCOMPLETETION: - FormatTimeToCompletion(iRowIndex, strBuffer); + FormatTimeToCompletion(iRowIndex, strDocumentText); break; case COLUMN_REPORTDEADLINE: - FormatReportDeadline(iRowIndex, strBuffer); + FormatReportDeadline(iRowIndex, strDocumentText); break; case COLUMN_STATUS: - FormatStatus(iRowIndex, strBuffer); + FormatStatus(iRowIndex, strDocumentText); break; } @@ -251,7 +250,7 @@ void CViewWork::OnListRender(wxTimerEvent &event) m_pListPane->GetItem(liItem); strListPaneText = liItem.GetText(); - if ( !strBuffer.IsSameAs(strListPaneText) ) + if ( !strDocumentText.IsSameAs(strListPaneText) ) bNeedRefreshData = true; } @@ -373,19 +372,15 @@ void CViewWork::OnTaskLinkClicked( const wxHtmlLinkInfo& link ) else if ( link.GetHref() == LINK_TASKSHOWGRAPHICS ) { iProjectIndex = m_pListPane->GetFirstSelected(); - pDoc->GetWorkProjectURL(iProjectIndex, strProjectURL); - pDoc->GetWorkName(iProjectIndex, strResultName); pDoc->WorkShowGraphics( - strProjectURL, - strResultName, + iProjectIndex, false ); } else if ( link.GetHref() == LINK_TASKABORT ) { iProjectIndex = m_pListPane->GetFirstSelected(); - pDoc->GetWorkProjectURL(iProjectIndex, strProjectURL); pDoc->GetWorkName(iProjectIndex, strResultName); strMessage.Printf( @@ -402,8 +397,7 @@ void CViewWork::OnTaskLinkClicked( const wxHtmlLinkInfo& link ) if ( wxYES == iAnswer ) { pDoc->WorkAbort( - strProjectURL, - strResultName + iProjectIndex ); } } diff --git a/lib/gui_rpc_client.C b/lib/gui_rpc_client.C index a2aa8cd065..394a686cf4 100644 --- a/lib/gui_rpc_client.C +++ b/lib/gui_rpc_client.C @@ -1097,7 +1097,7 @@ int RPC_CLIENT::get_disk_usage(PROJECTS& p) { } int RPC_CLIENT::show_graphics( - char* project_url, char* result_name, bool full_screen + const char* project_url, const char* result_name, bool full_screen ) { char buf[1024]; RPC rpc(this); diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index 5d475e9c8e..7fb415dc4e 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -342,7 +342,7 @@ public: int get_file_transfers(FILE_TRANSFERS&); int get_project_status(PROJECTS&); int get_disk_usage(PROJECTS&); - int show_graphics(char* project, char* result_name, bool full_screen); + int show_graphics(const char* project, const char* result_name, bool full_screen); int project_op(PROJECT&, char* op); int project_attach(char* url, char* auth); int set_run_mode(int mode);