1 // This file is part of BOINC.
2 // http://boinc.berkeley.edu
3 // Copyright (C) 2016 University of California
4 //
5 // BOINC is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License
7 // as published by the Free Software Foundation,
8 // either version 3 of the License, or (at your option) any later version.
9 //
10 // BOINC is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 // See the GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with BOINC. If not, see <http://www.gnu.org/licenses/>.
17
18 #if defined(__GNUG__) && !defined(__APPLE__)
19 #pragma implementation "AdvancedFrame.h"
20 #endif
21
22 #ifdef __APPLE__
23 #include "mac/MacGUI.pch"
24 #include "mac_util.h"
25 #endif
26
27 #include "stdwx.h"
28 #include "version.h"
29 #include "diagnostics.h"
30 #include "str_util.h"
31 #include "mfile.h"
32 #include "miofile.h"
33 #include "parse.h"
34 #include "util.h"
35 #include "BOINCGUIApp.h"
36 #include "Events.h"
37 #include "SkinManager.h"
38 #include "MainDocument.h"
39 #include "BOINCBaseFrame.h"
40 #include "BOINCBaseView.h"
41 #include "BOINCListCtrl.h"
42 #include "BOINCTaskBar.h"
43 #include "BOINCClientManager.h"
44 #include "BOINCDialupManager.h"
45 #include "AdvancedFrame.h"
46 #include "ViewNotices.h"
47 #include "ViewProjects.h"
48 #include "ViewWork.h"
49 #include "ViewTransfers.h"
50 #include "ViewMessages.h"
51 #include "ViewStatistics.h"
52 #include "ViewResources.h"
53 #include "DlgAbout.h"
54 #include "DlgOptions.h"
55 #include "DlgDiagnosticLogFlags.h"
56 #include "DlgHiddenColumns.h"
57 #include "DlgGenericMessage.h"
58 #include "DlgEventLog.h"
59 #include "browser.h"
60 #include "wizardex.h"
61 #include "BOINCBaseWizard.h"
62 #include "WizardAttach.h"
63 #include "DlgAdvPreferences.h"
64 #include "DlgExclusiveApps.h"
65
66 #include "res/connect.xpm"
67 #include "res/disconnect.xpm"
68
69 enum STATUSBARFIELDS {
70 STATUS_TEXT,
71 STATUS_CONNECTION_STATUS
72 };
73
74
IMPLEMENT_DYNAMIC_CLASS(CStatusBar,wxStatusBar)75 IMPLEMENT_DYNAMIC_CLASS(CStatusBar, wxStatusBar)
76
77 BEGIN_EVENT_TABLE(CStatusBar, wxStatusBar)
78 EVT_SIZE(CStatusBar::OnSize)
79 END_EVENT_TABLE()
80
81
82 CStatusBar::CStatusBar() {
83 wxLogTrace(wxT("Function Start/End"), wxT("CStatusBar::CStatusBar - Default Constructor Function Begin"));
84 wxLogTrace(wxT("Function Start/End"), wxT("CStatusBar::CStatusBar - Default Constructor Function End"));
85 }
86
87
CStatusBar(wxWindow * parent)88 CStatusBar::CStatusBar(wxWindow *parent) :
89 wxStatusBar(parent, ID_STATUSBAR, wxST_SIZEGRIP, _T("statusBar"))
90 {
91 wxLogTrace(wxT("Function Start/End"), wxT("CStatusBar::CStatusBar - Function Begin"));
92
93 const int widths[] = {-1, 300, 20};
94 SetFieldsCount(WXSIZEOF(widths), widths);
95
96 m_pbmpConnected = new wxStaticBitmap(this, -1, wxIcon(connect_xpm));
97 wxASSERT(m_pbmpConnected);
98 m_pbmpConnected->Hide();
99
100 m_ptxtConnected = new wxStaticText(this, -1, _("Connected"), wxPoint(0, 0), wxDefaultSize, wxALIGN_LEFT);
101 wxASSERT(m_ptxtConnected);
102 m_ptxtConnected->Hide();
103
104 m_pbmpDisconnect = new wxStaticBitmap(this, -1, wxIcon(disconnect_xpm));
105 wxASSERT(m_pbmpDisconnect);
106 m_pbmpDisconnect->Hide();
107
108 m_ptxtDisconnect = new wxStaticText(this, -1, _("Disconnected"), wxPoint(0, 0), wxDefaultSize, wxALIGN_LEFT);
109 wxASSERT(m_ptxtDisconnect);
110 m_ptxtDisconnect->Hide();
111
112 wxSizeEvent evt;
113 AddPendingEvent(evt);
114
115 wxLogTrace(wxT("Function Start/End"), wxT("CStatusBar::CStatusBar - Function End"));
116 }
117
118
~CStatusBar()119 CStatusBar::~CStatusBar()
120 {
121
122 }
123
124
OnSize(wxSizeEvent & event)125 void CStatusBar::OnSize(wxSizeEvent& event) {
126 wxLogTrace(wxT("Function Start/End"), wxT("CStatusBar::OnSize - Function Begin"));
127
128 if (IsShown()) {
129 wxRect rect;
130 wxSize size;
131
132 GetFieldRect(STATUS_CONNECTION_STATUS, rect);
133
134 if (m_pbmpConnected) {
135 size = m_pbmpConnected->GetSize();
136 m_pbmpConnected->Move(rect.x + 1,
137 rect.y + (rect.height - size.y) / 2);
138 }
139
140 if (m_ptxtConnected) {
141 m_ptxtConnected->Move((rect.x + size.x) + 2,
142 (rect.y + (rect.height - size.y) / 2) + 1);
143 }
144
145 if (m_pbmpDisconnect) {
146 size = m_pbmpDisconnect->GetSize();
147 m_pbmpDisconnect->Move(rect.x + 1,
148 rect.y + (rect.height - size.y) / 2);
149 }
150
151 if (m_ptxtDisconnect) {
152 m_ptxtDisconnect->Move((rect.x + size.x) + 2,
153 (rect.y + (rect.height - size.y) / 2) + 1);
154 }
155 }
156
157 event.Skip();
158
159 wxLogTrace(wxT("Function Start/End"), wxT("CStatusBar::OnSize - Function End"));
160 }
161
IMPLEMENT_DYNAMIC_CLASS(CAdvancedFrame,CBOINCBaseFrame)162 IMPLEMENT_DYNAMIC_CLASS(CAdvancedFrame, CBOINCBaseFrame)
163
164 BEGIN_EVENT_TABLE (CAdvancedFrame, CBOINCBaseFrame)
165 #ifndef __WXMSW__
166 EVT_MENU_OPEN(CAdvancedFrame::OnMenuOpening)
167 #endif
168 // View
169 EVT_MENU_RANGE(ID_ADVNOTICESVIEW, ID_ADVRESOURCEUSAGEVIEW, CAdvancedFrame::OnChangeView)
170 EVT_MENU(ID_CHANGEGUI, CAdvancedFrame::OnChangeGUI)
171 // Tools
172 EVT_MENU(ID_WIZARDATTACHPROJECT, CAdvancedFrame::OnWizardAttachProject)
173 EVT_MENU(ID_WIZARDATTACHACCOUNTMANAGER, CAdvancedFrame::OnWizardUpdate)
174 EVT_MENU(ID_WIZARDUPDATE, CAdvancedFrame::OnWizardUpdate)
175 EVT_MENU(ID_WIZARDDETACH, CAdvancedFrame::OnWizardDetach)
176 // Activity
177 EVT_MENU_RANGE(ID_ADVACTIVITYRUNALWAYS, ID_ADVACTIVITYSUSPEND, CAdvancedFrame::OnActivitySelection)
178 EVT_MENU_RANGE(ID_ADVACTIVITYGPUALWAYS, ID_ADVACTIVITYGPUSUSPEND, CAdvancedFrame::OnGPUSelection)
179 EVT_MENU_RANGE(ID_ADVNETWORKRUNALWAYS, ID_ADVNETWORKSUSPEND, CAdvancedFrame::OnNetworkSelection)
180 // Advanced
181 EVT_MENU(ID_OPTIONS, CAdvancedFrame::OnOptions)
182 EVT_MENU(ID_PREFERENCES, CAdvancedFrame::OnPreferences)
183 EVT_MENU(ID_EXCLUSIVE_APPS, CAdvancedFrame::OnExclusiveApps)
184 EVT_MENU(ID_DIAGNOSTICLOGFLAGS, CAdvancedFrame::OnDiagnosticLogFlags)
185 EVT_MENU(ID_SELECTCOLUMNS, CAdvancedFrame::OnSelectColumns)
186 EVT_MENU(ID_SELECTCOMPUTER, CAdvancedFrame::OnSelectComputer)
187 EVT_MENU(ID_SHUTDOWNCORECLIENT, CAdvancedFrame::OnClientShutdown)
188 EVT_MENU(ID_RUNBENCHMARKS, CAdvancedFrame::OnRunBenchmarks)
189 EVT_MENU(ID_RETRYCOMMUNICATIONS, CAdvancedFrame::OnRetryCommunications)
190 EVT_MENU(ID_READPREFERENCES, CAdvancedFrame::OnReadPreferences)
191 EVT_MENU(ID_READCONFIG, CAdvancedFrame::OnReadConfig)
192 EVT_MENU(ID_EVENTLOG, CAdvancedFrame::OnEventLog)
193 EVT_MENU(ID_LAUNCHNEWINSTANCE, CAdvancedFrame::OnLaunchNewInstance)
194 // Help
195 EVT_MENU(ID_HELPBOINC, CAdvancedFrame::OnHelpBOINC)
196 EVT_MENU(ID_HELPBOINCMANAGER, CAdvancedFrame::OnHelpBOINC)
197 EVT_MENU(ID_HELPBOINCWEBSITE, CAdvancedFrame::OnHelpBOINC)
198 EVT_MENU(wxID_ABOUT, CAdvancedFrame::OnHelpAbout)
199 EVT_MENU(ID_CHECK_VERSION, CAdvancedFrame::OnCheckVersion)
200 EVT_HELP(wxID_ANY, CAdvancedFrame::OnHelp)
201 // Custom Events & Timers
202 EVT_FRAME_CONNECT(CAdvancedFrame::OnConnect)
203 EVT_FRAME_NOTIFICATION(CAdvancedFrame::OnNotification)
204 EVT_TIMER(ID_REFRESHSTATETIMER, CAdvancedFrame::OnRefreshState)
205 EVT_TIMER(ID_FRAMERENDERTIMER, CAdvancedFrame::OnFrameRender)
206 EVT_NOTEBOOK_PAGE_CHANGED(ID_FRAMENOTEBOOK, CAdvancedFrame::OnNotebookSelectionChanged)
207 EVT_SIZE(CAdvancedFrame::OnSize)
208 EVT_MOVE(CAdvancedFrame::OnMove)
209 #ifdef __WXMAC__
210 EVT_MENU(wxID_PREFERENCES, CAdvancedFrame::OnPreferences)
211 EVT_CHAR_HOOK(CAdvancedFrame::OnKeyPressed)
212 #endif
213 END_EVENT_TABLE ()
214
215
216 CAdvancedFrame::CAdvancedFrame() {
217 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CAdvancedFrame - Default Constructor Function Begin"));
218 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CAdvancedFrame - Default Constructor Function End"));
219 }
220
221
CAdvancedFrame(wxString title,wxIconBundle * icons,wxPoint position,wxSize size)222 CAdvancedFrame::CAdvancedFrame(wxString title, wxIconBundle* icons, wxPoint position, wxSize size) :
223 CBOINCBaseFrame((wxFrame *)NULL, ID_ADVANCEDFRAME, title, position, size, wxDEFAULT_FRAME_STYLE)
224 {
225 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CAdvancedFrame - Function Begin"));
226
227 m_pMenubar = NULL;
228 m_pNotebook = NULL;
229 m_pStatusbar = NULL;
230
231 // Working Variables
232 m_strBaseTitle = title;
233
234 // Initialize Application
235 SetIcons(*icons);
236
237 // Create UI elements
238 wxCHECK_RET(CreateMenu(), _T("Failed to create menu bar."));
239 wxCHECK_RET(CreateNotebook(), _T("Failed to create notebook."));
240 wxCHECK_RET(CreateStatusbar(), _T("Failed to create status bar."));
241
242 RestoreState();
243
244 // For generic wxListCtrl, we must call Layout() for panel containing m_pNotebook
245 // after CBOINCListCtrl::RestoreState() has finished BOINCListCtrl initialization.
246 m_pNotebook->GetParent()->Layout();
247
248 m_pRefreshStateTimer = new wxTimer(this, ID_REFRESHSTATETIMER);
249 wxASSERT(m_pRefreshStateTimer);
250 m_pRefreshStateTimer->Start(300000); // Send event every 5 minutes
251
252 m_pFrameRenderTimer = new wxTimer(this, ID_FRAMERENDERTIMER);
253 wxASSERT(m_pFrameRenderTimer);
254 m_pFrameRenderTimer->Start(1000); // Send event every 1 second
255
256 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CAdvancedFrame - Function End"));
257 }
258
259
~CAdvancedFrame()260 CAdvancedFrame::~CAdvancedFrame() {
261 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::~CAdvancedFrame - Function Begin"));
262
263 wxASSERT(m_pRefreshStateTimer);
264 wxASSERT(m_pFrameRenderTimer);
265 wxASSERT(m_pMenubar);
266 wxASSERT(m_pNotebook);
267 wxASSERT(m_pStatusbar);
268
269 SaveState();
270
271 if (m_pRefreshStateTimer) {
272 m_pRefreshStateTimer->Stop();
273 delete m_pRefreshStateTimer;
274 m_pRefreshStateTimer = NULL;
275 }
276
277 if (m_pFrameRenderTimer) {
278 m_pFrameRenderTimer->Stop();
279 delete m_pFrameRenderTimer;
280 m_pFrameRenderTimer = NULL;
281 }
282
283 if (m_pStatusbar) {
284 wxCHECK_RET(DeleteStatusbar(), _T("Failed to delete status bar."));
285 }
286
287 if (m_pNotebook) {
288 wxCHECK_RET(DeleteNotebook(), _T("Failed to delete notebook."));
289 }
290
291 if (m_pMenubar) {
292 wxCHECK_RET(DeleteMenu(), _T("Failed to delete menu bar."));
293 }
294
295 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::~CAdvancedFrame - Function End"));
296 }
297
298
CreateMenu()299 bool CAdvancedFrame::CreateMenu() {
300 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateMenu - Function Begin"));
301
302 CMainDocument* pDoc = wxGetApp().GetDocument();
303 CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
304 ACCT_MGR_INFO ami;
305 bool is_acct_mgr_detected = false;
306 bool is_boinc_started_by_manager = false;
307 wxString strMenuName;
308 wxString strMenuDescription;
309
310 wxASSERT(pDoc);
311 wxASSERT(pSkinAdvanced);
312 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
313 wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
314
315 // Account managers have a different menu arrangement
316 if (pDoc->IsConnected()) {
317 pDoc->rpc.acct_mgr_info(ami);
318 is_acct_mgr_detected = ami.acct_mgr_url.size() ? true : false;
319 }
320
321 if (pDoc->m_pClientManager->WasBOINCStartedByManager()) {
322 is_boinc_started_by_manager = true;
323 }
324
325
326 // File menu
327 wxMenu *menuFile = new wxMenu;
328
329 strMenuName.Printf(
330 _("New %s window..."),
331 pSkinAdvanced->GetApplicationName().c_str()
332 );
333 strMenuDescription.Printf(
334 _("Open another %s window"),
335 pSkinAdvanced->GetApplicationName().c_str()
336 );
337 menuFile->Append(
338 ID_LAUNCHNEWINSTANCE,
339 strMenuName,
340 strMenuDescription
341 );
342
343 menuFile->Append(
344 ID_SELECTCOMPUTER,
345 _("Select computer...\tCtrl+Shift+I"),
346 _("Connect to a BOINC client on another computer")
347 );
348 menuFile->Append(
349 ID_SHUTDOWNCORECLIENT,
350 _("Shut down connected client..."),
351 _("Shut down the currently connected BOINC client")
352 );
353 menuFile->AppendSeparator();
354
355 strMenuDescription.Printf(
356 _("Close the %s window"),
357 pSkinAdvanced->GetApplicationName().c_str()
358 );
359 strMenuName = _("&Close window");
360 strMenuName += wxT("\tCtrl+W");
361 menuFile->Append(
362 ID_CLOSEWINDOW,
363 strMenuName,
364 strMenuDescription
365 );
366
367 strMenuDescription.Printf(
368 _("Exit %s"),
369 pSkinAdvanced->GetApplicationName().c_str()
370 );
371 if (is_boinc_started_by_manager) {
372 strMenuName.Printf(
373 _("Exit %s"),
374 pSkinAdvanced->GetApplicationShortName().c_str()
375 );
376 } else {
377 strMenuName.Printf(
378 _("Exit %s"),
379 pSkinAdvanced->GetApplicationName().c_str()
380 );
381 }
382 menuFile->Append(
383 wxID_EXIT,
384 strMenuName,
385 strMenuDescription
386 );
387
388 #ifdef __WXMAC__
389 // wxWidgets actually puts this in the BOINCManager menu
390 menuFile->Append(
391 wxID_PREFERENCES,
392 _("Preferences...")
393 );
394 #endif
395
396 // View menu
397 wxMenu *menuView = new wxMenu;
398
399 menuView->Append(
400 ID_ADVNOTICESVIEW,
401 _("&Notices\tCtrl+Shift+N"),
402 _("Show notices")
403 );
404
405 menuView->Append(
406 ID_ADVPROJECTSVIEW,
407 _("&Projects\tCtrl+Shift+P"),
408 _("Show projects")
409 );
410
411 menuView->Append(
412 ID_ADVTASKSVIEW,
413 _("&Tasks\tCtrl+Shift+T"),
414 _("Show tasks")
415 );
416
417 menuView->Append(
418 ID_ADVTRANSFERSVIEW,
419 _("Trans&fers\tCtrl+Shift+X"),
420 _("Show file transfers")
421 );
422
423 menuView->Append(
424 ID_ADVSTATISTICSVIEW,
425 _("&Statistics\tCtrl+Shift+S"),
426 _("Show statistics")
427 );
428
429 menuView->Append(
430 ID_ADVRESOURCEUSAGEVIEW,
431 _("&Disk\tCtrl+Shift+D"),
432 _("Show disk usage")
433 );
434
435 menuView->AppendSeparator();
436
437 menuView->Append(
438 ID_CHANGEGUI,
439 _("Simple &View...\tCtrl+Shift+V"),
440 _("Switch to the Simple View")
441 );
442
443 // Screen too small?
444 if (wxGetDisplaySize().GetHeight() < 600) {
445 menuView->Enable(ID_CHANGEGUI, false);
446 }
447
448 // Tools menu
449 wxMenu *menuTools = new wxMenu;
450
451 if (!is_acct_mgr_detected) {
452 menuTools->Append(
453 ID_WIZARDATTACHPROJECT,
454 _("&Add project..."),
455 _("Add a project")
456 );
457 menuTools->Append(
458 ID_WIZARDATTACHACCOUNTMANAGER,
459 _("&Use account manager..."),
460 _("Use an account manager to control this computer.")
461 );
462 } else {
463 strMenuName.Printf(
464 _("&Synchronize with %s"),
465 wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str()
466 );
467 strMenuDescription.Printf(
468 _("Get current settings from %s"),
469 wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str()
470 );
471 menuTools->Append(
472 ID_WIZARDUPDATE,
473 strMenuName,
474 strMenuDescription
475 );
476 menuTools->Append(
477 ID_WIZARDATTACHPROJECT,
478 _("&Add project..."),
479 _("Add a project")
480 );
481 strMenuName.Printf(
482 _("S&top using %s..."),
483 wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str()
484 );
485 menuTools->Append(
486 ID_WIZARDDETACH,
487 strMenuName,
488 _("Remove this computer from account manager control.")
489 );
490 }
491 menuTools->AppendSeparator();
492 menuTools->Append(
493 ID_RUNBENCHMARKS,
494 _("Run CPU &benchmarks"),
495 _("Run tests that measure CPU speed")
496 );
497 menuTools->Append(
498 ID_RETRYCOMMUNICATIONS,
499 _("Retry pending transfers"),
500 _("Retry deferred file transfers and task requests")
501 );
502 menuTools->AppendSeparator();
503 menuTools->Append(
504 ID_EVENTLOG,
505 _("Event Log...\tCtrl+Shift+E"),
506 _("Show diagnostic messages")
507 );
508
509 // Activity menu
510 wxMenu *menuActivity = new wxMenu;
511
512 menuActivity->AppendRadioItem(
513 ID_ADVACTIVITYRUNALWAYS,
514 _("&Run always"),
515 _("Allow work regardless of preferences")
516 );
517 menuActivity->AppendRadioItem(
518 ID_ADVACTIVITYRUNBASEDONPREPERENCES,
519 _("Run based on &preferences"),
520 _("Allow work according to preferences")
521 );
522 menuActivity->AppendRadioItem(
523 ID_ADVACTIVITYSUSPEND,
524 _("&Suspend"),
525 _("Stop work regardless of preferences")
526 );
527
528 if (pDoc->state.have_gpu()) {
529
530 #ifndef __WXGTK__
531 menuActivity->AppendSeparator();
532 #else
533 // for some reason, the above radio items do not display the active
534 // selection on linux (wxGtk library) with the separator here,
535 // so we add a blank disabled menu item instead
536 //
537 wxMenuItem* pItem = menuActivity->Append(
538 ID_MENUSEPARATOR1,
539 (const wxChar *) wxT(" "),
540 // wxEmptyString here causes a wxWidgets assertion when debugging
541 wxEmptyString,
542 wxITEM_NORMAL
543 // wxITEM_SEPARATOR here causes a wxWidgets assertion when debugging
544 );
545 pItem->Enable(false); // disable this menu item
546 #endif
547
548 menuActivity->AppendRadioItem(
549 ID_ADVACTIVITYGPUALWAYS,
550 _("Use GPU always"),
551 _("Allow GPU work regardless of preferences")
552 );
553 menuActivity->AppendRadioItem(
554 ID_ADVACTIVITYGPUBASEDONPREPERENCES,
555 _("Use GPU based on preferences"),
556 _("Allow GPU work according to preferences")
557 );
558 menuActivity->AppendRadioItem(
559 ID_ADVACTIVITYGPUSUSPEND,
560 _("Suspend GPU"),
561 _("Stop GPU work regardless of preferences")
562 );
563 }
564
565 #ifndef __WXGTK__
566 menuActivity->AppendSeparator();
567 #else
568 // for some reason, the above radio items do not display the active
569 // selection on linux (wxGtk library) with the separator here,
570 // so we add a blank disabled menu item instead
571 //
572 wxMenuItem* pItem = menuActivity->Append(
573 ID_MENUSEPARATOR2,
574 (const wxChar *) wxT(" "),
575 // wxEmptyString here causes a wxWidgets assertion when debugging
576 wxEmptyString,
577 wxITEM_NORMAL
578 // wxITEM_SEPARATOR here causes a wxWidgets assertion when debugging
579 );
580 pItem->Enable(false); // disable this menu item
581 #endif
582
583 menuActivity->AppendRadioItem(
584 ID_ADVNETWORKRUNALWAYS,
585 _("Network activity always"),
586 _("Allow network activity regardless of preferences")
587 );
588 menuActivity->AppendRadioItem(
589 ID_ADVNETWORKRUNBASEDONPREPERENCES,
590 _("Network activity based on preferences"),
591 _("Allow network activity according to preferences")
592 );
593 menuActivity->AppendRadioItem(
594 ID_ADVNETWORKSUSPEND,
595 _("Suspend network activity"),
596 _("Stop network activity")
597 );
598
599 // Options menu
600
601 wxMenu *menuOptions = new wxMenu;
602
603 menuOptions->Append(
604 ID_PREFERENCES,
605 _("Computing &preferences..."),
606 _("Configure computing preferences")
607 );
608
609 menuOptions->Append(
610 ID_EXCLUSIVE_APPS,
611 _("Exclusive applications..."),
612 _("Configure exclusive applications")
613 );
614 menuOptions->AppendSeparator();
615 menuOptions->Append(
616 ID_SELECTCOLUMNS,
617 _("Select columns..."),
618 _("Select which columns to display")
619 );
620 menuOptions->Append(
621 ID_DIAGNOSTICLOGFLAGS,
622 _("Event Log options...\tCtrl+Shift+F"),
623 _("Enable or disable various diagnostic messages")
624 );
625 menuOptions->Append(
626 ID_OPTIONS,
627 _("&Other options..."),
628 _("Configure display options and network settings")
629 );
630 menuOptions->AppendSeparator();
631 menuOptions->Append(
632 ID_READCONFIG,
633 _("Read config files"),
634 _("Read configuration info from cc_config.xml and any app_config.xml files")
635 );
636 menuOptions->Append(
637 ID_READPREFERENCES,
638 _("Read local prefs file"),
639 _("Read preferences from global_prefs_override.xml.")
640 );
641
642
643 // Help menu
644 wxMenu *menuHelp = new wxMenu;
645
646 strMenuName.Printf(
647 _("%s &help"),
648 pSkinAdvanced->GetApplicationShortName().c_str()
649 );
650 strMenuDescription.Printf(
651 _("Show information about %s"),
652 pSkinAdvanced->GetApplicationShortName().c_str()
653 );
654 menuHelp->Append(
655 ID_HELPBOINC,
656 strMenuName,
657 strMenuDescription
658 );
659
660 strMenuName.Printf(
661 _("&%s help"),
662 pSkinAdvanced->GetApplicationName().c_str()
663 );
664 strMenuDescription.Printf(
665 _("Show information about the %s"),
666 pSkinAdvanced->GetApplicationName().c_str()
667 );
668 menuHelp->Append(
669 ID_HELPBOINCMANAGER,
670 strMenuName,
671 strMenuDescription
672 );
673 menuHelp->AppendSeparator();
674
675 strMenuName.Printf(
676 _("%s &web site"),
677 pSkinAdvanced->GetApplicationShortName().c_str()
678 );
679 strMenuDescription.Printf(
680 _("Show information about BOINC and %s"),
681 pSkinAdvanced->GetApplicationName().c_str()
682 );
683 menuHelp->Append(
684 ID_HELPBOINCWEBSITE,
685 strMenuName,
686 strMenuDescription
687 );
688 menuHelp->AppendSeparator();
689
690 strMenuName.Printf(
691 _("Check for new %s version"),
692 pSkinAdvanced->GetApplicationShortName().c_str()
693 );
694 strMenuDescription.Printf(
695 _("Check for new %s version"),
696 pSkinAdvanced->GetApplicationShortName().c_str()
697 );
698 menuHelp->Append(
699 ID_CHECK_VERSION,
700 strMenuName,
701 strMenuDescription
702 );
703 menuHelp->AppendSeparator();
704
705 strMenuName.Printf(
706 _("&About %s..."),
707 pSkinAdvanced->GetApplicationName().c_str()
708 );
709 menuHelp->Append(
710 wxID_ABOUT,
711 strMenuName,
712 _("Licensing and copyright information.")
713 );
714
715 // construct menu
716 m_pMenubar = new wxMenuBar;
717 m_pMenubar->Append(
718 menuFile,
719 _("&File")
720 );
721 m_pMenubar->Append(
722 menuView,
723 _("&View")
724 );
725 m_pMenubar->Append(
726 menuActivity,
727 _("&Activity")
728 );
729 m_pMenubar->Append(
730 menuOptions,
731 _("&Options")
732 );
733 m_pMenubar->Append(
734 menuTools,
735 _("&Tools")
736 );
737 m_pMenubar->Append(
738 menuHelp,
739 _("&Help")
740 );
741
742 wxMenuBar* m_pOldMenubar = GetMenuBar();
743 SetMenuBar(m_pMenubar);
744 #ifdef __WXGTK__
745 // Force a redraw of the menu under Ubuntu's new interface
746 SendSizeEvent();
747 #endif
748 if (m_pOldMenubar) {
749 delete m_pOldMenubar;
750 }
751
752 #ifdef __WXMAC__
753 // Set HELP key as keyboard shortcut
754 m_Shortcuts[0].Set(wxACCEL_NORMAL, WXK_HELP, ID_HELPBOINCMANAGER);
755 m_pAccelTable = new wxAcceleratorTable(1, m_Shortcuts);
756 SetAcceleratorTable(*m_pAccelTable);
757 #endif
758
759 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateMenu - Function End"));
760 return true;
761 }
762
763
CreateNotebook()764 bool CAdvancedFrame::CreateNotebook() {
765 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateNotebook - Function Begin"));
766
767 // create frame panel
768 wxPanel *pPanel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
769 wxTAB_TRAVERSAL|wxCLIP_CHILDREN|wxNO_BORDER);
770 pPanel->SetAutoLayout(TRUE);
771
772 // initialize notebook
773 m_pNotebook = new wxNotebook(pPanel, ID_FRAMENOTEBOOK, wxDefaultPosition, wxDefaultSize,
774 wxNB_FIXEDWIDTH|wxCLIP_CHILDREN);
775
776 // layout frame panel
777 wxBoxSizer *pPanelSizer = new wxBoxSizer(wxVERTICAL);
778
779 pPanelSizer->Add(new wxStaticLine(pPanel, -1), 0, wxEXPAND);
780 pPanelSizer->Add(0, 5);
781 pPanelSizer->Add(m_pNotebook, 1, wxEXPAND);
782
783 // Display default views
784 RepopulateNotebook();
785
786 pPanel->SetSizer(pPanelSizer);
787 pPanel->Layout();
788
789 #ifdef __WXMAC__
790 //Accessibility
791 HIObjectSetAccessibilityIgnored((HIObjectRef)pPanel->GetHandle(), true);
792 #endif
793
794 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateNotebook - Function End"));
795 return true;
796 }
797
798
RepopulateNotebook()799 bool CAdvancedFrame::RepopulateNotebook() {
800 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::RepopulateNotebook - Function Begin"));
801
802 DeleteNotebook();
803
804 // Create the various notebook pages
805 CreateNotebookPage(new CViewNotices(m_pNotebook));
806 CreateNotebookPage(new CViewProjects(m_pNotebook));
807 CreateNotebookPage(new CViewWork(m_pNotebook));
808 CreateNotebookPage(new CViewTransfers(m_pNotebook));
809 CreateNotebookPage(new CViewStatistics(m_pNotebook));
810 CreateNotebookPage(new CViewResources(m_pNotebook));
811
812 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::RepopulateNotebook - Function End"));
813 return true;
814 }
815
816
CreateNotebookPage(CBOINCBaseView * pwndNewNotebookPage)817 bool CAdvancedFrame::CreateNotebookPage( CBOINCBaseView* pwndNewNotebookPage) {
818 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateNotebookPage - Function Begin"));
819
820 wxImageList* pImageList;
821 int iImageIndex = 0;
822
823 wxASSERT(pwndNewNotebookPage);
824 wxASSERT(m_pNotebook);
825 wxASSERT(wxDynamicCast(pwndNewNotebookPage, CBOINCBaseView));
826
827
828 pImageList = m_pNotebook->GetImageList();
829 if (!pImageList) {
830 pImageList = new wxImageList(ADJUSTFORXDPI(16), ADJUSTFORYDPI(16), true, 0);
831 wxASSERT(pImageList != NULL);
832 m_pNotebook->SetImageList(pImageList);
833 }
834
835 iImageIndex = pImageList->Add(GetScaledBitmapFromXPMData(pwndNewNotebookPage->GetViewIcon()));
836 m_pNotebook->AddPage(pwndNewNotebookPage, pwndNewNotebookPage->GetViewDisplayName(), TRUE, iImageIndex);
837
838 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateNotebookPage - Function End"));
839 return true;
840 }
841
842
GetNotebook()843 wxNotebook* CAdvancedFrame::GetNotebook() {
844 return m_pNotebook;
845 }
846
847
CreateStatusbar()848 bool CAdvancedFrame::CreateStatusbar() {
849 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateStatusbar - Function Begin"));
850
851 if (m_pStatusbar)
852 return true;
853
854 m_pStatusbar = new CStatusBar(this);
855 wxASSERT(m_pStatusbar);
856
857 SetStatusBar(m_pStatusbar);
858 SetStatusBarPane(0);
859
860 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::CreateStatusbar - Function End"));
861 return true;
862 }
863
864
DeleteMenu()865 bool CAdvancedFrame::DeleteMenu() {
866 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::DeleteMenu - Function Begin"));
867 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::DeleteMenu - Function End"));
868 return true;
869 }
870
871
DeleteNotebook()872 bool CAdvancedFrame::DeleteNotebook() {
873 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::DeleteNotebook - Function Begin"));
874
875 wxASSERT(m_pNotebook);
876
877 // Delete all existing pages
878 m_pNotebook->DeleteAllPages();
879
880 // Delete all existing images
881 wxImageList* pImageList = m_pNotebook->GetImageList();
882 if (pImageList) {
883 pImageList->RemoveAll();
884 }
885
886 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::DeleteNotebook - Function End"));
887 return true;
888 }
889
890
DeleteStatusbar()891 bool CAdvancedFrame::DeleteStatusbar() {
892 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::DeleteStatusbar - Function Begin"));
893
894 if (!m_pStatusbar)
895 return true;
896
897 SetStatusBar(NULL);
898
899 delete m_pStatusbar;
900 m_pStatusbar = NULL;
901
902 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::DeleteStatusbar - Function End"));
903 return true;
904 }
905
906
SaveState()907 bool CAdvancedFrame::SaveState() {
908 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::SaveState - Function Begin"));
909
910 wxString strBaseConfigLocation = wxString(wxT("/"));
911 wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
912 wxWindow* pwndNotebookPage = NULL;
913 CBOINCBaseView* pView = NULL;
914 wxString strConfigLocation;
915 wxString strPreviousLocation;
916 int iIndex = 0;
917 int iItemCount = 0;
918
919
920 wxASSERT(m_pNotebook);
921
922 CBOINCBaseFrame::SaveState();
923
924 // An odd case happens every once and awhile where wxWidgets looses
925 // the pointer to the config object, or it is cleaned up before
926 // the window has finished it's cleanup duty. If we detect a NULL
927 // pointer, return false.
928 if (!pConfig) return false;
929
930 //
931 // Save Frame State
932 //
933 pConfig->SetPath(strBaseConfigLocation);
934
935 // Store the latest window dimensions.
936 SaveWindowDimensions();
937
938 // Store the latest tab
939 pConfig->Write(wxT("CurrentPageV2"), m_pNotebook->GetSelection());
940
941 //
942 // Save Page(s) State
943 //
944
945 // Convert to a zero based index
946 iItemCount = (int)m_pNotebook->GetPageCount() - 1;
947
948 for (iIndex = 0; iIndex <= iItemCount; iIndex++) {
949 pwndNotebookPage = m_pNotebook->GetPage(iIndex);
950 wxASSERT(wxDynamicCast(pwndNotebookPage, CBOINCBaseView));
951
952 pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
953 wxASSERT(pView);
954
955 strPreviousLocation = pConfig->GetPath();
956 strConfigLocation = strPreviousLocation + pView->GetViewName();
957
958 pConfig->SetPath(strConfigLocation);
959 pView->FireOnSaveState(pConfig);
960 pConfig->SetPath(strPreviousLocation);
961 }
962
963 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::SaveState - Function End"));
964 return true;
965 }
966
967
RestoreState()968 bool CAdvancedFrame::RestoreState() {
969 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::RestoreState - Function Begin"));
970
971 wxString strBaseConfigLocation = wxString(wxT("/"));
972 wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
973 wxWindow* pwndNotebookPage = NULL;
974 CBOINCBaseView* pView = NULL;
975 wxString strConfigLocation;
976 wxString strPreviousLocation;
977 long iIndex;
978 long iPageCount;
979 long iCurrentPage;
980
981
982 wxASSERT(pConfig);
983 wxASSERT(m_pNotebook);
984
985
986 CBOINCBaseFrame::RestoreState();
987
988
989 // An odd case happens every once and awhile where wxWidgets looses
990 // the pointer to the config object, or it is cleaned up before
991 // the window has finished it's cleanup duty. If we detect a NULL
992 // pointer, return false.
993 if (!pConfig) return false;
994
995 //
996 // Restore Frame State
997 //
998 pConfig->SetPath(strBaseConfigLocation);
999
1000 if (wxGetApp().GetSkinManager()->GetAdvanced()->GetDefaultTab()) {
1001 m_pNotebook->SetSelection(wxGetApp().GetSkinManager()->GetAdvanced()->GetDefaultTab());
1002 } else {
1003 pConfig->Read(wxT("CurrentPageV2"), &iCurrentPage, (ID_ADVNOTICESVIEW - ID_ADVVIEWBASE));
1004 m_pNotebook->SetSelection(iCurrentPage);
1005 }
1006
1007 //
1008 // Restore Page(s) State
1009 //
1010
1011 // Convert to a zero based index
1012 iPageCount = (long)m_pNotebook->GetPageCount() - 1;
1013
1014 for (iIndex = 0; iIndex <= iPageCount; iIndex++) {
1015
1016 pwndNotebookPage = m_pNotebook->GetPage(iIndex);
1017 wxASSERT(wxDynamicCast(pwndNotebookPage, CBOINCBaseView));
1018
1019 pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
1020 wxASSERT(pView);
1021
1022 strPreviousLocation = pConfig->GetPath();
1023 strConfigLocation = strPreviousLocation + pView->GetViewName();
1024
1025 pConfig->SetPath(strConfigLocation);
1026 pView->FireOnRestoreState(pConfig);
1027 pConfig->SetPath(strPreviousLocation);
1028
1029 }
1030
1031 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::RestoreState - Function End"));
1032 return true;
1033 }
1034
1035
SaveWindowDimensions()1036 void CAdvancedFrame::SaveWindowDimensions() {
1037 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::SaveWindowDimensions - Function Begin"));
1038
1039 wxString strBaseConfigLocation = wxString(wxT("/"));
1040 wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
1041 wxPoint pos = GetPosition();
1042
1043 wxASSERT(pConfig);
1044
1045 pConfig->SetPath(strBaseConfigLocation);
1046
1047 bool iconized = IsIconized();
1048 pConfig->Write(wxT("WindowIconized"), iconized);
1049 pConfig->Write(wxT("WindowMaximized"), IsMaximized());
1050 if (!iconized) {
1051 pConfig->Write(wxT("Width"), GetSize().GetWidth());
1052 pConfig->Write(wxT("Height"), GetSize().GetHeight());
1053 pConfig->Write(wxT("XPos"), pos.x);
1054 pConfig->Write(wxT("YPos"), pos.y);
1055 }
1056
1057 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::SaveWindowDimensions - Function End"));
1058 }
1059
1060
OnSize(wxSizeEvent & event)1061 void CAdvancedFrame::OnSize(wxSizeEvent& event) {
1062 SaveWindowDimensions();
1063 event.Skip();
1064 }
1065
1066
OnMove(wxMoveEvent & event)1067 void CAdvancedFrame::OnMove(wxMoveEvent& event) {
1068 SaveWindowDimensions();
1069 event.Skip();
1070 }
1071
1072
_GetCurrentViewPage()1073 int CAdvancedFrame::_GetCurrentViewPage() {
1074
1075 wxWindow* pwndNotebookPage = NULL;
1076 CBOINCBaseView* pView = NULL;
1077
1078 wxASSERT(m_pNotebook);
1079
1080 pwndNotebookPage = m_pNotebook->GetPage(m_pNotebook->GetSelection());
1081 wxASSERT(pwndNotebookPage);
1082
1083 pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
1084 wxASSERT(pView);
1085
1086 return pView->GetViewCurrentViewPage();
1087 }
1088
1089
OnMenuOpening(wxMenuEvent & event)1090 void CAdvancedFrame::OnMenuOpening( wxMenuEvent &event) {
1091 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnMenuOpening - Function Begin"));
1092
1093 CMainDocument* pDoc = wxGetApp().GetDocument();
1094 wxMenu* menuFile = NULL;
1095 wxMenu* menuHelp = NULL;
1096
1097 wxASSERT(pDoc);
1098
1099 bool isConnected = pDoc->IsConnected();
1100 wxMenu* menu = event.GetMenu();
1101
1102 menu->FindItem(ID_SELECTCOMPUTER, &menuFile);
1103 menu->FindItem(ID_HELPBOINC, &menuHelp);
1104 size_t numItems = menu->GetMenuItemCount();
1105 for (size_t pos = 0; pos < numItems; ++pos) {
1106 wxMenuItem * item = menu->FindItemByPosition(pos);
1107 if ((menu == menuFile) || (menu == menuHelp)) {
1108 // Always enable all items in File menu or Help menu:
1109 // ID_LAUNCHNEWINSTANCE, ID_SELECTCOMPUTER, ID_SHUTDOWNCORECLIENT,
1110 // ID_CLOSEWINDOW, wxID_EXIT, ID_HELPBOINC, ID_HELPBOINCMANAGER,
1111 // ID_HELPBOINCWEBSITE, wxID_ABOUT
1112 item->Enable(true);
1113 } else {
1114 // Disable other menu items if not connected to client
1115 item->Enable(isConnected);
1116 }
1117 }
1118
1119 // wxID_EXIT and wxID_PREFERENCES are not in File menu on some platforms
1120 wxMenuItem* exitItem = menu->FindChildItem(wxID_EXIT, NULL);
1121 if (exitItem) {
1122 exitItem->Enable(true);
1123 }
1124
1125 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnMenuOpening - Function End"));
1126 }
1127
1128
OnChangeView(wxCommandEvent & event)1129 void CAdvancedFrame::OnChangeView(wxCommandEvent& event) {
1130 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnChangeView - Function Begin"));
1131
1132 m_pNotebook->SetSelection(event.GetId() - ID_ADVVIEWBASE);
1133
1134 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnChangeView - Function End"));
1135 }
1136
1137
OnChangeGUI(wxCommandEvent & WXUNUSED (event))1138 void CAdvancedFrame::OnChangeGUI(wxCommandEvent& WXUNUSED(event)) {
1139 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnChangeGUI - Function Begin"));
1140
1141 wxGetApp().SetActiveGUI(BOINC_SIMPLEGUI, true);
1142
1143 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnChangeGUI - Function End"));
1144 }
1145
1146
OnWizardAttachProject(wxCommandEvent & WXUNUSED (event))1147 void CAdvancedFrame::OnWizardAttachProject( wxCommandEvent& WXUNUSED(event) ) {
1148 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnWizardAttachProject - Function Begin"));
1149
1150 CMainDocument* pDoc = wxGetApp().GetDocument();
1151
1152 wxASSERT(pDoc);
1153 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1154
1155 if (!pDoc->IsUserAuthorized()) {
1156 return;
1157 }
1158
1159 if (pDoc->IsConnected()) {
1160
1161 // Stop all timers so that the wizard is the only thing doing anything
1162 StopTimers();
1163
1164 CWizardAttach* pWizard = new CWizardAttach(this);
1165
1166 pWizard->Run(
1167 wxEmptyString,
1168 wxEmptyString,
1169 wxEmptyString,
1170 wxEmptyString,
1171 wxEmptyString,
1172 wxEmptyString,
1173 wxEmptyString,
1174 false,
1175 false
1176 );
1177
1178 if (pWizard) {
1179 pWizard->Destroy();
1180 }
1181
1182 DeleteMenu();
1183 CreateMenu();
1184
1185 // Restart timers to continue normal operations.
1186 StartTimers();
1187
1188 pDoc->ForceCacheUpdate();
1189 FireRefreshView();
1190 } else {
1191 ShowNotCurrentlyConnectedAlert();
1192 }
1193
1194 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnWizardAttachProject - Function End"));
1195 }
1196
1197
OnWizardUpdate(wxCommandEvent & WXUNUSED (event))1198 void CAdvancedFrame::OnWizardUpdate(wxCommandEvent& WXUNUSED(event)) {
1199 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnWizardUpdate - Function Begin"));
1200
1201 CMainDocument* pDoc = wxGetApp().GetDocument();
1202
1203 wxASSERT(pDoc);
1204 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1205
1206 if (!pDoc->IsUserAuthorized())
1207 return;
1208
1209 if (pDoc->IsConnected()) {
1210 // Stop all timers so that the wizard is the only thing doing anything
1211 StopTimers();
1212
1213 CWizardAttach* pWizard = new CWizardAttach(this);
1214
1215 pWizard->SyncToAccountManager();
1216
1217 if (pWizard)
1218 pWizard->Destroy();
1219
1220 DeleteMenu();
1221 CreateMenu();
1222 pDoc->ForceCacheUpdate();
1223 FireRefreshView();
1224 ResetReminderTimers();
1225
1226 // Restart timers to continue normal operations.
1227 StartTimers();
1228 } else {
1229 ShowNotCurrentlyConnectedAlert();
1230 }
1231
1232 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnWizardUpdate - Function End"));
1233 }
1234
1235
OnWizardDetach(wxCommandEvent & WXUNUSED (event))1236 void CAdvancedFrame::OnWizardDetach(wxCommandEvent& WXUNUSED(event)) {
1237 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnWizardDetach - Function Begin"));
1238
1239 CMainDocument* pDoc = wxGetApp().GetDocument();
1240 CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
1241 wxInt32 iAnswer = 0;
1242 wxString strTitle = wxEmptyString;
1243 wxString strMessage = wxEmptyString;
1244 ACCT_MGR_INFO ami;
1245
1246 wxASSERT(pDoc);
1247 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1248 wxASSERT(pSkinAdvanced);
1249 wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
1250
1251 if (!pDoc->IsUserAuthorized())
1252 return;
1253
1254 if (pDoc->IsConnected()) {
1255
1256 pDoc->rpc.acct_mgr_info(ami);
1257
1258 strTitle.Printf(
1259 _("%s - Stop using %s"),
1260 pSkinAdvanced->GetApplicationName().c_str(),
1261 wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str()
1262 );
1263 strMessage.Printf(
1264 _("If you stop using %s,\nyou'll keep all your current projects,\nbut you'll have to manage projects manually.\n\nDo you want to stop using %s?"),
1265 wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str(),
1266 wxString(ami.acct_mgr_name.c_str(), wxConvUTF8).c_str()
1267 );
1268
1269 iAnswer = wxGetApp().SafeMessageBox(
1270 strMessage,
1271 strTitle,
1272 wxYES_NO | wxICON_QUESTION,
1273 this
1274 );
1275
1276 if (wxYES == iAnswer) {
1277 pDoc->rpc.acct_mgr_rpc("", "", "", false);
1278 }
1279
1280 DeleteMenu();
1281 CreateMenu();
1282 pDoc->ForceCacheUpdate();
1283 FireRefreshView();
1284
1285 } else {
1286 ShowNotCurrentlyConnectedAlert();
1287 }
1288
1289 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnWizardDetach - Function End"));
1290 }
1291
1292
OnActivitySelection(wxCommandEvent & event)1293 void CAdvancedFrame::OnActivitySelection(wxCommandEvent& event) {
1294 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnActivitySelection - Function Begin"));
1295
1296 CMainDocument* pDoc = wxGetApp().GetDocument();
1297
1298 wxASSERT(pDoc);
1299 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1300
1301 if (event.IsChecked()) {
1302 switch(event.GetId()) {
1303 case ID_ADVACTIVITYRUNALWAYS:
1304 pDoc->SetActivityRunMode(RUN_MODE_ALWAYS, 0);
1305 break;
1306 case ID_ADVACTIVITYSUSPEND:
1307 pDoc->SetActivityRunMode(RUN_MODE_NEVER, 0);
1308 break;
1309 case ID_ADVACTIVITYRUNBASEDONPREPERENCES:
1310 pDoc->SetActivityRunMode(RUN_MODE_AUTO, 0);
1311 break;
1312 }
1313 }
1314
1315 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnActivitySelection - Function End"));
1316 }
1317
OnGPUSelection(wxCommandEvent & event)1318 void CAdvancedFrame::OnGPUSelection(wxCommandEvent& event) {
1319 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnGPUSelection - Function Begin"));
1320
1321 CMainDocument* pDoc = wxGetApp().GetDocument();
1322
1323 wxASSERT(pDoc);
1324 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1325
1326 if (event.IsChecked()) {
1327 switch(event.GetId()) {
1328 case ID_ADVACTIVITYGPUALWAYS:
1329 pDoc->SetGPURunMode(RUN_MODE_ALWAYS, 0);
1330 break;
1331 case ID_ADVACTIVITYGPUSUSPEND:
1332 pDoc->SetGPURunMode(RUN_MODE_NEVER, 0);
1333 break;
1334 case ID_ADVACTIVITYGPUBASEDONPREPERENCES:
1335 pDoc->SetGPURunMode(RUN_MODE_AUTO, 0);
1336 break;
1337 }
1338 }
1339
1340 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnGPUSelection - Function End"));
1341 }
1342
1343
OnNetworkSelection(wxCommandEvent & event)1344 void CAdvancedFrame::OnNetworkSelection(wxCommandEvent& event) {
1345 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnNetworkSelection - Function Begin"));
1346
1347 CMainDocument* pDoc = wxGetApp().GetDocument();
1348
1349 wxASSERT(pDoc);
1350 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1351
1352 if (event.IsChecked()) {
1353 switch(event.GetId()) {
1354 case ID_ADVNETWORKRUNALWAYS:
1355 pDoc->SetNetworkRunMode(RUN_MODE_ALWAYS, 0);
1356 break;
1357 case ID_ADVNETWORKSUSPEND:
1358 pDoc->SetNetworkRunMode(RUN_MODE_NEVER, 0);
1359 break;
1360 case ID_ADVNETWORKRUNBASEDONPREPERENCES:
1361 pDoc->SetNetworkRunMode(RUN_MODE_AUTO, 0);
1362 break;
1363 }
1364 }
1365
1366 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnNetworkSelection - Function End"));
1367 }
1368
1369
OnOptions(wxCommandEvent & WXUNUSED (event))1370 void CAdvancedFrame::OnOptions(wxCommandEvent& WXUNUSED(event)) {
1371 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnOptions - Function Begin"));
1372
1373 CDlgOptions dlg(this);
1374 dlg.ShowModal();
1375
1376 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnOptions - Function End"));
1377 }
1378
1379
OnPreferences(wxCommandEvent & WXUNUSED (event))1380 void CAdvancedFrame::OnPreferences(wxCommandEvent& WXUNUSED(event)) {
1381 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnPreferences - Function Begin"));
1382
1383 CDlgAdvPreferences dlg(this);
1384 if (dlg.OKToShow()) {
1385 dlg.ShowModal();
1386 }
1387
1388 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnPreferences - Function End"));
1389 }
1390
1391
OnExclusiveApps(wxCommandEvent & WXUNUSED (event))1392 void CAdvancedFrame::OnExclusiveApps(wxCommandEvent& WXUNUSED(event)) {
1393 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnExclusiveApps - Function Begin"));
1394
1395 CDlgExclusiveApps dlg(this);
1396 dlg.ShowModal();
1397
1398 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnExclusiveApps - Function End"));
1399 }
1400
1401
OnDiagnosticLogFlags(wxCommandEvent & WXUNUSED (event))1402 void CAdvancedFrame::OnDiagnosticLogFlags(wxCommandEvent& WXUNUSED(event)) {
1403 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnDiagnosticLogFlags - Function Begin"));
1404
1405 CDlgDiagnosticLogFlags dlg(this);
1406 dlg.ShowModal();
1407
1408 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnDiagnosticLogFlags - Function End"));
1409 }
1410
1411
OnSelectColumns(wxCommandEvent & WXUNUSED (event))1412 void CAdvancedFrame::OnSelectColumns(wxCommandEvent& WXUNUSED(event)) {
1413 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnSelectColumns - Function Begin"));
1414
1415 CDlgHiddenColumns dlg(this);
1416 dlg.ShowModal();
1417
1418 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnSelectColumns - Function End"));
1419 }
1420
1421
OnSelectComputer(wxCommandEvent & WXUNUSED (event))1422 void CAdvancedFrame::OnSelectComputer(wxCommandEvent& WXUNUSED(event)) {
1423 wxString hostName = wxEmptyString;
1424 int portNum = GUI_RPC_PORT;
1425 wxString password = wxEmptyString;
1426 CMainDocument* pDoc = wxGetApp().GetDocument();
1427 long lRetVal = -1;
1428 bool bRetrievePasswordFromFile = FALSE;
1429
1430 wxASSERT(pDoc);
1431 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1432
1433 if (SelectComputer(hostName, portNum, password, false)) {
1434 // possibly read password from file if local computername AND no password was entered
1435 if (pDoc->IsComputerNameLocal(hostName) && password == wxEmptyString) {
1436 hostName = wxT("localhost");
1437 bRetrievePasswordFromFile = TRUE;
1438 }
1439 // Connect to the specified host
1440 lRetVal = pDoc->Connect(
1441 hostName.c_str(),
1442 portNum,
1443 password.c_str(),
1444 TRUE,
1445 bRetrievePasswordFromFile
1446 );
1447
1448 if (lRetVal) {
1449 ShowConnectionFailedAlert();
1450 }
1451 }
1452 }
1453
1454
OnClientShutdown(wxCommandEvent & WXUNUSED (event))1455 void CAdvancedFrame::OnClientShutdown(wxCommandEvent& WXUNUSED(event)) {
1456 wxCommandEvent evtSelectNewComputer(wxEVT_COMMAND_MENU_SELECTED, ID_SELECTCOMPUTER);
1457 CMainDocument* pDoc = wxGetApp().GetDocument();
1458 CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
1459 int showDialog = wxGetApp().GetBOINCMGRDisplayShutdownConnectedClientMessage();
1460 CDlgGenericMessage dlg(this);
1461 wxString strDialogTitle = wxEmptyString;
1462 wxString strDialogMessage = wxEmptyString;
1463
1464 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnClientShutdown - Function Begin"));
1465
1466 wxASSERT(pDoc);
1467 wxASSERT(pSkinAdvanced);
1468 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1469 wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
1470
1471 // Stop all timers
1472 StopTimers();
1473
1474 if (showDialog) {
1475 // %s is the application name
1476 // i.e. 'BOINC Manager', 'GridRepublic Manager'
1477 strDialogTitle.Printf(
1478 _("%s - Shut down the current client..."),
1479 pSkinAdvanced->GetApplicationName().c_str()
1480 );
1481
1482 // 1st %s is the application name
1483 // i.e. 'BOINC Manager', 'GridRepublic Manager'
1484 // 2nd %s is the project name
1485 // i.e. 'BOINC', 'GridRepublic'
1486 strDialogMessage.Printf(
1487 _("%s will shut down the current client\nand prompt you for another host to connect to."),
1488 pSkinAdvanced->GetApplicationName().c_str()
1489 );
1490
1491 dlg.SetTitle(strDialogTitle);
1492 dlg.m_DialogMessage->SetLabel(strDialogMessage);
1493 dlg.Fit();
1494 dlg.Centre();
1495 }
1496
1497 if (!showDialog || wxID_OK == dlg.ShowModal()) {
1498 wxGetApp().SetBOINCMGRDisplayShutdownConnectedClientMessage(!dlg.m_DialogDisableMessage->GetValue());
1499 pDoc->CoreClientQuit();
1500 pDoc->ForceDisconnect();
1501
1502 // Since the core cliet we were connected to just shutdown, prompt for a new one.
1503 ProcessEvent(evtSelectNewComputer);
1504 }
1505
1506
1507 // Restart timers
1508 StartTimers();
1509
1510 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnClientShutdown - Function End"));
1511 }
1512
1513
OnRunBenchmarks(wxCommandEvent & WXUNUSED (event))1514 void CAdvancedFrame::OnRunBenchmarks(wxCommandEvent& WXUNUSED(event)) {
1515 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRunBenchmarks - Function Begin"));
1516
1517 CMainDocument* pDoc = wxGetApp().GetDocument();
1518 wxASSERT(pDoc);
1519 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1520
1521 pDoc->RunBenchmarks();
1522
1523 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRunBenchmarks - Function End"));
1524 }
1525
1526
OnRetryCommunications(wxCommandEvent & WXUNUSED (event))1527 void CAdvancedFrame::OnRetryCommunications( wxCommandEvent& WXUNUSED(event) ) {
1528 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRetryCommunications - Function Begin"));
1529
1530 CMainDocument* pDoc = wxGetApp().GetDocument();
1531 wxASSERT(pDoc);
1532 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1533
1534 pDoc->rpc.network_available();
1535
1536 FireRefreshView();
1537
1538 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRetryCommunications - Function End"));
1539 }
1540
1541
OnReadConfig(wxCommandEvent & WXUNUSED (event))1542 void CAdvancedFrame::OnReadConfig(wxCommandEvent& WXUNUSED(event)) {
1543 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnReadConfig - Function Begin"));
1544
1545 CMainDocument* pDoc = wxGetApp().GetDocument();
1546
1547 wxASSERT(pDoc);
1548 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1549
1550 pDoc->rpc.read_cc_config();
1551
1552 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnReadConfig - Function End"));
1553 }
1554
1555
OnReadPreferences(wxCommandEvent & WXUNUSED (event))1556 void CAdvancedFrame::OnReadPreferences(wxCommandEvent& WXUNUSED(event)) {
1557 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnReadPreferences - Function Begin"));
1558
1559 CMainDocument* pDoc = wxGetApp().GetDocument();
1560
1561 wxASSERT(pDoc);
1562 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1563
1564 pDoc->rpc.read_global_prefs_override();
1565
1566 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnReadPreferences - Function End"));
1567 }
1568
1569
OnEventLog(wxCommandEvent & WXUNUSED (event))1570 void CAdvancedFrame::OnEventLog(wxCommandEvent& WXUNUSED(event)) {
1571 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnEventLog - Function Begin"));
1572
1573 wxGetApp().DisplayEventLog();
1574
1575 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnEventLog - Function End"));
1576 }
1577
1578
OnLaunchNewInstance(wxCommandEvent & WXUNUSED (event))1579 void CAdvancedFrame::OnLaunchNewInstance(wxCommandEvent& WXUNUSED(event)) {
1580 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnLaunchNewInstance - Function Begin"));
1581
1582 #ifndef __WXMAC__
1583 #ifdef __WXMSW__
1584 HANDLE prog;
1585 #else
1586 int prog;
1587 #endif
1588 int argc = 2;
1589 char* const argv[3] = {
1590 const_cast<char *>("boincmgr"),
1591 const_cast<char *>("--multiple"),
1592 NULL
1593 };
1594
1595 wxString strExecutable = wxGetApp().GetRootDirectory() + wxGetApp().GetExecutableName();
1596
1597 run_program(
1598 wxGetApp().GetRootDirectory().mb_str(),
1599 strExecutable.mb_str(),
1600 argc,
1601 argv,
1602 2.0,
1603 prog
1604 );
1605 #else
1606 char s[MAXPATHLEN];
1607 char path[MAXPATHLEN];
1608
1609 getPathToThisApp(path, sizeof(path));
1610 snprintf(s, sizeof(s), "open -n \"%s\" --args --multiple", path);
1611 system(s);
1612 #endif
1613
1614 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnLaunchNewInstance - Function End"));
1615 }
1616
1617
OnHelp(wxHelpEvent & event)1618 void CAdvancedFrame::OnHelp(wxHelpEvent& event) {
1619 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnHelpBOINCManager - Function Begin"));
1620
1621 if (IsShown()) {
1622 wxString strURL = wxGetApp().GetSkinManager()->GetAdvanced()->GetOrganizationHelpUrl();
1623
1624 wxString wxurl;
1625 wxurl.Printf(
1626 wxT("%s?target=advanced&version=%s&controlid=%d"),
1627 strURL.c_str(),
1628 wxString(BOINC_VERSION_STRING, wxConvUTF8).c_str(),
1629 event.GetId()
1630 );
1631 wxLaunchDefaultBrowser(wxurl);
1632 }
1633
1634 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnHelpBOINCManager - Function End"));
1635 }
1636
1637
OnHelpBOINC(wxCommandEvent & event)1638 void CAdvancedFrame::OnHelpBOINC(wxCommandEvent& event) {
1639 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnHelpBOINC - Function Begin"));
1640
1641 if (IsShown()) {
1642 wxString strURL = wxGetApp().GetSkinManager()->GetAdvanced()->GetOrganizationHelpUrl();
1643
1644 wxString wxurl;
1645 wxurl.Printf(
1646 wxT("%s?target=advanced&version=%s&controlid=%d"),
1647 strURL.c_str(),
1648 wxString(BOINC_VERSION_STRING, wxConvUTF8).c_str(),
1649 event.GetId()
1650 );
1651 wxLaunchDefaultBrowser(wxurl);
1652 }
1653
1654 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnHelpBOINC - Function End"));
1655 }
1656
1657
OnHelpAbout(wxCommandEvent & WXUNUSED (event))1658 void CAdvancedFrame::OnHelpAbout(wxCommandEvent& WXUNUSED(event)) {
1659 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnHelpAbout - Function Begin"));
1660
1661 CDlgAbout dlg(this);
1662 wxGetApp().SetAboutDialogIsOpen(true);
1663 dlg.ShowModal();
1664 wxGetApp().SetAboutDialogIsOpen(false);
1665
1666 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnHelpAbout - Function End"));
1667 }
1668
OnCheckVersion(wxCommandEvent & WXUNUSED (event))1669 void CAdvancedFrame::OnCheckVersion(wxCommandEvent& WXUNUSED(event)) {
1670 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnCheckVersion - Function Begin"));
1671
1672 wxGetApp().GetDocument()->CheckForVersionUpdate(true);
1673
1674 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnCheckVersion - Function End"));
1675 }
1676
OnRefreshView(CFrameEvent & WXUNUSED (event))1677 void CAdvancedFrame::OnRefreshView(CFrameEvent& WXUNUSED(event)) {
1678 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRefreshView - Function Begin"));
1679
1680 if (IsShown()) {
1681 CMainDocument* pDoc = wxGetApp().GetDocument();
1682 CBOINCBaseView* pView = NULL;
1683 wxTimerEvent timerEvent;
1684 wxString strTabTitle = wxEmptyString;
1685 int iCount = 0;
1686 static int iLastCount = 0;
1687
1688 wxASSERT(m_pNotebook);
1689 wxASSERT(pDoc);
1690 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1691
1692 // Force update the notice tab text
1693 pView = wxDynamicCast(m_pNotebook->GetPage(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE), CBOINCBaseView);
1694 iCount = pDoc->GetUnreadNoticeCount();
1695 if (iLastCount != iCount) {
1696 iLastCount = iCount;
1697
1698 if (iCount) {
1699 strTabTitle.Printf(wxT("%s (%d)"), pView->GetViewDisplayName().c_str(), iCount);
1700 } else {
1701 strTabTitle = pView->GetViewDisplayName();
1702 }
1703
1704 size_t noticesPage = ID_ADVNOTICESVIEW - ID_ADVVIEWBASE;
1705 m_pNotebook->SetPageText(noticesPage, strTabTitle);
1706 m_pNotebook->Layout();
1707 #ifdef __WXMSW__
1708 // Ugly hack to work around a bug in wxWidgets 3.0
1709 // which fails to center the updated tab label text.
1710 m_pNotebook->Freeze();
1711 if (m_pNotebook->GetSelection() == (int)noticesPage) {
1712 size_t projectsPage = ID_ADVPROJECTSVIEW - ID_ADVVIEWBASE;
1713 wxWindow * thePage = m_pNotebook->GetPage(projectsPage);
1714 strTabTitle = m_pNotebook->GetPageText(projectsPage);
1715 m_pNotebook->RemovePage(projectsPage);
1716 m_pNotebook->InsertPage(projectsPage, thePage, strTabTitle, false, projectsPage);
1717 } else {
1718 wxWindow * thePage = m_pNotebook->GetPage(noticesPage);
1719 m_pNotebook->RemovePage(noticesPage);
1720 m_pNotebook->InsertPage(noticesPage, thePage, strTabTitle, false, noticesPage);
1721 }
1722 m_pNotebook->Thaw();
1723 #endif
1724 }
1725
1726
1727 // Update current tab contents
1728 pView = wxDynamicCast(m_pNotebook->GetPage(m_pNotebook->GetSelection()), CBOINCBaseView);
1729 pView->FireOnListRender(timerEvent);
1730 }
1731
1732 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRefreshView - Function End"));
1733 }
1734
1735
OnConnect(CFrameEvent & WXUNUSED (event))1736 void CAdvancedFrame::OnConnect(CFrameEvent& WXUNUSED(event)) {
1737 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnConnect - Function Begin"));
1738
1739 CMainDocument* pDoc = wxGetApp().GetDocument();
1740 CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
1741 CWizardAttach* pWizard = NULL;
1742 wxString strComputer = wxEmptyString;
1743 wxString strDialogTitle = wxEmptyString;
1744 wxString strDialogDescription = wxEmptyString;
1745 std::string strProjectName;
1746 std::string strProjectURL;
1747 std::string strProjectAuthenticator;
1748 std::string strProjectInstitution;
1749 std::string strProjectDescription;
1750 std::string strProjectKnown;
1751 std::string strProjectSetupCookie;
1752 bool bAccountKeyDetected = false;
1753 bool bEmbedded = false;
1754 ACCT_MGR_INFO ami;
1755 PROJECT_INIT_STATUS pis;
1756 CC_STATUS status;
1757 wxWindow* pwndNotebookPage = NULL;
1758 CBOINCBaseView* pView = NULL;
1759 int iItemCount = 0, iIndex;
1760 int wasShown = 0;
1761 int wasVisible = 0;
1762
1763 wxASSERT(m_pNotebook);
1764 wxASSERT(pDoc);
1765 wxASSERT(pSkinAdvanced);
1766 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1767 wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
1768
1769 pDoc->GetCoreClientStatus(status, true);
1770
1771 // Do we need to bug out to the simple view?
1772 if (status.simple_gui_only) {
1773 wxGetApp().SetActiveGUI(BOINC_SIMPLEGUI, true);
1774 StartTimers();
1775 FireConnect();
1776 return;
1777 }
1778
1779
1780 // Stop all timers so that the wizard is the only thing doing anything
1781 StopTimers();
1782
1783
1784 // If we are connected to the localhost, run a really quick screensaver
1785 // test to trigger a firewall popup.
1786 pDoc->GetConnectedComputerName(strComputer);
1787 if (pDoc->IsComputerNameLocal(strComputer)) {
1788 wxGetApp().StartBOINCScreensaverTest();
1789 wxGetApp().StartBOINCDefaultScreensaverTest();
1790 }
1791
1792 // Clear selected rows in all tab pages when connecting to a different host
1793 iItemCount = (int)m_pNotebook->GetPageCount() - 1;
1794 for (iIndex = 0; iIndex <= iItemCount; iIndex++) {
1795 pwndNotebookPage = m_pNotebook->GetPage(iIndex);
1796 wxASSERT(wxDynamicCast(pwndNotebookPage, CBOINCBaseView));
1797
1798 pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
1799 wxASSERT(pView);
1800
1801 pView->ClearSelections();
1802 }
1803
1804 pDoc->RefreshRPCs();
1805 pDoc->ForceCacheUpdate();
1806
1807 pDoc->rpc.get_project_init_status(pis);
1808 pDoc->rpc.acct_mgr_info(ami);
1809
1810 if (ami.acct_mgr_url.size() && ami.have_credentials) {
1811 // Fall through
1812 //
1813 // There isn't a need to bring up the attach wizard, the client will
1814 // take care of attaching to projects when it completes the needed RPCs
1815 //
1816 } else if (ami.acct_mgr_url.size() && !ami.have_credentials) {
1817 wasShown = IsShown();
1818 Show();
1819 wasVisible = wxGetApp().IsApplicationVisible();
1820 if (!wasVisible) {
1821 wxGetApp().ShowApplication(true);
1822 }
1823
1824 pWizard = new CWizardAttach(this);
1825 if (pWizard->SyncToAccountManager()) {
1826
1827 // _GRIDREPUBLIC, _PROGRESSTHRUPROCESSORS and _CHARITYENGINE
1828 // are defined for those branded builds on Windows only
1829 #if defined(_GRIDREPUBLIC) || defined(_PROGRESSTHRUPROCESSORS) || defined(_CHARITYENGINE) || defined(__WXMAC__)
1830 #ifdef __WXMAC__
1831 // For GridRepublic, Charity Engine or ProgressThruProcessors,
1832 // the Mac installer put a branding file in our data directory
1833 long iBrandID = 0; // 0 is unbranded (default) BOINC
1834
1835 FILE *f = boinc_fopen("/Library/Application Support/BOINC Data/Branding", "r");
1836 if (f) {
1837 fscanf(f, "BrandId=%ld\n", &iBrandID);
1838 fclose(f);
1839 }
1840 if ((iBrandID > 0) && (iBrandID < 4))
1841 #endif
1842 {
1843 // If successful, hide the main window if we showed it
1844 if (!wasVisible) {
1845 wxGetApp().ShowApplication(false);
1846 }
1847 #ifndef __WXMAC__ // See comment in CBOINCGUIApp::OnFinishInit()
1848 if (!wasShown) {
1849 Hide();
1850 }
1851 #endif
1852 }
1853 #endif
1854
1855 // %s is the application name
1856 // i.e. 'BOINC Manager', 'GridRepublic Manager'
1857 strDialogTitle.Printf(
1858 _("%s"),
1859 pSkinAdvanced->GetApplicationName().c_str()
1860 );
1861
1862 // %s is the application name
1863 // i.e. 'BOINC Manager', 'GridRepublic Manager'
1864 // %s is the project name
1865 // i.e. 'BOINC', 'GridRepublic'
1866 strDialogDescription.Printf(
1867 _("%s has successfully added %s"),
1868 pSkinAdvanced->GetApplicationName().c_str(),
1869 pSkinAdvanced->GetApplicationShortName().c_str()
1870 );
1871
1872 ShowAlert(
1873 strDialogTitle,
1874 strDialogDescription,
1875 wxOK | wxICON_INFORMATION,
1876 true
1877 );
1878 } else {
1879 // If failure, display the notification tab
1880 m_pNotebook->SetSelection(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE);
1881 }
1882 } else if ((0 >= pDoc->GetProjectCount()) && !status.disallow_attach) {
1883 if (pis.url.size() > 0) {
1884
1885 strProjectName = pis.name.c_str();
1886 strProjectURL = pis.url.c_str();
1887 strProjectSetupCookie = pis.setup_cookie.c_str();
1888 bAccountKeyDetected = pis.has_account_key;
1889 bEmbedded = pis.embedded;
1890
1891 // If credentials are not cached, then we should try one last place to look up the
1892 // authenticator. Some projects will set a "Setup" cookie off of their URL with a
1893 // pretty short timeout. Lets take a crack at detecting it.
1894 //
1895 if (pis.url.length() && !pis.has_account_key) {
1896 detect_setup_authenticator(pis.url, strProjectAuthenticator);
1897 }
1898
1899 } else {
1900 detect_simple_account_credentials(
1901 strProjectName, strProjectURL, strProjectAuthenticator, strProjectInstitution, strProjectDescription, strProjectKnown
1902 );
1903 }
1904
1905 Show();
1906 wxGetApp().ShowApplication(true);
1907 pWizard = new CWizardAttach(this);
1908
1909 if (pWizard->Run(
1910 wxURI::Unescape(strProjectName),
1911 wxURI::Unescape(strProjectURL),
1912 wxURI::Unescape(strProjectAuthenticator),
1913 wxURI::Unescape(strProjectInstitution),
1914 wxURI::Unescape(strProjectDescription),
1915 wxURI::Unescape(strProjectKnown),
1916 wxURI::Unescape(strProjectSetupCookie),
1917 bAccountKeyDetected,
1918 bEmbedded)
1919 ){
1920 // If successful, display the work tab
1921 m_pNotebook->SetSelection(ID_ADVTASKSVIEW - ID_ADVVIEWBASE);
1922 } else {
1923 // If failure, display the notices tab
1924 m_pNotebook->SetSelection(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE);
1925 }
1926 }
1927
1928 // Update the menus
1929 DeleteMenu();
1930 CreateMenu();
1931
1932 // Restart timers to continue normal operations.
1933 StartTimers();
1934
1935
1936 // Set the correct refresh interval, then manually fire the refresh
1937 // event to do the initial population of the view.
1938 UpdateRefreshTimerInterval(m_pNotebook->GetSelection());
1939 FireRefreshView();
1940
1941
1942 if (pWizard)
1943 pWizard->Destroy();
1944
1945 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnConnect - Function End"));
1946 }
1947
1948
OnNotification(CFrameEvent & WXUNUSED (event))1949 void CAdvancedFrame::OnNotification(CFrameEvent& WXUNUSED(event)) {
1950 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnNotification - Function Begin"));
1951
1952 m_pNotebook->SetSelection(ID_ADVNOTICESVIEW - ID_ADVVIEWBASE);
1953
1954 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnNotification - Function End"));
1955 }
1956
1957
OnRefreshState(wxTimerEvent & WXUNUSED (event))1958 void CAdvancedFrame::OnRefreshState(wxTimerEvent& WXUNUSED(event)) {
1959 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRefreshState - Function Begin"));
1960
1961 // Write a snapshot of the current state to the config
1962 // module, on Win9x systems we don't always shutdown
1963 // in a nice way, if we are terminated by the user
1964 // we still want the UI state to have been stored
1965 // for their next use
1966 SaveState();
1967
1968 wxConfigBase::Get(FALSE)->Flush();
1969
1970 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnRefreshState - Function End"));
1971 }
1972
1973
OnFrameRender(wxTimerEvent & WXUNUSED (event))1974 void CAdvancedFrame::OnFrameRender(wxTimerEvent& WXUNUSED(event)) {
1975 CMainDocument* pDoc = wxGetApp().GetDocument();
1976 wxMenuBar* pMenuBar = GetMenuBar();
1977
1978 if (m_pFrameRenderTimer->IsRunning()) {
1979 if (IsShown()) {
1980 if (pDoc) {
1981 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
1982 wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
1983 wxASSERT(wxDynamicCast(m_pStatusbar, CStatusBar));
1984
1985 // Update the menu bar
1986 CC_STATUS status;
1987 if ((pDoc->IsConnected()) && (0 == pDoc->GetCoreClientStatus(status))) {
1988 UpdateActivityModeControls(status);
1989 if (pDoc->state.have_gpu()) {
1990 UpdateGPUModeControls(status);
1991 }
1992 UpdateNetworkModeControls(status);
1993
1994 if (status.disallow_attach) {
1995 pMenuBar->Enable(ID_WIZARDATTACHPROJECT, false);
1996 }
1997 }
1998
1999 // Update the statusbar
2000 if (pDoc->IsConnected() || pDoc->IsReconnecting()) {
2001 m_pStatusbar->m_pbmpConnected->Show();
2002 m_pStatusbar->m_ptxtConnected->Show();
2003 m_pStatusbar->m_pbmpDisconnect->Hide();
2004 m_pStatusbar->m_ptxtDisconnect->Hide();
2005
2006 wxString strComputerName = wxEmptyString;
2007 wxString strComputerVersion = wxEmptyString;
2008 wxString strStatusText = wxEmptyString;
2009 wxString strTitle = m_strBaseTitle;
2010
2011 if (pDoc->IsReconnecting()) {
2012 pDoc->GetConnectingComputerName(strComputerName);
2013 } else {
2014 pDoc->GetConnectedComputerName(strComputerName);
2015 pDoc->GetConnectedComputerVersion(strComputerVersion);
2016 }
2017
2018 if (pDoc->IsComputerNameLocal(strComputerName)) {
2019 strTitle.Printf(wxT("%s"), m_strBaseTitle.c_str());
2020 } else {
2021 strTitle.Printf(_("%s - (%s)"), m_strBaseTitle.c_str(), strComputerName.c_str());
2022 }
2023
2024 if (pDoc->IsReconnecting()) {
2025 strStatusText.Printf(_("Connecting to %s"), strComputerName.c_str());
2026 } else {
2027 strStatusText.Printf(
2028 _("Connected to %s (%s)"),
2029 strComputerName.c_str(),
2030 strComputerVersion.c_str()
2031 );
2032 }
2033
2034 // The Mac takes a huge performance hit redrawing this window,
2035 // window, so don't change the text unless we really have too.
2036 if (GetTitle() != strTitle) {
2037 SetTitle(strTitle);
2038 }
2039 if (m_pStatusbar->m_ptxtConnected->GetLabel() != strStatusText) {
2040 m_pStatusbar->m_ptxtConnected->SetLabel(strStatusText);
2041 }
2042 } else {
2043 m_pStatusbar->m_pbmpConnected->Hide();
2044 m_pStatusbar->m_ptxtConnected->Hide();
2045 m_pStatusbar->m_pbmpDisconnect->Show();
2046 m_pStatusbar->m_ptxtDisconnect->Show();
2047
2048 if (GetTitle() != m_strBaseTitle)
2049 SetTitle(m_strBaseTitle);
2050 }
2051 }
2052 }
2053 }
2054 }
2055
2056
OnNotebookSelectionChanged(wxNotebookEvent & event)2057 void CAdvancedFrame::OnNotebookSelectionChanged(wxNotebookEvent& event) {
2058 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnNotebookSelectionChanged - Function Begin"));
2059
2060 wxWindow* pwndNotebookPage = NULL;
2061 CBOINCBaseView* pView = NULL;
2062 int selection = event.GetSelection();
2063
2064 if ((-1 != selection)) {
2065 UpdateRefreshTimerInterval(selection);
2066
2067 CMainDocument* pDoc = wxGetApp().GetDocument();
2068 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
2069
2070 pDoc->RefreshRPCs();
2071 pDoc->RunPeriodicRPCs(0);
2072 }
2073
2074 pwndNotebookPage = m_pNotebook->GetPage(selection);
2075 wxASSERT(wxDynamicCast(pwndNotebookPage, CBOINCBaseView));
2076
2077 pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
2078 wxASSERT(pView);
2079
2080 pView->RefreshTaskPane();
2081 event.Skip();
2082
2083 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnNotebookSelectionChanged - Function End"));
2084 }
2085
2086
ResetReminderTimers()2087 void CAdvancedFrame::ResetReminderTimers() {
2088 #ifdef __WXMSW__
2089 wxASSERT(m_pDialupManager);
2090 wxASSERT(wxDynamicCast(m_pDialupManager, CBOINCDialUpManager));
2091
2092 m_pDialupManager->ResetReminderTimers();
2093 #endif
2094 }
2095
2096
UpdateActivityModeControls(CC_STATUS & status)2097 void CAdvancedFrame::UpdateActivityModeControls( CC_STATUS& status ) {
2098 wxMenuBar* pMenuBar = GetMenuBar();
2099 wxASSERT(pMenuBar);
2100 wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
2101
2102 if ((RUN_MODE_ALWAYS == status.task_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYRUNALWAYS)) return;
2103 if ((RUN_MODE_NEVER == status.task_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYSUSPEND)) return;
2104 if ((RUN_MODE_AUTO == status.task_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYRUNBASEDONPREPERENCES)) return;
2105
2106 if (RUN_MODE_ALWAYS == status.task_mode) {
2107 if (!pMenuBar->IsChecked(ID_ADVACTIVITYRUNALWAYS)) {
2108 pMenuBar->Check(ID_ADVACTIVITYRUNALWAYS, true);
2109 }
2110 if (pMenuBar->IsChecked(ID_ADVACTIVITYSUSPEND)) {
2111 pMenuBar->Check(ID_ADVACTIVITYSUSPEND, false);
2112 }
2113 if (pMenuBar->IsChecked(ID_ADVACTIVITYRUNBASEDONPREPERENCES)) {
2114 pMenuBar->Check(ID_ADVACTIVITYRUNBASEDONPREPERENCES, false);
2115 }
2116 }
2117 if (RUN_MODE_NEVER == status.task_mode) {
2118 if (!pMenuBar->IsChecked(ID_ADVACTIVITYSUSPEND)) {
2119 pMenuBar->Check(ID_ADVACTIVITYSUSPEND, true);
2120 }
2121 if (pMenuBar->IsChecked(ID_ADVACTIVITYRUNALWAYS)) {
2122 pMenuBar->Check(ID_ADVACTIVITYRUNALWAYS, false);
2123 }
2124 if (pMenuBar->IsChecked(ID_ADVACTIVITYRUNBASEDONPREPERENCES)) {
2125 pMenuBar->Check(ID_ADVACTIVITYRUNBASEDONPREPERENCES, false);
2126 }
2127 }
2128 if (RUN_MODE_AUTO == status.task_mode) {
2129 if (!pMenuBar->IsChecked(ID_ADVACTIVITYRUNBASEDONPREPERENCES)) {
2130 pMenuBar->Check(ID_ADVACTIVITYRUNBASEDONPREPERENCES, true);
2131 }
2132 if (pMenuBar->IsChecked(ID_ADVACTIVITYRUNALWAYS)) {
2133 pMenuBar->Check(ID_ADVACTIVITYRUNALWAYS, false);
2134 }
2135 if (pMenuBar->IsChecked(ID_ADVACTIVITYSUSPEND)) {
2136 pMenuBar->Check(ID_ADVACTIVITYSUSPEND, false);
2137 }
2138 }
2139 }
2140
UpdateGPUModeControls(CC_STATUS & status)2141 void CAdvancedFrame::UpdateGPUModeControls( CC_STATUS& status ) {
2142 wxMenuBar* pMenuBar = GetMenuBar();
2143 wxASSERT(pMenuBar);
2144 wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
2145
2146 // Prevent asserts on startup, the document hasn't been initialized
2147 // and so the flags used for determining the use of a GPU are initially
2148 // false. Later the document contains the latest information but the
2149 // menu hasn't been updated yet, an assert happens.
2150 if (!pMenuBar->FindItem(ID_ADVACTIVITYGPUALWAYS)) return;
2151 if (!pMenuBar->FindItem(ID_ADVACTIVITYGPUSUSPEND)) return;
2152 if (!pMenuBar->FindItem(ID_ADVACTIVITYGPUBASEDONPREPERENCES)) return;
2153
2154 if ((RUN_MODE_ALWAYS == status.gpu_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYGPUALWAYS)) return;
2155 if ((RUN_MODE_NEVER == status.gpu_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYGPUSUSPEND)) return;
2156 if ((RUN_MODE_AUTO == status.gpu_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYGPUBASEDONPREPERENCES)) return;
2157
2158 if (RUN_MODE_ALWAYS == status.gpu_mode) {
2159 if (!pMenuBar->IsChecked(ID_ADVACTIVITYGPUALWAYS)) {
2160 pMenuBar->Check(ID_ADVACTIVITYGPUALWAYS, true);
2161 }
2162 if (pMenuBar->IsChecked(ID_ADVACTIVITYGPUSUSPEND)) {
2163 pMenuBar->Check(ID_ADVACTIVITYGPUSUSPEND, false);
2164 }
2165 if (pMenuBar->IsChecked(ID_ADVACTIVITYGPUBASEDONPREPERENCES)) {
2166 pMenuBar->Check(ID_ADVACTIVITYGPUBASEDONPREPERENCES, false);
2167 }
2168 }
2169 if (RUN_MODE_NEVER == status.gpu_mode) {
2170 if (!pMenuBar->IsChecked(ID_ADVACTIVITYGPUSUSPEND)) {
2171 pMenuBar->Check(ID_ADVACTIVITYGPUSUSPEND, true);
2172 }
2173 if (pMenuBar->IsChecked(ID_ADVACTIVITYGPUALWAYS)) {
2174 pMenuBar->Check(ID_ADVACTIVITYGPUALWAYS, false);
2175 }
2176 if (pMenuBar->IsChecked(ID_ADVACTIVITYGPUBASEDONPREPERENCES)) {
2177 pMenuBar->Check(ID_ADVACTIVITYGPUBASEDONPREPERENCES, false);
2178 }
2179 }
2180 if (RUN_MODE_AUTO == status.gpu_mode) {
2181 if (!pMenuBar->IsChecked(ID_ADVACTIVITYGPUBASEDONPREPERENCES)) {
2182 pMenuBar->Check(ID_ADVACTIVITYGPUBASEDONPREPERENCES, true);
2183 }
2184 if (pMenuBar->IsChecked(ID_ADVACTIVITYGPUALWAYS)) {
2185 pMenuBar->Check(ID_ADVACTIVITYGPUALWAYS, false);
2186 }
2187 if (pMenuBar->IsChecked(ID_ADVACTIVITYGPUSUSPEND)) {
2188 pMenuBar->Check(ID_ADVACTIVITYGPUSUSPEND, false);
2189 }
2190 }
2191 }
2192
2193
UpdateNetworkModeControls(CC_STATUS & status)2194 void CAdvancedFrame::UpdateNetworkModeControls( CC_STATUS& status ) {
2195 wxMenuBar* pMenuBar = GetMenuBar();
2196 wxASSERT(pMenuBar);
2197 wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
2198
2199 if ((RUN_MODE_ALWAYS == status.network_mode) && pMenuBar->IsChecked(ID_ADVNETWORKRUNALWAYS)) return;
2200 if ((RUN_MODE_NEVER == status.network_mode) && pMenuBar->IsChecked(ID_ADVNETWORKSUSPEND)) return;
2201 if ((RUN_MODE_AUTO == status.network_mode) && pMenuBar->IsChecked(ID_ADVNETWORKRUNBASEDONPREPERENCES)) return;
2202
2203 if (RUN_MODE_ALWAYS == status.network_mode) {
2204 if (!pMenuBar->IsChecked(ID_ADVNETWORKRUNALWAYS)) {
2205 pMenuBar->Check(ID_ADVNETWORKRUNALWAYS, true);
2206 }
2207 if (pMenuBar->IsChecked(ID_ADVNETWORKSUSPEND)) {
2208 pMenuBar->Check(ID_ADVNETWORKSUSPEND, false);
2209 }
2210 if (pMenuBar->IsChecked(ID_ADVNETWORKRUNBASEDONPREPERENCES)) {
2211 pMenuBar->Check(ID_ADVNETWORKRUNBASEDONPREPERENCES, false);
2212 }
2213 }
2214 if (RUN_MODE_NEVER == status.network_mode) {
2215 if (!pMenuBar->IsChecked(ID_ADVNETWORKSUSPEND)) {
2216 pMenuBar->Check(ID_ADVNETWORKSUSPEND, true);
2217 }
2218 if (pMenuBar->IsChecked(ID_ADVNETWORKRUNALWAYS)) {
2219 pMenuBar->Check(ID_ADVNETWORKRUNALWAYS, false);
2220 }
2221 if (pMenuBar->IsChecked(ID_ADVNETWORKRUNBASEDONPREPERENCES)) {
2222 pMenuBar->Check(ID_ADVNETWORKRUNBASEDONPREPERENCES, false);
2223 }
2224 }
2225 if (RUN_MODE_AUTO == status.network_mode) {
2226 if (!pMenuBar->IsChecked(ID_ADVNETWORKRUNBASEDONPREPERENCES)) {
2227 pMenuBar->Check(ID_ADVNETWORKRUNBASEDONPREPERENCES, true);
2228 }
2229 if (pMenuBar->IsChecked(ID_ADVNETWORKRUNALWAYS)) {
2230 pMenuBar->Check(ID_ADVNETWORKRUNALWAYS, false);
2231 }
2232 if (pMenuBar->IsChecked(ID_ADVNETWORKSUSPEND)) {
2233 pMenuBar->Check(ID_ADVNETWORKSUSPEND, false);
2234 }
2235 }
2236 }
2237
2238
UpdateRefreshTimerInterval(wxInt32 iCurrentNotebookPage)2239 void CAdvancedFrame::UpdateRefreshTimerInterval( wxInt32 iCurrentNotebookPage ) {
2240 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::UpdateRefreshTimerInterval - Function Begin"));
2241
2242 if (IsShown()) {
2243 wxWindow* pwndNotebookPage = NULL;
2244 CBOINCBaseView* pView = NULL;
2245 CDlgEventLog* eventLog = wxGetApp().GetEventLog();
2246
2247 wxASSERT(m_pNotebook);
2248
2249 pwndNotebookPage = m_pNotebook->GetPage(iCurrentNotebookPage);
2250 wxASSERT(pwndNotebookPage);
2251
2252 pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
2253 wxASSERT(pView);
2254
2255 CMainDocument* pDoc = wxGetApp().GetDocument();
2256
2257 if (m_pPeriodicRPCTimer && m_pPeriodicRPCTimer->IsRunning()) {
2258 m_pPeriodicRPCTimer->Stop();
2259
2260 // View specific refresh rates only apply when a connection to the core
2261 // client has been established, otherwise the refresh rate should be 1
2262 // second.
2263 if (pDoc) {
2264 wxASSERT(wxDynamicCast(pDoc, CMainDocument));
2265 if (pDoc->IsConnected()) {
2266 // Set new view specific refresh rate
2267 m_iFrameRefreshRate = pView->GetViewRefreshRate() * 1000;
2268 if (eventLog) { // Update event log every second
2269 m_pPeriodicRPCTimer->Start(1000);
2270 } else {
2271 m_pPeriodicRPCTimer->Start(m_iFrameRefreshRate);
2272 }
2273 } else {
2274 // Set view refresh rate to 1 second
2275 m_iFrameRefreshRate = 1000;
2276 m_pPeriodicRPCTimer->Start(1000);
2277 }
2278 }
2279 }
2280 }
2281
2282 wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::UpdateRefreshTimerInterval - Function End"));
2283 }
2284
2285
UpdateRefreshTimerInterval()2286 void CAdvancedFrame::UpdateRefreshTimerInterval() {
2287 UpdateRefreshTimerInterval(m_pNotebook->GetSelection());
2288 }
2289
2290
StartTimers()2291 void CAdvancedFrame::StartTimers() {
2292 wxASSERT(m_pRefreshStateTimer);
2293 wxASSERT(m_pFrameRenderTimer);
2294 CBOINCBaseFrame::StartTimers();
2295 m_pRefreshStateTimer->Start();
2296 m_pFrameRenderTimer->Start();
2297 }
2298
2299
StopTimers()2300 void CAdvancedFrame::StopTimers() {
2301 wxASSERT(m_pRefreshStateTimer);
2302 wxASSERT(m_pFrameRenderTimer);
2303 CBOINCBaseFrame::StopTimers();
2304 m_pRefreshStateTimer->Stop();
2305 m_pFrameRenderTimer->Stop();
2306 }
2307
2308
2309 #ifdef __WXMAC__
2310 // Fix Keyboard navigation on Mac
OnKeyPressed(wxKeyEvent & event)2311 void CAdvancedFrame::OnKeyPressed(wxKeyEvent &event) {
2312 CBOINCBaseView* pView = wxDynamicCast(m_pNotebook->GetPage(m_pNotebook->GetSelection()), CBOINCBaseView);
2313 pView->OnKeyPressed(event);
2314 }
2315 #endif
2316