1
// Berkeley Open Infrastructure for Network Computing
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2005 University of California
5
// This is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation;
8
// either version 2.1 of the License, or (at your option) any later version.
10
// This software 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.
15
// To view the GNU Lesser General Public License visit
16
// http://www.gnu.org/copyleft/lesser.html
17
// or write to the Free Software Foundation, Inc.,
18
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
#if defined(__GNUG__) && !defined(__APPLE__)
22
#pragma implementation "ProjectPropertiesPage.h"
27
#include "diagnostics.h"
32
#include "error_numbers.h"
34
#include "error_numbers.h"
35
#include "BOINCGUIApp.h"
36
#include "SkinManager.h"
37
#include "MainDocument.h"
38
#include "BOINCWizards.h"
39
#include "BOINCBaseWizard.h"
40
#include "WizardAttachProject.h"
41
#include "ProjectPropertiesPage.h"
42
#include "ProjectInfoPage.h"
43
#include "CompletionErrorPage.h"
44
#include "TermsOfUsePage.h"
48
#include "res/wizprogress01.xpm"
49
#include "res/wizprogress02.xpm"
50
#include "res/wizprogress03.xpm"
51
#include "res/wizprogress04.xpm"
52
#include "res/wizprogress05.xpm"
53
#include "res/wizprogress06.xpm"
54
#include "res/wizprogress07.xpm"
55
#include "res/wizprogress08.xpm"
56
#include "res/wizprogress09.xpm"
57
#include "res/wizprogress10.xpm"
58
#include "res/wizprogress11.xpm"
59
#include "res/wizprogress12.xpm"
63
* CProjectPropertiesPage custom event definition
66
DEFINE_EVENT_TYPE(wxEVT_PROJECTPROPERTIES_STATECHANGE)
69
* CProjectPropertiesPage type definition
72
IMPLEMENT_DYNAMIC_CLASS( CProjectPropertiesPage, wxWizardPageEx )
75
* CProjectPropertiesPage event table definition
78
BEGIN_EVENT_TABLE( CProjectPropertiesPage, wxWizardPageEx )
80
EVT_PROJECTPROPERTIES_STATECHANGE( CProjectPropertiesPage::OnStateChange )
82
////@begin CProjectPropertiesPage event table entries
83
EVT_WIZARDEX_PAGE_CHANGED( -1, CProjectPropertiesPage::OnPageChanged )
84
EVT_WIZARDEX_CANCEL( -1, CProjectPropertiesPage::OnCancel )
86
////@end CProjectPropertiesPage event table entries
91
* CProjectPropertiesPage constructors
94
CProjectPropertiesPage::CProjectPropertiesPage( )
98
CProjectPropertiesPage::CProjectPropertiesPage( CBOINCBaseWizard* parent )
107
bool CProjectPropertiesPage::Create( CBOINCBaseWizard* parent )
109
////@begin CProjectPropertiesPage member initialisation
110
m_pTitleStaticCtrl = NULL;
111
m_pProgressIndicator = NULL;
112
////@end CProjectPropertiesPage member initialisation
114
m_bProjectPropertiesSucceeded = false;
115
m_bProjectPropertiesURLFailure = false;
116
m_bProjectAccountCreationDisabled = false;
117
m_bProjectClientAccountCreationDisabled = false;
118
m_bNetworkConnectionDetected = false;
119
m_bServerReportedError = false;
120
m_bTermsOfUseRequired = true;
122
m_iCurrentState = PROJPROP_INIT;
124
////@begin CProjectPropertiesPage creation
125
wxBitmap wizardBitmap(wxNullBitmap);
126
wxWizardPageEx::Create( parent, ID_PROJECTPROPERTIESPAGE, wizardBitmap );
129
GetSizer()->Fit(this);
130
////@end CProjectPropertiesPage creation
136
* Control creation for WizardPage
139
void CProjectPropertiesPage::CreateControls()
141
////@begin CProjectPropertiesPage content construction
142
CProjectPropertiesPage* itemWizardPage36 = this;
144
wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
145
itemWizardPage36->SetSizer(itemBoxSizer37);
147
m_pTitleStaticCtrl = new wxStaticText;
148
m_pTitleStaticCtrl->Create( itemWizardPage36, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
149
m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana")));
150
itemBoxSizer37->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
152
itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
154
wxFlexGridSizer* itemFlexGridSizer40 = new wxFlexGridSizer(1, 3, 0, 0);
155
itemFlexGridSizer40->AddGrowableRow(0);
156
itemFlexGridSizer40->AddGrowableCol(0);
157
itemFlexGridSizer40->AddGrowableCol(1);
158
itemFlexGridSizer40->AddGrowableCol(2);
159
itemBoxSizer37->Add(itemFlexGridSizer40, 0, wxGROW|wxALL, 5);
161
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
163
wxBitmap itemBitmap41(GetBitmapResource(wxT("res/wizprogress01.xpm")));
164
m_pProgressIndicator = new wxStaticBitmap;
165
m_pProgressIndicator->Create( itemWizardPage36, ID_PROGRESSCTRL, itemBitmap41, wxDefaultPosition, wxSize(184, 48), 0 );
166
itemFlexGridSizer40->Add(m_pProgressIndicator, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
168
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
169
////@end CProjectPropertiesPage content construction
173
* Gets the previous page.
176
wxWizardPageEx* CProjectPropertiesPage::GetPrev() const
178
return PAGE_TRANSITION_BACK;
182
* Gets the next page.
185
wxWizardPageEx* CProjectPropertiesPage::GetNext() const
187
if (CHECK_CLOSINGINPROGRESS()) {
188
// Cancel Event Detected
189
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
190
} else if (GetProjectPropertiesSucceeded() && GetProjectAlreadyAttached()) {
191
// Already attach to the project
192
return PAGE_TRANSITION_NEXT(ID_ERRALREADYATTACHEDPAGE);
193
} else if (GetProjectPropertiesSucceeded() && GetTermsOfUseRequired()) {
194
// Terms of Use are required before requesting account information
195
return PAGE_TRANSITION_NEXT(ID_TERMSOFUSEPAGE);
196
} else if (GetProjectPropertiesSucceeded()) {
197
// We were successful in retrieving the project properties
198
return PAGE_TRANSITION_NEXT(ID_ACCOUNTINFOPAGE);
199
} else if (GetProjectPropertiesURLFailure() && !GetNetworkConnectionDetected()) {
200
// No Internet Connection
201
return PAGE_TRANSITION_NEXT(ID_ERRPROXYINFOPAGE);
202
} else if (GetProjectPropertiesURLFailure()) {
203
// Not a BOINC based project
204
return PAGE_TRANSITION_NEXT(ID_ERRNOTDETECTEDPAGE);
205
} else if (GetServerReportedError()) {
206
// Server reported an error, display the error
207
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
209
// The project must be down for maintenance
210
return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
216
* Should we show tooltips?
219
bool CProjectPropertiesPage::ShowToolTips()
224
void CProjectPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
226
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
229
void CProjectPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
231
if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
234
str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
236
pBitmap->SetBitmap(GetBitmapResource(str));
240
void CProjectPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
242
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
246
* Get bitmap resources
249
wxBitmap CProjectPropertiesPage::GetBitmapResource( const wxString& name )
252
if (name == wxT("res/wizprogress01.xpm"))
254
wxBitmap bitmap(wizprogress01_xpm);
257
else if (name == wxT("res/wizprogress02.xpm"))
259
wxBitmap bitmap(wizprogress02_xpm);
262
else if (name == wxT("res/wizprogress03.xpm"))
264
wxBitmap bitmap(wizprogress03_xpm);
267
else if (name == wxT("res/wizprogress04.xpm"))
269
wxBitmap bitmap(wizprogress04_xpm);
272
else if (name == wxT("res/wizprogress05.xpm"))
274
wxBitmap bitmap(wizprogress05_xpm);
277
else if (name == wxT("res/wizprogress06.xpm"))
279
wxBitmap bitmap(wizprogress06_xpm);
282
else if (name == wxT("res/wizprogress07.xpm"))
284
wxBitmap bitmap(wizprogress07_xpm);
287
else if (name == wxT("res/wizprogress08.xpm"))
289
wxBitmap bitmap(wizprogress08_xpm);
292
else if (name == wxT("res/wizprogress09.xpm"))
294
wxBitmap bitmap(wizprogress09_xpm);
297
else if (name == wxT("res/wizprogress10.xpm"))
299
wxBitmap bitmap(wizprogress10_xpm);
302
else if (name == wxT("res/wizprogress11.xpm"))
304
wxBitmap bitmap(wizprogress11_xpm);
307
else if (name == wxT("res/wizprogress12.xpm"))
309
wxBitmap bitmap(wizprogress12_xpm);
319
wxIcon CProjectPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
322
////@begin CProjectPropertiesPage icon retrieval
324
////@end CProjectPropertiesPage icon retrieval
328
* wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
331
void CProjectPropertiesPage::OnPageChanged( wxWizardExEvent& event ) {
332
if (event.GetDirection() == false) return;
334
wxASSERT(m_pTitleStaticCtrl);
335
wxASSERT(m_pProgressIndicator);
337
m_pTitleStaticCtrl->SetLabel(
338
_("Communicating with project\nPlease wait...")
341
SetProjectPropertiesSucceeded(false);
342
SetProjectPropertiesURLFailure(false);
343
SetProjectAccountCreationDisabled(false);
344
SetProjectClientAccountCreationDisabled(false);
345
SetNetworkConnectionDetected(false);
346
SetNextState(PROJPROP_INIT);
348
CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
349
AddPendingEvent(TransitionEvent);
355
* wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
358
void CProjectPropertiesPage::OnCancel( wxWizardExEvent& event ) {
359
PROCESS_CANCELEVENT(event);
363
* wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
366
void CProjectPropertiesPage::OnStateChange( CProjectPropertiesPageEvent& WXUNUSED(event) )
368
CMainDocument* pDoc = wxGetApp().GetDocument();
369
CWizardAttachProject* pWAP = ((CWizardAttachProject*)GetParent());
370
PROJECT_CONFIG* pc = &((CWizardAttachProject*)GetParent())->project_config;
372
wxDateTime dtStartExecutionTime;
373
wxDateTime dtCurrentExecutionTime;
374
wxTimeSpan tsExecutionTime;
375
wxString strBuffer = wxEmptyString;
376
bool bPostNewEvent = true;
377
bool bSuccessfulCondition = false;
378
int iReturnValue = 0;
381
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
383
switch(GetCurrentState()) {
385
pWAP->DisableNextButton();
386
pWAP->DisableBackButton();
387
StartProgress(m_pProgressIndicator);
388
SetNextState(PROJPROP_RETRPROJECTPROPERTIES_BEGIN);
390
case PROJPROP_RETRPROJECTPROPERTIES_BEGIN:
391
SetNextState(PROJPROP_RETRPROJECTPROPERTIES_EXECUTE);
393
case PROJPROP_RETRPROJECTPROPERTIES_EXECUTE:
394
// Attempt to retrieve the project's account creation policies
395
pDoc->rpc.get_project_config(
396
(const char*)pWAP->m_ProjectInfoPage->GetProjectURL().mb_str()
399
// Wait until we are done processing the request.
400
dtStartExecutionTime = wxDateTime::Now();
401
dtCurrentExecutionTime = wxDateTime::Now();
402
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
405
pc->error_num = ERR_IN_PROGRESS;
406
while ((!iReturnValue && (ERR_IN_PROGRESS == pc->error_num)) &&
407
tsExecutionTime.GetSeconds() <= 60 &&
408
!CHECK_CLOSINGINPROGRESS()
411
dtCurrentExecutionTime = wxDateTime::Now();
412
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
413
iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
414
IncrementProgress(m_pProgressIndicator);
417
::wxSafeYield(GetParent());
420
// We either successfully retrieved the project's account creation
421
// policies or we were able to talk to the web server and found out
422
// they do not support account creation through the wizard. In either
423
// case we should claim success and set the correct flags to show the
424
// correct 'next' page.
425
bSuccessfulCondition =
426
(!iReturnValue) && (!pc->error_num) ||
427
(!iReturnValue) && (ERR_ACCT_CREATION_DISABLED == pc->error_num);
428
if (bSuccessfulCondition && !CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIES)) {
429
SetProjectPropertiesSucceeded(true);
431
bSuccessfulCondition = pc->account_creation_disabled;
432
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRACCOUNTCREATIONDISABLED)) {
433
SetProjectAccountCreationDisabled(true);
435
SetProjectAccountCreationDisabled(false);
438
bSuccessfulCondition =
439
(ERR_ALREADY_ATTACHED == pDoc->rpc.project_attach(
440
(const char*)pWAP->m_ProjectInfoPage->GetProjectURL().mb_str(),
443
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTALREADYATTACHED)) {
444
SetProjectAlreadyAttached(true);
446
SetProjectAlreadyAttached(false);
449
bSuccessfulCondition = pc->client_account_creation_disabled;
450
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRCLIENTACCOUNTCREATIONDISABLED)) {
451
SetProjectClientAccountCreationDisabled(true);
453
SetProjectClientAccountCreationDisabled(false);
456
bSuccessfulCondition = !pc->terms_of_use.empty();
457
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRTERMSOFUSEREQUIRED)) {
458
SetTermsOfUseRequired(true);
460
SetTermsOfUseRequired(false);
463
SetNextState(PROJPROP_CLEANUP);
465
SetProjectPropertiesSucceeded(false);
467
bSuccessfulCondition =
468
(!iReturnValue) && (ERR_FILE_NOT_FOUND == pc->error_num) ||
469
(!iReturnValue) && (ERR_GETHOSTBYNAME == pc->error_num) ||
470
(!iReturnValue) && (ERR_XML_PARSE == pc->error_num);
471
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIESURL)) {
472
SetProjectPropertiesURLFailure(true);
474
SetProjectPropertiesURLFailure(false);
477
bSuccessfulCondition =
478
((!iReturnValue) && (ERR_FILE_NOT_FOUND != pc->error_num)) &&
479
((!iReturnValue) && (ERR_GETHOSTBYNAME != pc->error_num)) &&
480
((!iReturnValue) && (ERR_XML_PARSE != pc->error_num)) &&
482
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIESURL)) {
483
SetServerReportedError(true);
485
strBuffer = pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
486
if (pc->error_msg.size()) {
487
strBuffer += wxString(pc->error_msg.c_str(), wxConvUTF8) + wxString(wxT("\n"));
489
pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
492
SetServerReportedError(false);
495
SetNextState(PROJPROP_DETERMINENETWORKSTATUS_BEGIN);
498
case PROJPROP_DETERMINENETWORKSTATUS_BEGIN:
499
SetNextState(PROJPROP_DETERMINENETWORKSTATUS_EXECUTE);
501
case PROJPROP_DETERMINENETWORKSTATUS_EXECUTE:
502
// Attempt to determine if we are even connected to a network
504
// Wait until we are done processing the request.
505
dtStartExecutionTime = wxDateTime::Now();
506
dtCurrentExecutionTime = wxDateTime::Now();
507
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
509
status.network_status = NETWORK_STATUS_LOOKUP_PENDING;
510
while ((!iReturnValue && (NETWORK_STATUS_LOOKUP_PENDING == status.network_status)) &&
511
tsExecutionTime.GetSeconds() <= 60 &&
512
!CHECK_CLOSINGINPROGRESS()
515
dtCurrentExecutionTime = wxDateTime::Now();
516
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
517
iReturnValue = pDoc->GetCoreClientStatus(status);
518
IncrementProgress(m_pProgressIndicator);
521
::wxSafeYield(GetParent());
524
bSuccessfulCondition = NETWORK_STATUS_WANT_CONNECTION != status.network_status;
525
if (bSuccessfulCondition && !CHECK_DEBUG_FLAG(WIZDEBUG_ERRNETDETECTION)) {
526
SetNetworkConnectionDetected(true);
528
SetNetworkConnectionDetected(false);
530
SetNextState(PROJPROP_CLEANUP);
533
case PROJPROP_CLEANUP:
534
FinishProgress(m_pProgressIndicator);
535
SetNextState(PROJPROP_END);
538
// Allow a glimps of what the result was before advancing to the next page.
540
pWAP->EnableNextButton();
541
pWAP->EnableBackButton();
542
pWAP->SimulateNextButton();
543
bPostNewEvent = false;
549
if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
550
CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
551
AddPendingEvent(TransitionEvent);
1
// This file is part of BOINC.
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2008 University of California
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.
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.
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/>.
18
#if defined(__GNUG__) && !defined(__APPLE__)
19
#pragma implementation "ProjectPropertiesPage.h"
24
#include "diagnostics.h"
29
#include "error_numbers.h"
31
#include "error_numbers.h"
32
#include "BOINCGUIApp.h"
33
#include "SkinManager.h"
34
#include "MainDocument.h"
35
#include "BOINCBaseWizard.h"
36
#include "WizardAttach.h"
37
#include "ProjectPropertiesPage.h"
38
#include "ProjectInfoPage.h"
39
#include "CompletionErrorPage.h"
40
#include "TermsOfUsePage.h"
44
#include "res/wizprogress01.xpm"
45
#include "res/wizprogress02.xpm"
46
#include "res/wizprogress03.xpm"
47
#include "res/wizprogress04.xpm"
48
#include "res/wizprogress05.xpm"
49
#include "res/wizprogress06.xpm"
50
#include "res/wizprogress07.xpm"
51
#include "res/wizprogress08.xpm"
52
#include "res/wizprogress09.xpm"
53
#include "res/wizprogress10.xpm"
54
#include "res/wizprogress11.xpm"
55
#include "res/wizprogress12.xpm"
59
* CProjectPropertiesPage custom event definition
62
DEFINE_EVENT_TYPE(wxEVT_PROJECTPROPERTIES_STATECHANGE)
65
* CProjectPropertiesPage type definition
68
IMPLEMENT_DYNAMIC_CLASS( CProjectPropertiesPage, wxWizardPageEx )
71
* CProjectPropertiesPage event table definition
74
BEGIN_EVENT_TABLE( CProjectPropertiesPage, wxWizardPageEx )
76
EVT_PROJECTPROPERTIES_STATECHANGE( CProjectPropertiesPage::OnStateChange )
78
////@begin CProjectPropertiesPage event table entries
79
EVT_WIZARDEX_PAGE_CHANGED( -1, CProjectPropertiesPage::OnPageChanged )
80
EVT_WIZARDEX_CANCEL( -1, CProjectPropertiesPage::OnCancel )
82
////@end CProjectPropertiesPage event table entries
87
* CProjectPropertiesPage constructors
90
CProjectPropertiesPage::CProjectPropertiesPage( )
94
CProjectPropertiesPage::CProjectPropertiesPage( CBOINCBaseWizard* parent )
103
bool CProjectPropertiesPage::Create( CBOINCBaseWizard* parent )
105
////@begin CProjectPropertiesPage member initialisation
106
m_pTitleStaticCtrl = NULL;
107
m_pProgressIndicator = NULL;
108
////@end CProjectPropertiesPage member initialisation
110
m_bProjectPropertiesSucceeded = false;
111
m_bProjectPropertiesURLFailure = false;
112
m_bProjectPropertiesCommunicationFailure = false;
113
m_bProjectAccountCreationDisabled = false;
114
m_bProjectClientAccountCreationDisabled = false;
115
m_bNetworkConnectionNotDetected = false;
116
m_bServerReportedError = false;
117
m_bTermsOfUseRequired = true;
119
m_iCurrentState = PROJPROP_INIT;
121
////@begin CProjectPropertiesPage creation
122
wxWizardPageEx::Create( parent, ID_PROJECTPROPERTIESPAGE );
125
GetSizer()->Fit(this);
126
////@end CProjectPropertiesPage creation
132
* Control creation for WizardPage
135
void CProjectPropertiesPage::CreateControls()
137
////@begin CProjectPropertiesPage content construction
138
CProjectPropertiesPage* itemWizardPage36 = this;
140
wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
141
itemWizardPage36->SetSizer(itemBoxSizer37);
143
m_pTitleStaticCtrl = new wxStaticText;
144
m_pTitleStaticCtrl->Create( itemWizardPage36, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
145
m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana")));
146
itemBoxSizer37->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
148
itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
150
wxFlexGridSizer* itemFlexGridSizer40 = new wxFlexGridSizer(1, 3, 0, 0);
151
itemFlexGridSizer40->AddGrowableRow(0);
152
itemFlexGridSizer40->AddGrowableCol(0);
153
itemFlexGridSizer40->AddGrowableCol(1);
154
itemFlexGridSizer40->AddGrowableCol(2);
155
itemBoxSizer37->Add(itemFlexGridSizer40, 0, wxGROW|wxALL, 5);
157
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
159
wxBitmap itemBitmap41(GetBitmapResource(wxT("res/wizprogress01.xpm")));
160
m_pProgressIndicator = new wxStaticBitmap;
161
m_pProgressIndicator->Create( itemWizardPage36, ID_PROGRESSCTRL, itemBitmap41, wxDefaultPosition, wxSize(184, 48), 0 );
162
itemFlexGridSizer40->Add(m_pProgressIndicator, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
164
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
165
////@end CProjectPropertiesPage content construction
169
* Gets the previous page.
172
wxWizardPageEx* CProjectPropertiesPage::GetPrev() const
174
return PAGE_TRANSITION_BACK;
178
* Gets the next page.
181
wxWizardPageEx* CProjectPropertiesPage::GetNext() const
183
if (CHECK_CLOSINGINPROGRESS()) {
184
// Cancel Event Detected
185
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
186
} else if (GetProjectPropertiesSucceeded() && GetTermsOfUseRequired()) {
187
// Terms of Use are required before requesting account information
188
return PAGE_TRANSITION_NEXT(ID_TERMSOFUSEPAGE);
189
} else if (GetProjectPropertiesSucceeded() && GetCredentialsAlreadyAvailable()) {
190
// Credentials are already available, do whatever we need to do.
191
return PAGE_TRANSITION_NEXT(ID_PROJECTPROCESSINGPAGE);
192
} else if (GetProjectPropertiesSucceeded()) {
193
// We were successful in retrieving the project properties
194
return PAGE_TRANSITION_NEXT(ID_ACCOUNTINFOPAGE);
195
} else if (GetProjectPropertiesCommunicationFailure() && GetNetworkConnectionNotDetected()) {
196
// No Internet Connection
197
return PAGE_TRANSITION_NEXT(ID_ERRPROXYINFOPAGE);
198
} else if (GetProjectPropertiesURLFailure()) {
199
// Not a BOINC based project
200
return PAGE_TRANSITION_NEXT(ID_ERRNOTDETECTEDPAGE);
201
} else if (GetServerReportedError()) {
202
// Server reported an error, display the error
203
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
205
// The project must be down for maintenance
206
return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
212
* Should we show tooltips?
215
bool CProjectPropertiesPage::ShowToolTips()
220
void CProjectPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
222
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
225
void CProjectPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
227
if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
230
str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
232
pBitmap->SetBitmap(GetBitmapResource(str));
236
void CProjectPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
238
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
242
* Get bitmap resources
245
wxBitmap CProjectPropertiesPage::GetBitmapResource( const wxString& name )
248
if (name == wxT("res/wizprogress01.xpm"))
250
wxBitmap bitmap(wizprogress01_xpm);
253
else if (name == wxT("res/wizprogress02.xpm"))
255
wxBitmap bitmap(wizprogress02_xpm);
258
else if (name == wxT("res/wizprogress03.xpm"))
260
wxBitmap bitmap(wizprogress03_xpm);
263
else if (name == wxT("res/wizprogress04.xpm"))
265
wxBitmap bitmap(wizprogress04_xpm);
268
else if (name == wxT("res/wizprogress05.xpm"))
270
wxBitmap bitmap(wizprogress05_xpm);
273
else if (name == wxT("res/wizprogress06.xpm"))
275
wxBitmap bitmap(wizprogress06_xpm);
278
else if (name == wxT("res/wizprogress07.xpm"))
280
wxBitmap bitmap(wizprogress07_xpm);
283
else if (name == wxT("res/wizprogress08.xpm"))
285
wxBitmap bitmap(wizprogress08_xpm);
288
else if (name == wxT("res/wizprogress09.xpm"))
290
wxBitmap bitmap(wizprogress09_xpm);
293
else if (name == wxT("res/wizprogress10.xpm"))
295
wxBitmap bitmap(wizprogress10_xpm);
298
else if (name == wxT("res/wizprogress11.xpm"))
300
wxBitmap bitmap(wizprogress11_xpm);
303
else if (name == wxT("res/wizprogress12.xpm"))
305
wxBitmap bitmap(wizprogress12_xpm);
315
wxIcon CProjectPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
318
////@begin CProjectPropertiesPage icon retrieval
320
////@end CProjectPropertiesPage icon retrieval
324
* wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
327
void CProjectPropertiesPage::OnPageChanged( wxWizardExEvent& event ) {
328
if (event.GetDirection() == false) return;
330
wxASSERT(m_pTitleStaticCtrl);
331
wxASSERT(m_pProgressIndicator);
333
m_pTitleStaticCtrl->SetLabel(
334
_("Communicating with project\nPlease wait...")
337
SetProjectPropertiesSucceeded(false);
338
SetProjectPropertiesURLFailure(false);
339
SetProjectPropertiesCommunicationFailure(false);
340
SetProjectAccountCreationDisabled(false);
341
SetProjectClientAccountCreationDisabled(false);
342
SetNetworkConnectionNotDetected(false);
343
SetNextState(PROJPROP_INIT);
345
CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
346
AddPendingEvent(TransitionEvent);
352
* wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
355
void CProjectPropertiesPage::OnCancel( wxWizardExEvent& event ) {
356
PROCESS_CANCELEVENT(event);
360
* wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
363
void CProjectPropertiesPage::OnStateChange( CProjectPropertiesPageEvent& WXUNUSED(event) )
365
CMainDocument* pDoc = wxGetApp().GetDocument();
366
CWizardAttach* pWAP = ((CWizardAttach*)GetParent());
367
PROJECT_CONFIG* pc = &pWAP->project_config;
369
wxDateTime dtStartExecutionTime;
370
wxDateTime dtCurrentExecutionTime;
371
wxTimeSpan tsExecutionTime;
372
wxString strBuffer = wxEmptyString;
373
bool bPostNewEvent = true;
374
int iReturnValue = 0;
377
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
379
switch(GetCurrentState()) {
381
pWAP->DisableNextButton();
382
pWAP->DisableBackButton();
383
StartProgress(m_pProgressIndicator);
384
SetNextState(PROJPROP_RETRPROJECTPROPERTIES_BEGIN);
386
case PROJPROP_RETRPROJECTPROPERTIES_BEGIN:
387
SetNextState(PROJPROP_RETRPROJECTPROPERTIES_EXECUTE);
389
case PROJPROP_RETRPROJECTPROPERTIES_EXECUTE:
390
// Attempt to retrieve the project's account creation policies
392
// Wait until we are done processing the request.
393
dtStartExecutionTime = wxDateTime::Now();
394
dtCurrentExecutionTime = wxDateTime::Now();
395
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
398
pc->error_num = ERR_RETRY;
401
((ERR_IN_PROGRESS == pc->error_num) || (ERR_RETRY == pc->error_num)) &&
402
tsExecutionTime.GetSeconds() <= 60 &&
403
!CHECK_CLOSINGINPROGRESS()
405
if (ERR_RETRY == pc->error_num) {
406
pDoc->rpc.get_project_config(
407
(const char*)pWAP->m_ProjectInfoPage->GetProjectURL().mb_str()
411
dtCurrentExecutionTime = wxDateTime::Now();
412
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
413
iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
414
IncrementProgress(m_pProgressIndicator);
417
::wxSafeYield(GetParent());
422
&& (!pc->error_num || pc->error_num == ERR_ACCT_CREATION_DISABLED)
424
// We either successfully retrieved the project's
425
// account creation policies or we were able to talk
426
// to the web server and found out they do not support
427
// account creation through the wizard.
428
// In either case, claim success and set the correct flags
429
// to show the correct 'next' page.
431
SetProjectPropertiesSucceeded(true);
432
SetProjectAccountCreationDisabled(pc->account_creation_disabled);
433
SetProjectClientAccountCreationDisabled(pc->client_account_creation_disabled);
434
SetTermsOfUseRequired(!pc->terms_of_use.empty());
438
SetProjectPropertiesSucceeded(false);
439
SetProjectPropertiesURLFailure(pc->error_num == ERR_FILE_NOT_FOUND);
441
bool comm_failure = !iReturnValue && (
442
(ERR_GETHOSTBYNAME == pc->error_num)
443
|| (ERR_CONNECT == pc->error_num)
444
|| (ERR_XML_PARSE == pc->error_num)
445
|| (ERR_PROJECT_DOWN == pc->error_num)
447
SetProjectPropertiesCommunicationFailure(comm_failure);
449
bool server_reported_error = !iReturnValue && (
450
(ERR_FILE_NOT_FOUND != pc->error_num)
451
&& (ERR_GETHOSTBYNAME != pc->error_num)
452
&& (ERR_CONNECT != pc->error_num)
453
&& (ERR_XML_PARSE != pc->error_num)
454
&& (ERR_PROJECT_DOWN != pc->error_num)
456
SetServerReportedError(server_reported_error);
458
if (server_reported_error) {
459
strBuffer = pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
460
if (pc->error_msg.size()) {
461
strBuffer += wxString(pc->error_msg.c_str(), wxConvUTF8) + wxString(wxT("\n"));
463
pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
467
SetNextState(PROJPROP_DETERMINENETWORKSTATUS_BEGIN);
469
case PROJPROP_DETERMINENETWORKSTATUS_BEGIN:
470
SetNextState(PROJPROP_DETERMINENETWORKSTATUS_EXECUTE);
472
case PROJPROP_DETERMINENETWORKSTATUS_EXECUTE:
473
// Attempt to determine if we are even connected to a network
475
// Wait until we are done processing the request.
476
dtStartExecutionTime = wxDateTime::Now();
477
dtCurrentExecutionTime = wxDateTime::Now();
478
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
480
status.network_status = NETWORK_STATUS_LOOKUP_PENDING;
481
while ((!iReturnValue && (NETWORK_STATUS_LOOKUP_PENDING == status.network_status)) &&
482
tsExecutionTime.GetSeconds() <= 60 &&
483
!CHECK_CLOSINGINPROGRESS()
486
dtCurrentExecutionTime = wxDateTime::Now();
487
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
488
iReturnValue = pDoc->GetCoreClientStatus(status);
489
IncrementProgress(m_pProgressIndicator);
492
::wxSafeYield(GetParent());
495
SetNetworkConnectionNotDetected(NETWORK_STATUS_WANT_CONNECTION == status.network_status);
497
SetNextState(PROJPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN);
499
case PROJPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN:
500
SetNextState(PROJPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE);
502
case PROJPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE:
503
// Determine if the account settings are already pre-populated.
504
// If so, advance to the Project Processing page.
505
SetCredentialsAlreadyAvailable(pWAP->m_bCredentialsCached || pWAP->m_bCredentialsDetected);
507
SetNextState(PROJPROP_CLEANUP);
509
case PROJPROP_CLEANUP:
510
FinishProgress(m_pProgressIndicator);
511
SetNextState(PROJPROP_END);
514
// Allow a glimps of what the result was before advancing to the next page.
516
pWAP->EnableNextButton();
517
pWAP->EnableBackButton();
518
pWAP->SimulateNextButton();
519
bPostNewEvent = false;
525
if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
526
CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
527
AddPendingEvent(TransitionEvent);