2006-06-23 08:20:08 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
2007-10-09 11:35:47 +00:00
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "BOINCBaseFrame.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "diagnostics.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "mfile.h"
|
|
|
|
#include "miofile.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "hyperlink.h"
|
|
|
|
#include "BOINCGUIApp.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "SkinManager.h"
|
|
|
|
#include "MainDocument.h"
|
2008-01-30 06:09:34 +00:00
|
|
|
#include "BOINCClientManager.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "BOINCTaskBar.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "BOINCBaseFrame.h"
|
2006-06-23 22:30:47 +00:00
|
|
|
#include "BOINCDialupManager.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "Events.h"
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_FRAME_ALERT)
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_FRAME_CONNECT)
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_FRAME_INITIALIZED)
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_FRAME_REFRESHVIEW)
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_FRAME_UPDATESTATUS)
|
2006-10-25 14:09:47 +00:00
|
|
|
DEFINE_EVENT_TYPE(wxEVT_FRAME_RELOADSKIN)
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CBOINCBaseFrame, wxFrame)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE (CBOINCBaseFrame, wxFrame)
|
2006-06-23 21:49:50 +00:00
|
|
|
EVT_TIMER(ID_DOCUMENTPOLLTIMER, CBOINCBaseFrame::OnDocumentPoll)
|
2006-06-23 22:30:47 +00:00
|
|
|
EVT_TIMER(ID_ALERTPOLLTIMER, CBOINCBaseFrame::OnAlertPoll)
|
2006-06-23 21:49:50 +00:00
|
|
|
EVT_FRAME_INITIALIZED(CBOINCBaseFrame::OnInitialized)
|
2006-06-23 08:20:08 +00:00
|
|
|
EVT_FRAME_ALERT(CBOINCBaseFrame::OnAlert)
|
|
|
|
EVT_CLOSE(CBOINCBaseFrame::OnClose)
|
2006-12-12 01:08:16 +00:00
|
|
|
EVT_MENU(ID_FILECLOSEWINDOW, CBOINCBaseFrame::OnCloseWindow)
|
2006-06-23 08:20:08 +00:00
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCBaseFrame::CBOINCBaseFrame()
|
|
|
|
{
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::CBOINCBaseFrame - Default Constructor Function Begin"));
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::CBOINCBaseFrame - Default Constructor Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCBaseFrame::CBOINCBaseFrame(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style) :
|
|
|
|
wxFrame(parent, id, title, pos, size, style)
|
|
|
|
{
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::CBOINCBaseFrame - Function Begin"));
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
// Configuration Settings
|
|
|
|
m_iSelectedLanguage = 0;
|
|
|
|
m_iReminderFrequency = 0;
|
2006-11-03 15:18:19 +00:00
|
|
|
wxGetApp().SetDisplayExitWarning(1);
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
m_strNetworkDialupConnectionName = wxEmptyString;
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
m_aSelectedComputerMRU.Clear();
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
|
2006-06-23 22:30:47 +00:00
|
|
|
m_pDialupManager = new CBOINCDialUpManager();
|
|
|
|
wxASSERT(m_pDialupManager->IsOk());
|
|
|
|
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
m_pDocumentPollTimer = new wxTimer(this, ID_DOCUMENTPOLLTIMER);
|
|
|
|
wxASSERT(m_pDocumentPollTimer);
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
m_pDocumentPollTimer->Start(250); // Send event every 250 milliseconds
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 22:30:47 +00:00
|
|
|
m_pAlertPollTimer = new wxTimer(this, ID_ALERTPOLLTIMER);
|
|
|
|
wxASSERT(m_pAlertPollTimer);
|
|
|
|
|
|
|
|
m_pAlertPollTimer->Start(1000); // Send event every 1000 milliseconds
|
|
|
|
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
// Limit the number of times the UI can update itself to two times a second
|
|
|
|
// NOTE: Linux and Mac were updating several times a second and eating
|
|
|
|
// CPU time
|
|
|
|
wxUpdateUIEvent::SetUpdateInterval(500);
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
// The second half of the initialization process picks up in the OnFrameRender()
|
|
|
|
// routine since the menus' and status bars' are drawn in the frameworks
|
|
|
|
// on idle routines, on idle events are sent in between the end of the
|
|
|
|
// constructor and the first call to OnFrameRender
|
2006-06-23 08:20:08 +00:00
|
|
|
//
|
2006-06-23 21:49:50 +00:00
|
|
|
// Look for the 'if (!bAlreadyRunOnce) {' statement
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::CBOINCBaseFrame - Function End"));
|
|
|
|
}
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
CBOINCBaseFrame::~CBOINCBaseFrame() {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::~CBOINCBaseFrame - Function Begin"));
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 22:30:47 +00:00
|
|
|
wxASSERT(m_pAlertPollTimer);
|
2006-06-23 21:49:50 +00:00
|
|
|
wxASSERT(m_pDocumentPollTimer);
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 22:30:47 +00:00
|
|
|
if (m_pAlertPollTimer) {
|
|
|
|
m_pAlertPollTimer->Stop();
|
|
|
|
delete m_pAlertPollTimer;
|
|
|
|
}
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
if (m_pDocumentPollTimer) {
|
|
|
|
m_pDocumentPollTimer->Stop();
|
|
|
|
delete m_pDocumentPollTimer;
|
2006-06-23 08:20:08 +00:00
|
|
|
}
|
|
|
|
|
2006-06-23 22:30:47 +00:00
|
|
|
if (m_pDialupManager)
|
|
|
|
delete m_pDialupManager;
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::~CBOINCBaseFrame - Function End"));
|
2006-06-23 08:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 22:30:47 +00:00
|
|
|
void CBOINCBaseFrame::OnDocumentPoll(wxTimerEvent& WXUNUSED(event)) {
|
2006-06-23 21:49:50 +00:00
|
|
|
static bool bAlreadyRunOnce = false;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-12-29 16:35:33 +00:00
|
|
|
if (!bAlreadyRunOnce && m_pDocumentPollTimer->IsRunning()) {
|
2006-06-23 21:49:50 +00:00
|
|
|
// Complete any remaining initialization that has to happen after we are up
|
|
|
|
// and running
|
|
|
|
FireInitialize();
|
|
|
|
bAlreadyRunOnce = true;
|
2006-06-23 08:20:08 +00:00
|
|
|
}
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
pDoc->OnPoll();
|
|
|
|
}
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
|
2006-06-23 22:30:47 +00:00
|
|
|
void CBOINCBaseFrame::OnAlertPoll(wxTimerEvent& WXUNUSED(event)) {
|
|
|
|
static bool bAlreadyRunningLoop = false;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
2006-12-29 16:35:33 +00:00
|
|
|
if (!bAlreadyRunningLoop && m_pAlertPollTimer->IsRunning()) {
|
2006-06-23 22:30:47 +00:00
|
|
|
bAlreadyRunningLoop = true;
|
|
|
|
|
|
|
|
// Update idle detection if needed.
|
|
|
|
wxGetApp().UpdateSystemIdleDetection();
|
|
|
|
|
|
|
|
// Check to see if there is anything that we need to do from the
|
|
|
|
// dial up user perspective.
|
|
|
|
if (pDoc && m_pDialupManager) {
|
|
|
|
if (pDoc->IsConnected()) {
|
2006-12-29 16:35:33 +00:00
|
|
|
m_pDialupManager->OnPoll();
|
2006-06-23 22:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bAlreadyRunningLoop = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
void CBOINCBaseFrame::OnInitialized(CFrameEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnInitialized - Function Begin"));
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnInitialized - Function End"));
|
2006-06-23 08:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCBaseFrame::OnAlert(CFrameAlertEvent& event) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnAlert - Function Begin"));
|
2006-09-18 05:29:33 +00:00
|
|
|
static bool bAlreadyRunningLoop = false;
|
|
|
|
|
|
|
|
if (!bAlreadyRunningLoop) {
|
|
|
|
bAlreadyRunningLoop = true;
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
2006-09-18 05:29:33 +00:00
|
|
|
CTaskBarIcon* pTaskbar = wxGetApp().GetTaskBarIcon();
|
|
|
|
wxASSERT(pTaskbar);
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-09-18 05:29:33 +00:00
|
|
|
if ((IsShown() && !event.m_notification_only) || (IsShown() && !pTaskbar->IsBalloonsSupported())) {
|
|
|
|
if (!event.m_notification_only) {
|
|
|
|
int retval = 0;
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-09-18 05:29:33 +00:00
|
|
|
if (!IsShown()) {
|
|
|
|
Show();
|
|
|
|
}
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-09-18 05:29:33 +00:00
|
|
|
retval = ::wxMessageBox(event.m_message, event.m_title, event.m_style, this);
|
|
|
|
if (event.m_alert_event_type == AlertProcessResponse) {
|
|
|
|
event.ProcessResponse(retval);
|
|
|
|
}
|
2006-06-23 08:20:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-09-18 05:29:33 +00:00
|
|
|
// If the main window is hidden or minimzed use the system tray ballon
|
|
|
|
// to notify the user instead. This keeps dialogs from interfering
|
|
|
|
// with people typing email messages or any other activity where they
|
|
|
|
// do not want keyboard focus changed to another window while typing.
|
|
|
|
unsigned int icon_type;
|
|
|
|
|
|
|
|
if (wxICON_ERROR & event.m_style) {
|
|
|
|
icon_type = NIIF_ERROR;
|
|
|
|
} else if (wxICON_WARNING & event.m_style) {
|
|
|
|
icon_type = NIIF_WARNING;
|
|
|
|
} else if (wxICON_INFORMATION & event.m_style) {
|
|
|
|
icon_type = NIIF_INFO;
|
|
|
|
} else {
|
|
|
|
icon_type = NIIF_NONE;
|
2006-06-23 08:20:08 +00:00
|
|
|
}
|
|
|
|
|
2006-09-18 05:29:33 +00:00
|
|
|
pTaskbar->SetBalloon(
|
|
|
|
pTaskbar->m_iconTaskBarNormal,
|
|
|
|
event.m_title,
|
|
|
|
event.m_message,
|
|
|
|
5000,
|
|
|
|
icon_type
|
|
|
|
);
|
|
|
|
}
|
2008-02-05 12:00:06 +00:00
|
|
|
#elif defined (__WXMAC__)
|
|
|
|
// Notification only events on platforms other than Windows and Mac are
|
|
|
|
// currently discarded. On Linux the application is restored and
|
|
|
|
// input focus is set on the notification which interrupts whatever
|
|
|
|
// the user was up to.
|
|
|
|
if (!event.m_notification_only) {
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
// if (!IsShown()) {
|
|
|
|
// Show();
|
|
|
|
// }
|
|
|
|
|
|
|
|
retval = ::wxMessageBox(event.m_message, event.m_title, event.m_style, this);
|
|
|
|
if (event.m_alert_event_type == AlertProcessResponse) {
|
|
|
|
event.ProcessResponse(retval);
|
2006-06-23 08:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-09-18 05:29:33 +00:00
|
|
|
bAlreadyRunningLoop = false;
|
|
|
|
}
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnAlert - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
void CBOINCBaseFrame::OnClose(wxCloseEvent& event) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnClose - Function Begin"));
|
|
|
|
|
2006-08-14 19:30:40 +00:00
|
|
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
2006-06-23 21:49:50 +00:00
|
|
|
if (!event.CanVeto()) {
|
|
|
|
Destroy();
|
|
|
|
} else {
|
|
|
|
Hide();
|
|
|
|
}
|
2006-08-14 19:30:40 +00:00
|
|
|
#else
|
|
|
|
Destroy();
|
|
|
|
#endif
|
2006-06-23 21:49:50 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnClose - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-12 01:08:16 +00:00
|
|
|
void CBOINCBaseFrame::OnCloseWindow(wxCommandEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnCloseWindow - Function Begin"));
|
|
|
|
|
|
|
|
Close();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnCloseWindow - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-03 15:18:19 +00:00
|
|
|
void CBOINCBaseFrame::OnExit(wxCommandEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnExit - Function Begin"));
|
|
|
|
|
2007-01-19 14:30:18 +00:00
|
|
|
if (wxGetApp().ConfirmExit()) {
|
2007-02-15 05:37:19 +00:00
|
|
|
// Under wxWidgets 2.8.0, the task bar icons must be deleted for app to exit its main loop
|
2007-01-19 14:30:18 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
CMacSystemMenu* pMSM = wxGetApp().GetMacSystemMenu();
|
|
|
|
if (pMSM)
|
|
|
|
delete pMSM;
|
|
|
|
#endif
|
2007-01-19 17:32:16 +00:00
|
|
|
|
2007-02-15 05:37:19 +00:00
|
|
|
// TaskBarIcon isn't used in Linux
|
2007-01-19 17:32:16 +00:00
|
|
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
2007-01-19 14:30:18 +00:00
|
|
|
CTaskBarIcon* pTBI = wxGetApp().GetTaskBarIcon();
|
2007-05-21 16:07:10 +00:00
|
|
|
if (pTBI && !pTBI->m_bTaskbarInitiatedShutdown) {
|
2007-01-19 14:30:18 +00:00
|
|
|
delete pTBI;
|
2007-05-21 16:07:10 +00:00
|
|
|
}
|
2007-01-19 17:32:16 +00:00
|
|
|
#endif
|
2007-01-21 19:03:52 +00:00
|
|
|
Close(true);
|
|
|
|
|
2007-01-19 14:30:18 +00:00
|
|
|
}
|
2006-11-03 15:18:19 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnExit - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
void CBOINCBaseFrame::FireInitialize() {
|
|
|
|
CFrameEvent event(wxEVT_FRAME_INITIALIZED, this);
|
|
|
|
AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCBaseFrame::FireRefreshView() {
|
|
|
|
CFrameEvent event(wxEVT_FRAME_REFRESHVIEW, this);
|
|
|
|
AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCBaseFrame::FireConnect() {
|
|
|
|
CFrameEvent event(wxEVT_FRAME_CONNECT, this);
|
|
|
|
AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-25 14:09:47 +00:00
|
|
|
void CBOINCBaseFrame::FireReloadSkin() {
|
|
|
|
CFrameEvent event(wxEVT_FRAME_RELOADSKIN, this);
|
|
|
|
AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-11 17:56:21 +00:00
|
|
|
void CBOINCBaseFrame::ShowConnectionBadPasswordAlert( bool bUsedDefaultPassword, int m_iReadGUIRPCAuthFailure ) {
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2006-06-23 08:20:08 +00:00
|
|
|
wxString strDialogTitle = wxEmptyString;
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
|
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowConnectionBadPasswordAlert - Function Begin"));
|
|
|
|
|
|
|
|
// %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
strDialogTitle.Printf(
|
|
|
|
_("%s - Connection Error"),
|
2006-10-20 15:00:14 +00:00
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
2006-06-23 08:20:08 +00:00
|
|
|
);
|
|
|
|
|
2007-01-30 15:50:16 +00:00
|
|
|
if ( bUsedDefaultPassword ) {
|
2008-01-12 01:45:29 +00:00
|
|
|
#ifdef __WXMSW__
|
2008-01-11 17:56:21 +00:00
|
|
|
if ( EACCES == m_iReadGUIRPCAuthFailure || ENOENT == m_iReadGUIRPCAuthFailure ) {
|
|
|
|
ShowAlert(
|
|
|
|
strDialogTitle,
|
|
|
|
_("You currently are not authorized to manage the client.\n"
|
|
|
|
"Please contact your administrator to add you to the 'boinc_users' local user group."),
|
|
|
|
wxOK | wxICON_ERROR
|
|
|
|
);
|
2008-01-12 01:45:29 +00:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2008-01-11 17:56:21 +00:00
|
|
|
ShowAlert(
|
|
|
|
strDialogTitle,
|
2008-02-05 12:00:06 +00:00
|
|
|
#ifndef __WXMAC__
|
2008-02-06 00:42:59 +00:00
|
|
|
_("Authorization failed connecting to running client."
|
2008-02-05 12:00:06 +00:00
|
|
|
"\nMake sure you start this program in the same directory as the client."
|
|
|
|
),
|
2008-02-06 00:42:59 +00:00
|
|
|
#else
|
|
|
|
_("Authorization failed connecting to running client."),
|
|
|
|
#endif
|
2008-01-11 17:56:21 +00:00
|
|
|
wxOK | wxICON_ERROR
|
|
|
|
);
|
|
|
|
}
|
2007-01-30 15:50:16 +00:00
|
|
|
} else {
|
|
|
|
ShowAlert(
|
|
|
|
strDialogTitle,
|
|
|
|
_("The password you have provided is incorrect, please try again."),
|
|
|
|
wxOK | wxICON_ERROR
|
|
|
|
);
|
|
|
|
}
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowConnectionBadPasswordAlert - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCBaseFrame::ShowConnectionFailedAlert() {
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2008-02-05 12:00:06 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxString strConnectedCompter = wxEmptyString;
|
2006-06-23 08:20:08 +00:00
|
|
|
wxString strDialogTitle = wxEmptyString;
|
|
|
|
wxString strDialogMessage = wxEmptyString;
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
2008-02-05 12:00:06 +00:00
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowConnectionFailedAlert - Function Begin"));
|
|
|
|
|
2008-02-05 12:00:06 +00:00
|
|
|
// Did BOINC crash on local computer? If so restart it and reconnect.
|
|
|
|
pDoc->GetConnectedComputerName(strConnectedCompter);
|
|
|
|
if (pDoc->IsComputerNameLocal(strConnectedCompter)) {
|
|
|
|
if (pDoc->m_pClientManager->AutoRestart()) {
|
|
|
|
boinc_sleep(0.5); // Allow time for Client to restart
|
|
|
|
if (pDoc->m_pClientManager->IsBOINCCoreRunning()) {
|
|
|
|
pDoc->Reconnect();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-01-19 23:45:19 +00:00
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
// %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
strDialogTitle.Printf(
|
|
|
|
_("%s - Connection Failed"),
|
2006-10-20 15:00:14 +00:00
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
2006-06-23 08:20:08 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// 1st %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
// 2st %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
strDialogMessage.Printf(
|
|
|
|
_("%s is not able to connect to a %s client.\n"
|
|
|
|
"Would you like to try to connect again?"),
|
2006-10-20 15:00:14 +00:00
|
|
|
pSkinAdvanced->GetApplicationName().c_str(),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-06-23 08:20:08 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
ShowAlert(
|
|
|
|
strDialogTitle,
|
|
|
|
strDialogMessage,
|
|
|
|
wxYES_NO | wxICON_QUESTION,
|
|
|
|
false,
|
|
|
|
AlertProcessResponse
|
|
|
|
);
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowConnectionFailedAlert - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-30 06:09:34 +00:00
|
|
|
void CBOINCBaseFrame::ShowDaemonStartFailedAlert() {
|
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
|
|
|
wxString strDialogTitle = wxEmptyString;
|
|
|
|
wxString strDialogMessage = wxEmptyString;
|
|
|
|
|
|
|
|
|
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowDaemonStartFailedAlert - Function Begin"));
|
|
|
|
|
|
|
|
|
|
|
|
// %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
strDialogTitle.Printf(
|
|
|
|
_("%s - Daemon Start Failed"),
|
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
|
|
|
);
|
|
|
|
|
|
|
|
// 1st %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
// 2st %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
strDialogMessage.Printf(
|
|
|
|
_("%s is not able to start a %s client.\n"
|
|
|
|
"Please launch the Control Panel->Administative Tools->Services "
|
|
|
|
"applet and start the BOINC service."),
|
|
|
|
pSkinAdvanced->GetApplicationName().c_str(),
|
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
|
|
|
);
|
|
|
|
#else
|
|
|
|
strDialogMessage.Printf(
|
|
|
|
_("%s is not able to start a %s client.\n"
|
|
|
|
"Please start the daemon and try again."),
|
|
|
|
pSkinAdvanced->GetApplicationName().c_str(),
|
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ShowAlert(
|
|
|
|
strDialogTitle,
|
|
|
|
strDialogMessage,
|
|
|
|
wxOK | wxICON_ERROR
|
|
|
|
);
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowDaemonStartFailedAlert - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
void CBOINCBaseFrame::ShowNotCurrentlyConnectedAlert() {
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2008-02-05 12:00:06 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxString strConnectedCompter = wxEmptyString;
|
2006-06-23 08:20:08 +00:00
|
|
|
wxString strDialogTitle = wxEmptyString;
|
|
|
|
wxString strDialogMessage = wxEmptyString;
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
2008-02-05 12:00:06 +00:00
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowNotCurrentlyConnectedAlert - Function Begin"));
|
|
|
|
|
2008-02-05 12:00:06 +00:00
|
|
|
// Did BOINC crash on local computer? If so restart it and reconnect.
|
|
|
|
pDoc->GetConnectedComputerName(strConnectedCompter);
|
|
|
|
if (pDoc->IsComputerNameLocal(strConnectedCompter)) {
|
|
|
|
if (pDoc->m_pClientManager->AutoRestart()) {
|
|
|
|
boinc_sleep(0.5); // Allow time for Client to restart
|
|
|
|
if (pDoc->m_pClientManager->IsBOINCCoreRunning()) {
|
|
|
|
pDoc->Reconnect();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
// %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
strDialogTitle.Printf(
|
|
|
|
_("%s - Connection Status"),
|
2006-10-20 15:00:14 +00:00
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
2006-06-23 08:20:08 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// 1st %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
// 2nd %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
// 3nd %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
strDialogMessage.Printf(
|
|
|
|
_("%s is not currently connected to a %s client.\n"
|
2006-11-15 11:32:52 +00:00
|
|
|
"Please use the 'Advanced\\Select Computer...' menu option to connect up to a %s client.\n"
|
2006-06-23 08:20:08 +00:00
|
|
|
"To connect up to your local computer please use 'localhost' as the host name."),
|
2006-10-20 15:00:14 +00:00
|
|
|
pSkinAdvanced->GetApplicationName().c_str(),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str(),
|
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-06-23 08:20:08 +00:00
|
|
|
);
|
|
|
|
ShowAlert(
|
|
|
|
strDialogTitle,
|
|
|
|
strDialogMessage,
|
|
|
|
wxOK | wxICON_ERROR
|
|
|
|
);
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::ShowNotCurrentlyConnectedAlert - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-29 16:35:33 +00:00
|
|
|
void CBOINCBaseFrame::StartTimers() {
|
|
|
|
wxASSERT(m_pAlertPollTimer);
|
|
|
|
m_pAlertPollTimer->Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCBaseFrame::StopTimers() {
|
|
|
|
wxASSERT(m_pAlertPollTimer);
|
|
|
|
m_pAlertPollTimer->Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
void CBOINCBaseFrame::UpdateStatusText(const wxChar* szStatus) {
|
|
|
|
CFrameEvent event(wxEVT_FRAME_UPDATESTATUS, this, szStatus);
|
|
|
|
ProcessEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCBaseFrame::ShowAlert( const wxString title, const wxString message, const int style, const bool notification_only, const FrameAlertEventType alert_event_type ) {
|
|
|
|
CFrameAlertEvent event(wxEVT_FRAME_ALERT, this, title, message, style, notification_only, alert_event_type);
|
|
|
|
AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCBaseFrame::ExecuteBrowserLink(const wxString &strLink) {
|
|
|
|
wxHyperLink::ExecuteLink(strLink);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 21:49:50 +00:00
|
|
|
bool CBOINCBaseFrame::SaveState() {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::SaveState - Function Begin"));
|
|
|
|
|
|
|
|
wxString strBaseConfigLocation = wxString(wxT("/"));
|
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
|
|
|
wxString strConfigLocation;
|
|
|
|
wxString strPreviousLocation;
|
|
|
|
wxString strBuffer;
|
|
|
|
int iIndex;
|
|
|
|
int iItemCount;
|
|
|
|
|
|
|
|
|
|
|
|
wxASSERT(pConfig);
|
|
|
|
|
|
|
|
// An odd case happens every once and awhile where wxWidgets looses
|
|
|
|
// the pointer to the config object, or it is cleaned up before
|
|
|
|
// the window has finished it's cleanup duty. If we detect a NULL
|
|
|
|
// pointer, return false.
|
|
|
|
if (!pConfig) return false;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save Frame State
|
|
|
|
//
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
|
|
|
pConfig->Write(wxT("Language"), m_iSelectedLanguage);
|
|
|
|
pConfig->Write(wxT("ReminderFrequency"), m_iReminderFrequency);
|
2006-11-03 15:18:19 +00:00
|
|
|
pConfig->Write(wxT("DisplayExitWarning"), wxGetApp().GetDisplayExitWarning());
|
2006-06-23 21:49:50 +00:00
|
|
|
|
|
|
|
pConfig->Write(wxT("NetworkDialupConnectionName"), m_strNetworkDialupConnectionName);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save Computer MRU list
|
|
|
|
//
|
|
|
|
strPreviousLocation = pConfig->GetPath();
|
|
|
|
strConfigLocation = strPreviousLocation + wxT("ComputerMRU");
|
|
|
|
|
|
|
|
pConfig->SetPath(strConfigLocation);
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
iItemCount = (int)m_aSelectedComputerMRU.GetCount() - 1;
|
2006-06-23 21:49:50 +00:00
|
|
|
for (iIndex = 0; iIndex <= iItemCount; iIndex++) {
|
|
|
|
strBuffer.Printf(wxT("%d"), iIndex);
|
|
|
|
pConfig->Write(
|
|
|
|
strBuffer,
|
|
|
|
m_aSelectedComputerMRU.Item(iIndex)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
pConfig->SetPath(strPreviousLocation);
|
|
|
|
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::SaveState - Function End"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CBOINCBaseFrame::RestoreState() {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::RestoreState - Function Begin"));
|
|
|
|
|
|
|
|
wxString strBaseConfigLocation = wxString(wxT("/"));
|
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
|
|
|
wxString strConfigLocation;
|
|
|
|
wxString strPreviousLocation;
|
|
|
|
wxString strBuffer;
|
|
|
|
wxString strValue;
|
|
|
|
long iIndex;
|
|
|
|
bool bKeepEnumerating = false;
|
2006-11-03 15:18:19 +00:00
|
|
|
int iDisplayExitWarning;
|
2006-06-23 21:49:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxASSERT(pConfig);
|
|
|
|
|
|
|
|
// An odd case happens every once and awhile where wxWidgets looses
|
|
|
|
// the pointer to the config object, or it is cleaned up before
|
|
|
|
// the window has finished it's cleanup duty. If we detect a NULL
|
|
|
|
// pointer, return false.
|
|
|
|
if (!pConfig) return false;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Restore Frame State
|
|
|
|
//
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
|
|
|
pConfig->Read(wxT("Language"), &m_iSelectedLanguage, 0L);
|
|
|
|
pConfig->Read(wxT("ReminderFrequency"), &m_iReminderFrequency, 60L);
|
2006-11-03 15:18:19 +00:00
|
|
|
pConfig->Read(wxT("DisplayExitWarning"), &iDisplayExitWarning, 1L);
|
|
|
|
wxGetApp().SetDisplayExitWarning(iDisplayExitWarning);
|
2006-06-23 21:49:50 +00:00
|
|
|
|
|
|
|
pConfig->Read(wxT("NetworkDialupConnectionName"), &m_strNetworkDialupConnectionName, wxEmptyString);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Restore Computer MRU list
|
|
|
|
//
|
|
|
|
strPreviousLocation = pConfig->GetPath();
|
|
|
|
strConfigLocation = strPreviousLocation + wxT("ComputerMRU");
|
|
|
|
|
|
|
|
pConfig->SetPath(strConfigLocation);
|
|
|
|
|
|
|
|
m_aSelectedComputerMRU.Clear();
|
|
|
|
bKeepEnumerating = pConfig->GetFirstEntry(strBuffer, iIndex);
|
|
|
|
while (bKeepEnumerating) {
|
|
|
|
pConfig->Read(strBuffer, &strValue);
|
|
|
|
|
|
|
|
m_aSelectedComputerMRU.Add(strValue);
|
|
|
|
bKeepEnumerating = pConfig->GetNextEntry(strBuffer, iIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
pConfig->SetPath(strPreviousLocation);
|
|
|
|
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::RestoreState - Function End"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-30 04:07:41 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
bool CBOINCBaseFrame::Show(bool show) {
|
|
|
|
ProcessSerialNumber psn;
|
|
|
|
|
|
|
|
GetCurrentProcess(&psn);
|
|
|
|
if (show) {
|
|
|
|
SetFrontProcess(&psn); // Shows process if hidden
|
|
|
|
} else {
|
|
|
|
// GetWindowDimensions();
|
2006-10-30 05:49:58 +00:00
|
|
|
if (wxGetApp().GetCurrentGUISelection() == m_iWindowType)
|
2006-10-30 04:07:41 +00:00
|
|
|
if (IsProcessVisible(&psn))
|
|
|
|
ShowHideProcess(&psn, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxFrame::Show(show);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __WXMAC__
|
|
|
|
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
void CFrameAlertEvent::ProcessResponse(const int response) const {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
if ((AlertProcessResponse == m_alert_event_type) && (wxYES == response)) {
|
|
|
|
pDoc->Reconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *BOINC_RCSID_0a1bd38a5b = "$Id$";
|