2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-05-17 22:15:10 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2004-04-10 09:11:03 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
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"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "MainFrame.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() {
|
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_strProgress.Clear();
|
|
|
|
m_strSize.Clear();
|
|
|
|
m_strTime.Clear();
|
|
|
|
m_strSpeed.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)
|
2005-04-21 06:04:26 +00:00
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
2004-04-10 09:11:03 +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) :
|
2005-09-06 06:18:36 +00:00
|
|
|
CBOINCBaseView(pNotebook, ID_TASK_TRANSFERSVIEW, DEFAULT_TASK_FLAGS, ID_LIST_TRANSFERSVIEW, DEFAULT_LIST_SINGLE_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"),
|
|
|
|
_("Click 'Abort transfer' to delete the file from the transfer queue. "
|
|
|
|
"This will prevent you from being granted credit for this result."),
|
|
|
|
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
|
|
|
|
|
|
|
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() {
|
2005-09-02 20:56:08 +00:00
|
|
|
static wxString strViewName(_("Transfers"));
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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"));
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
CMainFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CMainFrame);
|
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);
|
2005-04-21 06:04:26 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pTaskPane);
|
|
|
|
wxASSERT(m_pListPane);
|
2005-04-21 06:04:26 +00:00
|
|
|
|
|
|
|
pFrame->UpdateStatusText(_("Retrying transfer now..."));
|
|
|
|
pDoc->TransferRetryNow(m_pListPane->GetFirstSelected());
|
|
|
|
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"));
|
|
|
|
|
|
|
|
wxInt32 iAnswer = 0;
|
|
|
|
wxString strName = wxEmptyString;
|
|
|
|
wxString strMessage = wxEmptyString;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
CMainFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CMainFrame);
|
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);
|
2005-04-21 06:04:26 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pTaskPane);
|
|
|
|
wxASSERT(m_pListPane);
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2006-06-22 10:10:51 +00:00
|
|
|
if (!pDoc->IsUserAuthorized())
|
|
|
|
return;
|
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
pFrame->UpdateStatusText(_("Aborting transfer..."));
|
|
|
|
|
|
|
|
strMessage.Printf(
|
2006-02-15 02:25:14 +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."),
|
2006-06-14 18:31:20 +00:00
|
|
|
wxString(pDoc->file_transfer(m_pListPane->GetFirstSelected())->name.c_str(), wxConvUTF8).c_str()
|
2006-02-15 02:25:14 +00:00
|
|
|
);
|
2005-04-21 06:04:26 +00:00
|
|
|
|
2005-06-24 10:49:42 +00:00
|
|
|
iAnswer = ::wxMessageBox(
|
2005-04-21 06:04:26 +00:00
|
|
|
strMessage,
|
|
|
|
_("Abort File Transfer"),
|
2005-06-24 10:49:42 +00:00
|
|
|
wxYES_NO | wxICON_QUESTION,
|
2005-04-21 06:04:26 +00:00
|
|
|
this
|
|
|
|
);
|
|
|
|
|
|
|
|
if (wxYES == iAnswer) {
|
|
|
|
pDoc->TransferAbort(m_pListPane->GetFirstSelected());
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
CTransfer* transfer = m_TransferCache.at(item);
|
2004-12-02 07:43:47 +00:00
|
|
|
wxString strBuffer = wxEmptyString;
|
2004-10-22 00:41:18 +00:00
|
|
|
|
2005-11-02 18:28:45 +00:00
|
|
|
try {
|
|
|
|
transfer = m_TransferCache.at(item);
|
|
|
|
} catch ( std::out_of_range ) {
|
|
|
|
transfer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transfer) {
|
|
|
|
switch(column) {
|
|
|
|
case COLUMN_PROJECT:
|
|
|
|
strBuffer = transfer->m_strProjectName;
|
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
|
|
|
strBuffer = transfer->m_strFileName;
|
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
|
|
|
strBuffer = transfer->m_strProgress;
|
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
|
|
|
strBuffer = transfer->m_strSize;
|
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
|
|
|
strBuffer = transfer->m_strTime;
|
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
|
|
|
strBuffer = transfer->m_strSpeed;
|
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
|
|
|
strBuffer = transfer->m_strStatus;
|
|
|
|
break;
|
|
|
|
}
|
2004-12-02 07:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return strBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxString CViewTransfers::OnDocGetItemText(long item, long column) const {
|
2004-12-02 07:43:47 +00:00
|
|
|
wxString strBuffer = wxEmptyString;
|
2004-10-22 00:41:18 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
switch(column) {
|
2004-08-11 23:52:22 +00:00
|
|
|
case COLUMN_PROJECT:
|
2005-04-07 07:04:50 +00:00
|
|
|
FormatProjectName(item, strBuffer);
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
2005-04-07 07:04:50 +00:00
|
|
|
FormatFileName(item, strBuffer);
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
2005-04-07 07:04:50 +00:00
|
|
|
FormatProgress(item, strBuffer);
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
2005-04-07 07:04:50 +00:00
|
|
|
FormatSize(item, strBuffer);
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
2005-04-07 07:04:50 +00:00
|
|
|
FormatTime(item, strBuffer);
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
2005-04-07 07:04:50 +00:00
|
|
|
FormatSpeed(item, strBuffer);
|
2004-08-11 23:52:22 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
2005-04-07 07:04:50 +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
|
|
|
|
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);
|
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();
|
2004-12-02 07:43:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::GetCacheCount() {
|
2005-01-29 00:58:43 +00:00
|
|
|
return m_TransferCache.size();
|
2004-12-02 07:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::RemoveCacheElement() {
|
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);
|
2004-12-02 07:43:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::UpdateCache(long item, long column, wxString& strNewData) {
|
|
|
|
CTransfer* transfer = m_TransferCache.at(item);
|
2004-12-02 07:43:47 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
switch(column) {
|
2004-12-02 07:43:47 +00:00
|
|
|
case COLUMN_PROJECT:
|
2005-03-15 23:44:48 +00:00
|
|
|
transfer->m_strProjectName = strNewData;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
2005-03-15 23:44:48 +00:00
|
|
|
transfer->m_strFileName = strNewData;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
2005-03-15 23:44:48 +00:00
|
|
|
transfer->m_strProgress = strNewData;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
2005-03-15 23:44:48 +00:00
|
|
|
transfer->m_strSize = strNewData;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
2005-03-15 23:44:48 +00:00
|
|
|
transfer->m_strTime = strNewData;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
2005-03-15 23:44:48 +00:00
|
|
|
transfer->m_strSpeed = strNewData;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
2005-03-15 23:44:48 +00:00
|
|
|
transfer->m_strStatus = strNewData;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CViewTransfers::UpdateSelection() {
|
2005-04-22 06:06:22 +00:00
|
|
|
CTaskItemGroup* pGroup = m_TaskGroups[0];
|
2006-01-09 14:03:13 +00:00
|
|
|
|
|
|
|
CBOINCBaseView::PreUpdateSelection();
|
|
|
|
|
2005-04-27 06:32:40 +00:00
|
|
|
if (m_pListPane->GetSelectedItemCount()) {
|
|
|
|
m_pTaskPane->EnableTaskGroupTasks(pGroup);
|
2005-04-22 06:06:22 +00:00
|
|
|
} else {
|
2005-04-27 06:32:40 +00:00
|
|
|
m_pTaskPane->DisableTaskGroupTasks(pGroup);
|
2005-04-22 06:06:22 +00:00
|
|
|
}
|
2005-07-24 08:35:57 +00:00
|
|
|
|
2006-01-09 14:03:13 +00:00
|
|
|
CBOINCBaseView::PostUpdateSelection();
|
2004-09-24 22:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::FormatProjectName(wxInt32 item, wxString& strBuffer) const {
|
2005-06-13 08:47:51 +00:00
|
|
|
FILE_TRANSFER* transfer = wxGetApp().GetDocument()->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->project_name.c_str(), wxConvUTF8);
|
2005-06-13 08:47:51 +00:00
|
|
|
}
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::FormatFileName(wxInt32 item, wxString& strBuffer) const {
|
2005-06-13 08:47:51 +00:00
|
|
|
FILE_TRANSFER* transfer = wxGetApp().GetDocument()->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);
|
2005-06-13 08:47:51 +00:00
|
|
|
}
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::FormatProgress(wxInt32 item, wxString& strBuffer) const {
|
2004-10-22 08:51:50 +00:00
|
|
|
float fBytesSent = 0;
|
|
|
|
float fFileSize = 0;
|
2005-06-13 08:47:51 +00:00
|
|
|
FILE_TRANSFER* transfer = wxGetApp().GetDocument()->file_transfer(item);
|
2004-10-22 08:51:50 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-02-15 02:25:14 +00:00
|
|
|
if ( 0.0 == fFileSize ) {
|
|
|
|
strBuffer = wxT("0%");
|
|
|
|
} else {
|
2006-02-16 21:44:26 +00:00
|
|
|
strBuffer.Printf(wxT("%.2f%%"), floor((fBytesSent / fFileSize) * 10000)/100);
|
2006-02-15 02:25:14 +00:00
|
|
|
}
|
2004-10-22 08:51:50 +00:00
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
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;
|
2005-06-13 08:47:51 +00:00
|
|
|
FILE_TRANSFER* transfer = wxGetApp().GetDocument()->file_transfer(item);
|
2004-10-22 08:51:50 +00:00
|
|
|
|
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;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
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;
|
2005-06-13 08:47:51 +00:00
|
|
|
FILE_TRANSFER* transfer = wxGetApp().GetDocument()->file_transfer(item);
|
2004-10-22 18:39:21 +00:00
|
|
|
|
2005-06-13 08:47:51 +00:00
|
|
|
if (transfer) {
|
|
|
|
fBuffer = transfer->time_so_far;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::FormatSpeed(wxInt32 item, wxString& strBuffer) const {
|
2004-10-22 08:51:50 +00:00
|
|
|
float fTransferSpeed = 0;
|
2005-06-13 08:47:51 +00:00
|
|
|
FILE_TRANSFER* transfer = wxGetApp().GetDocument()->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)
|
|
|
|
fTransferSpeed = transfer->xfer_speed / 1024;
|
|
|
|
else
|
|
|
|
fTransferSpeed = 0.0;
|
2005-04-07 07:04:50 +00:00
|
|
|
}
|
2004-10-22 08:51:50 +00:00
|
|
|
|
2005-06-13 08:47:51 +00:00
|
|
|
strBuffer.Printf(wxT("%.2f KBps"), fTransferSpeed);
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::FormatStatus(wxInt32 item, wxString& strBuffer) const {
|
2004-10-31 22:41:15 +00:00
|
|
|
wxInt32 iActivityMode = -1;
|
2005-02-22 07:10:44 +00:00
|
|
|
bool bActivitiesSuspended = false;
|
|
|
|
bool bNetworkSuspended = false;
|
2005-06-13 08:47:51 +00:00
|
|
|
CMainDocument* doc = wxGetApp().GetDocument();
|
|
|
|
FILE_TRANSFER* transfer = wxGetApp().GetDocument()->file_transfer(item);
|
2004-10-22 18:39:21 +00:00
|
|
|
|
2005-06-13 08:47:51 +00:00
|
|
|
wxASSERT(doc);
|
|
|
|
wxASSERT(wxDynamicCast(doc, CMainDocument));
|
2004-10-22 18:39:21 +00:00
|
|
|
|
2005-06-13 08:47:51 +00:00
|
|
|
doc->GetActivityState(bActivitiesSuspended, bNetworkSuspended);
|
|
|
|
doc->GetActivityRunMode(iActivityMode);
|
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());
|
|
|
|
|
2005-08-26 18:13:36 +00:00
|
|
|
if (transfer) {
|
|
|
|
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 {
|
2005-08-26 18:13:36 +00:00
|
|
|
if (bNetworkSuspended) {
|
|
|
|
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
|
|
|
}
|
2004-10-22 18:39:21 +00:00
|
|
|
}
|
|
|
|
|
2005-05-29 07:12:00 +00:00
|
|
|
if (iActivityMode == RUN_MODE_NEVER) {
|
2005-04-07 07:04:50 +00:00
|
|
|
strBuffer = wxT(" (") + strBuffer + wxT(") ");
|
2004-10-31 22:41:15 +00:00
|
|
|
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$";
|