*** empty log message ***

svn path=/trunk/boinc/; revision=4266
This commit is contained in:
Rom Walton 2004-09-29 22:21:45 +00:00
parent 348e8398d0
commit 29f6ea9b84
6 changed files with 286 additions and 69 deletions

View File

@ -21,6 +21,9 @@
// Revision History:
//
// $Log$
// Revision 1.15 2004/09/29 22:20:43 rwalton
// *** empty log message ***
//
// Revision 1.14 2004/09/28 01:19:46 rwalton
// *** empty log message ***
//
@ -62,6 +65,17 @@
#include "error_numbers.h"
// Descending message sorting function
struct MessageSorter
{
bool operator()(MESSAGE*& rpStart, MESSAGE*& rpEnd)
{
return rpStart->seqno < rpEnd->seqno;
}
};
IMPLEMENT_DYNAMIC_CLASS(CMainDocument, wxObject)
@ -78,7 +92,6 @@ CMainDocument::CMainDocument()
}
#endif
m_bCachedProjectStatusLocked = false;
m_bCachedStateLocked = false;
m_bIsConnected = false;
@ -93,7 +106,6 @@ CMainDocument::~CMainDocument()
m_dtCachedStateLockTimestamp = wxDateTime::Now();
m_bIsConnected = false;
m_bCachedStateLocked = false;
m_bCachedProjectStatusLocked = false;
#ifdef __WIN32__
WSACleanup();
@ -104,6 +116,7 @@ CMainDocument::~CMainDocument()
wxInt32 CMainDocument::CachedProjectStatusUpdate()
{
wxInt32 retval = 0;
wxInt32 i = 0;
if (!m_bIsConnected)
{
@ -120,7 +133,13 @@ wxInt32 CMainDocument::CachedProjectStatusUpdate()
retval = rpc.get_project_status(project_status);
if (retval)
{
wxLogTrace("CMainDocument::CachedProjectStatusUpdate - Get State Failed '%d'", retval);
wxLogTrace("CMainDocument::CachedProjectStatusUpdate - Get Project Status Failed '%d'", retval);
}
m_fProjectTotalResourceShare = 0.0;
for (i=0; i < (long)project_status.projects.size(); i++) {
m_fProjectTotalResourceShare += project_status.projects[i]->resource_share;
}
return retval;
@ -176,41 +195,73 @@ wxInt32 CMainDocument::GetProjectTeamName(wxInt32 iIndex, wxString& strBuffer)
}
wxInt32 CMainDocument::GetProjectTotalCredit(wxInt32 iIndex, wxString& strBuffer)
wxInt32 CMainDocument::GetProjectTotalCredit(wxInt32 iIndex, float& fBuffer)
{
PROJECT* pProject = project_status.projects[iIndex];
if ( NULL != pProject )
strBuffer.Printf(wxT("%0.2f"), pProject->user_total_credit);
fBuffer = pProject->user_total_credit;
return 0;
}
wxInt32 CMainDocument::GetProjectAvgCredit(wxInt32 iIndex, wxString& strBuffer)
wxInt32 CMainDocument::GetProjectAvgCredit(wxInt32 iIndex, float& fBuffer)
{
PROJECT* pProject = project_status.projects[iIndex];
if ( NULL != pProject )
strBuffer.Printf(wxT("%0.2f"), pProject->user_expavg_credit);
fBuffer = pProject->user_expavg_credit;
return 0;
}
wxInt32 CMainDocument::GetProjectResourceShare(wxInt32 iIndex, wxString& strBuffer)
wxInt32 CMainDocument::GetProjectResourceShare(wxInt32 iIndex, float& fBuffer)
{
PROJECT* pProject = project_status.projects[iIndex];
if ( NULL != pProject )
strBuffer.Printf(wxT("%0.2f%%"), pProject->resource_share);
fBuffer = pProject->resource_share;
return 0;
}
wxInt32 CMainDocument::GetProjectTotalResourceShare(wxInt32 iIndex, float& fBuffer)
{
fBuffer = this->m_fProjectTotalResourceShare;
return 0;
}
wxInt32 CMainDocument::GetProjectMinRPCTime(wxInt32 iIndex, wxInt32& iBuffer)
{
PROJECT* pProject = project_status.projects[iIndex];
if ( NULL != pProject )
iBuffer = pProject->min_rpc_time;
return 0;
}
bool CMainDocument::IsProjectSuspended(wxInt32 iIndex)
{
PROJECT* pProject = project_status.projects[iIndex];
return pProject->suspended_via_gui;
}
bool CMainDocument::IsProjectRPCPending(wxInt32 iIndex)
{
PROJECT* pProject = project_status.projects[iIndex];
return pProject->sched_rpc_pending;
}
wxInt32 CMainDocument::ProjectAttach( wxString& strURL, wxString& strAccountKey )
{
return rpc.project_attach((char *)strURL.c_str(), (char *)strAccountKey.c_str());
}
wxInt32 CMainDocument::ProjectDetach( wxString& strURL )
{
PROJECT p;
@ -218,6 +269,7 @@ wxInt32 CMainDocument::ProjectDetach( wxString& strURL )
return rpc.project_op(p, wxT("detach"));
}
wxInt32 CMainDocument::ProjectUpdate( wxString& strURL )
{
PROJECT p;
@ -225,6 +277,7 @@ wxInt32 CMainDocument::ProjectUpdate( wxString& strURL )
return rpc.project_op(p, wxT("update"));
}
wxInt32 CMainDocument::ProjectReset( wxString& strURL )
{
PROJECT p;
@ -249,6 +302,92 @@ wxInt32 CMainDocument::ProjectResume( wxString& strURL )
}
wxInt32 CMainDocument::CachedMessageUpdate()
{
wxInt32 retval = 0;
wxInt32 i = 0;
if (!m_bIsConnected)
{
retval = rpc.init(NULL);
if (retval)
{
wxLogTrace("CMainDocument::CachedMessageUpdate - RPC Initialization Failed '%d'", retval);
return retval;
}
m_bIsConnected = true;
}
retval = rpc.get_messages( 255, m_iMessageSequenceNumber, messages );
if (retval)
{
wxLogTrace("CMainDocument::CachedMessageUpdate - Get Messages Failed '%d'", retval);
}
std::sort(messages.messages.begin(), messages.messages.end(), MessageSorter());
m_iMessageSequenceNumber = messages.messages[messages.messages.size()-1]->seqno;
return retval;
}
wxInt32 CMainDocument::GetMessageCount()
{
CachedMessageUpdate();
wxInt32 iCount = messages.messages.size();
return iCount;
}
wxInt32 CMainDocument::GetMessageProjectName(wxInt32 iIndex, wxString& strBuffer)
{
MESSAGE* pMessage = messages.messages.at( iIndex );
if ( NULL != pMessage )
strBuffer = pMessage->project.c_str();
return 0;
}
wxInt32 CMainDocument::GetMessageTime(wxInt32 iIndex, wxDateTime& dtBuffer)
{
MESSAGE* pMessage = messages.messages.at( iIndex );
if ( NULL != pMessage )
{
wxDateTime dtTemp((time_t)pMessage->timestamp);
dtBuffer = dtTemp;
}
return 0;
}
wxInt32 CMainDocument::GetMessagePriority(wxInt32 iIndex, wxInt32& iBuffer)
{
MESSAGE* pMessage = messages.messages.at( iIndex );
if ( NULL != pMessage )
iBuffer = pMessage->priority;
return 0;
}
wxInt32 CMainDocument::GetMessageMessage(wxInt32 iIndex, wxString& strBuffer)
{
MESSAGE* pMessage = messages.messages.at( iIndex );
if ( NULL != pMessage )
strBuffer = pMessage->body.c_str();
return 0;
}
wxInt32 CMainDocument::GetWorkCount() {
CachedStateUpdate();
return state.results.size();
@ -353,36 +492,6 @@ wxString CMainDocument::GetTransferTime(wxInt32 iIndex) {
}
wxInt32 CMainDocument::GetMessageCount() {
CachedStateUpdate();
return 0;
}
wxString CMainDocument::GetMessageProjectName(wxInt32 iIndex) {
CachedStateUpdate();
return wxString::Format(_T(""));
}
wxString CMainDocument::GetMessageTime(wxInt32 iIndex) {
CachedStateUpdate();
return wxString::Format(_T(""));
}
wxInt32 CMainDocument::GetMessagePriority(wxInt32 iIndex) {
CachedStateUpdate();
return 0;
}
wxString CMainDocument::GetMessageMessage(wxInt32 iIndex) {
CachedStateUpdate();
return wxString::Format(_T(""));
}
wxInt32 CMainDocument::CachedStateLock() {
m_bCachedStateLocked = true;
m_dtCachedStateLockTimestamp = wxDateTime::Now();

View File

@ -21,6 +21,9 @@
// Revision History:
//
// $Log$
// Revision 1.14 2004/09/29 22:20:43 rwalton
// *** empty log message ***
//
// Revision 1.13 2004/09/28 01:19:46 rwalton
// *** empty log message ***
//
@ -71,30 +74,38 @@ public:
CMainDocument();
~CMainDocument();
//
// Global
//
private:
RPC_CLIENT rpc;
//
// Project Tab
//
private:
RPC_CLIENT rpc;
PROJECTS project_status;
bool m_bCachedProjectStatusLocked;
float m_fProjectTotalResourceShare;
wxInt32 CachedProjectStatusUpdate();
public:
wxInt32 CachedProjectStatusLock();
wxInt32 CachedProjectStatusUnlock();
wxInt32 GetProjectCount();
wxInt32 GetProjectProjectName(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetProjectProjectURL(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetProjectAccountName(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetProjectTeamName(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetProjectTotalCredit(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetProjectAvgCredit(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetProjectResourceShare(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetProjectTotalCredit(wxInt32 iIndex, float& fBuffer);
wxInt32 GetProjectAvgCredit(wxInt32 iIndex, float& fBuffer);
wxInt32 GetProjectResourceShare(wxInt32 iIndex, float& fBuffer);
wxInt32 GetProjectTotalResourceShare(wxInt32 iIndex, float& fBuffer);
wxInt32 GetProjectMinRPCTime(wxInt32 iIndex, wxInt32& iBuffer);
bool IsProjectSuspended(wxInt32 iIndex);
bool IsProjectRPCPending(wxInt32 iIndex);
wxInt32 ProjectAttach( wxString& strURL, wxString& strAccountKey );
wxInt32 ProjectDetach( wxString& strURL );
@ -103,12 +114,31 @@ public:
wxInt32 ProjectSuspend( wxString& strURL );
wxInt32 ProjectResume( wxString& strURL );
//
// Messages Tab
//
private:
MESSAGES messages;
wxInt32 m_iMessageSequenceNumber;
wxInt32 CachedMessageUpdate();
public:
wxInt32 GetMessageCount();
wxInt32 GetMessageProjectName(wxInt32 iIndex, wxString& strBuffer);
wxInt32 GetMessageTime(wxInt32 iIndex, wxDateTime& dtBuffer);
wxInt32 GetMessagePriority(wxInt32 iIndex, wxInt32& iBuffer);
wxInt32 GetMessageMessage(wxInt32 iIndex, wxString& strBuffer);
private:
CC_STATE state;
RESULTS results;
FILE_TRANSFERS ft;
MESSAGES messages;
wxDateTime m_dtCachedStateTimestamp;
wxDateTime m_dtCachedStateLockTimestamp;
bool m_bCachedStateLocked;
@ -141,12 +171,6 @@ public:
wxString GetTransferStatus(wxInt32 iIndex);
wxString GetTransferTime(wxInt32 iIndex);
wxInt32 GetMessageCount();
wxString GetMessageProjectName(wxInt32 iIndex);
wxString GetMessageTime(wxInt32 iIndex);
wxInt32 GetMessagePriority(wxInt32 iIndex);
wxString GetMessageMessage(wxInt32 iIndex);
};
#endif

View File

@ -21,6 +21,9 @@
// Revision History:
//
// $Log$
// Revision 1.5 2004/09/29 22:20:43 rwalton
// *** empty log message ***
//
// Revision 1.4 2004/09/25 21:33:23 rwalton
// *** empty log message ***
//
@ -70,6 +73,9 @@
#define COLUMN_TIME 1
#define COLUMN_MESSAGE 2
#define PRIORITY_INFO 1
#define PRIORITY_ERROR 2
IMPLEMENT_DYNAMIC_CLASS(CViewMessages, CBOINCBaseView)
@ -105,6 +111,9 @@ CViewMessages::CViewMessages(wxNotebook* pNotebook) :
m_pListPane->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, -1);
m_pListPane->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, -1);
m_pMessageInfoAttr = new wxListItemAttr( *wxBLACK, *wxWHITE, wxNullFont );
m_pMessageErrorAttr = new wxListItemAttr( *wxRED, *wxWHITE, wxNullFont );
m_bTipsHeaderHidden = false;
SetCurrentQuickTip(
@ -118,6 +127,17 @@ CViewMessages::CViewMessages(wxNotebook* pNotebook) :
CViewMessages::~CViewMessages()
{
if ( m_pMessageInfoAttr )
{
delete m_pMessageInfoAttr;
m_pMessageInfoAttr = NULL;
}
if ( m_pMessageErrorAttr )
{
delete m_pMessageErrorAttr;
m_pMessageErrorAttr = NULL;
}
}
@ -192,27 +212,45 @@ void CViewMessages::OnListDeselected ( wxListEvent& event )
wxString CViewMessages::OnListGetItemText( long item, long column ) const
{
wxString strBuffer;
switch(column) {
wxString strBuffer;
wxDateTime dtBuffer(wxDateTime::Now());
switch(column)
{
case COLUMN_PROJECT:
if (item == m_iCacheFrom) wxGetApp().GetDocument()->CachedStateLock();
strBuffer = wxGetApp().GetDocument()->GetMessageProjectName(item);
wxGetApp().GetDocument()->GetMessageProjectName(item, strBuffer);
break;
case COLUMN_TIME:
strBuffer = wxGetApp().GetDocument()->GetMessageTime(item);
wxGetApp().GetDocument()->GetMessageTime(item, dtBuffer);
strBuffer = dtBuffer.Format();
break;
case COLUMN_MESSAGE:
strBuffer = wxGetApp().GetDocument()->GetMessageMessage(item);
if (item == m_iCacheTo) wxGetApp().GetDocument()->CachedStateUnlock();
wxGetApp().GetDocument()->GetMessageMessage(item, strBuffer);
break;
}
return strBuffer;
}
wxListItemAttr* CViewMessages::OnListGetItemAttr( long item ) const
{
return NULL;
wxListItemAttr* pAttribute = NULL;
wxInt32 iBuffer = 0;
wxGetApp().GetDocument()->GetMessagePriority(item, iBuffer);
switch(iBuffer)
{
case PRIORITY_INFO:
pAttribute = m_pMessageInfoAttr;
break;
case PRIORITY_ERROR:
pAttribute = m_pMessageErrorAttr;
break;
}
return pAttribute;
}

View File

@ -21,6 +21,9 @@
// Revision History:
//
// $Log$
// Revision 1.4 2004/09/29 22:20:43 rwalton
// *** empty log message ***
//
// Revision 1.3 2004/09/25 21:33:23 rwalton
// *** empty log message ***
//
@ -76,6 +79,9 @@ private:
bool m_bItemSelected;
wxListItemAttr* m_pMessageInfoAttr;
wxListItemAttr* m_pMessageErrorAttr;
virtual void UpdateSelection();
virtual void UpdateTaskPane();

View File

@ -21,6 +21,9 @@
// Revision History:
//
// $Log$
// Revision 1.8 2004/09/29 22:20:43 rwalton
// *** empty log message ***
//
// Revision 1.7 2004/09/28 01:19:46 rwalton
// *** empty log message ***
//
@ -97,6 +100,7 @@
#define COLUMN_TOTALCREDIT 3
#define COLUMN_AVGCREDIT 4
#define COLUMN_RESOURCESHARE 5
#define COLUMN_STATUS 6
IMPLEMENT_DYNAMIC_CLASS(CViewProjects, CBOINCBaseView)
@ -141,6 +145,7 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) :
m_pListPane->InsertColumn(COLUMN_TOTALCREDIT, _("Total Credit"), wxLIST_FORMAT_LEFT, -1);
m_pListPane->InsertColumn(COLUMN_AVGCREDIT, _("Avg. Credit"), wxLIST_FORMAT_LEFT, -1);
m_pListPane->InsertColumn(COLUMN_RESOURCESHARE, _("Resource Share"), wxLIST_FORMAT_LEFT, -1);
m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, -1);
m_bTipsHeaderHidden = false;
@ -228,7 +233,11 @@ void CViewProjects::OnListDeselected ( wxListEvent& event )
wxString CViewProjects::OnListGetItemText(long item, long column) const {
wxString strBuffer;
float fBuffer;
float fBuffer2;
switch(column) {
case COLUMN_PROJECT:
wxGetApp().GetDocument()->GetProjectProjectName(item, strBuffer);
@ -240,13 +249,36 @@ wxString CViewProjects::OnListGetItemText(long item, long column) const {
wxGetApp().GetDocument()->GetProjectTeamName(item, strBuffer);
break;
case COLUMN_TOTALCREDIT:
wxGetApp().GetDocument()->GetProjectTotalCredit(item, strBuffer);
wxGetApp().GetDocument()->GetProjectTotalCredit(item, fBuffer);
strBuffer.Printf(wxT("%0.2f"), fBuffer);
break;
case COLUMN_AVGCREDIT:
wxGetApp().GetDocument()->GetProjectAvgCredit(item, strBuffer);
wxGetApp().GetDocument()->GetProjectAvgCredit(item, fBuffer);
strBuffer.Printf(wxT("%0.2f"), fBuffer);
break;
case COLUMN_RESOURCESHARE:
wxGetApp().GetDocument()->GetProjectResourceShare(item, strBuffer);
wxGetApp().GetDocument()->GetProjectResourceShare(item, fBuffer);
wxGetApp().GetDocument()->GetProjectTotalResourceShare(item, fBuffer2);
strBuffer.Printf(wxT("%0.0f ( %0.2f%% )"), fBuffer, ((fBuffer / fBuffer2) * 100));
break;
case COLUMN_STATUS:
if (wxGetApp().GetDocument()->IsProjectSuspended(item))
{
strBuffer = _("Project Suspended");
}
else if (wxGetApp().GetDocument()->IsProjectRPCPending(item))
{
wxInt32 iNextRPC;
wxGetApp().GetDocument()->GetProjectMinRPCTime(item, iNextRPC);
wxDateTime dtNextRPC((time_t)iNextRPC);
if (dtNextRPC > wxDateTime::Now())
{
wxTimeSpan tsNextRPC(dtNextRPC - wxDateTime::Now());
strBuffer = _("Retry in ") + tsNextRPC.Format();
}
}
break;
}
return strBuffer;
@ -599,8 +631,18 @@ void CViewProjects::UpdateSelection()
m_bTaskAttachToProjectHidden = false;
m_bTaskDetachFromProjectHidden = false;
m_bTaskResetProjectHidden = false;
m_bTaskSuspendProjectHidden = false;
m_bTaskResumeProjectHidden = false;
if ( wxGetApp().GetDocument()->IsProjectSuspended(lSelected) )
{
m_bTaskSuspendProjectHidden = true;
m_bTaskResumeProjectHidden = false;
}
else
{
m_bTaskSuspendProjectHidden = false;
m_bTaskResumeProjectHidden = true;
}
m_bTaskUpdateProjectHidden = false;
m_bWebsiteHeaderHidden = false;

View File

@ -1109,8 +1109,6 @@ int RPC_CLIENT::get_messages( int nmessages, int seqno, MESSAGES& msgs) {
RPC rpc(this);
int retval;
msgs.clear();
sprintf(buf,
"<get_messages>\n"
" <nmessages>%d</nmessages>\n"