2008-08-06 18:36:30 +00:00
// This file is part of BOINC.
2005-01-20 23:22:22 +00:00
// http://boinc.berkeley.edu
2008-08-06 18:36:30 +00:00
// Copyright (C) 2008 University of California
2004-05-17 22:15:10 +00:00
//
2008-08-06 18:36:30 +00:00
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
2004-04-10 09:11:03 +00:00
//
2008-08-06 18:36:30 +00:00
// BOINC is distributed in the hope that it will be useful,
2005-01-20 23:22:22 +00:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
2004-05-17 22:15:10 +00:00
//
2008-08-06 18:36:30 +00:00
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
2004-04-10 09:11:03 +00:00
2004-04-11 04:37:10 +00:00
# if defined(__GNUG__) && !defined(__APPLE__)
2004-09-21 01:30:29 +00:00
# pragma implementation "ViewTransfers.h"
2004-04-11 04:37:10 +00:00
# endif
2004-04-10 09:11:03 +00:00
# include "stdwx.h"
2004-08-11 23:52:22 +00:00
# include "BOINCGUIApp.h"
2006-10-20 15:00:14 +00:00
# include "BOINCBaseFrame.h"
2004-08-11 23:52:22 +00:00
# include "MainDocument.h"
2006-06-24 05:00:57 +00:00
# include "AdvancedFrame.h"
2004-09-24 22:19:02 +00:00
# include "BOINCTaskCtrl.h"
# include "BOINCListCtrl.h"
2004-09-21 01:30:29 +00:00
# include "ViewTransfers.h"
2004-07-13 05:56:03 +00:00
# include "Events.h"
2004-10-22 18:39:21 +00:00
# include "error_numbers.h"
2004-04-10 09:11:03 +00:00
2004-12-02 07:43:47 +00:00
2004-04-13 00:33:40 +00:00
# include "res/xfer.xpm"
2004-09-24 22:19:02 +00:00
2004-08-11 23:52:22 +00:00
# define COLUMN_PROJECT 0
# define COLUMN_FILE 1
# define COLUMN_PROGRESS 2
# define COLUMN_SIZE 3
# define COLUMN_TIME 4
# define COLUMN_SPEED 5
# define COLUMN_STATUS 6
2005-04-22 06:06:22 +00:00
// buttons in the "tasks" area
# define BTN_RETRY 0
# define BTN_ABORT 1
2004-08-11 23:52:22 +00:00
2005-04-07 07:04:50 +00:00
CTransfer : : CTransfer ( ) {
2008-09-08 09:11:56 +00:00
m_fProgress = - 1.0 ;
m_fBytesXferred = - 1.0 ;
m_fTotalBytes = - 1.0 ;
m_dTime = - 1.0 ;
m_dSpeed = - 1.0 ;
2004-12-02 07:43:47 +00:00
}
2005-04-07 07:04:50 +00:00
CTransfer : : ~ CTransfer ( ) {
2004-12-02 07:43:47 +00:00
m_strProjectName . Clear ( ) ;
m_strFileName . Clear ( ) ;
m_strStatus . Clear ( ) ;
}
2004-09-21 01:30:29 +00:00
IMPLEMENT_DYNAMIC_CLASS ( CViewTransfers , CBOINCBaseView )
2004-04-10 09:11:03 +00:00
2005-04-21 06:04:26 +00:00
BEGIN_EVENT_TABLE ( CViewTransfers , CBOINCBaseView )
EVT_BUTTON ( ID_TASK_TRANSFERS_RETRYNOW , CViewTransfers : : OnTransfersRetryNow )
EVT_BUTTON ( ID_TASK_TRANSFERS_ABORT , CViewTransfers : : OnTransfersAbort )
2005-04-21 23:14:10 +00:00
EVT_LIST_ITEM_SELECTED ( ID_LIST_TRANSFERSVIEW , CViewTransfers : : OnListSelected )
EVT_LIST_ITEM_DESELECTED ( ID_LIST_TRANSFERSVIEW , CViewTransfers : : OnListDeselected )
2008-06-27 10:05:47 +00:00
EVT_LIST_COL_CLICK ( ID_LIST_TRANSFERSVIEW , CViewTransfers : : OnColClick )
EVT_LIST_CACHE_HINT ( ID_LIST_TRANSFERSVIEW , CViewTransfers : : OnCacheHint )
2005-04-21 06:04:26 +00:00
END_EVENT_TABLE ( )
2004-04-10 09:11:03 +00:00
2008-06-27 10:05:47 +00:00
static CViewTransfers * MyCViewTransfers ;
2008-07-08 15:13:34 +00:00
static bool CompareViewTransferItems ( int iRowIndex1 , int iRowIndex2 ) {
2008-10-14 12:35:48 +00:00
CTransfer * transfer1 ;
CTransfer * transfer2 ;
2008-06-27 10:05:47 +00:00
int result = 0 ;
2008-10-14 12:35:48 +00:00
try {
transfer1 = MyCViewTransfers - > m_TransferCache . at ( iRowIndex1 ) ;
} catch ( std : : out_of_range ) {
return 0 ;
}
try {
transfer2 = MyCViewTransfers - > m_TransferCache . at ( iRowIndex2 ) ;
} catch ( std : : out_of_range ) {
return 0 ;
}
2008-06-27 10:05:47 +00:00
switch ( MyCViewTransfers - > m_iSortColumn ) {
2008-10-14 12:35:48 +00:00
case COLUMN_PROJECT :
result = transfer1 - > m_strProjectName . CmpNoCase ( transfer2 - > m_strProjectName ) ;
2008-06-27 10:05:47 +00:00
break ;
case COLUMN_FILE :
2008-10-14 12:35:48 +00:00
result = transfer1 - > m_strFileName . CmpNoCase ( transfer2 - > m_strFileName ) ;
2008-06-27 10:05:47 +00:00
break ;
case COLUMN_PROGRESS :
if ( transfer1 - > m_fProgress < transfer2 - > m_fProgress ) {
result = - 1 ;
} else if ( transfer1 - > m_fProgress > transfer2 - > m_fProgress ) {
result = 1 ;
}
break ;
case COLUMN_SIZE :
if ( transfer1 - > m_fBytesXferred < transfer2 - > m_fBytesXferred ) {
result = - 1 ;
} else if ( transfer1 - > m_fBytesXferred > transfer2 - > m_fBytesXferred ) {
result = 1 ;
}
break ;
case COLUMN_TIME :
if ( transfer1 - > m_dTime < transfer2 - > m_dTime ) {
result = - 1 ;
} else if ( transfer1 - > m_dTime > transfer2 - > m_dTime ) {
result = 1 ;
}
break ;
case COLUMN_SPEED :
if ( transfer1 - > m_dSpeed < transfer2 - > m_dSpeed ) {
result = - 1 ;
} else if ( transfer1 - > m_dSpeed > transfer2 - > m_dSpeed ) {
result = 1 ;
}
break ;
case COLUMN_STATUS :
result = transfer1 - > m_strStatus . CmpNoCase ( transfer2 - > m_strStatus ) ;
break ;
}
2008-07-08 15:13:34 +00:00
// Always return FALSE for equality (result == 0)
2008-10-24 11:24:39 +00:00
return ( MyCViewTransfers - > m_bReverseSort ? ( result > 0 ) : ( result < 0 ) ) ;
2008-06-27 10:05:47 +00:00
}
2005-09-02 18:40:06 +00:00
CViewTransfers : : CViewTransfers ( )
{ }
2004-04-10 09:11:03 +00:00
2004-09-21 01:30:29 +00:00
CViewTransfers : : CViewTransfers ( wxNotebook * pNotebook ) :
2008-06-27 10:05:47 +00:00
CBOINCBaseView ( pNotebook , ID_TASK_TRANSFERSVIEW , DEFAULT_TASK_FLAGS , ID_LIST_TRANSFERSVIEW , DEFAULT_LIST_MULTI_SEL_FLAGS )
2005-04-21 06:04:26 +00:00
{
CTaskItemGroup * pGroup = NULL ;
CTaskItem * pItem = NULL ;
2005-04-27 06:55:28 +00:00
wxASSERT ( m_pTaskPane ) ;
wxASSERT ( m_pListPane ) ;
2004-09-21 01:30:29 +00:00
2004-12-23 01:06:41 +00:00
//
// Setup View
//
2006-02-08 06:56:34 +00:00
pGroup = new CTaskItemGroup ( _ ( " Commands " ) ) ;
2005-04-21 06:04:26 +00:00
m_TaskGroups . push_back ( pGroup ) ;
pItem = new CTaskItem (
_ ( " Retry Now " ) ,
_ ( " Click 'Retry now' to transfer the file now " ) ,
ID_TASK_TRANSFERS_RETRYNOW
) ;
pGroup - > m_Tasks . push_back ( pItem ) ;
2004-09-24 22:19:02 +00:00
2005-04-21 06:04:26 +00:00
pItem = new CTaskItem (
_ ( " Abort Transfer " ) ,
2008-07-08 20:05:07 +00:00
_ ( " Click 'Abort transfer' to delete the file from the transfer queue. This will prevent you from being granted credit for this result. " ) ,
2005-04-21 06:04:26 +00:00
ID_TASK_TRANSFERS_ABORT
) ;
pGroup - > m_Tasks . push_back ( pItem ) ;
2004-09-24 22:19:02 +00:00
2005-04-21 06:04:26 +00:00
// Create Task Pane Items
2005-04-21 23:14:10 +00:00
m_pTaskPane - > UpdateControls ( ) ;
2004-09-24 22:19:02 +00:00
2005-04-21 06:04:26 +00:00
// Create List Pane Items
2004-10-22 18:39:21 +00:00
m_pListPane - > InsertColumn ( COLUMN_PROJECT , _ ( " Project " ) , wxLIST_FORMAT_LEFT , 125 ) ;
m_pListPane - > InsertColumn ( COLUMN_FILE , _ ( " File " ) , wxLIST_FORMAT_LEFT , 205 ) ;
m_pListPane - > InsertColumn ( COLUMN_PROGRESS , _ ( " Progress " ) , wxLIST_FORMAT_CENTRE , 60 ) ;
m_pListPane - > InsertColumn ( COLUMN_SIZE , _ ( " Size " ) , wxLIST_FORMAT_LEFT , 80 ) ;
2005-06-17 04:53:35 +00:00
m_pListPane - > InsertColumn ( COLUMN_TIME , _ ( " Elapsed Time " ) , wxLIST_FORMAT_LEFT , 80 ) ;
2004-10-22 18:39:21 +00:00
m_pListPane - > InsertColumn ( COLUMN_SPEED , _ ( " Speed " ) , wxLIST_FORMAT_LEFT , 80 ) ;
m_pListPane - > InsertColumn ( COLUMN_STATUS , _ ( " Status " ) , wxLIST_FORMAT_LEFT , 150 ) ;
2005-04-22 01:46:32 +00:00
2008-06-24 10:52:12 +00:00
m_iProgressColumn = COLUMN_PROGRESS ;
2008-06-27 10:05:47 +00:00
// Needed by static sort routine;
MyCViewTransfers = this ;
m_funcSortCompare = CompareViewTransferItems ;
2005-04-22 01:46:32 +00:00
UpdateSelection ( ) ;
2004-04-10 09:11:03 +00:00
}
2005-04-07 07:04:50 +00:00
CViewTransfers : : ~ CViewTransfers ( ) {
2005-02-01 00:54:06 +00:00
EmptyCache ( ) ;
2005-04-21 06:04:26 +00:00
EmptyTasks ( ) ;
2004-04-10 09:11:03 +00:00
}
2005-09-02 21:03:36 +00:00
wxString & CViewTransfers : : GetViewName ( ) {
2009-05-01 01:32:26 +00:00
static wxString strViewName ( wxT ( " Transfers " ) ) ;
2005-09-02 20:56:08 +00:00
return strViewName ;
2004-04-10 09:11:03 +00:00
}
2004-04-11 05:09:18 +00:00
2004-04-13 00:33:40 +00:00
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
wxString & CViewTransfers : : GetViewDisplayName ( ) {
static wxString strViewName ( _ ( " Transfers " ) ) ;
return strViewName ;
}
2005-04-07 07:04:50 +00:00
const char * * CViewTransfers : : GetViewIcon ( ) {
2004-04-13 00:33:40 +00:00
return xfer_xpm ;
}
2004-05-21 06:27:15 +00:00
2009-12-22 01:22:11 +00:00
const int CViewTransfers : : GetViewCurrentViewPage ( ) {
return VW_XFER ;
}
2008-09-04 13:00:24 +00:00
wxString CViewTransfers : : GetKeyValue1 ( int iRowIndex ) {
2008-10-14 12:35:48 +00:00
CTransfer * transfer ;
if ( GetTransferCacheAtIndex ( transfer , m_iSortedIndexes [ iRowIndex ] ) ) {
return wxEmptyString ;
}
2008-09-04 13:00:24 +00:00
return transfer - > m_strFileName ;
}
wxString CViewTransfers : : GetKeyValue2 ( int iRowIndex ) {
2008-10-14 12:35:48 +00:00
CTransfer * transfer ;
if ( GetTransferCacheAtIndex ( transfer , m_iSortedIndexes [ iRowIndex ] ) ) {
return wxEmptyString ;
}
2008-09-04 13:00:24 +00:00
return transfer - > m_strProjectURL ;
}
int CViewTransfers : : FindRowIndexByKeyValues ( wxString & key1 , wxString & key2 ) {
CTransfer * transfer ;
unsigned int iRowIndex , n = GetCacheCount ( ) ;
for ( iRowIndex = 0 ; iRowIndex < n ; iRowIndex + + ) {
2008-10-14 12:35:48 +00:00
if ( GetTransferCacheAtIndex ( transfer , m_iSortedIndexes [ iRowIndex ] ) ) {
continue ;
}
2008-09-04 13:00:24 +00:00
if ( ! ( transfer - > m_strFileName ) . IsSameAs ( key1 ) ) continue ;
if ( ( transfer - > m_strProjectURL ) . IsSameAs ( key2 ) ) return iRowIndex ;
}
return - 1 ;
}
2005-07-07 22:26:49 +00:00
void CViewTransfers : : OnTransfersRetryNow ( wxCommandEvent & WXUNUSED ( event ) ) {
2005-04-21 06:04:26 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CViewTransfers::OnTransfersRetryNow - Function Begin " ) ) ;
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
CAdvancedFrame * pFrame = wxDynamicCast ( GetParent ( ) - > GetParent ( ) - > GetParent ( ) , CAdvancedFrame ) ;
2008-06-27 10:05:47 +00:00
int row ;
2005-04-21 06:04:26 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2005-04-21 06:04:26 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pFrame ) ;
2006-06-24 05:00:57 +00:00
wxASSERT ( wxDynamicCast ( pFrame , CAdvancedFrame ) ) ;
2008-09-13 00:27:13 +00:00
wxASSERT ( m_pListPane ) ;
2005-04-21 06:04:26 +00:00
pFrame - > UpdateStatusText ( _ ( " Retrying transfer now... " ) ) ;
2008-06-27 10:05:47 +00:00
row = - 1 ;
while ( 1 ) {
// Step through all selected items
row = m_pListPane - > GetNextItem ( row , wxLIST_NEXT_ALL , wxLIST_STATE_SELECTED ) ;
if ( row < 0 ) break ;
pDoc - > TransferRetryNow ( m_iSortedIndexes [ row ] ) ;
}
2005-04-21 06:04:26 +00:00
pFrame - > UpdateStatusText ( wxT ( " " ) ) ;
2005-04-21 23:14:10 +00:00
UpdateSelection ( ) ;
2006-02-17 20:59:15 +00:00
pFrame - > ResetReminderTimers ( ) ;
2005-05-05 06:07:14 +00:00
pFrame - > FireRefreshView ( ) ;
2005-04-21 23:14:10 +00:00
2005-04-21 06:04:26 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CViewTransfers::OnTransfersRetryNow - Function End " ) ) ;
}
2005-07-07 22:26:49 +00:00
void CViewTransfers : : OnTransfersAbort ( wxCommandEvent & WXUNUSED ( event ) ) {
2005-04-21 06:04:26 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CViewTransfers::OnTransfersAbort - Function Begin " ) ) ;
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
wxInt32 iAnswer = 0 ;
wxString strMessage = wxEmptyString ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
CAdvancedFrame * pFrame = wxDynamicCast ( GetParent ( ) - > GetParent ( ) - > GetParent ( ) , CAdvancedFrame ) ;
CTransfer * pTransfer = NULL ;
2008-06-27 10:05:47 +00:00
int row ;
2005-04-21 06:04:26 +00:00
2005-04-27 06:55:28 +00:00
wxASSERT ( pDoc ) ;
2005-04-21 06:04:26 +00:00
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pFrame ) ;
2006-06-24 05:00:57 +00:00
wxASSERT ( wxDynamicCast ( pFrame , CAdvancedFrame ) ) ;
2008-09-13 00:27:13 +00:00
wxASSERT ( m_pListPane ) ;
2006-06-22 10:10:51 +00:00
if ( ! pDoc - > IsUserAuthorized ( ) )
return ;
2005-04-21 06:04:26 +00:00
pFrame - > UpdateStatusText ( _ ( " Aborting transfer... " ) ) ;
2008-06-27 10:05:47 +00:00
row = - 1 ;
while ( 1 ) {
// Step through all selected items
row = m_pListPane - > GetNextItem ( row , wxLIST_NEXT_ALL , wxLIST_STATE_SELECTED ) ;
if ( row < 0 ) break ;
2008-10-14 12:35:48 +00:00
if ( GetTransferCacheAtIndex ( pTransfer , m_iSortedIndexes [ row ] ) ) {
return ;
}
2008-06-27 10:05:47 +00:00
strMessage . Printf (
2008-07-08 20:05:07 +00:00
_ ( " Are you sure you want to abort this file transfer '%s'? \n NOTE: Aborting a transfer will invalidate a task and you \n will not receive credit for it. " ) ,
2008-06-27 10:05:47 +00:00
pTransfer - > m_strFileName . c_str ( )
) ;
2008-08-20 16:07:06 +00:00
iAnswer = wxGetApp ( ) . SafeMessageBox (
2008-06-27 10:05:47 +00:00
strMessage ,
_ ( " Abort File Transfer " ) ,
wxYES_NO | wxICON_QUESTION ,
this
) ;
if ( wxYES = = iAnswer ) {
pDoc - > TransferAbort ( m_iSortedIndexes [ row ] ) ;
}
2005-04-21 06:04:26 +00:00
}
2008-06-27 10:05:47 +00:00
2005-04-21 06:04:26 +00:00
pFrame - > UpdateStatusText ( wxT ( " " ) ) ;
2005-04-21 23:14:10 +00:00
UpdateSelection ( ) ;
2005-05-05 06:07:14 +00:00
pFrame - > FireRefreshView ( ) ;
2005-04-21 23:14:10 +00:00
2005-04-21 06:04:26 +00:00
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CViewTransfers::OnTransfersAbort - Function End " ) ) ;
}
2005-04-07 07:04:50 +00:00
wxInt32 CViewTransfers : : GetDocCount ( ) {
2006-04-17 20:26:59 +00:00
return wxGetApp ( ) . GetDocument ( ) - > GetTransferCount ( ) ;
2004-10-26 08:41:02 +00:00
}
2005-04-07 07:04:50 +00:00
wxString CViewTransfers : : OnListGetItemText ( long item , long column ) const {
2008-09-08 09:11:56 +00:00
CTransfer * transfer ;
2004-12-02 07:43:47 +00:00
wxString strBuffer = wxEmptyString ;
2004-10-22 00:41:18 +00:00
2008-10-06 11:33:28 +00:00
m_pListPane - > AddPendingProgressBar ( item ) ;
2008-09-09 10:09:54 +00:00
2008-09-08 09:11:56 +00:00
try {
transfer = m_TransferCache . at ( m_iSortedIndexes [ item ] ) ;
} catch ( std : : out_of_range ) {
transfer = NULL ;
}
if ( transfer ) {
switch ( column ) {
2004-08-11 23:52:22 +00:00
case COLUMN_PROJECT :
2008-09-08 09:11:56 +00:00
strBuffer = transfer - > m_strProjectName ;
2004-08-11 23:52:22 +00:00
break ;
case COLUMN_FILE :
2008-09-08 09:11:56 +00:00
strBuffer = transfer - > m_strFileName ;
2004-08-11 23:52:22 +00:00
break ;
case COLUMN_PROGRESS :
2008-10-06 12:01:27 +00:00
// CBOINCListCtrl::DrawProgressBars() will draw this using
2009-10-29 11:13:48 +00:00
// data provided by GetProgressText() and GetProgressValue(),
// but we need it here for accessibility programs.
strBuffer = transfer - > m_strProgress ;
2004-08-11 23:52:22 +00:00
break ;
case COLUMN_SIZE :
2008-09-08 09:11:56 +00:00
strBuffer = transfer - > m_strSize ;
2004-08-11 23:52:22 +00:00
break ;
case COLUMN_TIME :
2008-09-08 09:11:56 +00:00
strBuffer = transfer - > m_strTime ;
2004-08-11 23:52:22 +00:00
break ;
case COLUMN_SPEED :
2008-09-08 09:11:56 +00:00
strBuffer = transfer - > m_strSpeed ;
2004-08-11 23:52:22 +00:00
break ;
case COLUMN_STATUS :
2008-09-08 09:11:56 +00:00
strBuffer = transfer - > m_strStatus ;
2004-08-11 23:52:22 +00:00
break ;
2008-09-08 09:11:56 +00:00
}
2004-08-11 23:52:22 +00:00
}
2004-12-02 07:43:47 +00:00
2004-08-11 23:52:22 +00:00
return strBuffer ;
}
2004-09-24 22:19:02 +00:00
2005-04-07 07:04:50 +00:00
wxInt32 CViewTransfers : : AddCacheElement ( ) {
2004-12-02 07:43:47 +00:00
CTransfer * pItem = new CTransfer ( ) ;
2005-04-27 06:55:28 +00:00
wxASSERT ( pItem ) ;
if ( pItem ) {
2005-04-07 07:04:50 +00:00
m_TransferCache . push_back ( pItem ) ;
2008-06-27 10:05:47 +00:00
m_iSortedIndexes . Add ( ( int ) m_TransferCache . size ( ) - 1 ) ;
2004-12-02 07:43:47 +00:00
return 0 ;
}
return - 1 ;
}
2005-04-07 07:04:50 +00:00
wxInt32 CViewTransfers : : EmptyCache ( ) {
2005-01-29 19:59:39 +00:00
unsigned int i ;
for ( i = 0 ; i < m_TransferCache . size ( ) ; i + + ) {
delete m_TransferCache [ i ] ;
}
2005-01-29 00:58:43 +00:00
m_TransferCache . clear ( ) ;
2008-06-27 10:05:47 +00:00
m_iSortedIndexes . Clear ( ) ;
2004-12-02 07:43:47 +00:00
return 0 ;
}
2005-04-07 07:04:50 +00:00
wxInt32 CViewTransfers : : GetCacheCount ( ) {
2006-07-21 08:23:26 +00:00
return ( wxInt32 ) m_TransferCache . size ( ) ;
2004-12-02 07:43:47 +00:00
}
2005-04-07 07:04:50 +00:00
wxInt32 CViewTransfers : : RemoveCacheElement ( ) {
2008-06-27 10:05:47 +00:00
unsigned int i ;
2005-01-29 21:30:45 +00:00
delete m_TransferCache . back ( ) ;
2005-04-07 07:04:50 +00:00
m_TransferCache . erase ( m_TransferCache . end ( ) - 1 ) ;
2008-06-27 10:05:47 +00:00
m_iSortedIndexes . Clear ( ) ;
for ( i = 0 ; i < m_TransferCache . size ( ) ; i + + ) {
m_iSortedIndexes . Add ( i ) ;
}
2004-12-02 07:43:47 +00:00
return 0 ;
}
2008-10-30 01:55:11 +00:00
bool CViewTransfers : : IsSelectionManagementNeeded ( ) {
- client: include precompiled header in rr_sim.cpp so memory
leak detection will work.
- MGR: Have the BaseFrame call a function to determine if the
selection list should be saved instead of traversing
the application pointer. Each view just overrides the function
returning a true/false value. We don't have to worry about null
pointers and the like.
- MGR: BOINCGUIApp should never need to know how either the views
work or the document. Move the code that determines which
RPCs should be fired into each of the views. Have the document
look for it there.
- MGR: Reduce duplicate code for hiding and showing an application
- MGR: Move some Windows and Mac specific code into functions
and streamline the application startup and shutdown rountines.
- MGR: Move the event processing that was in BOINCGUIApp into the
BaseFrame.
- MGR: General cleanup.
- MGR: Doxygen comments.
- MGR: Cleanup some warnings.
client/
rr_sim.cpp
clientgui/
AdvancedFrame.cpp, .h
AsyncRPC.cpp, .h
BOINCBaseFrame.cpp, .h
BOINCBaseView.cpp, .h
BOINCClientManager.cpp
BOINCGUIApp.cpp, .h
BOINCTaskBar.cpp
MainDocument.cpp, .h
sg_BoincSimpleGUI.cpp, .h
ViewProjects.cpp, .h
ViewTransfers.cpp, .h
ViewWork.cpp, .h
WelcomePage.cpp
win_build/installerv2/
BOINC.ism
BOINCx64.ism
win_build/
sim.vcproj
svn path=/trunk/boinc/; revision=16357
2008-10-29 22:44:55 +00:00
return true ;
}
2008-06-27 10:05:47 +00:00
void CViewTransfers : : UpdateSelection ( ) {
CTaskItemGroup * pGroup = m_TaskGroups [ 0 ] ;
2004-12-02 07:43:47 +00:00
2008-06-27 10:05:47 +00:00
CBOINCBaseView : : PreUpdateSelection ( ) ;
if ( m_pListPane - > GetSelectedItemCount ( ) ) {
m_pTaskPane - > EnableTaskGroupTasks ( pGroup ) ;
} else {
m_pTaskPane - > DisableTaskGroupTasks ( pGroup ) ;
}
CBOINCBaseView : : PostUpdateSelection ( ) ;
}
bool CViewTransfers : : SynchronizeCacheItem ( wxInt32 iRowIndex , wxInt32 iColumnIndex ) {
wxString strDocumentText = wxEmptyString ;
2008-09-04 13:00:24 +00:00
wxString strDocumentText2 = wxEmptyString ;
2008-06-27 10:05:47 +00:00
float fDocumentFloat = 0.0 ;
2008-09-08 09:11:56 +00:00
double fDocumentDouble = 0.0 , fDocumentDouble2 = 0.0 ;
2008-10-14 12:35:48 +00:00
CTransfer * transfer ;
2008-06-27 10:05:47 +00:00
bool bNeedRefresh = false ;
strDocumentText . Empty ( ) ;
2008-10-14 12:35:48 +00:00
if ( GetTransferCacheAtIndex ( transfer , m_iSortedIndexes [ iRowIndex ] ) ) {
return false ;
}
2008-06-27 10:05:47 +00:00
switch ( iColumnIndex ) {
2004-12-02 07:43:47 +00:00
case COLUMN_PROJECT :
2008-06-27 10:05:47 +00:00
GetDocProjectName ( m_iSortedIndexes [ iRowIndex ] , strDocumentText ) ;
2008-09-04 13:00:24 +00:00
GetDocProjectURL ( m_iSortedIndexes [ iRowIndex ] , strDocumentText2 ) ;
if ( ! strDocumentText . IsSameAs ( transfer - > m_strProjectName ) | | ! strDocumentText2 . IsSameAs ( transfer - > m_strProjectURL ) ) {
2008-06-27 10:05:47 +00:00
transfer - > m_strProjectName = strDocumentText ;
2008-09-04 13:00:24 +00:00
transfer - > m_strProjectURL = strDocumentText2 ;
2008-06-27 10:05:47 +00:00
bNeedRefresh = true ;
}
2004-12-02 07:43:47 +00:00
break ;
case COLUMN_FILE :
2008-06-27 10:05:47 +00:00
GetDocFileName ( m_iSortedIndexes [ iRowIndex ] , strDocumentText ) ;
if ( ! strDocumentText . IsSameAs ( transfer - > m_strFileName ) ) {
transfer - > m_strFileName = strDocumentText ;
bNeedRefresh = true ;
}
2004-12-02 07:43:47 +00:00
break ;
case COLUMN_PROGRESS :
2008-06-27 10:05:47 +00:00
GetDocProgress ( m_iSortedIndexes [ iRowIndex ] , fDocumentFloat ) ;
if ( fDocumentFloat ! = transfer - > m_fProgress ) {
transfer - > m_fProgress = fDocumentFloat ;
2008-09-08 09:11:56 +00:00
FormatProgress ( fDocumentFloat , transfer - > m_strProgress ) ;
2008-06-27 10:05:47 +00:00
bNeedRefresh = true ;
}
2004-12-02 07:43:47 +00:00
break ;
case COLUMN_SIZE :
2008-06-27 10:05:47 +00:00
GetDocBytesXferred ( m_iSortedIndexes [ iRowIndex ] , fDocumentDouble ) ;
2008-09-08 09:11:56 +00:00
GetDocTotalBytes ( m_iSortedIndexes [ iRowIndex ] , fDocumentDouble2 ) ;
if ( ( fDocumentDouble ! = transfer - > m_fBytesXferred ) | |
( fDocumentDouble2 ! = transfer - > m_fTotalBytes )
) {
2008-06-27 10:05:47 +00:00
transfer - > m_fBytesXferred = fDocumentDouble ;
2008-09-08 09:11:56 +00:00
transfer - > m_fTotalBytes = fDocumentDouble2 ;
FormatSize ( fDocumentDouble , fDocumentDouble2 , transfer - > m_strSize ) ;
2008-06-27 10:05:47 +00:00
bNeedRefresh = true ;
}
2004-12-02 07:43:47 +00:00
break ;
case COLUMN_TIME :
2008-06-27 10:05:47 +00:00
GetDocTime ( m_iSortedIndexes [ iRowIndex ] , fDocumentDouble ) ;
if ( fDocumentDouble ! = transfer - > m_dTime ) {
transfer - > m_dTime = fDocumentDouble ;
2008-09-08 09:11:56 +00:00
FormatTime ( fDocumentDouble , transfer - > m_strTime ) ;
2008-06-27 10:05:47 +00:00
bNeedRefresh = true ;
}
2004-12-02 07:43:47 +00:00
break ;
case COLUMN_SPEED :
2008-06-27 10:05:47 +00:00
GetDocSpeed ( m_iSortedIndexes [ iRowIndex ] , fDocumentDouble ) ;
if ( fDocumentDouble ! = transfer - > m_dSpeed ) {
transfer - > m_dSpeed = fDocumentDouble ;
2008-09-08 09:11:56 +00:00
FormatSpeed ( fDocumentDouble , transfer - > m_strSpeed ) ;
2008-06-27 10:05:47 +00:00
bNeedRefresh = true ;
}
2004-12-02 07:43:47 +00:00
break ;
case COLUMN_STATUS :
2008-06-27 10:05:47 +00:00
GetDocStatus ( m_iSortedIndexes [ iRowIndex ] , strDocumentText ) ;
if ( ! strDocumentText . IsSameAs ( transfer - > m_strStatus ) ) {
transfer - > m_strStatus = strDocumentText ;
return true ;
}
2004-12-02 07:43:47 +00:00
break ;
}
2008-06-27 10:05:47 +00:00
return bNeedRefresh ;
2004-12-02 07:43:47 +00:00
}
2008-06-27 10:05:47 +00:00
void CViewTransfers : : GetDocProjectName ( wxInt32 item , wxString & strBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2006-01-09 14:03:13 +00:00
2008-06-27 10:05:47 +00:00
if ( transfer ) {
2008-09-08 09:11:56 +00:00
strBuffer = HtmlEntityDecode ( wxString ( transfer - > project_name . c_str ( ) , wxConvUTF8 ) ) ;
2005-04-22 06:06:22 +00:00
} else {
2008-06-27 10:05:47 +00:00
strBuffer = wxEmptyString ;
2005-04-22 06:06:22 +00:00
}
2004-09-24 22:19:02 +00:00
}
2008-06-27 10:05:47 +00:00
void CViewTransfers : : GetDocFileName ( wxInt32 item , wxString & strBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2004-10-22 00:41:18 +00:00
2005-06-13 08:47:51 +00:00
if ( transfer ) {
2006-03-23 01:17:07 +00:00
strBuffer = wxString ( transfer - > name . c_str ( ) , wxConvUTF8 ) ;
2008-06-27 10:05:47 +00:00
} else {
strBuffer = wxEmptyString ;
2005-06-13 08:47:51 +00:00
}
2008-06-27 10:05:47 +00:00
}
void CViewTransfers : : GetDocProgress ( wxInt32 item , float & fBuffer ) const {
2004-10-22 08:51:50 +00:00
float fBytesSent = 0 ;
float fFileSize = 0 ;
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2004-10-22 08:51:50 +00:00
2008-06-27 10:05:47 +00:00
fBuffer = 0 ;
2005-06-13 08:47:51 +00:00
if ( transfer ) {
2006-02-15 02:25:14 +00:00
fBytesSent = transfer - > bytes_xferred ;
2005-06-13 08:47:51 +00:00
fFileSize = transfer - > nbytes ;
}
2004-10-22 08:51:50 +00:00
2005-11-03 01:36:37 +00:00
// Curl apparently counts the HTTP header in byte count.
// Prevent this from causing > 100% display
//
if ( fBytesSent > fFileSize ) {
fBytesSent = fFileSize ;
}
2008-06-27 10:05:47 +00:00
if ( fFileSize ) {
fBuffer = floor ( ( fBytesSent / fFileSize ) * 10000 ) / 100 ;
2006-02-15 02:25:14 +00:00
}
2008-06-27 10:05:47 +00:00
}
2004-10-22 08:51:50 +00:00
2008-09-08 09:11:56 +00:00
wxInt32 CViewTransfers : : FormatProgress ( float fBuffer , wxString & strBuffer ) const {
strBuffer . Printf ( wxT ( " %.2f%% " ) , fBuffer ) ;
2004-10-22 00:41:18 +00:00
return 0 ;
}
2008-06-27 10:05:47 +00:00
void CViewTransfers : : GetDocBytesXferred ( wxInt32 item , double & fBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2004-10-22 08:51:50 +00:00
2005-06-13 08:47:51 +00:00
if ( transfer ) {
2008-06-27 10:05:47 +00:00
fBuffer = transfer - > bytes_xferred ;
} else {
fBuffer = 0.0 ;
2005-06-13 08:47:51 +00:00
}
2008-06-27 10:05:47 +00:00
}
void CViewTransfers : : GetDocTotalBytes ( wxInt32 item , double & fBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2008-06-27 10:05:47 +00:00
if ( transfer ) {
fBuffer = transfer - > nbytes ;
} else {
fBuffer = 0.0 ;
}
}
2008-09-08 09:11:56 +00:00
wxInt32 CViewTransfers : : FormatSize ( double fBytesSent , double fFileSize , wxString & strBuffer ) const {
2008-06-27 10:05:47 +00:00
double xTera = 1099511627776.0 ;
double xGiga = 1073741824.0 ;
double xMega = 1048576.0 ;
double xKilo = 1024.0 ;
2005-04-07 07:04:50 +00:00
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 ) ;
2004-10-22 08:51:50 +00:00
}
2005-04-07 07:04:50 +00:00
} 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 ) ;
2004-10-22 08:51:50 +00:00
}
}
2005-06-13 08:47:51 +00:00
2004-10-22 00:41:18 +00:00
return 0 ;
}
2008-06-27 10:05:47 +00:00
void CViewTransfers : : GetDocTime ( wxInt32 item , double & fBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2008-06-27 10:05:47 +00:00
if ( transfer ) {
fBuffer = transfer - > time_so_far ;
} else {
fBuffer = 0.0 ;
}
}
2008-09-08 09:11:56 +00:00
wxInt32 CViewTransfers : : FormatTime ( double fBuffer , wxString & strBuffer ) const {
2004-10-22 19:23:09 +00:00
wxInt32 iHour = 0 ;
wxInt32 iMin = 0 ;
wxInt32 iSec = 0 ;
wxTimeSpan ts ;
2004-10-22 18:39:21 +00:00
2004-10-22 19:23:09 +00:00
iHour = ( wxInt32 ) ( fBuffer / ( 60 * 60 ) ) ;
iMin = ( wxInt32 ) ( fBuffer / 60 ) % 60 ;
iSec = ( wxInt32 ) ( fBuffer ) % 60 ;
2005-04-07 07:04:50 +00:00
ts = wxTimeSpan ( iHour , iMin , iSec ) ;
2004-10-22 18:39:21 +00:00
2004-10-22 19:23:09 +00:00
strBuffer = ts . Format ( ) ;
2004-10-22 18:39:21 +00:00
2004-10-22 00:41:18 +00:00
return 0 ;
}
2008-06-27 10:05:47 +00:00
void CViewTransfers : : GetDocSpeed ( wxInt32 item , double & fBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2004-10-22 08:51:50 +00:00
2005-06-13 08:47:51 +00:00
if ( transfer ) {
if ( transfer - > xfer_active )
2008-06-27 10:05:47 +00:00
fBuffer = transfer - > xfer_speed / 1024 ;
2005-06-13 08:47:51 +00:00
else
2008-06-27 10:05:47 +00:00
fBuffer = 0.0 ;
2005-04-07 07:04:50 +00:00
}
2008-06-27 10:05:47 +00:00
}
2004-10-22 08:51:50 +00:00
2008-06-27 10:05:47 +00:00
2008-09-08 09:11:56 +00:00
wxInt32 CViewTransfers : : FormatSpeed ( double fBuffer , wxString & strBuffer ) const {
strBuffer . Printf ( wxT ( " %.2f KBps " ) , fBuffer ) ;
2005-06-13 08:47:51 +00:00
2004-10-22 00:41:18 +00:00
return 0 ;
}
2008-06-27 10:05:47 +00:00
void CViewTransfers : : GetDocStatus ( wxInt32 item , wxString & strBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
int retval ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2006-08-31 19:24:38 +00:00
CC_STATUS status ;
2004-10-22 18:39:21 +00:00
2008-10-21 23:30:59 +00:00
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2004-10-22 18:39:21 +00:00
2008-10-21 23:30:59 +00:00
retval = pDoc - > GetCoreClientStatus ( status ) ;
2005-02-22 07:10:44 +00:00
2005-06-13 08:47:51 +00:00
wxDateTime dtNextRequest ( ( time_t ) transfer - > next_request_time ) ;
2004-10-22 18:39:21 +00:00
wxDateTime dtNow ( wxDateTime : : Now ( ) ) ;
2008-10-21 23:30:59 +00:00
if ( transfer & & ! retval ) {
2005-08-26 18:13:36 +00:00
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 " ) ;
2005-04-07 07:04:50 +00:00
} else {
2006-08-31 19:24:38 +00:00
if ( status . network_suspend_reason ) {
2005-08-26 18:13:36 +00:00
strBuffer = _ ( " Suspended " ) ;
} else {
2006-03-04 00:53:20 +00:00
if ( transfer - > xfer_active ) {
strBuffer = transfer - > generated_locally ? _ ( " Uploading " ) : _ ( " Downloading " ) ;
} else {
strBuffer = transfer - > generated_locally ? _ ( " Upload pending " ) : _ ( " Download pending " ) ;
}
2005-08-26 18:13:36 +00:00
}
2005-02-22 07:10:44 +00:00
}
2009-07-31 19:46:47 +00:00
if ( transfer - > project_backoff ) {
wxString x ;
2009-07-31 23:52:47 +00:00
FormatTime ( transfer - > project_backoff , x ) ;
2009-07-31 19:46:47 +00:00
strBuffer + = _ ( " (project backoff: " ) + x + _ ( " ) " ) ;
2009-07-22 22:00:51 +00:00
}
2004-10-22 18:39:21 +00:00
}
2008-06-27 10:05:47 +00:00
}
2008-09-04 13:00:24 +00:00
void CViewTransfers : : GetDocProjectURL ( wxInt32 item , wxString & strBuffer ) const {
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( item ) ;
}
2008-09-04 13:00:24 +00:00
wxASSERT ( transfer ) ;
if ( transfer ) {
strBuffer = wxString ( transfer - > project_url . c_str ( ) , wxConvUTF8 ) ;
}
}
2008-06-24 10:52:12 +00:00
double CViewTransfers : : GetProgressValue ( long item ) {
2008-06-27 10:05:47 +00:00
double fBytesSent = 0 ;
double fFileSize = 0 ;
2008-10-21 23:30:59 +00:00
FILE_TRANSFER * transfer = NULL ;
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
if ( pDoc ) {
transfer = pDoc - > file_transfer ( m_iSortedIndexes [ item ] ) ;
}
2008-06-24 10:52:12 +00:00
if ( transfer ) {
fBytesSent = transfer - > bytes_xferred ;
fFileSize = transfer - > nbytes ;
}
// Curl apparently counts the HTTP header in byte count.
// Prevent this from causing > 100% display
//
if ( fBytesSent > fFileSize ) {
fBytesSent = fFileSize ;
}
if ( 0.0 = = fFileSize ) return 0.0 ;
return ( fBytesSent / fFileSize ) ;
}
2008-10-06 11:33:28 +00:00
wxString CViewTransfers : : GetProgressText ( long item ) {
CTransfer * transfer ;
wxString strBuffer = wxEmptyString ;
2008-10-14 12:35:48 +00:00
GetTransferCacheAtIndex ( transfer , m_iSortedIndexes [ item ] ) ;
2008-10-06 11:33:28 +00:00
if ( transfer ) {
strBuffer = transfer - > m_strProgress ;
}
return strBuffer ;
}
2008-10-14 12:35:48 +00:00
int CViewTransfers : : GetTransferCacheAtIndex ( CTransfer * & transferPtr , int index ) {
try {
transferPtr = m_TransferCache . at ( index ) ;
} catch ( std : : out_of_range ) {
transferPtr = NULL ;
return - 1 ;
}
return 0 ;
}
2005-01-02 18:29:53 +00:00
const char * BOINC_RCSID_7aadb93332 = " $Id$ " ;