*** empty log message ***

svn path=/trunk/boinc/; revision=9519
This commit is contained in:
Rom Walton 2006-02-21 21:38:55 +00:00
parent 801da91c13
commit 88d0b14340
6 changed files with 142 additions and 64 deletions

View File

@ -2149,3 +2149,18 @@ Charlie 21 Feb 2006
mac_saver_module.cpp
lib/
mac_backtrace.C
Rom 21 Feb 2006
- Check in new suspend menu code.
- Bug Fix: Fix memory leak condition in gui rpc.
- Bug Fix: Copy gui_urls from new project class to the old class when
updating project stats.
- Bug Fix: Make sure the default connection is properly displayed
in the connection tab.
clientgui/
BOINCTaskBar.cpp, .h
Events.h
MainFrame.cpp
lib/
gui_rpc_client_ops.C

View File

@ -31,11 +31,11 @@
BEGIN_EVENT_TABLE (CTaskBarIcon, wxTaskBarIconEx)
EVT_IDLE(CTaskBarIcon::OnIdle)
EVT_CLOSE(CTaskBarIcon::OnClose)
EVT_TIMER(ID_TB_TIMER, CTaskBarIcon::OnTimer)
EVT_TASKBAR_LEFT_DCLICK(CTaskBarIcon::OnLButtonDClick)
EVT_MENU(wxID_OPEN, CTaskBarIcon::OnOpen)
EVT_MENU(ID_OPENWEBSITE, CTaskBarIcon::OnOpenWebsite)
EVT_MENU(ID_TB_ACTIVITYSUSPEND, CTaskBarIcon::OnActivitySelection)
EVT_MENU(ID_TB_NETWORKSUSPEND, CTaskBarIcon::OnNetworkSelection)
EVT_MENU_RANGE(ID_TB_SUSPENDNONE, ID_TB_SUSPENDINDEFINITELY, CTaskBarIcon::OnSuspend)
EVT_MENU(wxID_ABOUT, CTaskBarIcon::OnAbout)
EVT_MENU(wxID_EXIT, CTaskBarIcon::OnExit)
@ -62,6 +62,13 @@ CTaskBarIcon::CTaskBarIcon(wxString title, wxIcon* icon) :
m_dtLastHoverDetected = wxDateTime((time_t)0);
m_dtLastBalloonDisplayed = wxDateTime((time_t)0);
m_iSuspendId = ID_TB_SUSPENDNONE;
m_iPreviousActivityMode = RUN_MODE_AUTO;
m_iPreviousNetworkMode = RUN_MODE_AUTO;
m_pTimer = new wxTimer(this, ID_TB_TIMER);
#ifndef __WXMAC__
SetIcon(m_iconTaskBarIcon, title);
#endif
@ -70,6 +77,13 @@ CTaskBarIcon::CTaskBarIcon(wxString title, wxIcon* icon) :
CTaskBarIcon::~CTaskBarIcon() {
RemoveIcon();
m_iSuspendId = 0;
if (m_pTimer) {
m_pTimer->Stop();
delete m_pTimer;
}
}
@ -96,6 +110,23 @@ void CTaskBarIcon::OnClose(wxCloseEvent& event) {
}
void CTaskBarIcon::OnTimer(wxTimerEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnTimer - Function Begin"));
CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
m_pTimer->Stop();
m_iSuspendId = ID_TB_SUSPENDNONE;
pDoc->SetActivityRunMode(m_iPreviousActivityMode);
pDoc->SetNetworkRunMode(m_iPreviousNetworkMode);
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnTimer - Function End"));
}
void CTaskBarIcon::OnLButtonDClick(wxTaskBarIconEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnLButtonDClick - Function Begin"));
@ -153,7 +184,9 @@ void CTaskBarIcon::OnOpenWebsite(wxCommandEvent& WXUNUSED(event)) {
}
void CTaskBarIcon::OnActivitySelection(wxCommandEvent& event) {
void CTaskBarIcon::OnSuspend(wxCommandEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnSuspend - Function Begin"));
ResetTaskBar();
CMainDocument* pDoc = wxGetApp().GetDocument();
@ -161,27 +194,43 @@ void CTaskBarIcon::OnActivitySelection(wxCommandEvent& event) {
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
if (event.IsChecked()) {
m_iSuspendId = event.GetId();
switch(m_iSuspendId) {
case ID_TB_SUSPENDNONE:
pDoc->SetActivityRunMode(m_iPreviousActivityMode);
pDoc->SetNetworkRunMode(m_iPreviousActivityMode);
m_pTimer->Stop();
break;
case ID_TB_SUSPEND30:
m_pTimer->Start(30*60*1000); // Send event every 30 minutes
break;
case ID_TB_SUSPEND60:
m_pTimer->Start(60*60*1000); // Send event every 60 minutes
break;
case ID_TB_SUSPEND120:
m_pTimer->Start(120*60*1000); // Send event every 120 minutes
break;
case ID_TB_SUSPEND240:
m_pTimer->Start(240*60*1000); // Send event every 240 minutes
break;
case ID_TB_SUSPEND480:
m_pTimer->Start(480*60*1000); // Send event every 480 minutes
break;
case ID_TB_SUSPENDINDEFINITELY:
m_pTimer->Stop();
break;
}
pDoc->GetActivityRunMode(m_iPreviousActivityMode);
pDoc->GetNetworkRunMode(m_iPreviousNetworkMode);
if (ID_TB_SUSPENDNONE != m_iSuspendId) {
pDoc->SetActivityRunMode(RUN_MODE_NEVER);
} else {
pDoc->SetActivityRunMode(RUN_MODE_AUTO);
}
}
void CTaskBarIcon::OnNetworkSelection(wxCommandEvent& event) {
ResetTaskBar();
CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
if (event.IsChecked()) {
pDoc->SetNetworkRunMode(RUN_MODE_NEVER);
} else {
pDoc->SetNetworkRunMode(RUN_MODE_AUTO);
}
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnSuspend - Function End"));
}
@ -444,7 +493,9 @@ wxMenu *CTaskBarIcon::BuildContextMenu() {
CMainDocument* pDoc = wxGetApp().GetDocument();
ACCT_MGR_INFO ami;
bool is_acct_mgr_detected = false;
wxMenu* menu = new wxMenu;
wxMenu* pMenu = new wxMenu;
wxMenu* pSuspendMenu = new wxMenu;
wxMenuItem* pMenuItem = NULL;
wxString menuName = wxEmptyString;
wxFont font = wxNullFont;
#ifdef __WXMSW__
@ -452,7 +503,7 @@ wxMenu *CTaskBarIcon::BuildContextMenu() {
size_t loc = 0;
#endif
wxASSERT(menu);
wxASSERT(pMenu);
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
@ -465,53 +516,61 @@ wxMenu *CTaskBarIcon::BuildContextMenu() {
_("Open %s Web..."),
wxGetApp().GetBrand()->GetProjectName().c_str()
);
menu->Append(ID_OPENWEBSITE, menuName, wxEmptyString);
pMenu->Append(ID_OPENWEBSITE, menuName, wxEmptyString);
}
menuName.Printf(
_("Open %s..."),
wxGetApp().GetBrand()->GetApplicationName().c_str()
);
menu->Append(wxID_OPEN, menuName, wxEmptyString);
pMenu->Append(wxID_OPEN, menuName, wxEmptyString);
menu->AppendCheckItem(ID_TB_ACTIVITYSUSPEND, _("&Suspend activities"), wxEmptyString);
menu->AppendCheckItem(ID_TB_NETWORKSUSPEND, _("Suspend &network activities"), wxEmptyString);
pSuspendMenu->AppendRadioItem(ID_TB_SUSPENDNONE, _("&Wakeup"), wxEmptyString);
pSuspendMenu->AppendRadioItem(ID_TB_SUSPEND30, _("&30 minutes"), wxEmptyString);
pSuspendMenu->AppendRadioItem(ID_TB_SUSPEND60, _("&1 hour"), wxEmptyString);
pSuspendMenu->AppendRadioItem(ID_TB_SUSPEND120, _("&2 hours"), wxEmptyString);
pSuspendMenu->AppendRadioItem(ID_TB_SUSPEND240, _("&4 hours"), wxEmptyString);
pSuspendMenu->AppendRadioItem(ID_TB_SUSPEND480, _("&8 hours"), wxEmptyString);
pSuspendMenu->AppendRadioItem(ID_TB_SUSPENDINDEFINITELY, _("&Indefinitely"), wxEmptyString);
pMenuItem = pMenu->Append(wxID_ANY, _("Snooze"), wxEmptyString);
pMenuItem->SetSubMenu(pSuspendMenu);
menuName.Printf(
_("&About %s..."),
wxGetApp().GetBrand()->GetApplicationName().c_str()
);
menu->Append(wxID_ABOUT, menuName, wxEmptyString);
pMenu->Append(wxID_ABOUT, menuName, wxEmptyString);
#ifdef __WXMSW__
for (loc = 0; loc < menu->GetMenuItemCount(); loc++) {
menuItem = menu->FindItemByPosition(loc);
menu->Remove(menuItem);
for (loc = 0; loc < pMenu->GetMenuItemCount(); loc++) {
pMenuItem = pMenu->FindItemByPosition(loc);
pMenu->Remove(pMenuItem);
font = menuItem->GetFont();
if (menuItem->GetId() != wxID_OPEN) {
font = pMenuItem->GetFont();
if (pMenuItem->GetId() != wxID_OPEN) {
font.SetWeight(wxFONTWEIGHT_NORMAL);
} else {
font.SetWeight(wxFONTWEIGHT_BOLD);
}
menuItem->SetFont(font);
pMenuItem->SetFont(font);
menu->Insert(loc, menuItem);
pMenu->Insert(loc, pMenuItem);
}
#endif
if (is_acct_mgr_detected) {
menu->InsertSeparator(4);
menu->InsertSeparator(2);
pMenu->InsertSeparator(3);
pMenu->InsertSeparator(2);
} else {
menu->InsertSeparator(3);
menu->InsertSeparator(1);
pMenu->InsertSeparator(2);
pMenu->InsertSeparator(1);
}
AdjustMenuItems(menu);
AdjustMenuItems(pMenu);
return menu;
return pMenu;
}
void CTaskBarIcon::AdjustMenuItems(wxMenu* menu) {
@ -521,20 +580,8 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* menu) {
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
pDoc->GetActivityRunMode(iMode);
if (RUN_MODE_NEVER == iMode) {
menu->Check(ID_TB_ACTIVITYSUSPEND, true);
} else {
menu->Check(ID_TB_ACTIVITYSUSPEND, false);
}
pDoc->GetNetworkRunMode(iMode);
if (RUN_MODE_NEVER == iMode) {
menu->Check(ID_TB_NETWORKSUSPEND, true);
} else {
menu->Check(ID_TB_NETWORKSUSPEND, false);
}
menu->Check(m_iSuspendId, true);
#ifdef __WXMAC__
// WindowRef win = ActiveNonFloatingWindow();
WindowRef win = FrontWindow();

View File

@ -42,16 +42,17 @@ public:
void OnOpenWebsite(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event);
void OnActivitySelection(wxCommandEvent& event);
void OnNetworkSelection(wxCommandEvent& event);
void OnSuspend(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
#ifdef __WXMSW__
void OnShutdown(wxTaskBarIconExEvent& event);
#endif
void OnIdle(wxIdleEvent& event);
void OnClose(wxCloseEvent& event);
void OnTimer(wxTimerEvent& event);
#ifdef __WXMSW__
void OnMouseMove(wxTaskBarIconEvent& event);
@ -86,9 +87,17 @@ private:
wxDateTime m_dtLastHoverDetected;
wxDateTime m_dtLastBalloonDisplayed;
wxTimer* m_pTimer;
bool m_bButtonPressed;
int m_iSuspendId;
int m_iPreviousActivityMode;
int m_iPreviousNetworkMode;
void ResetSuspendState();
void ResetTaskBar();
void CreateContextMenu();
DECLARE_EVENT_TABLE()

View File

@ -43,11 +43,17 @@
#define ID_OPTIONSOPTIONS 6020
#define ID_HELPBOINC 6021
#define ID_HELPBOINCMANAGER 6022
#define ID_TB_ACTIVITYSUSPEND 6025
#define ID_TB_NETWORKSUSPEND 6028
#define ID_TOOLSAMUPDATENOW 6029
#define ID_ADVANCEDAMDEFECT 6030
#define ID_OPENWEBSITE 6031
#define ID_TB_TIMER 6800
#define ID_TB_SUSPENDNONE 6801
#define ID_TB_SUSPEND30 6802
#define ID_TB_SUSPEND60 6803
#define ID_TB_SUSPEND120 6804
#define ID_TB_SUSPEND240 6805
#define ID_TB_SUSPEND480 6806
#define ID_TB_SUSPENDINDEFINITELY 6807
#define ID_LIST_BASE 7000
#define ID_LIST_PROJECTSVIEW 7000
#define ID_LIST_WORKVIEW 7001

View File

@ -1342,9 +1342,8 @@ void CMainFrame::OnOptionsOptions(wxCommandEvent& WXUNUSED(event)) {
m_pDialupManager->GetISPNames(astrDialupConnections);
pDlg->m_DialupConnectionsCtrl->Append(astrDialupConnections);
pDlg->SetDefaultDialupConnection(m_strNetworkDialupConnectionName);
} else {
pDlg->m_DialupConnectionsCtrl->Append(astrDialupConnections);
pDlg->m_DialupSetDefaultCtrl->Disable();
pDlg->m_DialupClearDefaultCtrl->Disable();
}

View File

@ -98,6 +98,7 @@ void PROJECT::copy(PROJECT& p) {
suspended_via_gui = p.suspended_via_gui;
dont_request_more_work = p.dont_request_more_work;
scheduler_rpc_in_progress = p.scheduler_rpc_in_progress;
gui_urls = p.gui_urls;
}
int PROJECT::parse(MIOFILE& in) {
@ -1050,7 +1051,7 @@ int RPC_CLIENT::get_project_status(PROJECTS& p) {
int RPC_CLIENT::get_project_status(CC_STATE& state) {
char buf[256];
RPC rpc(this);
int retval;
int retval = 0;
retval = rpc.do_rpc("<get_project_status/>\n");
if (retval) return retval;
@ -1065,12 +1066,13 @@ int RPC_CLIENT::get_project_status(CC_STATE& state) {
if (state_project && (project->master_url == state_project->master_url)) {
state_project->copy(*project);
} else {
return ERR_NOT_FOUND;
retval = ERR_NOT_FOUND;
}
delete project;
continue;
}
}
return 0;
return retval;
}
int RPC_CLIENT::get_disk_usage(PROJECTS& p) {