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
2014-12-15 05:47:37 +00:00
// Column IDs must be equal to the column's default
// position (left to right, zero-based) when all
// columns are shown. However, any column may be
// hidden, either by default or by the user.
// (On MS Windows only, the user can also rearrange
// the columns from the default order.)
//
2014-12-11 14:18:47 +00:00
// Column IDs
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
2014-12-15 05:47:37 +00:00
// DefaultShownColumns is an array containing the
// columnIDs of the columns to be shown by default,
// in ascending order. It may or may not include
// all columns.
//
// For now, show all columns by default
2014-12-15 05:54:51 +00:00
static int DefaultShownColumns [ ] = { COLUMN_PROJECT , COLUMN_FILE , COLUMN_PROGRESS ,
COLUMN_SIZE , COLUMN_TIME , COLUMN_SPEED ,
2014-12-15 05:47:37 +00:00
COLUMN_STATUS } ;
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 )
2014-06-25 03:15:49 +00:00
// We currently handle EVT_LIST_CACHE_HINT on Windows or
// EVT_CHECK_SELECTION_CHANGED on Mac & Linux instead of EVT_LIST_ITEM_SELECTED
// or EVT_LIST_ITEM_DESELECTED. See CBOINCBaseView::OnCacheHint() for info.
2014-05-28 08:52:33 +00:00
# if USE_LIST_CACHE_HINT
2014-06-05 00:43:38 +00:00
EVT_LIST_CACHE_HINT ( ID_LIST_TRANSFERSVIEW , CViewTransfers : : OnCacheHint )
2014-05-22 03:13:34 +00:00
# else
2014-05-22 02:11:22 +00:00
EVT_CHECK_SELECTION_CHANGED ( CViewTransfers : : OnCheckSelectionChanged )
2014-05-22 03:13:34 +00:00
# endif
2014-05-21 09:39:34 +00:00
EVT_LIST_COL_CLICK ( ID_LIST_TRANSFERSVIEW , CViewTransfers : : OnColClick )
2013-11-05 02:11:36 +00:00
EVT_LIST_COL_END_DRAG ( ID_LIST_TRANSFERSVIEW , CViewTransfers : : OnColResize )
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 ;
}
2014-12-11 14:18:47 +00:00
switch ( MyCViewTransfers - > m_iSortColumnID ) {
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 :
2013-08-10 04:08:23 +00:00
if ( transfer1 - > m_fTotalBytes < transfer2 - > m_fTotalBytes ) {
2008-06-27 10:05:47 +00:00
result = - 1 ;
2013-08-10 04:08:23 +00:00
} else if ( transfer1 - > m_fTotalBytes > transfer2 - > m_fTotalBytes ) {
2008-06-27 10:05:47 +00:00
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 ) :
2014-04-05 06:11:48 +00:00
CBOINCBaseView ( pNotebook , ID_TASK_TRANSFERSVIEW , DEFAULT_TASK_FLAGS , ID_LIST_TRANSFERSVIEW , DEFAULT_LIST_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 " ) ,
2013-05-15 18:18:40 +00:00
_ ( " Retry the file transfer now " ) ,
2005-04-21 06:04:26 +00:00
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 " ) ,
2013-05-15 18:18:40 +00:00
_ ( " Abort this file transfer. You won't get credit for the task. " ) ,
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
2014-12-15 05:47:37 +00:00
// m_aStdColNameOrder is an array of all column heading labels
// (localized) in order of ascending Column ID.
// Once initialized, it should not be modified.
//
2014-12-04 14:01:15 +00:00
m_aStdColNameOrder = new wxArrayString ;
2014-12-11 14:18:47 +00:00
m_aStdColNameOrder - > Insert ( _ ( " Project " ) , COLUMN_PROJECT ) ;
m_aStdColNameOrder - > Insert ( _ ( " File " ) , COLUMN_FILE ) ;
m_aStdColNameOrder - > Insert ( _ ( " Progress " ) , COLUMN_PROGRESS ) ;
m_aStdColNameOrder - > Insert ( _ ( " Size " ) , COLUMN_SIZE ) ;
m_aStdColNameOrder - > Insert ( _ ( " Elapsed " ) , COLUMN_TIME ) ;
m_aStdColNameOrder - > Insert ( _ ( " Speed " ) , COLUMN_SPEED ) ;
m_aStdColNameOrder - > Insert ( _ ( " Status " ) , COLUMN_STATUS ) ;
2015-04-30 10:39:59 +00:00
// m_iStdColWidthOrder is an array of the width for each column.
2014-12-15 05:47:37 +00:00
// Entries must be in order of ascending Column ID. We initalize
// it here to the default column widths. It is updated by
// CBOINCListCtrl::OnRestoreState() and also when a user resizes
2015-05-01 10:20:05 +00:00
// a column by dragging the divider between two columns.
2014-12-15 05:47:37 +00:00
//
2014-12-11 14:18:47 +00:00
m_iStdColWidthOrder . Clear ( ) ;
m_iStdColWidthOrder . Insert ( 125 , COLUMN_PROJECT ) ;
m_iStdColWidthOrder . Insert ( 205 , COLUMN_FILE ) ;
m_iStdColWidthOrder . Insert ( 60 , COLUMN_PROGRESS ) ;
m_iStdColWidthOrder . Insert ( 80 , COLUMN_SIZE ) ;
m_iStdColWidthOrder . Insert ( 80 , COLUMN_TIME ) ;
m_iStdColWidthOrder . Insert ( 80 , COLUMN_SPEED ) ;
m_iStdColWidthOrder . Insert ( 150 , COLUMN_STATUS ) ;
2014-12-15 05:47:37 +00:00
m_iDefaultShownColumns = DefaultShownColumns ;
m_iNumDefaultShownColumns = sizeof ( DefaultShownColumns ) / sizeof ( int ) ;
2014-12-11 14:18:47 +00:00
wxASSERT ( m_iStdColWidthOrder . size ( ) = = m_aStdColNameOrder - > size ( ) ) ;
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
}
2014-12-11 14:18:47 +00:00
// Create List Pane Items
void CViewTransfers : : AppendColumn ( int columnID ) {
switch ( columnID ) {
case COLUMN_PROJECT :
m_pListPane - > AppendColumn ( ( * m_aStdColNameOrder ) [ COLUMN_PROJECT ] ,
wxLIST_FORMAT_LEFT , m_iStdColWidthOrder [ COLUMN_PROJECT ] ) ;
break ;
case COLUMN_FILE :
m_pListPane - > AppendColumn ( ( * m_aStdColNameOrder ) [ COLUMN_FILE ] ,
wxLIST_FORMAT_LEFT , m_iStdColWidthOrder [ COLUMN_FILE ] ) ;
break ;
case COLUMN_PROGRESS :
m_pListPane - > AppendColumn ( ( * m_aStdColNameOrder ) [ COLUMN_PROGRESS ] ,
wxLIST_FORMAT_CENTRE , m_iStdColWidthOrder [ COLUMN_PROGRESS ] ) ;
break ;
case COLUMN_SIZE :
m_pListPane - > AppendColumn ( ( * m_aStdColNameOrder ) [ COLUMN_SIZE ] ,
wxLIST_FORMAT_LEFT , m_iStdColWidthOrder [ COLUMN_SIZE ] ) ;
break ;
case COLUMN_TIME :
m_pListPane - > AppendColumn ( ( * m_aStdColNameOrder ) [ COLUMN_TIME ] ,
wxLIST_FORMAT_LEFT , m_iStdColWidthOrder [ COLUMN_TIME ] ) ;
break ;
case COLUMN_SPEED :
m_pListPane - > AppendColumn ( ( * m_aStdColNameOrder ) [ COLUMN_SPEED ] ,
wxLIST_FORMAT_LEFT , m_iStdColWidthOrder [ COLUMN_SPEED ] ) ;
break ;
case COLUMN_STATUS :
m_pListPane - > AppendColumn ( ( * m_aStdColNameOrder ) [ COLUMN_STATUS ] ,
wxLIST_FORMAT_LEFT , m_iStdColWidthOrder [ COLUMN_STATUS ] ) ;
break ;
}
}
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
2013-02-07 18:26:02 +00:00
int CViewTransfers : : GetViewCurrentViewPage ( ) {
2009-12-22 01:22:11 +00:00
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 ;
}
2015-10-22 08:39:20 +00:00
if ( m_iColumnIDToColumnIndex [ COLUMN_FILE ] < 0 ) {
// Column is hidden, so SynchronizeCacheItem() did not set its value
2015-10-22 09:34:03 +00:00
GetDocFileName ( m_iSortedIndexes [ iRowIndex ] , transfer - > m_strFileName ) ;
2015-10-22 08:39:20 +00:00
}
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 ;
}
2015-10-22 08:39:20 +00:00
if ( m_iColumnIDToColumnIndex [ COLUMN_PROJECT ] < 0 ) {
// Column is hidden, so SynchronizeCacheItem() did not set its value
2015-10-22 09:34:03 +00:00
GetDocProjectURL ( m_iSortedIndexes [ iRowIndex ] , transfer - > m_strProjectURL ) ;
2015-10-22 08:39:20 +00:00
}
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 ) ;
2010-05-01 05:28:59 +00:00
CC_STATUS status ;
pDoc - > GetCoreClientStatus ( status ) ;
if ( status . network_suspend_reason ) {
2010-05-10 22:34:25 +00:00
wxString msg = _ ( " Network activity is suspended - " ) ;
msg + = suspend_reason_wxstring ( status . network_suspend_reason ) ;
msg + = _ ( " . \n You can enable it using the Activity menu. " ) ;
2010-05-01 05:28:59 +00:00
wxGetApp ( ) . SafeMessageBox (
2010-05-10 22:34:25 +00:00
msg ,
2010-05-01 05:28:59 +00:00
_ ( " BOINC " ) ,
wxOK | wxICON_INFORMATION ,
this
) ;
return ;
}
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 " ) ) ;
}
2013-11-05 09:37:57 +00:00
void CViewTransfers : : OnColResize ( wxListEvent & ) {
2013-11-05 02:11:36 +00:00
// Register the new column widths immediately
CAdvancedFrame * pFrame = wxDynamicCast ( GetParent ( ) - > GetParent ( ) - > GetParent ( ) , CAdvancedFrame ) ;
wxASSERT ( pFrame ) ;
wxASSERT ( wxDynamicCast ( pFrame , CAdvancedFrame ) ) ;
2013-11-05 09:37:57 +00:00
pFrame - > SaveState ( ) ;
2013-11-05 02:11:36 +00:00
}
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 ;
}
2014-12-11 14:18:47 +00:00
if ( transfer & & ( column > = 0 ) ) {
switch ( m_iColumnIndexToColumnID [ 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 ;
2015-09-07 08:03:54 +00:00
double x = 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 ;
}
2014-12-11 14:18:47 +00:00
if ( iColumnIndex < 0 ) return false ;
switch ( m_iColumnIndexToColumnID [ 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 :
2015-09-07 08:03:54 +00:00
GetDocProgress ( m_iSortedIndexes [ iRowIndex ] , x ) ;
if ( x ! = transfer - > m_fProgress ) {
transfer - > m_fProgress = x ;
FormatProgress ( x , 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 ;
2015-08-27 06:30:50 +00:00
transfer - > m_strTime = FormatTime ( fDocumentDouble ) ;
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
}
2015-09-07 08:03:54 +00:00
void CViewTransfers : : GetDocProgress ( wxInt32 item , double & fBuffer ) const {
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 ( 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
2015-09-07 08:03:54 +00:00
wxInt32 CViewTransfers : : FormatProgress ( double fBuffer , wxString & strBuffer ) const {
2008-09-08 09:11:56 +00:00
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 ;
}
}
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 ( ) ;
2011-07-20 19:12:10 +00:00
int retval ;
strBuffer = wxString ( " " , wxConvUTF8 ) ;
2008-10-21 23:30:59 +00:00
2011-07-20 19:12:10 +00:00
transfer = pDoc - > file_transfer ( item ) ;
if ( ! transfer ) return ;
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 ) ;
2011-07-20 19:12:10 +00:00
if ( retval ) return ;
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 ( ) ) ;
2011-07-20 19:12:10 +00:00
strBuffer = transfer - > is_upload ? _ ( " Upload " ) : _ ( " Download " ) ;
strBuffer + = wxString ( " : " , wxConvUTF8 ) ;
if ( dtNextRequest > dtNow ) {
wxTimeSpan tsNextRequest ( dtNextRequest - dtNow ) ;
strBuffer + = _ ( " retry in " ) + tsNextRequest . Format ( ) ;
} else if ( transfer - > status = = ERR_GIVEUP_DOWNLOAD | | transfer - > status = = ERR_GIVEUP_UPLOAD ) {
strBuffer = _ ( " failed " ) ;
} else {
if ( status . network_suspend_reason ) {
strBuffer + = _ ( " suspended " ) ;
strBuffer + = wxString ( " - " , wxConvUTF8 ) ;
strBuffer + = suspend_reason_wxstring ( status . network_suspend_reason ) ;
2005-04-07 07:04:50 +00:00
} else {
2011-07-20 19:12:10 +00:00
if ( transfer - > xfer_active ) {
strBuffer + = _ ( " active " ) ;
2005-08-26 18:13:36 +00:00
} else {
2011-07-20 19:12:10 +00:00
strBuffer + = _ ( " pending " ) ;
2005-08-26 18:13:36 +00:00
}
2005-02-22 07:10:44 +00:00
}
2011-07-20 19:12:10 +00:00
}
if ( transfer - > project_backoff ) {
2015-08-27 06:30:50 +00:00
wxString x = FormatTime ( transfer - > project_backoff ) ;
2011-07-20 19:12:10 +00:00
strBuffer + = _ ( " (project backoff: " ) + x + _ ( " ) " ) ;
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 ;
}