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"
|
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
|
|
|
m_strProjectName = wxEmptyString;
|
|
|
|
m_strFileName = wxEmptyString;
|
|
|
|
m_strProgress = wxEmptyString;
|
|
|
|
m_strSize = wxEmptyString;
|
|
|
|
m_strTime = wxEmptyString;
|
|
|
|
m_strSpeed = wxEmptyString;
|
|
|
|
m_strStatus = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-04-07 07:04:50 +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-04-21 06:04:26 +00:00
|
|
|
CBOINCBaseView(pNotebook, ID_TASK_TRANSFERSVIEW, DEFAULT_TASK_FLAGS, ID_LIST_TRANSFERSVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
//
|
2005-04-21 06:04:26 +00:00
|
|
|
pGroup = new CTaskItemGroup( _("Tasks") );
|
|
|
|
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);
|
|
|
|
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);
|
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-04-07 07:04:50 +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
|
|
|
|
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-04-21 06:04:26 +00:00
|
|
|
void CViewTransfers::OnTransfersRetryNow( wxCommandEvent& event ) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfers::OnTransfersRetryNow - Function Begin"));
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
|
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();
|
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"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewTransfers::OnTransfersAbort( wxCommandEvent& event ) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfers::OnTransfersAbort - Function Begin"));
|
|
|
|
|
|
|
|
wxInt32 iAnswer = 0;
|
|
|
|
wxInt32 iProjectIndex = 0;
|
|
|
|
wxString strName = wxEmptyString;
|
|
|
|
wxString strMessage = wxEmptyString;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
|
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(_("Aborting transfer..."));
|
|
|
|
|
|
|
|
pDoc->GetTransferFileName(iProjectIndex, strName);
|
|
|
|
|
|
|
|
strMessage.Printf(
|
|
|
|
_("Are you sure you want to abort this file transfer '%s'?"),
|
|
|
|
strName.c_str());
|
|
|
|
|
|
|
|
iAnswer = wxMessageBox(
|
|
|
|
strMessage,
|
|
|
|
_("Abort File Transfer"),
|
|
|
|
wxYES_NO | wxICON_QUESTION,
|
|
|
|
this
|
|
|
|
);
|
|
|
|
|
|
|
|
if (wxYES == iAnswer) {
|
|
|
|
pDoc->TransferAbort(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() {
|
2004-10-26 08:41:02 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-26 08:41:02 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
return pDoc->GetTransferCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-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
|
|
|
strBuffer = transfer->m_strProjectName;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
2005-03-15 23:44:48 +00:00
|
|
|
strBuffer = transfer->m_strFileName;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
2005-03-15 23:44:48 +00:00
|
|
|
strBuffer = transfer->m_strProgress;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
2005-03-15 23:44:48 +00:00
|
|
|
strBuffer = transfer->m_strSize;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
2005-03-15 23:44:48 +00:00
|
|
|
strBuffer = transfer->m_strTime;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
2005-03-15 23:44:48 +00:00
|
|
|
strBuffer = transfer->m_strSpeed;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
2005-03-15 23:44:48 +00:00
|
|
|
strBuffer = transfer->m_strStatus;
|
2004-12-02 07:43:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
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
|
|
|
}
|
2004-09-24 22:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::FormatProjectName(wxInt32 item, wxString& strBuffer) const {
|
2004-10-22 00:41:18 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-22 00:41:18 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
|
|
|
pDoc->GetTransferProjectName(item, strBuffer);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxInt32 CViewTransfers::FormatFileName(wxInt32 item, wxString& strBuffer) const {
|
2004-10-22 00:41:18 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-22 00:41:18 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
|
|
|
pDoc->GetTransferFileName(item, strBuffer);
|
|
|
|
|
|
|
|
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;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-22 08:51:50 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (pDoc->IsTransferActive(item))
|
|
|
|
pDoc->GetTransferBytesXfered(item, fBytesSent);
|
2004-10-22 08:51:50 +00:00
|
|
|
else
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetTransferFileSize(item, fBytesSent);
|
2004-10-22 08:51:50 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetTransferFileSize(item, fFileSize);
|
2004-10-22 08:51:50 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
strBuffer.Printf(wxT("%.2f%%"), (100 * (fBytesSent / fFileSize)));
|
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;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-22 08:51:50 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (pDoc->IsTransferActive(item))
|
|
|
|
pDoc->GetTransferBytesXfered(item, fBytesSent);
|
2004-10-22 08:51:50 +00:00
|
|
|
else
|
2005-04-07 07:04:50 +00:00
|
|
|
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);
|
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
|
|
|
}
|
|
|
|
}
|
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;
|
2004-10-22 18:39:21 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-22 18:39:21 +00:00
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-22 08:51:50 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (pDoc->IsTransferActive(item)) {
|
|
|
|
pDoc->GetTransferSpeed(item, fTransferSpeed);
|
|
|
|
strBuffer.Printf(wxT("%0.2f KBps"), (fTransferSpeed / 1024));
|
|
|
|
} else {
|
2005-02-04 21:24:28 +00:00
|
|
|
strBuffer.Printf(wxT("%.2f KBps"), 0.0);
|
2005-04-07 07:04:50 +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::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;
|
2005-02-22 07:10:44 +00:00
|
|
|
bool bActivitiesSuspended = false;
|
|
|
|
bool bNetworkSuspended = false;
|
2004-10-22 18:39:21 +00:00
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pDoc);
|
2004-10-22 18:39:21 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strBuffer.Clear();
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetActivityState(bActivitiesSuspended, bNetworkSuspended);
|
2004-10-22 18:39:21 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetTransferNextRequestTime(item, iTime);
|
|
|
|
pDoc->GetTransferStatus(item, iStatus);
|
2004-10-22 18:39:21 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
pDoc->GetActivityRunMode(iActivityMode);
|
2005-02-22 07:10:44 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
wxDateTime dtNextRequest((time_t)iTime);
|
2004-10-22 18:39:21 +00:00
|
|
|
wxDateTime dtNow(wxDateTime::Now());
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (dtNextRequest > dtNow) {
|
2004-10-22 18:39:21 +00:00
|
|
|
wxTimeSpan tsNextRequest(dtNextRequest - dtNow);
|
|
|
|
strBuffer = _("Retry in ") + tsNextRequest.Format();
|
2005-04-07 07:04:50 +00:00
|
|
|
} else if (ERR_GIVEUP_DOWNLOAD == iStatus) {
|
2004-10-22 18:39:21 +00:00
|
|
|
strBuffer = _("Download failed");
|
2005-04-07 07:04:50 +00:00
|
|
|
} else if (ERR_GIVEUP_UPLOAD == iStatus) {
|
2004-10-22 18:39:21 +00:00
|
|
|
strBuffer = _("Upload failed");
|
2005-04-07 07:04:50 +00:00
|
|
|
} else {
|
|
|
|
if (bNetworkSuspended) {
|
2005-02-22 07:10:44 +00:00
|
|
|
strBuffer = _("Suspended");
|
2005-04-07 07:04:50 +00:00
|
|
|
} else {
|
|
|
|
strBuffer = pDoc->IsTransferGeneratedLocally(item)? _("Uploading") : _("Downloading");
|
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$";
|