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 "AccountManagerPropertiesPage.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 "WizardAccountManager.h"
41
#include "AccountManagerPropertiesPage.h"
42
#include "AccountManagerInfoPage.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
* CAccountManagerPropertiesPage custom event definition
66
DEFINE_EVENT_TYPE(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE)
69
* CAccountManagerPropertiesPage type definition
72
IMPLEMENT_DYNAMIC_CLASS( CAccountManagerPropertiesPage, wxWizardPageEx )
75
* CAccountManagerPropertiesPage event table definition
78
BEGIN_EVENT_TABLE( CAccountManagerPropertiesPage, wxWizardPageEx )
80
EVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE( CAccountManagerPropertiesPage::OnStateChange )
82
////@begin CAccountManagerPropertiesPage event table entries
83
EVT_WIZARDEX_PAGE_CHANGED( -1, CAccountManagerPropertiesPage::OnPageChanged )
84
EVT_WIZARDEX_CANCEL( -1, CAccountManagerPropertiesPage::OnCancel )
86
////@end CAccountManagerPropertiesPage event table entries
91
* CAccountManagerPropertiesPage constructors
94
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( )
98
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( CBOINCBaseWizard* parent )
104
* CProjectPropertiesPage creator
107
bool CAccountManagerPropertiesPage::Create( CBOINCBaseWizard* parent )
109
////@begin CAccountManagerPropertiesPage member initialisation
110
m_pTitleStaticCtrl = NULL;
111
m_pPleaseWaitStaticCtrl = NULL;
112
m_pProgressIndicator = NULL;
113
////@end CAccountManagerPropertiesPage member initialisation
115
m_bProjectPropertiesSucceeded = false;
116
m_bProjectPropertiesURLFailure = false;
117
m_bProjectAccountCreationDisabled = false;
118
m_bProjectClientAccountCreationDisabled = false;
119
m_bNetworkConnectionDetected = false;
120
m_bServerReportedError = false;
121
m_bTermsOfUseRequired = true;
123
m_iCurrentState = ACCTMGRPROP_INIT;
125
////@begin CAccountManagerPropertiesPage creation
126
wxBitmap wizardBitmap(wxNullBitmap);
127
wxWizardPageEx::Create( parent, ID_ACCOUNTMANAGERPROPERTIESPAGE, wizardBitmap );
130
GetSizer()->Fit(this);
131
////@end CAccountManagerPropertiesPage creation
136
* Control creation for CProjectPropertiesPage
139
void CAccountManagerPropertiesPage::CreateControls()
141
////@begin CAccountManagerPropertiesPage content construction
142
CAccountManagerPropertiesPage* 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
m_pPleaseWaitStaticCtrl = new wxStaticText;
153
m_pPleaseWaitStaticCtrl->Create( itemWizardPage36, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
154
itemBoxSizer37->Add(m_pPleaseWaitStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
156
itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
158
wxFlexGridSizer* itemFlexGridSizer40 = new wxFlexGridSizer(1, 3, 0, 0);
159
itemFlexGridSizer40->AddGrowableRow(0);
160
itemFlexGridSizer40->AddGrowableCol(0);
161
itemFlexGridSizer40->AddGrowableCol(1);
162
itemFlexGridSizer40->AddGrowableCol(2);
163
itemBoxSizer37->Add(itemFlexGridSizer40, 0, wxGROW|wxALL, 5);
165
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
167
wxBitmap itemBitmap41(GetBitmapResource(wxT("res/wizprogress01.xpm")));
168
m_pProgressIndicator = new wxStaticBitmap;
169
m_pProgressIndicator->Create( itemWizardPage36, ID_PROGRESSCTRL, itemBitmap41, wxDefaultPosition, wxSize(184, 48), 0 );
170
itemFlexGridSizer40->Add(m_pProgressIndicator, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
172
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
173
////@end CAccountManagerPropertiesPage content construction
177
* wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
180
void CAccountManagerPropertiesPage::OnPageChanged( wxWizardExEvent& event )
182
if (event.GetDirection() == false) return;
184
CWizardAccountManager* pWAM = ((CWizardAccountManager*)GetParent());
186
wxASSERT(m_pTitleStaticCtrl);
187
wxASSERT(m_pPleaseWaitStaticCtrl);
188
wxASSERT(m_pProgressIndicator);
191
if (!pWAM->m_strProjectName.IsEmpty()) {
194
// %s is the project name
195
// i.e. 'BOINC', 'GridRepublic'
196
str.Printf(_("Communicating with %s."), pWAM->m_strProjectName.c_str());
198
m_pTitleStaticCtrl->SetLabel(
202
m_pTitleStaticCtrl->SetLabel(
203
_("Communicating with server.")
207
m_pPleaseWaitStaticCtrl->SetLabel(
211
SetProjectPropertiesSucceeded(false);
212
SetProjectPropertiesURLFailure(false);
213
SetProjectAccountCreationDisabled(false);
214
SetProjectClientAccountCreationDisabled(false);
215
SetNetworkConnectionDetected(false);
216
SetNextState(ACCTMGRPROP_INIT);
218
CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
219
AddPendingEvent(TransitionEvent);
225
* wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
228
void CAccountManagerPropertiesPage::OnCancel( wxWizardExEvent& event ) {
229
PROCESS_CANCELEVENT(event);
233
* wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
236
void CAccountManagerPropertiesPage::OnStateChange( CAccountManagerPropertiesPageEvent& WXUNUSED(event) )
238
CMainDocument* pDoc = wxGetApp().GetDocument();
239
CWizardAccountManager* pWAM = ((CWizardAccountManager*)GetParent());
240
PROJECT_CONFIG* pc = &pWAM->project_config;
242
wxDateTime dtStartExecutionTime;
243
wxDateTime dtCurrentExecutionTime;
244
wxTimeSpan tsExecutionTime;
245
wxString strBuffer = wxEmptyString;
246
bool bPostNewEvent = true;
247
bool bSuccessfulCondition = false;
248
int iReturnValue = 0;
251
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
253
switch(GetCurrentState()) {
254
case ACCTMGRPROP_INIT:
255
pWAM->DisableNextButton();
256
pWAM->DisableBackButton();
257
StartProgress(m_pProgressIndicator);
258
SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN);
260
case ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN:
261
SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_EXECUTE);
263
case ACCTMGRPROP_RETRPROJECTPROPERTIES_EXECUTE:
264
// Attempt to retrieve the project's account creation policies
265
pDoc->rpc.get_project_config(
266
(const char*)pWAM->m_AccountManagerInfoPage->GetProjectURL().mb_str()
269
// Wait until we are done processing the request.
270
dtStartExecutionTime = wxDateTime::Now();
271
dtCurrentExecutionTime = wxDateTime::Now();
272
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
275
pc->error_num = ERR_IN_PROGRESS;
276
while ((!iReturnValue && (ERR_IN_PROGRESS == pc->error_num)) &&
277
tsExecutionTime.GetSeconds() <= 60 &&
278
!CHECK_CLOSINGINPROGRESS()
281
dtCurrentExecutionTime = wxDateTime::Now();
282
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
283
iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
284
IncrementProgress(m_pProgressIndicator);
287
::wxSafeYield(GetParent());
290
// We either successfully retrieved the project's account creation
291
// policies or we were able to talk to the web server and found out
292
// they do not support account creation through the wizard. In either
293
// case we should claim success and set the correct flags to show the
294
// correct 'next' page.
295
bSuccessfulCondition =
296
(!iReturnValue) && (!pc->error_num) ||
297
(!iReturnValue) && (ERR_ACCT_CREATION_DISABLED == pc->error_num);
298
if (bSuccessfulCondition && !CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIES)) {
299
SetProjectPropertiesSucceeded(true);
301
bSuccessfulCondition = pc->account_creation_disabled;
302
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRACCOUNTCREATIONDISABLED)) {
303
SetProjectAccountCreationDisabled(true);
305
SetProjectAccountCreationDisabled(false);
308
bSuccessfulCondition = pc->client_account_creation_disabled;
309
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRCLIENTACCOUNTCREATIONDISABLED)) {
310
SetProjectClientAccountCreationDisabled(true);
312
SetProjectClientAccountCreationDisabled(false);
315
bSuccessfulCondition = !pc->terms_of_use.empty();
316
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRTERMSOFUSEREQUIRED)) {
317
SetTermsOfUseRequired(true);
319
SetTermsOfUseRequired(false);
322
pWAM->m_strProjectName = wxString(pc->name.c_str(), wxConvUTF8);
324
SetNextState(ACCTMGRPROP_CLEANUP);
326
SetProjectPropertiesSucceeded(false);
328
bSuccessfulCondition =
329
(!iReturnValue) && (ERR_FILE_NOT_FOUND == pc->error_num) ||
330
(!iReturnValue) && (ERR_GETHOSTBYNAME == pc->error_num) ||
331
(!iReturnValue) && (ERR_XML_PARSE == pc->error_num);
332
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIESURL)) {
333
SetProjectPropertiesURLFailure(true);
335
SetProjectPropertiesURLFailure(false);
338
bSuccessfulCondition =
339
((!iReturnValue) && (ERR_FILE_NOT_FOUND != pc->error_num)) &&
340
((!iReturnValue) && (ERR_GETHOSTBYNAME != pc->error_num)) &&
341
((!iReturnValue) && (ERR_XML_PARSE != pc->error_num)) &&
343
if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIESURL)) {
344
SetServerReportedError(true);
346
strBuffer = pWAM->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
347
if (pc->error_msg.size()) {
348
strBuffer += wxString(pc->error_msg.c_str(), wxConvUTF8) + wxString(wxT("\n"));
350
pWAM->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
353
SetServerReportedError(false);
356
SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN);
359
case ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN:
360
SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE);
362
case ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE:
363
// Attempt to determine if we are even connected to a network
365
// Wait until we are done processing the request.
366
dtStartExecutionTime = wxDateTime::Now();
367
dtCurrentExecutionTime = wxDateTime::Now();
368
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
370
status.network_status = NETWORK_STATUS_LOOKUP_PENDING;
371
while ((!iReturnValue && (NETWORK_STATUS_LOOKUP_PENDING == status.network_status)) &&
372
tsExecutionTime.GetSeconds() <= 60 &&
373
!CHECK_CLOSINGINPROGRESS()
376
dtCurrentExecutionTime = wxDateTime::Now();
377
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
378
iReturnValue = pDoc->GetCoreClientStatus(status);
379
IncrementProgress(m_pProgressIndicator);
382
::wxSafeYield(GetParent());
385
bSuccessfulCondition = NETWORK_STATUS_WANT_CONNECTION != status.network_status;
386
if (bSuccessfulCondition && !CHECK_DEBUG_FLAG(WIZDEBUG_ERRNETDETECTION)) {
387
SetNetworkConnectionDetected(true);
389
SetNetworkConnectionDetected(false);
392
SetNextState(ACCTMGRPROP_CLEANUP);
394
case ACCTMGRPROP_CLEANUP:
395
FinishProgress(m_pProgressIndicator);
396
SetNextState(ACCTMGRPROP_END);
399
// Allow a glimps of what the result was before advancing to the next page.
401
pWAM->EnableNextButton();
402
pWAM->EnableBackButton();
403
pWAM->SimulateNextButton();
404
bPostNewEvent = false;
410
if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
411
CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
412
AddPendingEvent(TransitionEvent);
417
* Gets the previous page.
420
wxWizardPageEx* CAccountManagerPropertiesPage::GetPrev() const
422
return PAGE_TRANSITION_BACK;
426
* Gets the next page.
429
wxWizardPageEx* CAccountManagerPropertiesPage::GetNext() const
431
if (CHECK_CLOSINGINPROGRESS()) {
432
// Cancel Event Detected
433
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
434
} else if (GetProjectPropertiesSucceeded() && GetTermsOfUseRequired()) {
435
// Terms of Use are required before requesting account information
436
return PAGE_TRANSITION_NEXT(ID_TERMSOFUSEPAGE);
437
} else if (GetProjectPropertiesSucceeded()) {
438
// We were successful in retrieving the project properties
439
return PAGE_TRANSITION_NEXT(ID_ACCOUNTINFOPAGE);
440
} else if (GetProjectPropertiesURLFailure() && !GetNetworkConnectionDetected()) {
441
// No Internet Connection
442
return PAGE_TRANSITION_NEXT(ID_ERRPROXYINFOPAGE);
443
} else if (GetProjectPropertiesURLFailure()) {
444
// Not a BOINC based project
445
return PAGE_TRANSITION_NEXT(ID_ERRNOTDETECTEDPAGE);
446
} else if (GetServerReportedError()) {
447
// Server reported an error, display the error
448
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
450
// The project must be down for maintenance
451
return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
457
* Should we show tooltips?
460
bool CAccountManagerPropertiesPage::ShowToolTips()
466
void CAccountManagerPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
468
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
471
void CAccountManagerPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
473
if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
476
str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
478
pBitmap->SetBitmap(GetBitmapResource(str));
482
void CAccountManagerPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
484
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
488
* Get bitmap resources
491
wxBitmap CAccountManagerPropertiesPage::GetBitmapResource( const wxString& name )
494
if (name == wxT("res/wizprogress01.xpm"))
496
wxBitmap bitmap(wizprogress01_xpm);
499
else if (name == wxT("res/wizprogress02.xpm"))
501
wxBitmap bitmap(wizprogress02_xpm);
504
else if (name == wxT("res/wizprogress03.xpm"))
506
wxBitmap bitmap(wizprogress03_xpm);
509
else if (name == wxT("res/wizprogress04.xpm"))
511
wxBitmap bitmap(wizprogress04_xpm);
514
else if (name == wxT("res/wizprogress05.xpm"))
516
wxBitmap bitmap(wizprogress05_xpm);
519
else if (name == wxT("res/wizprogress06.xpm"))
521
wxBitmap bitmap(wizprogress06_xpm);
524
else if (name == wxT("res/wizprogress07.xpm"))
526
wxBitmap bitmap(wizprogress07_xpm);
529
else if (name == wxT("res/wizprogress08.xpm"))
531
wxBitmap bitmap(wizprogress08_xpm);
534
else if (name == wxT("res/wizprogress09.xpm"))
536
wxBitmap bitmap(wizprogress09_xpm);
539
else if (name == wxT("res/wizprogress10.xpm"))
541
wxBitmap bitmap(wizprogress10_xpm);
544
else if (name == wxT("res/wizprogress11.xpm"))
546
wxBitmap bitmap(wizprogress11_xpm);
549
else if (name == wxT("res/wizprogress12.xpm"))
551
wxBitmap bitmap(wizprogress12_xpm);
561
wxIcon CAccountManagerPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
564
////@begin CAccountManagerPropertiesPage icon retrieval
566
////@end CAccountManagerPropertiesPage icon retrieval
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 "AccountManagerPropertiesPage.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 "ProjectListCtrl.h"
37
#include "WizardAttach.h"
38
#include "AccountManagerPropertiesPage.h"
39
#include "AccountManagerInfoPage.h"
40
#include "AccountInfoPage.h"
41
#include "CompletionErrorPage.h"
42
#include "TermsOfUsePage.h"
46
#include "res/wizprogress01.xpm"
47
#include "res/wizprogress02.xpm"
48
#include "res/wizprogress03.xpm"
49
#include "res/wizprogress04.xpm"
50
#include "res/wizprogress05.xpm"
51
#include "res/wizprogress06.xpm"
52
#include "res/wizprogress07.xpm"
53
#include "res/wizprogress08.xpm"
54
#include "res/wizprogress09.xpm"
55
#include "res/wizprogress10.xpm"
56
#include "res/wizprogress11.xpm"
57
#include "res/wizprogress12.xpm"
61
* CAccountManagerPropertiesPage custom event definition
64
DEFINE_EVENT_TYPE(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE)
67
* CAccountManagerPropertiesPage type definition
70
IMPLEMENT_DYNAMIC_CLASS( CAccountManagerPropertiesPage, wxWizardPageEx )
73
* CAccountManagerPropertiesPage event table definition
76
BEGIN_EVENT_TABLE( CAccountManagerPropertiesPage, wxWizardPageEx )
78
EVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE( CAccountManagerPropertiesPage::OnStateChange )
80
////@begin CAccountManagerPropertiesPage event table entries
81
EVT_WIZARDEX_PAGE_CHANGED( -1, CAccountManagerPropertiesPage::OnPageChanged )
82
EVT_WIZARDEX_CANCEL( -1, CAccountManagerPropertiesPage::OnCancel )
84
////@end CAccountManagerPropertiesPage event table entries
89
* CAccountManagerPropertiesPage constructors
92
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( )
96
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( CBOINCBaseWizard* parent )
102
* CProjectPropertiesPage creator
105
bool CAccountManagerPropertiesPage::Create( CBOINCBaseWizard* parent )
107
////@begin CAccountManagerPropertiesPage member initialisation
108
m_pTitleStaticCtrl = NULL;
109
m_pPleaseWaitStaticCtrl = NULL;
110
m_pProgressIndicator = NULL;
111
////@end CAccountManagerPropertiesPage member initialisation
113
m_bProjectPropertiesSucceeded = false;
114
m_bProjectPropertiesURLFailure = false;
115
m_bProjectPropertiesCommunicationFailure = false;
116
m_bProjectAccountCreationDisabled = false;
117
m_bProjectClientAccountCreationDisabled = false;
118
m_bNetworkConnectionNotDetected = false;
119
m_bServerReportedError = false;
120
m_bTermsOfUseRequired = true;
121
m_bCredentialsAlreadyAvailable = false;
123
m_iCurrentState = ACCTMGRPROP_INIT;
125
////@begin CAccountManagerPropertiesPage creation
126
wxWizardPageEx::Create( parent, ID_ACCOUNTMANAGERPROPERTIESPAGE );
129
GetSizer()->Fit(this);
130
////@end CAccountManagerPropertiesPage creation
135
* Control creation for CProjectPropertiesPage
138
void CAccountManagerPropertiesPage::CreateControls()
140
////@begin CAccountManagerPropertiesPage content construction
141
CAccountManagerPropertiesPage* itemWizardPage36 = this;
143
wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
144
itemWizardPage36->SetSizer(itemBoxSizer37);
146
m_pTitleStaticCtrl = new wxStaticText;
147
m_pTitleStaticCtrl->Create( itemWizardPage36, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
148
m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana")));
149
itemBoxSizer37->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
151
m_pPleaseWaitStaticCtrl = new wxStaticText;
152
m_pPleaseWaitStaticCtrl->Create( itemWizardPage36, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
153
itemBoxSizer37->Add(m_pPleaseWaitStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
155
itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
157
wxFlexGridSizer* itemFlexGridSizer40 = new wxFlexGridSizer(1, 3, 0, 0);
158
itemFlexGridSizer40->AddGrowableRow(0);
159
itemFlexGridSizer40->AddGrowableCol(0);
160
itemFlexGridSizer40->AddGrowableCol(1);
161
itemFlexGridSizer40->AddGrowableCol(2);
162
itemBoxSizer37->Add(itemFlexGridSizer40, 0, wxGROW|wxALL, 5);
164
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
166
wxBitmap itemBitmap41(GetBitmapResource(wxT("res/wizprogress01.xpm")));
167
m_pProgressIndicator = new wxStaticBitmap;
168
m_pProgressIndicator->Create( itemWizardPage36, ID_PROGRESSCTRL, itemBitmap41, wxDefaultPosition, wxSize(184, 48), 0 );
169
itemFlexGridSizer40->Add(m_pProgressIndicator, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
171
itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
172
////@end CAccountManagerPropertiesPage content construction
176
* wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
179
void CAccountManagerPropertiesPage::OnPageChanged( wxWizardExEvent& event )
181
if (event.GetDirection() == false) return;
183
CWizardAttach* pWA = ((CWizardAttach*)GetParent());
184
wxASSERT(m_pTitleStaticCtrl);
185
wxASSERT(m_pPleaseWaitStaticCtrl);
186
wxASSERT(m_pProgressIndicator);
189
if (!pWA->m_strProjectName.IsEmpty()) {
192
// %s is the project name
193
// i.e. 'BOINC', 'GridRepublic'
194
str.Printf(_("Communicating with %s."), pWA->m_strProjectName.c_str());
196
m_pTitleStaticCtrl->SetLabel(
200
m_pTitleStaticCtrl->SetLabel(
201
_("Communicating with server.")
205
m_pPleaseWaitStaticCtrl->SetLabel(
209
SetProjectPropertiesSucceeded(false);
210
SetProjectPropertiesURLFailure(false);
211
SetProjectPropertiesCommunicationFailure(false);
212
SetProjectAccountCreationDisabled(false);
213
SetProjectClientAccountCreationDisabled(false);
214
SetNetworkConnectionNotDetected(false);
215
SetTermsOfUseRequired(true);
216
SetCredentialsAlreadyAvailable(false);
217
SetNextState(ACCTMGRPROP_INIT);
219
CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
220
AddPendingEvent(TransitionEvent);
226
* wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
229
void CAccountManagerPropertiesPage::OnCancel( wxWizardExEvent& event ) {
230
PROCESS_CANCELEVENT(event);
234
* wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
237
void CAccountManagerPropertiesPage::OnStateChange( CAccountManagerPropertiesPageEvent& WXUNUSED(event) )
239
CMainDocument* pDoc = wxGetApp().GetDocument();
240
CWizardAttach* pWA = ((CWizardAttach*)GetParent());
241
PROJECT_CONFIG* pc = &pWA->project_config;
243
wxDateTime dtStartExecutionTime;
244
wxDateTime dtCurrentExecutionTime;
245
wxTimeSpan tsExecutionTime;
246
wxString strBuffer = wxEmptyString;
247
bool bPostNewEvent = true;
248
int iReturnValue = 0;
251
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
253
switch(GetCurrentState()) {
254
case ACCTMGRPROP_INIT:
255
pWA->DisableNextButton();
256
pWA->DisableBackButton();
257
StartProgress(m_pProgressIndicator);
258
SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN);
260
case ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN:
261
SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_EXECUTE);
263
case ACCTMGRPROP_RETRPROJECTPROPERTIES_EXECUTE:
264
// Attempt to retrieve the project's account creation policies
266
// Wait until we are done processing the request.
267
dtStartExecutionTime = wxDateTime::Now();
268
dtCurrentExecutionTime = wxDateTime::Now();
269
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
272
pc->error_num = ERR_RETRY;
275
((ERR_IN_PROGRESS == pc->error_num) || (ERR_RETRY == pc->error_num)) &&
276
tsExecutionTime.GetSeconds() <= 60 &&
277
!CHECK_CLOSINGINPROGRESS()
279
if (ERR_RETRY == pc->error_num) {
280
pDoc->rpc.get_project_config(
281
(const char*)pWA->m_AccountManagerInfoPage->GetProjectURL().mb_str()
285
dtCurrentExecutionTime = wxDateTime::Now();
286
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
287
iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
288
IncrementProgress(m_pProgressIndicator);
291
::wxSafeYield(GetParent());
296
&& (!pc->error_num || pc->error_num == ERR_ACCT_CREATION_DISABLED)
298
// We either successfully retrieved the project's account creation
299
// policies or we were able to talk to the web server and found out
300
// they do not support account creation through the wizard. In either
301
// case we should claim success and set the correct flags to show the
302
// correct 'next' page.
303
SetProjectPropertiesSucceeded(true);
304
SetProjectAccountCreationDisabled(pc->account_creation_disabled);
305
SetProjectClientAccountCreationDisabled(pc->client_account_creation_disabled);
306
SetTermsOfUseRequired(!pc->terms_of_use.empty());
308
pWA->m_strProjectName = wxString(pc->name.c_str(), wxConvUTF8);
312
SetProjectPropertiesSucceeded(false);
313
SetProjectPropertiesURLFailure(pc->error_num == ERR_FILE_NOT_FOUND);
315
bool comm_failure = !iReturnValue && (
316
(ERR_GETHOSTBYNAME == pc->error_num)
317
|| (ERR_CONNECT == pc->error_num)
318
|| (ERR_XML_PARSE == pc->error_num)
319
|| (ERR_PROJECT_DOWN == pc->error_num)
321
SetProjectPropertiesCommunicationFailure(comm_failure);
323
bool server_reported_error = !iReturnValue && (
324
(ERR_FILE_NOT_FOUND != pc->error_num)
325
&& (ERR_GETHOSTBYNAME != pc->error_num)
326
&& (ERR_CONNECT != pc->error_num)
327
&& (ERR_XML_PARSE != pc->error_num)
328
&& (ERR_PROJECT_DOWN != pc->error_num)
330
SetServerReportedError(server_reported_error);
332
if (server_reported_error) {
333
SetServerReportedError(true);
335
strBuffer = pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->GetLabel();
336
if (pc->error_msg.size()) {
337
strBuffer += wxString(pc->error_msg.c_str(), wxConvUTF8) + wxString(wxT("\n"));
339
pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
341
SetServerReportedError(false);
345
SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN);
347
case ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN:
348
SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE);
350
case ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE:
351
// Attempt to determine if we are even connected to a network
353
// Wait until we are done processing the request.
354
dtStartExecutionTime = wxDateTime::Now();
355
dtCurrentExecutionTime = wxDateTime::Now();
356
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
358
status.network_status = NETWORK_STATUS_LOOKUP_PENDING;
359
while ((!iReturnValue && (NETWORK_STATUS_LOOKUP_PENDING == status.network_status)) &&
360
tsExecutionTime.GetSeconds() <= 60 &&
361
!CHECK_CLOSINGINPROGRESS()
364
dtCurrentExecutionTime = wxDateTime::Now();
365
tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
366
iReturnValue = pDoc->GetCoreClientStatus(status);
367
IncrementProgress(m_pProgressIndicator);
370
::wxSafeYield(GetParent());
373
SetNetworkConnectionNotDetected(NETWORK_STATUS_WANT_CONNECTION == status.network_status);
375
SetNextState(ACCTMGRPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN);
377
case ACCTMGRPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN:
378
SetNextState(ACCTMGRPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE);
380
case ACCTMGRPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE:
381
// Determine if the account settings are already pre-populated.
382
// If so, advance to the Account Manager Processing page.
383
SetCredentialsAlreadyAvailable(pWA->m_bCredentialsCached || pWA->m_bCredentialsDetected);
384
SetNextState(ACCTMGRPROP_CLEANUP);
386
case ACCTMGRPROP_CLEANUP:
387
FinishProgress(m_pProgressIndicator);
388
SetNextState(ACCTMGRPROP_END);
391
// Allow a glimps of what the result was before advancing to the next page.
393
pWA->EnableNextButton();
394
pWA->EnableBackButton();
395
pWA->SimulateNextButton();
396
bPostNewEvent = false;
402
if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
403
CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
404
AddPendingEvent(TransitionEvent);
409
* Gets the previous page.
412
wxWizardPageEx* CAccountManagerPropertiesPage::GetPrev() const
414
return PAGE_TRANSITION_BACK;
418
* Gets the next page.
421
wxWizardPageEx* CAccountManagerPropertiesPage::GetNext() const
423
if (CHECK_CLOSINGINPROGRESS()) {
424
// Cancel Event Detected
425
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
426
} else if (GetProjectPropertiesSucceeded() && GetTermsOfUseRequired()) {
427
// Terms of Use are required before requesting account information
428
return PAGE_TRANSITION_NEXT(ID_TERMSOFUSEPAGE);
429
} else if (GetProjectPropertiesSucceeded() && GetCredentialsAlreadyAvailable()) {
430
// Credentials are already available, do whatever we need to do.
431
return PAGE_TRANSITION_NEXT(ID_ACCOUNTMANAGERPROCESSINGPAGE);
432
} else if (GetProjectPropertiesSucceeded()) {
433
// We were successful in retrieving the project properties
434
return PAGE_TRANSITION_NEXT(ID_ACCOUNTINFOPAGE);
435
} else if (GetProjectPropertiesCommunicationFailure() && GetNetworkConnectionNotDetected()) {
436
// No Internet Connection
437
return PAGE_TRANSITION_NEXT(ID_ERRPROXYINFOPAGE);
438
} else if (GetProjectPropertiesURLFailure()) {
439
// Not a BOINC based project
440
return PAGE_TRANSITION_NEXT(ID_ERRNOTDETECTEDPAGE);
441
} else if (GetServerReportedError()) {
442
// Server reported an error, display the error
443
return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
445
// The project must be down for maintenance
446
return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
452
* Should we show tooltips?
455
bool CAccountManagerPropertiesPage::ShowToolTips()
461
void CAccountManagerPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
463
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
466
void CAccountManagerPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
468
if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
471
str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
473
pBitmap->SetBitmap(GetBitmapResource(str));
477
void CAccountManagerPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
479
pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
483
* Get bitmap resources
486
wxBitmap CAccountManagerPropertiesPage::GetBitmapResource( const wxString& name )
489
if (name == wxT("res/wizprogress01.xpm"))
491
wxBitmap bitmap(wizprogress01_xpm);
494
else if (name == wxT("res/wizprogress02.xpm"))
496
wxBitmap bitmap(wizprogress02_xpm);
499
else if (name == wxT("res/wizprogress03.xpm"))
501
wxBitmap bitmap(wizprogress03_xpm);
504
else if (name == wxT("res/wizprogress04.xpm"))
506
wxBitmap bitmap(wizprogress04_xpm);
509
else if (name == wxT("res/wizprogress05.xpm"))
511
wxBitmap bitmap(wizprogress05_xpm);
514
else if (name == wxT("res/wizprogress06.xpm"))
516
wxBitmap bitmap(wizprogress06_xpm);
519
else if (name == wxT("res/wizprogress07.xpm"))
521
wxBitmap bitmap(wizprogress07_xpm);
524
else if (name == wxT("res/wizprogress08.xpm"))
526
wxBitmap bitmap(wizprogress08_xpm);
529
else if (name == wxT("res/wizprogress09.xpm"))
531
wxBitmap bitmap(wizprogress09_xpm);
534
else if (name == wxT("res/wizprogress10.xpm"))
536
wxBitmap bitmap(wizprogress10_xpm);
539
else if (name == wxT("res/wizprogress11.xpm"))
541
wxBitmap bitmap(wizprogress11_xpm);
544
else if (name == wxT("res/wizprogress12.xpm"))
546
wxBitmap bitmap(wizprogress12_xpm);
556
wxIcon CAccountManagerPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
559
////@begin CAccountManagerPropertiesPage icon retrieval
561
////@end CAccountManagerPropertiesPage icon retrieval