2004-05-17 22:15:10 +00:00
|
|
|
// $Id$
|
|
|
|
//
|
2004-04-10 09:11:03 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
2004-05-17 22:15:10 +00:00
|
|
|
// Revision History:
|
|
|
|
//
|
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"
|
|
|
|
#include "MainDocument.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
|
|
|
#include "wx/arrimpl.cpp"
|
|
|
|
|
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
#include "res/xfer.xpm"
|
2004-09-24 22:19:02 +00:00
|
|
|
#include "res/task.xpm"
|
|
|
|
#include "res/tips.xpm"
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2004-12-02 07:43:47 +00:00
|
|
|
WX_DEFINE_OBJARRAY( CTransferCache );
|
|
|
|
|
|
|
|
|
|
|
|
CTransfer::CTransfer()
|
|
|
|
{
|
|
|
|
m_strProjectName = wxEmptyString;
|
|
|
|
m_strFileName = wxEmptyString;
|
|
|
|
m_strProgress = wxEmptyString;
|
|
|
|
m_strSize = wxEmptyString;
|
|
|
|
m_strTime = wxEmptyString;
|
|
|
|
m_strSpeed = wxEmptyString;
|
|
|
|
m_strStatus = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CTransfer::~CTransfer()
|
|
|
|
{
|
|
|
|
m_strProjectName.Clear();
|
|
|
|
m_strFileName.Clear();
|
|
|
|
m_strProgress.Clear();
|
|
|
|
m_strSize.Clear();
|
|
|
|
m_strTime.Clear();
|
|
|
|
m_strSpeed.Clear();
|
|
|
|
m_strStatus.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::GetProjectName( wxString& strProjectName )
|
|
|
|
{
|
|
|
|
strProjectName = m_strProjectName;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::GetFileName( wxString& strFileName )
|
|
|
|
{
|
|
|
|
strFileName = m_strFileName;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::GetProgress( wxString& strProgress )
|
|
|
|
{
|
|
|
|
strProgress = m_strProgress;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::GetSize( wxString& strSize )
|
|
|
|
{
|
|
|
|
strSize = m_strSize;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::GetTime( wxString& strTime )
|
|
|
|
{
|
|
|
|
strTime = m_strTime;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::GetSpeed( wxString& strSpeed )
|
|
|
|
{
|
|
|
|
strSpeed = m_strSpeed;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::GetStatus( wxString& strStatus )
|
|
|
|
{
|
|
|
|
strStatus = m_strStatus;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::SetProjectName( wxString& strProjectName )
|
|
|
|
{
|
|
|
|
m_strProjectName = strProjectName;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::SetFileName( wxString& strFileName )
|
|
|
|
{
|
|
|
|
m_strFileName = strFileName;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::SetProgress( wxString& strProgress )
|
|
|
|
{
|
|
|
|
m_strProgress = strProgress;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::SetSize( wxString& strSize )
|
|
|
|
{
|
|
|
|
m_strSize = strSize;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::SetTime( wxString& strTime )
|
|
|
|
{
|
|
|
|
m_strTime = strTime;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::SetSpeed( wxString& strSpeed )
|
|
|
|
{
|
|
|
|
m_strSpeed = strSpeed;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CTransfer::SetStatus( wxString& strStatus )
|
|
|
|
{
|
|
|
|
m_strStatus = strStatus;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CViewTransfers, CBOINCBaseView)
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
CViewTransfers::CViewTransfers()
|
2004-04-10 09:11:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
CViewTransfers::CViewTransfers(wxNotebook* pNotebook) :
|
2004-10-27 21:10:22 +00:00
|
|
|
CBOINCBaseView( pNotebook, ID_HTML_TRANSFERSVIEW, DEFAULT_HTML_FLAGS, ID_LIST_TRANSFERSVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS )
|
2004-04-10 09:11:03 +00:00
|
|
|
{
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
|
2004-12-23 01:06:41 +00:00
|
|
|
//
|
|
|
|
// Globalization/Localization
|
|
|
|
//
|
|
|
|
VIEW_HEADER = wxT("xfer");
|
|
|
|
|
|
|
|
SECTION_TASK = VIEW_HEADER + wxT("task");
|
|
|
|
SECTION_TIPS = VIEW_HEADER + wxT("tips");
|
|
|
|
|
|
|
|
BITMAP_TRANSFER = VIEW_HEADER + wxT(".xpm");
|
|
|
|
BITMAP_TASKHEADER = SECTION_TASK + wxT(".xpm");
|
|
|
|
BITMAP_TIPSHEADER = SECTION_TIPS + wxT(".xpm");
|
|
|
|
|
|
|
|
LINKDESC_DEFAULT =
|
|
|
|
_("Click an item to see additional options.");
|
|
|
|
|
|
|
|
LINK_TASKRETRY = SECTION_TASK + wxT("retry");
|
|
|
|
LINKDESC_TASKRETRY =
|
|
|
|
_("<b>Retry now</b><br>"
|
|
|
|
"Click <b>Retry now</b> to upload the file now");
|
|
|
|
|
|
|
|
LINK_TASKABORT = SECTION_TASK + wxT("abort");
|
|
|
|
LINKDESC_TASKABORT =
|
|
|
|
_("<b>Abort upload</b><br>"
|
|
|
|
"Click <b>Abort upload</b> to delete the file from the upload queue. "
|
|
|
|
"This will prevent you from being granted credit for this result.");
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Setup View
|
|
|
|
//
|
2004-09-24 22:19:02 +00:00
|
|
|
wxBitmap bmpTransfer(xfer_xpm);
|
|
|
|
wxBitmap bmpTask(task_xpm);
|
|
|
|
wxBitmap bmpTips(tips_xpm);
|
|
|
|
|
|
|
|
bmpTransfer.SetMask(new wxMask(bmpTransfer, wxColour(255, 0, 255)));
|
|
|
|
bmpTask.SetMask(new wxMask(bmpTask, wxColour(255, 0, 255)));
|
|
|
|
bmpTips.SetMask(new wxMask(bmpTips, wxColour(255, 0, 255)));
|
|
|
|
|
2004-10-05 03:40:28 +00:00
|
|
|
m_pTaskPane->AddVirtualFile(BITMAP_TRANSFER, bmpTransfer, wxBITMAP_TYPE_XPM);
|
2004-09-24 22:19:02 +00:00
|
|
|
|
2004-10-05 03:40:28 +00:00
|
|
|
m_pTaskPane->CreateTaskHeader(BITMAP_TASKHEADER, bmpTask, _("Tasks"));
|
2004-12-19 20:35:37 +00:00
|
|
|
m_pTaskPane->CreateTaskHeader(BITMAP_TIPSHEADER, bmpTips, _("Tips"));
|
2004-09-24 22:19:02 +00:00
|
|
|
|
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);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 80);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_SPEED, _("Speed"), wxLIST_FORMAT_LEFT, 80);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, 150);
|
2004-09-24 22:19:02 +00:00
|
|
|
|
|
|
|
m_bTipsHeaderHidden = false;
|
2004-10-26 17:12:58 +00:00
|
|
|
m_bItemSelected = false;
|
2004-09-24 22:19:02 +00:00
|
|
|
|
|
|
|
SetCurrentQuickTip(
|
2004-10-05 03:40:28 +00:00
|
|
|
LINK_DEFAULT,
|
2004-10-19 19:41:29 +00:00
|
|
|
LINKDESC_DEFAULT
|
2004-09-24 22:19:02 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
UpdateSelection();
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
CViewTransfers::~CViewTransfers()
|
2004-04-10 09:11:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
wxString CViewTransfers::GetViewName()
|
2004-04-10 09:11:03 +00:00
|
|
|
{
|
|
|
|
return wxString(_("Transfers"));
|
|
|
|
}
|
2004-04-11 05:09:18 +00:00
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
char** CViewTransfers::GetViewIcon()
|
2004-04-13 00:33:40 +00:00
|
|
|
{
|
|
|
|
return xfer_xpm;
|
|
|
|
}
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-12-02 07:43:47 +00:00
|
|
|
wxInt32 CViewTransfers::GetDocCount()
|
2004-10-26 08:41:02 +00:00
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
return pDoc->GetTransferCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
wxString CViewTransfers::OnListGetItemText(long item, long column) const
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-12-02 07:43:47 +00:00
|
|
|
CTransfer& transfer = m_TransferCache.Item( item );
|
|
|
|
wxString strBuffer = wxEmptyString;
|
2004-10-22 00:41:18 +00:00
|
|
|
|
2004-12-02 07:43:47 +00:00
|
|
|
switch(column)
|
|
|
|
{
|
|
|
|
case COLUMN_PROJECT:
|
|
|
|
transfer.GetProjectName( strBuffer );
|
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
|
|
|
transfer.GetFileName( strBuffer );
|
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
|
|
|
transfer.GetProgress( strBuffer );
|
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
|
|
|
transfer.GetSize( strBuffer );
|
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
|
|
|
transfer.GetTime( strBuffer );
|
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
|
|
|
transfer.GetSpeed( strBuffer );
|
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
|
|
|
transfer.GetStatus( strBuffer );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return strBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CViewTransfers::OnDocGetItemText(long item, long column) const
|
|
|
|
{
|
|
|
|
wxString strBuffer = wxEmptyString;
|
2004-10-22 00:41:18 +00:00
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
switch(column)
|
|
|
|
{
|
2004-08-11 23:52:22 +00:00
|
|
|
case COLUMN_PROJECT:
|
2004-10-22 00:41:18 +00:00
|
|
|
FormatProjectName( item, strBuffer );
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
2004-10-22 00:41:18 +00:00
|
|
|
FormatFileName( item, strBuffer );
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
2004-10-22 00:41:18 +00:00
|
|
|
FormatProgress( item, strBuffer );
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
2004-10-22 00:41:18 +00:00
|
|
|
FormatSize( item, strBuffer );
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
2004-10-22 00:41:18 +00:00
|
|
|
FormatTime( item, strBuffer );
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
2004-10-22 00:41:18 +00:00
|
|
|
FormatSpeed( item, strBuffer );
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
2004-10-22 00:41:18 +00:00
|
|
|
FormatStatus( item, strBuffer );
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
void CViewTransfers::OnTaskLinkClicked( const wxHtmlLinkInfo& link )
|
|
|
|
{
|
2004-10-22 19:23:09 +00:00
|
|
|
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));
|
2004-09-24 22:19:02 +00:00
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
|
2004-12-23 03:36:51 +00:00
|
|
|
m_bTaskHeaderHidden = false;
|
|
|
|
m_bTipsHeaderHidden = false;
|
|
|
|
|
|
|
|
if ( link.GetHref() == LINK_TASKRETRY )
|
2004-10-22 19:23:09 +00:00
|
|
|
{
|
|
|
|
iProjectIndex = m_pListPane->GetFirstSelected();
|
2004-09-24 22:19:02 +00:00
|
|
|
|
2004-10-22 19:23:09 +00:00
|
|
|
pDoc->TransferRetryNow(
|
|
|
|
iProjectIndex
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if ( link.GetHref() == LINK_TASKABORT )
|
|
|
|
{
|
|
|
|
iProjectIndex = m_pListPane->GetFirstSelected();
|
|
|
|
pDoc->GetTransferFileName(iProjectIndex, strName);
|
|
|
|
|
|
|
|
strMessage.Printf(
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Are you sure you want to abort this file transfer '%s'?"),
|
2004-10-22 19:23:09 +00:00
|
|
|
strName.c_str());
|
2004-09-24 22:19:02 +00:00
|
|
|
|
2004-10-22 19:23:09 +00:00
|
|
|
iAnswer = wxMessageBox(
|
|
|
|
strMessage,
|
|
|
|
_("Abort File Transfer"),
|
|
|
|
wxYES_NO | wxICON_QUESTION,
|
|
|
|
this
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( wxYES == iAnswer )
|
|
|
|
{
|
|
|
|
pDoc->TransferAbort(
|
|
|
|
iProjectIndex
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2004-09-24 22:19:02 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
2004-10-22 19:23:09 +00:00
|
|
|
m_pListPane->Refresh();
|
2004-09-24 22:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-19 08:11:49 +00:00
|
|
|
void CViewTransfers::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
|
2004-09-24 22:19:02 +00:00
|
|
|
{
|
|
|
|
if ( NULL != cell->GetLink() )
|
|
|
|
{
|
|
|
|
bool bUpdateSelection = false;
|
|
|
|
wxString strLink;
|
|
|
|
|
|
|
|
strLink = cell->GetLink()->GetHref();
|
|
|
|
|
2004-10-05 03:40:28 +00:00
|
|
|
if ( UpdateQuickTip( strLink, LINK_TASKRETRY, LINKDESC_TASKRETRY ) )
|
|
|
|
bUpdateSelection = true;
|
|
|
|
else if ( UpdateQuickTip( strLink, LINK_TASKABORT, LINKDESC_TASKABORT ) )
|
|
|
|
bUpdateSelection = true;
|
2004-09-24 22:19:02 +00:00
|
|
|
else
|
|
|
|
{
|
2004-10-05 02:55:26 +00:00
|
|
|
if ( 0 == m_pListPane->GetSelectedItemCount() )
|
2004-09-24 22:19:02 +00:00
|
|
|
{
|
2004-10-05 03:40:28 +00:00
|
|
|
if ( LINK_DEFAULT != GetCurrentQuickTip() )
|
2004-09-24 22:19:02 +00:00
|
|
|
{
|
|
|
|
SetCurrentQuickTip(
|
2004-10-05 03:40:28 +00:00
|
|
|
LINK_DEFAULT,
|
2004-10-19 19:41:29 +00:00
|
|
|
LINKDESC_DEFAULT
|
2004-09-24 22:19:02 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
bUpdateSelection = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bUpdateSelection )
|
|
|
|
{
|
|
|
|
UpdateSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-02 07:43:47 +00:00
|
|
|
wxInt32 CViewTransfers::AddCacheElement()
|
|
|
|
{
|
|
|
|
CTransfer* pItem = new CTransfer();
|
|
|
|
wxASSERT( NULL != pItem );
|
|
|
|
if ( NULL != pItem )
|
|
|
|
{
|
|
|
|
m_TransferCache.Add( pItem );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::EmptyCache()
|
|
|
|
{
|
|
|
|
m_TransferCache.Empty();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::GetCacheCount()
|
|
|
|
{
|
|
|
|
return m_TransferCache.GetCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::RemoveCacheElement()
|
|
|
|
{
|
|
|
|
m_TransferCache.RemoveAt( GetCacheCount() - 1 );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::UpdateCache( long item, long column, wxString& strNewData )
|
|
|
|
{
|
|
|
|
CTransfer& transfer = m_TransferCache.Item( item );
|
|
|
|
|
|
|
|
switch(column)
|
|
|
|
{
|
|
|
|
case COLUMN_PROJECT:
|
|
|
|
transfer.SetProjectName( strNewData );
|
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
|
|
|
transfer.SetFileName( strNewData );
|
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
|
|
|
transfer.SetProgress( strNewData );
|
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
|
|
|
transfer.SetSize( strNewData );
|
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
|
|
|
transfer.SetTime( strNewData );
|
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
|
|
|
transfer.SetSpeed( strNewData );
|
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
|
|
|
transfer.SetStatus( strNewData );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
void CViewTransfers::UpdateSelection()
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
if ( 0 == m_pListPane->GetSelectedItemCount() )
|
2004-09-24 22:19:02 +00:00
|
|
|
{
|
|
|
|
m_bTaskHeaderHidden = true;
|
|
|
|
m_bTaskRetryHidden = true;
|
|
|
|
m_bTaskAbortHidden = true;
|
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
if ( m_bItemSelected )
|
|
|
|
{
|
|
|
|
SetCurrentQuickTip(
|
|
|
|
LINK_DEFAULT,
|
|
|
|
wxT("")
|
|
|
|
);
|
|
|
|
}
|
2004-09-24 22:19:02 +00:00
|
|
|
m_bItemSelected = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_bTaskHeaderHidden = false;
|
|
|
|
m_bTaskRetryHidden = false;
|
|
|
|
m_bTaskAbortHidden = false;
|
|
|
|
|
|
|
|
m_bItemSelected = true;
|
|
|
|
}
|
|
|
|
UpdateTaskPane();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewTransfers::UpdateTaskPane()
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
|
|
|
|
m_pTaskPane->BeginTaskPage();
|
|
|
|
|
2004-12-23 03:36:51 +00:00
|
|
|
m_pTaskPane->BeginTaskSection( BITMAP_TASKHEADER, m_bTaskHeaderHidden );
|
2004-09-24 22:19:02 +00:00
|
|
|
if (!m_bTaskHeaderHidden)
|
|
|
|
{
|
2004-12-23 03:36:51 +00:00
|
|
|
m_pTaskPane->CreateTask( LINK_TASKRETRY, _("Retry Now"), m_bTaskRetryHidden );
|
|
|
|
m_pTaskPane->CreateTask( LINK_TASKABORT, _("Abort Upload"), m_bTaskAbortHidden );
|
2004-09-24 22:19:02 +00:00
|
|
|
}
|
|
|
|
m_pTaskPane->EndTaskSection( m_bTaskHeaderHidden );
|
|
|
|
|
2004-12-23 03:36:51 +00:00
|
|
|
m_pTaskPane->UpdateQuickTip( BITMAP_TIPSHEADER, GetCurrentQuickTipText(), m_bTipsHeaderHidden );
|
2004-09-24 22:19:02 +00:00
|
|
|
|
|
|
|
m_pTaskPane->EndTaskPage();
|
|
|
|
}
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
|
|
|
|
wxInt32 CViewTransfers::FormatProjectName( wxInt32 item, wxString& strBuffer ) const
|
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
|
|
|
pDoc->GetTransferProjectName(item, strBuffer);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::FormatFileName( wxInt32 item, wxString& strBuffer ) const
|
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
|
|
|
pDoc->GetTransferFileName(item, strBuffer);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::FormatProgress( wxInt32 item, wxString& strBuffer ) const
|
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
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 ) ) );
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::FormatSize( wxInt32 item, wxString& strBuffer ) const
|
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::FormatTime( wxInt32 item, wxString& strBuffer ) const
|
|
|
|
{
|
2004-10-22 18:39:21 +00:00
|
|
|
float fBuffer = 0;
|
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
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
|
|
|
pDoc->GetTransferTime(item, fBuffer);
|
|
|
|
|
2004-10-22 19:23:09 +00:00
|
|
|
iHour = (wxInt32)(fBuffer / (60 * 60));
|
|
|
|
iMin = (wxInt32)(fBuffer / 60) % 60;
|
|
|
|
iSec = (wxInt32)(fBuffer) % 60;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::FormatSpeed( wxInt32 item, wxString& strBuffer ) const
|
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
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");
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTransfers::FormatStatus( wxInt32 item, wxString& strBuffer ) const
|
|
|
|
{
|
2004-10-31 22:41:15 +00:00
|
|
|
wxInt32 iTime = 0;
|
|
|
|
wxInt32 iStatus = 0;
|
2004-10-22 18:39:21 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2004-10-31 22:41:15 +00:00
|
|
|
wxInt32 iActivityMode = -1;
|
2004-10-22 18:39:21 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
|
|
|
pDoc->GetTransferNextRequestTime( item, iTime );
|
|
|
|
pDoc->GetTransferStatus( item, iStatus );
|
|
|
|
|
|
|
|
wxDateTime dtNextRequest( (time_t)iTime );
|
|
|
|
wxDateTime dtNow(wxDateTime::Now());
|
|
|
|
|
|
|
|
if ( dtNextRequest > dtNow )
|
|
|
|
{
|
|
|
|
wxTimeSpan tsNextRequest(dtNextRequest - dtNow);
|
|
|
|
strBuffer = _("Retry in ") + tsNextRequest.Format();
|
|
|
|
}
|
|
|
|
else if ( ERR_GIVEUP_DOWNLOAD == iStatus )
|
|
|
|
{
|
|
|
|
strBuffer = _("Download failed");
|
|
|
|
}
|
|
|
|
else if ( ERR_GIVEUP_UPLOAD == iStatus )
|
|
|
|
{
|
|
|
|
strBuffer = _("Upload failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strBuffer = pDoc->IsTransferGeneratedLocally( item )? _("Uploading") : _("Downloading");
|
|
|
|
}
|
|
|
|
|
2004-10-31 22:41:15 +00:00
|
|
|
pDoc->GetActivityRunMode( iActivityMode );
|
|
|
|
if ( CMainDocument::MODE_NEVER == iActivityMode )
|
|
|
|
{
|
|
|
|
strBuffer = wxT(" ( ") + strBuffer + wxT(" ) ");
|
|
|
|
strBuffer = _("Suspended") + strBuffer;
|
|
|
|
}
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_7aadb93332 = "$Id$";
|