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__)
|
|
|
|
#pragma implementation "MainDocument.h"
|
|
|
|
#endif
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
#include "stdwx.h"
|
2004-10-09 03:05:01 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2004-04-11 04:12:44 +00:00
|
|
|
#include "MainDocument.h"
|
2004-07-12 08:46:26 +00:00
|
|
|
#include "error_numbers.h"
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
|
2004-09-10 23:17:08 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CMainDocument, wxObject)
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
|
2004-07-12 08:46:26 +00:00
|
|
|
CMainDocument::CMainDocument()
|
|
|
|
{
|
2004-09-10 23:17:08 +00:00
|
|
|
#ifdef __WIN32__
|
|
|
|
wxInt32 retval;
|
|
|
|
WSADATA wsdata;
|
|
|
|
|
|
|
|
retval = WSAStartup( MAKEWORD( 1, 1 ), &wsdata);
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::CMainDocument - Winsock Initialization Failure '%d'", retval);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_bIsConnected = false;
|
2004-09-25 21:33:24 +00:00
|
|
|
|
2004-10-24 07:38:38 +00:00
|
|
|
m_iCachedActivityRunMode = 0;
|
|
|
|
m_iCachedNetworkRunMode = 0;
|
|
|
|
|
2004-10-01 00:06:32 +00:00
|
|
|
m_fProjectTotalResourceShare = 0.0;
|
|
|
|
|
|
|
|
m_iMessageSequenceNumber = 0;
|
|
|
|
|
|
|
|
m_bCachedStateLocked = false;
|
2004-07-13 05:56:03 +00:00
|
|
|
m_dtCachedStateLockTimestamp = wxDateTime::Now();
|
2004-10-24 07:38:38 +00:00
|
|
|
m_dtCachedStateTimestamp = wxDateTime( (time_t)0 );
|
|
|
|
m_dtCachedActivityRunModeTimestamp = wxDateTime( (time_t)0 );
|
|
|
|
m_dtCachedNetworkRunModeTimestamp = wxDateTime( (time_t)0 );
|
2004-07-12 08:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CMainDocument::~CMainDocument()
|
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
m_dtCachedNetworkRunModeTimestamp = wxDateTime::Now();
|
|
|
|
m_dtCachedActivityRunModeTimestamp = wxDateTime::Now();
|
2004-07-13 05:56:03 +00:00
|
|
|
m_dtCachedStateTimestamp = wxDateTime::Now();
|
|
|
|
m_dtCachedStateLockTimestamp = wxDateTime::Now();
|
|
|
|
m_bCachedStateLocked = false;
|
2004-09-10 23:17:08 +00:00
|
|
|
|
2004-10-01 00:06:32 +00:00
|
|
|
m_iMessageSequenceNumber = 0;
|
|
|
|
|
|
|
|
m_fProjectTotalResourceShare = 0.0;
|
|
|
|
|
2004-10-24 07:38:38 +00:00
|
|
|
m_iCachedActivityRunMode = 0;
|
|
|
|
m_iCachedNetworkRunMode = 0;
|
|
|
|
|
2004-10-01 00:06:32 +00:00
|
|
|
m_bIsConnected = false;
|
|
|
|
|
2004-09-10 23:17:08 +00:00
|
|
|
#ifdef __WIN32__
|
|
|
|
WSACleanup();
|
|
|
|
#endif
|
2004-07-12 08:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
wxInt32 CMainDocument::CachedStateUpdate()
|
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
wxString strEmpty = wxEmptyString;
|
|
|
|
|
|
|
|
wxASSERT(NULL != pFrame);
|
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
|
|
|
|
|
|
|
wxTimeSpan ts(m_dtCachedStateLockTimestamp - m_dtCachedStateTimestamp);
|
2004-10-24 07:38:38 +00:00
|
|
|
if (!m_bCachedStateLocked && (ts.GetSeconds() > 3600))
|
2004-10-24 05:40:12 +00:00
|
|
|
{
|
|
|
|
pFrame->UpdateStatusbar( _("Retrieving the BOINC system state. Please wait...") );
|
|
|
|
m_dtCachedStateTimestamp = m_dtCachedStateLockTimestamp;
|
|
|
|
|
|
|
|
retval = rpc.get_state(state);
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::CachedStateUpdate - Get State Failed '%d'", retval);
|
|
|
|
state.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
pFrame->UpdateStatusbar( _("Retrieving the BOINC host information. Please wait...") );
|
|
|
|
retval = rpc.get_host_info(host);
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::CachedStateUpdate - Get Host Information Failed '%d'", retval);
|
|
|
|
host.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
pFrame->UpdateStatusbar( strEmpty );
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
wxInt32 CMainDocument::OnInit()
|
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
|
|
|
if (!m_bIsConnected)
|
|
|
|
{
|
|
|
|
retval = rpc.init(NULL);
|
|
|
|
if (retval)
|
2004-10-20 01:29:53 +00:00
|
|
|
wxLogTrace("CMainDocument::OnInit - RPC Initialization Failed '%d'", retval);
|
2004-10-09 03:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::OnExit()
|
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
|
|
|
if (m_bIsConnected)
|
|
|
|
rpc.close();
|
|
|
|
|
|
|
|
return retval;
|
2004-10-09 03:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::OnIdle()
|
|
|
|
{
|
|
|
|
if (m_bIsConnected)
|
|
|
|
{
|
|
|
|
CachedStateUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
wxInt32 CMainDocument::CachedStateLock()
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
2004-10-24 05:40:12 +00:00
|
|
|
m_bCachedStateLocked = true;
|
|
|
|
m_dtCachedStateLockTimestamp = wxDateTime::Now();
|
|
|
|
return 0;
|
|
|
|
}
|
2004-10-09 03:05:01 +00:00
|
|
|
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
wxInt32 CMainDocument::CachedStateUnlock()
|
|
|
|
{
|
|
|
|
m_bCachedStateLocked = false;
|
|
|
|
return 0;
|
|
|
|
}
|
2004-10-09 03:05:01 +00:00
|
|
|
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
wxInt32 CMainDocument::GetActivityRunMode( wxInt32& iMode )
|
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
wxTimeSpan ts(wxDateTime::Now() - m_dtCachedActivityRunModeTimestamp);
|
|
|
|
if ( ts.GetSeconds() > 10 )
|
|
|
|
{
|
|
|
|
m_dtCachedActivityRunModeTimestamp = wxDateTime::Now();
|
|
|
|
|
|
|
|
iRetVal = rpc.get_run_mode( iMode );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
m_iCachedActivityRunMode = iMode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iMode = m_iCachedActivityRunMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
2004-10-19 18:14:40 +00:00
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
wxInt32 CMainDocument::SetActivityRunMode( wxInt32 iMode )
|
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
iRetVal = rpc.set_run_mode( iMode );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
m_dtCachedActivityRunModeTimestamp = wxDateTime::Now();
|
|
|
|
m_iCachedActivityRunMode = iMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-09 03:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
wxInt32 CMainDocument::GetNetworkRunMode( wxInt32& iMode )
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
wxTimeSpan ts(wxDateTime::Now() - m_dtCachedNetworkRunModeTimestamp);
|
|
|
|
if ( ts.GetSeconds() > 10 )
|
|
|
|
{
|
|
|
|
m_dtCachedNetworkRunModeTimestamp = wxDateTime::Now();
|
|
|
|
|
|
|
|
iRetVal = rpc.get_network_mode( iMode );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
m_iCachedNetworkRunMode = iMode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iMode = m_iCachedNetworkRunMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-09 03:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
wxInt32 CMainDocument::SetNetworkRunMode( wxInt32 iMode )
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
iRetVal = rpc.set_network_mode( iMode );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
m_dtCachedNetworkRunModeTimestamp = wxDateTime::Now();
|
|
|
|
m_iCachedNetworkRunMode = iMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-09 03:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
wxInt32 CMainDocument::CachedProjectStatusUpdate()
|
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
2004-09-29 22:21:45 +00:00
|
|
|
wxInt32 i = 0;
|
2004-09-25 21:33:24 +00:00
|
|
|
|
|
|
|
retval = rpc.get_project_status(project_status);
|
|
|
|
if (retval)
|
|
|
|
{
|
2004-09-29 22:21:45 +00:00
|
|
|
wxLogTrace("CMainDocument::CachedProjectStatusUpdate - Get Project Status Failed '%d'", retval);
|
2004-10-20 01:29:53 +00:00
|
|
|
project_status.clear();
|
2004-09-29 22:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_fProjectTotalResourceShare = 0.0;
|
|
|
|
for (i=0; i < (long)project_status.projects.size(); i++) {
|
2004-10-01 00:06:32 +00:00
|
|
|
m_fProjectTotalResourceShare += project_status.projects.at( i )->resource_share;
|
2004-09-25 21:33:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProjectCount()
|
|
|
|
{
|
2004-10-21 21:19:49 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
CachedStateUpdate();
|
2004-09-25 21:33:24 +00:00
|
|
|
CachedProjectStatusUpdate();
|
2004-10-21 21:19:49 +00:00
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-21 21:19:49 +00:00
|
|
|
iCount = project_status.projects.size();
|
2004-09-25 21:33:24 +00:00
|
|
|
|
2004-09-10 23:17:08 +00:00
|
|
|
return iCount;
|
2004-07-12 08:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectProjectName( wxInt32 iIndex, wxString& strBuffer )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if ( NULL != pProject )
|
|
|
|
strBuffer = pProject->project_name.c_str();
|
|
|
|
|
|
|
|
return 0;
|
2004-07-12 08:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectProjectURL( wxInt32 iIndex, wxString& strBuffer )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if ( NULL != pProject )
|
|
|
|
strBuffer = pProject->master_url.c_str();
|
|
|
|
|
|
|
|
return 0;
|
2004-07-12 08:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectAccountName( wxInt32 iIndex, wxString& strBuffer )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if ( NULL != pProject )
|
|
|
|
strBuffer = pProject->user_name.c_str();
|
|
|
|
|
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectTeamName( wxInt32 iIndex, wxString& strBuffer )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if ( NULL != pProject )
|
|
|
|
strBuffer = pProject->team_name.c_str();
|
|
|
|
|
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectTotalCredit( wxInt32 iIndex, float& fBuffer )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-29 22:21:45 +00:00
|
|
|
if ( NULL != pProject )
|
|
|
|
fBuffer = pProject->user_total_credit;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectAvgCredit( wxInt32 iIndex, float& fBuffer )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if ( NULL != pProject )
|
2004-09-29 22:21:45 +00:00
|
|
|
fBuffer = pProject->user_expavg_credit;
|
2004-09-25 21:33:24 +00:00
|
|
|
|
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectResourceShare( wxInt32 iIndex, float& fBuffer )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if ( NULL != pProject )
|
2004-09-29 22:21:45 +00:00
|
|
|
fBuffer = pProject->resource_share;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectTotalResourceShare( wxInt32 iIndex, float& fBuffer )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-05 02:55:26 +00:00
|
|
|
fBuffer = m_fProjectTotalResourceShare;
|
2004-09-25 21:33:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectMinRPCTime( wxInt32 iIndex, wxInt32& iBuffer )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if ( NULL != pProject )
|
2004-09-29 22:21:45 +00:00
|
|
|
iBuffer = pProject->min_rpc_time;
|
2004-09-25 21:33:24 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectWebsiteCount( wxInt32 iIndex )
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
wxString strProjectURL = wxEmptyString;
|
|
|
|
std::string str;
|
|
|
|
PROJECT* pProject = NULL;
|
2004-10-11 04:38:00 +00:00
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
CachedStateUpdate();
|
|
|
|
|
2004-10-20 01:29:53 +00:00
|
|
|
GetProjectProjectURL( iIndex, strProjectURL );
|
|
|
|
str = strProjectURL.c_str();
|
|
|
|
pProject = state.lookup_project( str );
|
2004-10-09 03:05:01 +00:00
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
iCount = pProject->gui_urls.size();
|
|
|
|
|
|
|
|
return iCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectWebsiteName( wxInt32 iProjectIndex, wxInt32 iWebsiteIndex, wxString& strBuffer )
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
|
|
|
wxString strProjectURL = wxEmptyString;
|
|
|
|
std::string str;
|
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
GUI_URL Url;
|
|
|
|
|
|
|
|
CachedStateUpdate();
|
|
|
|
|
|
|
|
GetProjectProjectURL( iProjectIndex, strProjectURL );
|
|
|
|
str = strProjectURL.c_str();
|
|
|
|
pProject = state.lookup_project( str );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
{
|
|
|
|
Url = pProject->gui_urls.at( iWebsiteIndex );
|
|
|
|
strBuffer = Url.name.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectWebsiteDescription( wxInt32 iProjectIndex, wxInt32 iWebsiteIndex, wxString& strBuffer )
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
|
|
|
wxString strProjectURL = wxEmptyString;
|
|
|
|
std::string str;
|
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
GUI_URL Url;
|
|
|
|
|
|
|
|
CachedStateUpdate();
|
|
|
|
|
|
|
|
GetProjectProjectURL( iProjectIndex, strProjectURL );
|
|
|
|
str = strProjectURL.c_str();
|
|
|
|
pProject = state.lookup_project( str );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
{
|
|
|
|
Url = pProject->gui_urls.at( iWebsiteIndex );
|
|
|
|
strBuffer = Url.description.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetProjectWebsiteLink( wxInt32 iProjectIndex, wxInt32 iWebsiteIndex, wxString& strBuffer )
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
|
|
|
wxString strProjectURL = wxEmptyString;
|
|
|
|
std::string str;
|
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
GUI_URL Url;
|
|
|
|
|
|
|
|
CachedStateUpdate();
|
|
|
|
|
|
|
|
GetProjectProjectURL( iProjectIndex, strProjectURL );
|
|
|
|
str = strProjectURL.c_str();
|
|
|
|
pProject = state.lookup_project( str );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
{
|
|
|
|
Url = pProject->gui_urls.at( iWebsiteIndex );
|
|
|
|
strBuffer = Url.url.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
bool CMainDocument::IsProjectSuspended( wxInt32 iIndex )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
bRetVal = pProject->suspended_via_gui;
|
|
|
|
|
|
|
|
return bRetVal;
|
2004-09-29 22:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
bool CMainDocument::IsProjectRPCPending( wxInt32 iIndex )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
bRetVal = pProject->sched_rpc_pending;
|
|
|
|
|
|
|
|
return bRetVal;
|
2004-09-29 22:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
wxInt32 CMainDocument::ProjectAttach( wxString& strURL, wxString& strAccountKey )
|
|
|
|
{
|
|
|
|
return rpc.project_attach((char *)strURL.c_str(), (char *)strAccountKey.c_str());
|
|
|
|
}
|
|
|
|
|
2004-09-29 22:21:45 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxInt32 CMainDocument::ProjectDetach( wxInt32 iIndex )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
wxInt32 iRetVal = -1;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-21 14:29:59 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
iRetVal = rpc.project_op( (*pProject), wxT("detach") );
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-09-25 21:33:24 +00:00
|
|
|
}
|
|
|
|
|
2004-09-29 22:21:45 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxInt32 CMainDocument::ProjectUpdate( wxInt32 iIndex )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
wxInt32 iRetVal = -1;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-21 14:29:59 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
iRetVal = rpc.project_op( (*pProject), wxT("update") );
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-09-25 21:33:24 +00:00
|
|
|
}
|
|
|
|
|
2004-09-29 22:21:45 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxInt32 CMainDocument::ProjectReset( wxInt32 iIndex )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
wxInt32 iRetVal = -1;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-21 14:29:59 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
iRetVal = rpc.project_op( (*pProject), wxT("reset") );
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-09-28 01:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxInt32 CMainDocument::ProjectSuspend( wxInt32 iIndex )
|
2004-09-28 01:19:46 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
PROJECT* pStateProject = NULL;
|
|
|
|
wxInt32 iRetVal = -1;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-21 14:29:59 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
{
|
|
|
|
iRetVal = rpc.project_op( (*pProject), wxT("suspend") );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
pProject->suspended_via_gui = true;
|
|
|
|
pStateProject = state.lookup_project( pProject->master_url );
|
|
|
|
if ( NULL != pStateProject )
|
|
|
|
pStateProject->suspended_via_gui = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-09-28 01:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxInt32 CMainDocument::ProjectResume( wxInt32 iIndex )
|
2004-09-28 01:19:46 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
PROJECT* pStateProject = NULL;
|
|
|
|
wxInt32 iRetVal = -1;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !project_status.projects.empty() )
|
2004-10-21 14:29:59 +00:00
|
|
|
pProject = project_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
{
|
|
|
|
iRetVal = rpc.project_op( (*pProject), wxT("resume") );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
pProject->suspended_via_gui = false;
|
|
|
|
pStateProject = state.lookup_project( pProject->master_url );
|
|
|
|
if ( NULL != pStateProject )
|
|
|
|
pStateProject->suspended_via_gui = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
wxInt32 CMainDocument::CachedResultsStatusUpdate()
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
retval = rpc.get_results(results);
|
2004-09-29 22:21:45 +00:00
|
|
|
if (retval)
|
|
|
|
{
|
2004-10-11 04:38:00 +00:00
|
|
|
wxLogTrace("CMainDocument::CachedResultsStatusUpdate - Get Result Status Failed '%d'", retval);
|
2004-10-20 01:29:53 +00:00
|
|
|
results.clear();
|
2004-09-29 22:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkCount()
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-21 21:19:49 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
CachedStateUpdate();
|
|
|
|
CachedResultsStatusUpdate();
|
2004-10-21 21:19:49 +00:00
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-21 21:19:49 +00:00
|
|
|
iCount = results.results.size();
|
2004-09-29 22:21:45 +00:00
|
|
|
|
|
|
|
return iCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkProjectName( wxInt32 iIndex, wxString& strBuffer )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
2004-10-19 18:14:40 +00:00
|
|
|
RESULT* pStateResult = NULL;
|
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
2004-10-19 18:14:40 +00:00
|
|
|
if ( NULL != pResult )
|
|
|
|
{
|
2004-10-19 22:41:26 +00:00
|
|
|
pStateResult = state.lookup_result( pResult->project_url, pResult->name );
|
2004-10-19 18:14:40 +00:00
|
|
|
if ( NULL != pStateResult )
|
|
|
|
{
|
|
|
|
pProject = pStateResult->project;
|
|
|
|
if ( NULL != pProject )
|
|
|
|
{
|
|
|
|
strBuffer = pProject->project_name.c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkProjectURL( wxInt32 iIndex, wxString& strBuffer )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
if ( NULL != pResult )
|
2004-10-19 22:41:26 +00:00
|
|
|
strBuffer = pResult->project_url.c_str();
|
2004-09-29 22:21:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkApplicationName( wxInt32 iIndex, wxString& strBuffer )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
2004-10-19 18:14:40 +00:00
|
|
|
RESULT* pStateResult = NULL;
|
2004-10-11 04:38:00 +00:00
|
|
|
WORKUNIT* pWorkunit = NULL;
|
|
|
|
APP_VERSION* pAppVersion = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
if ( NULL != pResult )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-19 22:41:26 +00:00
|
|
|
pStateResult = state.lookup_result( pResult->project_url, pResult->name );
|
2004-10-19 18:14:40 +00:00
|
|
|
if ( NULL != pStateResult )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-19 18:14:40 +00:00
|
|
|
pWorkunit = pStateResult->wup;
|
|
|
|
if ( NULL != pWorkunit )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-19 18:14:40 +00:00
|
|
|
pAppVersion = pWorkunit->avp;
|
|
|
|
if ( NULL != pAppVersion )
|
|
|
|
{
|
|
|
|
strBuffer = pAppVersion->app_name.c_str();
|
|
|
|
}
|
2004-10-11 04:38:00 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-29 22:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkApplicationVersion( wxInt32 iIndex, wxInt32& iBuffer )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
2004-10-19 18:14:40 +00:00
|
|
|
RESULT* pStateResult = NULL;
|
2004-10-11 04:38:00 +00:00
|
|
|
WORKUNIT* pWorkunit = NULL;
|
|
|
|
APP_VERSION* pAppVersion = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
if ( NULL != pResult )
|
|
|
|
{
|
2004-10-19 22:41:26 +00:00
|
|
|
pStateResult = state.lookup_result( pResult->project_url, pResult->name );
|
2004-10-19 18:14:40 +00:00
|
|
|
if ( NULL != pStateResult )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-19 18:14:40 +00:00
|
|
|
pWorkunit = pStateResult->wup;
|
|
|
|
if ( NULL != pWorkunit )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-19 18:14:40 +00:00
|
|
|
pAppVersion = pWorkunit->avp;
|
|
|
|
if ( NULL != pAppVersion )
|
|
|
|
{
|
|
|
|
iBuffer = pAppVersion->version_num;
|
|
|
|
}
|
2004-10-11 04:38:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-29 22:21:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkName( wxInt32 iIndex, wxString& strBuffer )
|
2004-09-29 22:21:45 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
strBuffer = pResult->name.c_str();
|
2004-09-29 22:21:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkCurrentCPUTime( wxInt32 iIndex, float& fBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-09-29 22:21:45 +00:00
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
if ( NULL != pResult )
|
|
|
|
fBuffer = pResult->current_cpu_time;
|
2004-09-29 22:21:45 +00:00
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-09-29 22:21:45 +00:00
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkEstimatedCPUTime( wxInt32 iIndex, float& fBuffer )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
2004-10-19 18:14:40 +00:00
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
2004-10-19 18:14:40 +00:00
|
|
|
if ( NULL != pResult )
|
2004-10-20 21:50:28 +00:00
|
|
|
fBuffer = pResult->estimated_cpu_time_remaining;
|
2004-10-19 18:14:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkFinalCPUTime( wxInt32 iIndex, float& fBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
fBuffer = pResult->final_cpu_time;
|
|
|
|
|
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkFractionDone( wxInt32 iIndex, float& fBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
fBuffer = pResult->fraction_done;
|
|
|
|
|
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkReportDeadline( wxInt32 iIndex, wxInt32& iBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
iBuffer = pResult->report_deadline;
|
|
|
|
|
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkState( wxInt32 iIndex )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
|
|
|
wxInt32 iBuffer = 0;
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
iBuffer = pResult->state;
|
|
|
|
|
|
|
|
return iBuffer;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetWorkSchedulerState( wxInt32 iIndex )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
|
|
|
wxInt32 iBuffer = 0;
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
2004-10-19 18:14:40 +00:00
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
iBuffer = pResult->scheduler_state;
|
|
|
|
|
|
|
|
return iBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
bool CMainDocument::IsWorkAcknowledged( wxInt32 iIndex )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
bRetVal = pResult->got_server_ack;
|
|
|
|
|
|
|
|
return bRetVal;
|
2004-10-19 18:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
bool CMainDocument::IsWorkActive( wxInt32 iIndex )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
2004-10-20 23:38:56 +00:00
|
|
|
bRetVal = pResult->active_task;
|
2004-10-20 01:29:53 +00:00
|
|
|
|
|
|
|
return bRetVal;
|
2004-10-19 18:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
bool CMainDocument::IsWorkReadyToReport( wxInt32 iIndex )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
bRetVal = pResult->ready_to_report;
|
|
|
|
|
|
|
|
return bRetVal;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
bool CMainDocument::IsWorkSuspended( wxInt32 iIndex )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
bRetVal = pResult->suspended_via_gui;
|
|
|
|
|
|
|
|
return bRetVal;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-26 23:37:19 +00:00
|
|
|
bool CMainDocument::IsWorkGraphicsSupported( wxInt32 iIndex )
|
|
|
|
{
|
|
|
|
RESULT* pResult = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
|
|
|
if ( !results.results.empty() )
|
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
bRetVal = pResult->supports_graphics;
|
|
|
|
|
|
|
|
return bRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxInt32 CMainDocument::WorkSuspend( wxInt32 iIndex )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
RESULT* pStateResult = NULL;
|
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-21 14:29:59 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
{
|
|
|
|
pStateResult = state.lookup_result( pResult->project_url, pResult->name );
|
|
|
|
if ( NULL != pStateResult )
|
|
|
|
{
|
|
|
|
iRetVal = rpc.result_op( (*pStateResult), wxT("suspend") );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
pResult->suspended_via_gui = true;
|
|
|
|
pStateResult->suspended_via_gui = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-19 18:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxInt32 CMainDocument::WorkResume( wxInt32 iIndex )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
RESULT* pStateResult = NULL;
|
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !results.results.empty() )
|
2004-10-21 14:29:59 +00:00
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
{
|
|
|
|
pStateResult = state.lookup_result( pResult->project_url, pResult->name );
|
|
|
|
if ( NULL != pStateResult )
|
|
|
|
{
|
|
|
|
iRetVal = rpc.result_op( (*pStateResult), wxT("resume") );
|
|
|
|
if ( 0 == iRetVal )
|
|
|
|
{
|
|
|
|
pResult->suspended_via_gui = false;
|
|
|
|
pStateResult->suspended_via_gui = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-19 18:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
wxInt32 CMainDocument::WorkShowGraphics( wxInt32 iIndex, bool bFullScreen )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
if ( !results.results.empty() )
|
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
iRetVal = rpc.show_graphics( pResult->project_url.c_str(), pResult->name.c_str(), bFullScreen );
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-19 18:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
wxInt32 CMainDocument::WorkAbort( wxInt32 iIndex )
|
2004-10-19 18:14:40 +00:00
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
RESULT* pResult = NULL;
|
|
|
|
RESULT* pStateResult = NULL;
|
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
if ( !results.results.empty() )
|
|
|
|
pResult = results.results.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pResult )
|
|
|
|
{
|
|
|
|
pStateResult = state.lookup_result( pResult->project_url, pResult->name );
|
|
|
|
if ( NULL != pStateResult )
|
|
|
|
{
|
|
|
|
iRetVal = rpc.result_op( (*pStateResult), wxT("abort") );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iRetVal;
|
2004-10-19 18:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
wxInt32 CMainDocument::CachedMessageUpdate()
|
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
|
|
|
retval = rpc.get_messages( m_iMessageSequenceNumber, messages );
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::CachedMessageUpdate - Get Messages Failed '%d'", retval);
|
2004-10-20 01:29:53 +00:00
|
|
|
messages.clear();
|
2004-10-11 04:38:00 +00:00
|
|
|
}
|
|
|
|
|
2004-10-20 01:29:53 +00:00
|
|
|
if ( messages.messages.size() != 0 )
|
|
|
|
m_iMessageSequenceNumber = messages.messages.at( messages.messages.size()-1 )->seqno;
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
return retval;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
wxInt32 CMainDocument::GetMessageCount()
|
|
|
|
{
|
2004-10-21 21:19:49 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
|
2004-07-13 05:56:03 +00:00
|
|
|
CachedStateUpdate();
|
2004-10-11 04:38:00 +00:00
|
|
|
CachedMessageUpdate();
|
2004-10-21 21:19:49 +00:00
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !messages.messages.empty() )
|
2004-10-21 21:19:49 +00:00
|
|
|
iCount = messages.messages.size();
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
return iCount;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetMessageProjectName( wxInt32 iIndex, wxString& strBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
MESSAGE* pMessage = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !messages.messages.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pMessage = messages.messages.at( iIndex );
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
if ( NULL != pMessage )
|
|
|
|
strBuffer = pMessage->project.c_str();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetMessageTime( wxInt32 iIndex, wxDateTime& dtBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
MESSAGE* pMessage = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !messages.messages.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pMessage = messages.messages.at( iIndex );
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
if ( NULL != pMessage )
|
|
|
|
{
|
|
|
|
wxDateTime dtTemp((time_t)pMessage->timestamp);
|
|
|
|
dtBuffer = dtTemp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetMessagePriority( wxInt32 iIndex, wxInt32& iBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
MESSAGE* pMessage = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !messages.messages.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pMessage = messages.messages.at( iIndex );
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
if ( NULL != pMessage )
|
|
|
|
iBuffer = pMessage->priority;
|
|
|
|
|
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetMessageMessage( wxInt32 iIndex, wxString& strBuffer )
|
2004-10-11 04:38:00 +00:00
|
|
|
{
|
2004-10-20 01:29:53 +00:00
|
|
|
MESSAGE* pMessage = NULL;
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
if ( !messages.messages.empty() )
|
2004-10-20 01:29:53 +00:00
|
|
|
pMessage = messages.messages.at( iIndex );
|
|
|
|
|
2004-10-11 04:38:00 +00:00
|
|
|
if ( NULL != pMessage )
|
|
|
|
strBuffer = pMessage->body.c_str();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::CachedFileTransfersUpdate()
|
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
|
|
|
retval = rpc.get_file_transfers( ft );
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::CachedFileTransfersUpdate - Get File Transfers Failed '%d'", retval);
|
|
|
|
ft.clear();
|
|
|
|
}
|
2004-10-11 04:38:00 +00:00
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2004-10-11 04:38:00 +00:00
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetTransferCount()
|
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
|
2004-07-13 05:56:03 +00:00
|
|
|
CachedStateUpdate();
|
2004-10-22 08:51:50 +00:00
|
|
|
CachedFileTransfersUpdate();
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
iCount = ft.file_transfers.size();
|
|
|
|
|
|
|
|
return iCount;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetTransferProjectName( wxInt32 iIndex, wxString& strBuffer )
|
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
2004-10-22 20:11:38 +00:00
|
|
|
strBuffer = pFT->project_name.c_str();
|
2004-10-22 08:51:50 +00:00
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
2004-07-13 05:56:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
wxInt32 CMainDocument::GetTransferFileName( wxInt32 iIndex, wxString& strBuffer )
|
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
strBuffer = pFT->name.c_str();
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
2004-07-12 08:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
wxInt32 CMainDocument::GetTransferFileSize( wxInt32 iIndex, float& fBuffer )
|
2004-10-22 00:41:18 +00:00
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
fBuffer = pFT->nbytes;
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
2004-08-11 23:52:22 +00:00
|
|
|
}
|
2004-07-12 08:46:26 +00:00
|
|
|
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
wxInt32 CMainDocument::GetTransferBytesXfered( wxInt32 iIndex, float& fBuffer )
|
2004-10-22 00:41:18 +00:00
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
fBuffer = pFT->bytes_xferred;
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
2004-07-12 08:46:26 +00:00
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
wxInt32 CMainDocument::GetTransferSpeed( wxInt32 iIndex, float& fBuffer )
|
2004-10-22 00:41:18 +00:00
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
fBuffer = pFT->xfer_speed;
|
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
2004-08-11 23:52:22 +00:00
|
|
|
}
|
2004-07-12 08:46:26 +00:00
|
|
|
|
|
|
|
|
2004-10-22 18:39:21 +00:00
|
|
|
wxInt32 CMainDocument::GetTransferTime( wxInt32 iIndex, float& fBuffer )
|
2004-10-22 00:41:18 +00:00
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
2004-10-22 18:39:21 +00:00
|
|
|
if ( NULL != pFT )
|
|
|
|
fBuffer = pFT->time_so_far;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetTransferNextRequestTime( wxInt32 iIndex, wxInt32& iBuffer )
|
|
|
|
{
|
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
iBuffer = pFT->next_request_time;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetTransferStatus( wxInt32 iIndex, wxInt32& iBuffer )
|
|
|
|
{
|
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
iBuffer = pFT->status;
|
2004-10-22 08:51:50 +00:00
|
|
|
|
2004-10-22 00:41:18 +00:00
|
|
|
return 0;
|
2004-07-12 08:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 08:51:50 +00:00
|
|
|
bool CMainDocument::IsTransferActive( wxInt32 iIndex )
|
2004-10-22 00:41:18 +00:00
|
|
|
{
|
2004-10-22 08:51:50 +00:00
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
bRetVal = pFT->pers_xfer_active;
|
|
|
|
|
|
|
|
return bRetVal;
|
2004-08-11 23:52:22 +00:00
|
|
|
}
|
2004-07-12 08:46:26 +00:00
|
|
|
|
2004-10-22 18:39:21 +00:00
|
|
|
bool CMainDocument::IsTransferGeneratedLocally( wxInt32 iIndex )
|
|
|
|
{
|
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
bool bRetVal = false;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
bRetVal = pFT->generated_locally;
|
|
|
|
|
|
|
|
return bRetVal;
|
|
|
|
}
|
|
|
|
|
2004-10-22 19:23:09 +00:00
|
|
|
|
|
|
|
wxInt32 CMainDocument::TransferRetryNow( wxInt32 iIndex )
|
|
|
|
{
|
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
iRetVal = rpc.file_transfer_op( (*pFT), wxT("retry") );
|
|
|
|
|
|
|
|
return iRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::TransferAbort( wxInt32 iIndex )
|
|
|
|
{
|
|
|
|
FILE_TRANSFER* pFT = NULL;
|
|
|
|
wxInt32 iRetVal = 0;
|
|
|
|
|
|
|
|
if ( !ft.file_transfers.empty() )
|
|
|
|
pFT = ft.file_transfers.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pFT )
|
|
|
|
iRetVal = rpc.file_transfer_op( (*pFT), wxT("abort") );
|
|
|
|
|
|
|
|
return iRetVal;
|
|
|
|
}
|
|
|
|
|
2004-10-22 22:37:11 +00:00
|
|
|
|
|
|
|
wxInt32 CMainDocument::CachedResourceStatusUpdate()
|
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
|
|
|
retval = rpc.get_disk_usage(resource_status);
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::CachedResourceStatusUpdate - Get Disk Usage Failed '%d'", retval);
|
|
|
|
resource_status.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetResourceCount()
|
|
|
|
{
|
|
|
|
wxInt32 iCount = 0;
|
|
|
|
|
|
|
|
CachedStateUpdate();
|
|
|
|
CachedResourceStatusUpdate();
|
|
|
|
|
|
|
|
if ( !resource_status.projects.empty() )
|
|
|
|
iCount = resource_status.projects.size();
|
|
|
|
|
|
|
|
return iCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetResourceProjectName( wxInt32 iIndex, wxString& strBuffer )
|
|
|
|
{
|
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
PROJECT* pStateProject = NULL;
|
|
|
|
|
|
|
|
if ( !resource_status.projects.empty() )
|
|
|
|
pProject = resource_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
{
|
|
|
|
pStateProject = state.lookup_project( pProject->master_url );
|
|
|
|
if ( NULL != pStateProject )
|
|
|
|
{
|
|
|
|
strBuffer = pStateProject->project_name.c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetResourceDiskspace( wxInt32 iIndex, float& fBuffer )
|
|
|
|
{
|
|
|
|
PROJECT* pProject = NULL;
|
|
|
|
|
|
|
|
if ( !resource_status.projects.empty() )
|
|
|
|
pProject = resource_status.projects.at( iIndex );
|
|
|
|
|
|
|
|
if ( NULL != pProject )
|
|
|
|
fBuffer = pProject->disk_usage;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-25 16:14:51 +00:00
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
wxInt32 CMainDocument::GetProxyConfiguration()
|
2004-10-25 16:14:51 +00:00
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
|
|
|
retval = rpc.get_proxy_settings(proxy_info);
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::GetProxyInfo - Get Proxy Info Failed '%d'", retval);
|
|
|
|
proxy_info.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
wxInt32 CMainDocument::GetProxyHTTPProxyEnabled( bool& bEnabled )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
bEnabled = proxy_info.use_http_proxy;
|
2004-10-25 20:58:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxyHTTPServerName( wxString& strServerName )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
strServerName.Clear();
|
2004-10-25 20:58:06 +00:00
|
|
|
strServerName = proxy_info.http_server_name.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxyHTTPServerPort( wxInt32& iPortNumber )
|
|
|
|
{
|
|
|
|
iPortNumber = proxy_info.http_server_port;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxyHTTPUserName( wxString& strUserName )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
strUserName.Clear();
|
2004-10-25 20:58:06 +00:00
|
|
|
strUserName = proxy_info.http_user_name.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxyHTTPPassword( wxString& strPassword )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
strPassword.Clear();
|
2004-10-25 20:58:06 +00:00
|
|
|
strPassword = proxy_info.http_user_passwd.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxySOCKSProxyEnabled( bool& bEnabled )
|
|
|
|
{
|
|
|
|
bEnabled = proxy_info.use_socks_proxy;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxySOCKSServerName( wxString& strServerName )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
strServerName.Clear();
|
2004-10-25 20:58:06 +00:00
|
|
|
strServerName = proxy_info.socks_server_name.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxySOCKSServerPort( wxInt32& iPortNumber )
|
|
|
|
{
|
|
|
|
iPortNumber = proxy_info.socks_server_port;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxySOCKSUserName( wxString& strUserName )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
strUserName.Clear();
|
2004-10-25 20:58:06 +00:00
|
|
|
strUserName = proxy_info.socks5_user_name.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::GetProxySOCKSPassword( wxString& strPassword )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
strPassword.Clear();
|
2004-10-25 20:58:06 +00:00
|
|
|
strPassword = proxy_info.socks5_user_passwd.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxyConfiguration()
|
2004-10-25 16:14:51 +00:00
|
|
|
{
|
|
|
|
wxInt32 retval = 0;
|
|
|
|
|
2004-10-27 21:33:37 +00:00
|
|
|
if ( !proxy_info.http_user_name.empty() || !proxy_info.http_user_passwd.empty() )
|
|
|
|
proxy_info.use_http_authentication = true;
|
|
|
|
|
|
|
|
proxy_info.socks_version = 4;
|
|
|
|
if ( !proxy_info.socks5_user_name.empty() || !proxy_info.socks5_user_passwd.empty() )
|
|
|
|
proxy_info.socks_version = 5;
|
|
|
|
|
2004-10-27 03:17:40 +00:00
|
|
|
retval = rpc.set_proxy_settings( proxy_info );
|
2004-10-25 16:14:51 +00:00
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
wxLogTrace("CMainDocument::SetProxyInfo - Set Proxy Info Failed '%d'", retval);
|
|
|
|
proxy_info.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
wxInt32 CMainDocument::SetProxyHTTPProxyEnabled( const bool bEnabled )
|
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
proxy_info.use_http_proxy = bEnabled;
|
2004-10-25 20:58:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxyHTTPServerName( const wxString& strServerName )
|
|
|
|
{
|
|
|
|
proxy_info.http_server_name = strServerName.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
2004-10-25 16:14:51 +00:00
|
|
|
|
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
wxInt32 CMainDocument::SetProxyHTTPServerPort( const wxInt32 iPortNumber )
|
|
|
|
{
|
|
|
|
proxy_info.http_server_port = iPortNumber;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxyHTTPUserName( const wxString& strUserName )
|
|
|
|
{
|
|
|
|
proxy_info.http_user_name = strUserName.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxyHTTPPassword( const wxString& strPassword )
|
|
|
|
{
|
|
|
|
proxy_info.http_user_passwd = strPassword.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-25 16:14:51 +00:00
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
wxInt32 CMainDocument::SetProxySOCKSProxyEnabled( const bool bEnabled )
|
|
|
|
{
|
|
|
|
proxy_info.use_socks_proxy = bEnabled;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxySOCKSServerName( const wxString& strServerName )
|
|
|
|
{
|
|
|
|
proxy_info.socks_server_name = strServerName.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxySOCKSServerPort( const wxInt32 iPortNumber )
|
|
|
|
{
|
|
|
|
proxy_info.socks_server_port = iPortNumber;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxySOCKSUserName( const wxString& strUserName )
|
|
|
|
{
|
|
|
|
proxy_info.socks5_user_name = strUserName.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CMainDocument::SetProxySOCKSPassword( const wxString& strPassword )
|
|
|
|
{
|
|
|
|
proxy_info.socks5_user_passwd = strPassword.c_str();
|
|
|
|
return 0;
|
|
|
|
}
|
2004-10-25 16:14:51 +00:00
|
|
|
|