diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index e2d4dda832..8c58c09e3c 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -1203,3 +1203,33 @@ bool CMainDocument::IsTransferGeneratedLocally( wxInt32 iIndex ) return bRetVal; } + +wxInt32 CMainDocument::TransferRetryNow( wxInt32 iIndex ) +{ + FILE_TRANSFER* pFT = NULL; + wxInt32 iRetVal = 0; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + iRetVal = rpc.file_transfer_op( (*pFT), wxT("retry") ); + + return iRetVal; +} + + +wxInt32 CMainDocument::TransferAbort( wxInt32 iIndex ) +{ + FILE_TRANSFER* pFT = NULL; + wxInt32 iRetVal = 0; + + if ( !ft.file_transfers.empty() ) + pFT = ft.file_transfers.at( iIndex ); + + if ( NULL != pFT ) + iRetVal = rpc.file_transfer_op( (*pFT), wxT("abort") ); + + return iRetVal; +} + diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index 49ca7b18a8..e22d3ff987 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -193,10 +193,12 @@ public: wxInt32 GetTransferTime( wxInt32 iIndex, float& fBuffer ); wxInt32 GetTransferNextRequestTime( wxInt32 iIndex, wxInt32& iBuffer ); wxInt32 GetTransferStatus( wxInt32 iIndex, wxInt32& iBuffer ); - bool IsTransferActive( wxInt32 iIndex ); bool IsTransferGeneratedLocally( wxInt32 iIndex ); + wxInt32 TransferRetryNow( wxInt32 iIndex ); + wxInt32 TransferAbort( wxInt32 iIndex ); + }; #endif diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index d484900257..500f658502 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -316,19 +316,56 @@ wxString CViewTransfers::OnListGetItemText(long item, long column) const void CViewTransfers::OnTaskLinkClicked( const wxHtmlLinkInfo& link ) { + wxInt32 iAnswer = 0; + wxInt32 iProjectIndex = 0; + wxInt32 iWebsiteIndex = 0; + wxString strName = wxEmptyString; + wxString strMessage = wxEmptyString; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(NULL != m_pTaskPane); wxASSERT(NULL != m_pListPane); - wxString strMessage; - - if ( link.GetHref() == SECTION_TASK ) + if ( link.GetHref() == SECTION_TASK ) m_bTaskHeaderHidden ? m_bTaskHeaderHidden = false : m_bTaskHeaderHidden = true; + else if ( link.GetHref() == LINK_TASKRETRY ) + { + iProjectIndex = m_pListPane->GetFirstSelected(); - if ( link.GetHref() == SECTION_TIPS ) + pDoc->TransferRetryNow( + iProjectIndex + ); + } + else if ( link.GetHref() == LINK_TASKABORT ) + { + iProjectIndex = m_pListPane->GetFirstSelected(); + pDoc->GetTransferFileName(iProjectIndex, strName); + + strMessage.Printf( + _("Are you sure you wish to abort this file transfer '%s'?"), + strName.c_str()); + + iAnswer = wxMessageBox( + strMessage, + _("Abort File Transfer"), + wxYES_NO | wxICON_QUESTION, + this + ); + + if ( wxYES == iAnswer ) + { + pDoc->TransferAbort( + iProjectIndex + ); + } + } + else if ( link.GetHref() == SECTION_TIPS ) m_bTipsHeaderHidden ? m_bTipsHeaderHidden = false : m_bTipsHeaderHidden = true; - UpdateSelection(); + m_pListPane->Refresh(); } @@ -551,9 +588,10 @@ wxInt32 CViewTransfers::FormatSize( wxInt32 item, wxString& strBuffer ) const wxInt32 CViewTransfers::FormatTime( wxInt32 item, wxString& strBuffer ) const { float fBuffer = 0; - int xhour = 0; - int xmin = 0; - int xsec = 0; + wxInt32 iHour = 0; + wxInt32 iMin = 0; + wxInt32 iSec = 0; + wxTimeSpan ts; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(NULL != pDoc); @@ -563,11 +601,13 @@ wxInt32 CViewTransfers::FormatTime( wxInt32 item, wxString& strBuffer ) const pDoc->GetTransferTime(item, fBuffer); - xhour = (int)(fBuffer / (60 * 60)); - xmin = (int)(fBuffer / 60) % 60; - xsec = (int)(fBuffer) % 60; + iHour = (wxInt32)(fBuffer / (60 * 60)); + iMin = (wxInt32)(fBuffer / 60) % 60; + iSec = (wxInt32)(fBuffer) % 60; - strBuffer.Printf(wxT("%0.2d:%0.2d:%0.2d"), xhour, xmin, xsec); + ts = wxTimeSpan( iHour, iMin, iSec ); + + strBuffer = ts.Format(); return 0; } diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index 8db54bd165..a09f614abd 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -573,9 +573,10 @@ wxInt32 CViewWork::FormatName( wxInt32 item, wxString& strBuffer ) const wxInt32 CViewWork::FormatCPUTime( wxInt32 item, wxString& strBuffer ) const { float fBuffer = 0; - int cpuhour = 0; - int cpumin = 0; - int cpusec = 0; + wxInt32 iHour = 0; + wxInt32 iMin = 0; + wxInt32 iSec = 0; + wxTimeSpan ts; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(NULL != pDoc); @@ -601,11 +602,13 @@ wxInt32 CViewWork::FormatCPUTime( wxInt32 item, wxString& strBuffer ) const } else { - cpuhour = (int)(fBuffer / (60 * 60)); - cpumin = (int)(fBuffer / 60) % 60; - cpusec = (int)(fBuffer) % 60; + iHour = (wxInt32)(fBuffer / (60 * 60)); + iMin = (wxInt32)(fBuffer / 60) % 60; + iSec = (wxInt32)(fBuffer) % 60; - strBuffer.Printf(wxT("%0.2d:%0.2d:%0.2d"), cpuhour, cpumin, cpusec); + ts = wxTimeSpan( iHour, iMin, iSec ); + + strBuffer = ts.Format(); } return 0; @@ -642,9 +645,10 @@ wxInt32 CViewWork::FormatProgress( wxInt32 item, wxString& strBuffer ) const wxInt32 CViewWork::FormatTimeToCompletion( wxInt32 item, wxString& strBuffer ) const { float fBuffer = 0; - int cpuhour = 0; - int cpumin = 0; - int cpusec = 0; + wxInt32 iHour = 0; + wxInt32 iMin = 0; + wxInt32 iSec = 0; + wxTimeSpan ts; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(NULL != pDoc); @@ -660,11 +664,13 @@ wxInt32 CViewWork::FormatTimeToCompletion( wxInt32 item, wxString& strBuffer ) c } else { - cpuhour = (int)(fBuffer / (60 * 60)); - cpumin = (int)(fBuffer / 60) % 60; - cpusec = (int)(fBuffer) % 60; + iHour = (wxInt32)(fBuffer / (60 * 60)); + iMin = (wxInt32)(fBuffer / 60) % 60; + iSec = (wxInt32)(fBuffer) % 60; - strBuffer.Printf(wxT("%0.2d:%0.2d:%0.2d"), cpuhour, cpumin, cpusec); + ts = wxTimeSpan( iHour, iMin, iSec ); + + strBuffer = ts.Format(); } return 0; diff --git a/lib/gui_rpc_client.C b/lib/gui_rpc_client.C index be2a85c541..3cd47e6029 100644 --- a/lib/gui_rpc_client.C +++ b/lib/gui_rpc_client.C @@ -1317,7 +1317,7 @@ int RPC_CLIENT::file_transfer_op(FILE_TRANSFER& ft, char* op) { " %s\n" "\n", tag, - ft.project->master_url.c_str(), + ft.project_url.c_str(), ft.name.c_str(), tag );