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:
|
|
|
|
//
|
|
|
|
// $Log$
|
2004-09-25 21:33:24 +00:00
|
|
|
// Revision 1.4 2004/09/25 21:33:23 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-09-24 22:19:02 +00:00
|
|
|
// Revision 1.3 2004/09/24 22:19:01 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-09-24 02:01:53 +00:00
|
|
|
// Revision 1.2 2004/09/24 02:01:53 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-09-21 01:30:29 +00:00
|
|
|
// Revision 1.1 2004/09/21 01:26:25 rwalton
|
2004-05-17 22:15:10 +00:00
|
|
|
// *** empty log message ***
|
|
|
|
//
|
|
|
|
//
|
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-04-10 09:11:03 +00:00
|
|
|
|
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"
|
|
|
|
|
|
|
|
#define VIEW_HEADER "xfer"
|
|
|
|
|
|
|
|
#define SECTION_TASK VIEW_HEADER "task"
|
|
|
|
#define SECTION_TIPS VIEW_HEADER "tips"
|
|
|
|
|
|
|
|
#define BITMAP_TRANSFER VIEW_HEADER ".xpm"
|
|
|
|
#define BITMAP_TASKHEADER SECTION_TASK ".xpm"
|
|
|
|
#define BITMAP_TIPSHEADER SECTION_TIPS ".xpm"
|
2004-04-13 00:33:40 +00:00
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
#define LINK_TASKRETRY SECTION_TASK "retry"
|
|
|
|
#define LINK_TASKABORT SECTION_TASK "abort"
|
|
|
|
|
|
|
|
#define LINK_DEFAULT "default"
|
2004-04-10 09:11:03 +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
|
|
|
|
|
|
|
|
|
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-09-24 02:01:53 +00:00
|
|
|
CBOINCBaseView(pNotebook, ID_HTML_TRANSFERSVIEW, ID_LIST_TRANSFERSVIEW)
|
2004-04-10 09:11:03 +00:00
|
|
|
{
|
2004-09-25 21:33:24 +00:00
|
|
|
m_bProcessingTaskRenderEvent = false;
|
|
|
|
m_bProcessingListRenderEvent = false;
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
m_pTaskPane->AddVirtualFile(wxT(BITMAP_TRANSFER), bmpTransfer, wxBITMAP_TYPE_XPM);
|
|
|
|
|
|
|
|
m_pTaskPane->CreateTaskHeader(wxT(BITMAP_TASKHEADER), bmpTask, _("Tasks"));
|
|
|
|
m_pTaskPane->CreateTaskHeader(wxT(BITMAP_TIPSHEADER), bmpTips, _("Quick Tips"));
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
m_pListPane->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, -1);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_FILE, _("File"), wxLIST_FORMAT_LEFT, -1);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_PROGRESS, _("Progress"), wxLIST_FORMAT_LEFT, -1);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_SIZE, _("Size"), wxLIST_FORMAT_LEFT, -1);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, -1);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_SPEED, _("Speed"), wxLIST_FORMAT_LEFT, -1);
|
|
|
|
m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, -1);
|
2004-09-24 22:19:02 +00:00
|
|
|
|
|
|
|
m_bTipsHeaderHidden = false;
|
|
|
|
|
|
|
|
SetCurrentQuickTip(
|
|
|
|
wxT(LINK_DEFAULT),
|
|
|
|
_("Please select a transfer item to see additional options.")
|
|
|
|
);
|
|
|
|
|
|
|
|
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-09-25 21:33:24 +00:00
|
|
|
void CViewTransfers::OnTaskRender(wxTimerEvent &event)
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-09-25 21:33:24 +00:00
|
|
|
if (!m_bProcessingTaskRenderEvent)
|
2004-08-11 23:52:22 +00:00
|
|
|
{
|
2004-09-25 21:33:24 +00:00
|
|
|
m_bProcessingTaskRenderEvent = true;
|
2004-08-11 23:52:22 +00:00
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(NULL != m_pListPane);
|
2004-08-11 23:52:22 +00:00
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
long lSelected = m_pListPane->GetFirstSelected();
|
|
|
|
if ( (-1 == lSelected) && m_bItemSelected )
|
|
|
|
{
|
|
|
|
UpdateSelection();
|
|
|
|
}
|
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
m_bProcessingTaskRenderEvent = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewTransfers::OnListRender(wxTimerEvent &event)
|
|
|
|
{
|
|
|
|
if (!m_bProcessingListRenderEvent)
|
|
|
|
{
|
|
|
|
m_bProcessingListRenderEvent = true;
|
|
|
|
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
|
|
|
|
wxInt32 iCount = wxGetApp().GetDocument()->GetTransferCount();
|
|
|
|
m_pListPane->SetItemCount(iCount);
|
|
|
|
|
|
|
|
m_bProcessingListRenderEvent = false;
|
2004-08-11 23:52:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
void CViewTransfers::OnListSelected ( wxListEvent& event )
|
|
|
|
{
|
|
|
|
UpdateSelection();
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewTransfers::OnListDeselected ( wxListEvent& event )
|
|
|
|
{
|
|
|
|
UpdateSelection();
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CViewTransfers::OnListGetItemText(long item, long column) const
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-08-11 23:52:22 +00:00
|
|
|
wxString strBuffer;
|
|
|
|
switch(column) {
|
|
|
|
case COLUMN_PROJECT:
|
|
|
|
if (item == m_iCacheFrom) wxGetApp().GetDocument()->CachedStateLock();
|
|
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferProjectName(item);
|
|
|
|
break;
|
|
|
|
case COLUMN_FILE:
|
|
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferFileName(item);
|
|
|
|
break;
|
|
|
|
case COLUMN_PROGRESS:
|
|
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferProgress(item);
|
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
|
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferSize(item);
|
|
|
|
break;
|
|
|
|
case COLUMN_TIME:
|
|
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferTime(item);
|
|
|
|
break;
|
|
|
|
case COLUMN_SPEED:
|
|
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferSpeed(item);
|
|
|
|
break;
|
|
|
|
case COLUMN_STATUS:
|
|
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferStatus(item);
|
|
|
|
if (item == m_iCacheTo) wxGetApp().GetDocument()->CachedStateUnlock();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return strBuffer;
|
|
|
|
}
|
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
|
|
|
|
void CViewTransfers::OnTaskLinkClicked( const wxHtmlLinkInfo& link )
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
|
|
|
|
wxString strMessage;
|
|
|
|
|
|
|
|
if ( link.GetHref() == wxT(SECTION_TASK) )
|
|
|
|
m_bTaskHeaderHidden ? m_bTaskHeaderHidden = false : m_bTaskHeaderHidden = true;
|
|
|
|
|
|
|
|
if ( link.GetHref() == wxT(SECTION_TIPS) )
|
|
|
|
m_bTipsHeaderHidden ? m_bTipsHeaderHidden = false : m_bTipsHeaderHidden = true;
|
|
|
|
|
|
|
|
|
|
|
|
UpdateSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewTransfers::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y )
|
|
|
|
{
|
|
|
|
if ( NULL != cell->GetLink() )
|
|
|
|
{
|
|
|
|
bool bUpdateSelection = false;
|
|
|
|
wxString strLink;
|
|
|
|
|
|
|
|
strLink = cell->GetLink()->GetHref();
|
|
|
|
|
|
|
|
if ( wxT(LINK_TASKRETRY) == strLink )
|
|
|
|
{
|
|
|
|
if ( wxT(LINK_TASKRETRY) != GetCurrentQuickTip() )
|
|
|
|
{
|
|
|
|
SetCurrentQuickTip(
|
|
|
|
wxT(LINK_TASKRETRY),
|
|
|
|
_("<b>Retry Now</b><br>"
|
|
|
|
"Selecting retry now will attempt to upload the result data file "
|
|
|
|
"to the project server now.")
|
|
|
|
);
|
|
|
|
|
|
|
|
bUpdateSelection = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( wxT(LINK_TASKABORT) == strLink )
|
|
|
|
{
|
|
|
|
if ( wxT(LINK_TASKABORT) != GetCurrentQuickTip() )
|
|
|
|
{
|
|
|
|
SetCurrentQuickTip(
|
|
|
|
wxT(LINK_TASKABORT),
|
|
|
|
_("<b>Abort Upload</b><br>"
|
|
|
|
"Selecting abort upload will delete the result from the upload queue. "
|
|
|
|
"Doing this will keep you from being granted any credit for this result.")
|
|
|
|
);
|
|
|
|
|
|
|
|
bUpdateSelection = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
long lSelected = m_pListPane->GetFirstSelected();
|
|
|
|
if ( -1 == lSelected )
|
|
|
|
{
|
|
|
|
if ( wxT(LINK_DEFAULT) != GetCurrentQuickTip() )
|
|
|
|
{
|
|
|
|
SetCurrentQuickTip(
|
|
|
|
wxT(LINK_DEFAULT),
|
|
|
|
_("Please select an result upload to see additional options.")
|
|
|
|
);
|
|
|
|
|
|
|
|
bUpdateSelection = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bUpdateSelection )
|
|
|
|
{
|
|
|
|
UpdateSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewTransfers::UpdateSelection()
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
|
|
|
|
long lSelected = m_pListPane->GetFirstSelected();
|
|
|
|
if ( -1 == lSelected )
|
|
|
|
{
|
|
|
|
m_bTaskHeaderHidden = true;
|
|
|
|
m_bTaskRetryHidden = true;
|
|
|
|
m_bTaskAbortHidden = true;
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
m_pTaskPane->BeginTaskSection( wxT(SECTION_TASK), wxT(BITMAP_TASKHEADER), m_bTaskHeaderHidden );
|
|
|
|
if (!m_bTaskHeaderHidden)
|
|
|
|
{
|
|
|
|
m_pTaskPane->CreateTask( wxT(LINK_TASKRETRY), wxT(BITMAP_TRANSFER), _("Retry Now"), m_bTaskRetryHidden );
|
|
|
|
m_pTaskPane->CreateTask( wxT(LINK_TASKABORT), wxT(BITMAP_TRANSFER), _("Abort Upload"), m_bTaskAbortHidden );
|
|
|
|
}
|
|
|
|
m_pTaskPane->EndTaskSection( m_bTaskHeaderHidden );
|
|
|
|
|
|
|
|
m_pTaskPane->UpdateQuickTip(wxT(SECTION_TIPS), wxT(BITMAP_TIPSHEADER), GetCurrentQuickTipText(), m_bTipsHeaderHidden);
|
|
|
|
|
|
|
|
m_pTaskPane->EndTaskPage();
|
|
|
|
}
|
|
|
|
|