~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to clientgui/AccountManagerPropertiesPage.cpp

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Berkeley Open Infrastructure for Network Computing
2
 
// http://boinc.berkeley.edu
3
 
// Copyright (C) 2005 University of California
4
 
//
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.
9
 
//
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.
14
 
//
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
19
 
//
20
 
 
21
 
#if defined(__GNUG__) && !defined(__APPLE__)
22
 
#pragma implementation "AccountManagerPropertiesPage.h"
23
 
#endif
24
 
 
25
 
#include "stdwx.h"
26
 
#include "network.h"
27
 
#include "diagnostics.h"
28
 
#include "util.h"
29
 
#include "mfile.h"
30
 
#include "miofile.h"
31
 
#include "parse.h"
32
 
#include "error_numbers.h"
33
 
#include "wizardex.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"
45
 
 
46
 
 
47
 
////@begin XPM images
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"
60
 
////@end XPM images
61
 
 
62
 
/*!
63
 
 * CAccountManagerPropertiesPage custom event definition
64
 
 */
65
 
 
66
 
DEFINE_EVENT_TYPE(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE)
67
 
  
68
 
/*!
69
 
 * CAccountManagerPropertiesPage type definition
70
 
 */
71
 
 
72
 
IMPLEMENT_DYNAMIC_CLASS( CAccountManagerPropertiesPage, wxWizardPageEx )
73
 
 
74
 
/*!
75
 
 * CAccountManagerPropertiesPage event table definition
76
 
 */
77
 
 
78
 
BEGIN_EVENT_TABLE( CAccountManagerPropertiesPage, wxWizardPageEx )
79
 
 
80
 
    EVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE( CAccountManagerPropertiesPage::OnStateChange )
81
 
 
82
 
////@begin CAccountManagerPropertiesPage event table entries
83
 
    EVT_WIZARDEX_PAGE_CHANGED( -1, CAccountManagerPropertiesPage::OnPageChanged )
84
 
    EVT_WIZARDEX_CANCEL( -1, CAccountManagerPropertiesPage::OnCancel )
85
 
 
86
 
////@end CAccountManagerPropertiesPage event table entries
87
 
 
88
 
END_EVENT_TABLE()
89
 
 
90
 
/*!
91
 
 * CAccountManagerPropertiesPage constructors
92
 
 */
93
 
 
94
 
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( )
95
 
{
96
 
}
97
 
 
98
 
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( CBOINCBaseWizard* parent )
99
 
{
100
 
    Create( parent );
101
 
}
102
 
 
103
 
/*!
104
 
 * CProjectPropertiesPage creator
105
 
 */
106
 
 
107
 
bool CAccountManagerPropertiesPage::Create( CBOINCBaseWizard* parent )
108
 
{
109
 
////@begin CAccountManagerPropertiesPage member initialisation
110
 
    m_pTitleStaticCtrl = NULL;
111
 
    m_pPleaseWaitStaticCtrl = NULL;
112
 
    m_pProgressIndicator = NULL;
113
 
////@end CAccountManagerPropertiesPage member initialisation
114
 
 
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;
122
 
    m_iBitmapIndex = 0;
123
 
    m_iCurrentState = ACCTMGRPROP_INIT;
124
 
 
125
 
////@begin CAccountManagerPropertiesPage creation
126
 
    wxBitmap wizardBitmap(wxNullBitmap);
127
 
    wxWizardPageEx::Create( parent, ID_ACCOUNTMANAGERPROPERTIESPAGE, wizardBitmap );
128
 
 
129
 
    CreateControls();
130
 
    GetSizer()->Fit(this);
131
 
////@end CAccountManagerPropertiesPage creation
132
 
    return TRUE;
133
 
}
134
 
 
135
 
/*!
136
 
 * Control creation for CProjectPropertiesPage
137
 
 */
138
 
 
139
 
void CAccountManagerPropertiesPage::CreateControls()
140
 
{    
141
 
////@begin CAccountManagerPropertiesPage content construction
142
 
    CAccountManagerPropertiesPage* itemWizardPage36 = this;
143
 
 
144
 
    wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
145
 
    itemWizardPage36->SetSizer(itemBoxSizer37);
146
 
 
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);
151
 
 
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);
155
 
 
156
 
    itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
157
 
 
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);
164
 
 
165
 
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
166
 
 
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);
171
 
 
172
 
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
173
 
////@end CAccountManagerPropertiesPage content construction
174
 
}
175
 
 
176
 
/*!
177
 
 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
178
 
 */
179
 
 
180
 
void CAccountManagerPropertiesPage::OnPageChanged( wxWizardExEvent& event )
181
 
{
182
 
    if (event.GetDirection() == false) return;
183
 
 
184
 
    CWizardAccountManager* pWAM = ((CWizardAccountManager*)GetParent());
185
 
 
186
 
    wxASSERT(m_pTitleStaticCtrl);
187
 
    wxASSERT(m_pPleaseWaitStaticCtrl);
188
 
    wxASSERT(m_pProgressIndicator);
189
 
    wxASSERT(pWAM);
190
 
 
191
 
    if (!pWAM->m_strProjectName.IsEmpty()) {
192
 
        wxString str;
193
 
 
194
 
        // %s is the project name
195
 
        //    i.e. 'BOINC', 'GridRepublic'
196
 
        str.Printf(_("Communicating with %s."), pWAM->m_strProjectName.c_str());
197
 
 
198
 
        m_pTitleStaticCtrl->SetLabel(
199
 
            str
200
 
        );
201
 
    } else {
202
 
        m_pTitleStaticCtrl->SetLabel(
203
 
            _("Communicating with server.")
204
 
        );
205
 
    }
206
 
 
207
 
    m_pPleaseWaitStaticCtrl->SetLabel(
208
 
        _("Please wait...")
209
 
    );
210
 
 
211
 
    SetProjectPropertiesSucceeded(false);
212
 
    SetProjectPropertiesURLFailure(false);
213
 
    SetProjectAccountCreationDisabled(false);
214
 
    SetProjectClientAccountCreationDisabled(false);
215
 
    SetNetworkConnectionDetected(false);
216
 
    SetNextState(ACCTMGRPROP_INIT);
217
 
 
218
 
    CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
219
 
    AddPendingEvent(TransitionEvent);
220
 
 
221
 
    Fit();
222
 
}
223
 
 
224
 
/*!
225
 
 * wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
226
 
 */
227
 
 
228
 
void CAccountManagerPropertiesPage::OnCancel( wxWizardExEvent& event ) {
229
 
    PROCESS_CANCELEVENT(event);
230
 
}
231
 
 
232
 
/*!
233
 
 * wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
234
 
 */
235
 
 
236
 
void CAccountManagerPropertiesPage::OnStateChange( CAccountManagerPropertiesPageEvent& WXUNUSED(event) )
237
 
{
238
 
    CMainDocument* pDoc         = wxGetApp().GetDocument();
239
 
    CWizardAccountManager* pWAM = ((CWizardAccountManager*)GetParent());
240
 
    PROJECT_CONFIG* pc          = &pWAM->project_config;
241
 
    CC_STATUS status;
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;
249
 
 
250
 
    wxASSERT(pDoc);
251
 
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
252
 
 
253
 
    switch(GetCurrentState()) {
254
 
        case ACCTMGRPROP_INIT:
255
 
            pWAM->DisableNextButton();
256
 
            pWAM->DisableBackButton();
257
 
            StartProgress(m_pProgressIndicator);
258
 
            SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN);
259
 
            break;
260
 
        case ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN:
261
 
            SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_EXECUTE);
262
 
            break;
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()
267
 
            );
268
 
 
269
 
            // Wait until we are done processing the request.
270
 
            dtStartExecutionTime = wxDateTime::Now();
271
 
            dtCurrentExecutionTime = wxDateTime::Now();
272
 
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
273
 
            iReturnValue = 0;
274
 
            pc->clear();
275
 
            pc->error_num = ERR_IN_PROGRESS;
276
 
            while ((!iReturnValue && (ERR_IN_PROGRESS == pc->error_num)) &&
277
 
                   tsExecutionTime.GetSeconds() <= 60 &&
278
 
                   !CHECK_CLOSINGINPROGRESS()
279
 
                  )
280
 
            {
281
 
                dtCurrentExecutionTime = wxDateTime::Now();
282
 
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
283
 
                iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
284
 
                IncrementProgress(m_pProgressIndicator);
285
 
 
286
 
                ::wxMilliSleep(500);
287
 
                ::wxSafeYield(GetParent());
288
 
            }
289
 
 
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);
300
 
 
301
 
                bSuccessfulCondition = pc->account_creation_disabled;
302
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRACCOUNTCREATIONDISABLED)) {
303
 
                    SetProjectAccountCreationDisabled(true);
304
 
                } else {
305
 
                    SetProjectAccountCreationDisabled(false);
306
 
                }
307
 
 
308
 
                bSuccessfulCondition = pc->client_account_creation_disabled;
309
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRCLIENTACCOUNTCREATIONDISABLED)) {
310
 
                    SetProjectClientAccountCreationDisabled(true);
311
 
                } else {
312
 
                    SetProjectClientAccountCreationDisabled(false);
313
 
                }
314
 
 
315
 
                bSuccessfulCondition = !pc->terms_of_use.empty();
316
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRTERMSOFUSEREQUIRED)) {
317
 
                    SetTermsOfUseRequired(true);
318
 
                } else {
319
 
                    SetTermsOfUseRequired(false);
320
 
                }
321
 
 
322
 
                pWAM->m_strProjectName = wxString(pc->name.c_str(), wxConvUTF8);
323
 
 
324
 
                SetNextState(ACCTMGRPROP_CLEANUP);
325
 
            } else {
326
 
                SetProjectPropertiesSucceeded(false);
327
 
 
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);
334
 
                } else {
335
 
                    SetProjectPropertiesURLFailure(false);
336
 
                }
337
 
 
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)) &&
342
 
                    (!iReturnValue);
343
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIESURL)) {
344
 
                    SetServerReportedError(true);
345
 
 
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"));
349
 
                    }
350
 
                    pWAM->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
351
 
 
352
 
                } else {
353
 
                    SetServerReportedError(false);
354
 
                }
355
 
 
356
 
                SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN);
357
 
            }
358
 
            break;
359
 
        case ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN:
360
 
            SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE);
361
 
            break;
362
 
        case ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE:
363
 
            // Attempt to determine if we are even connected to a network
364
 
 
365
 
            // Wait until we are done processing the request.
366
 
            dtStartExecutionTime = wxDateTime::Now();
367
 
            dtCurrentExecutionTime = wxDateTime::Now();
368
 
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
369
 
            iReturnValue = 0;
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()
374
 
                  )
375
 
            {
376
 
                dtCurrentExecutionTime = wxDateTime::Now();
377
 
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
378
 
                iReturnValue = pDoc->GetCoreClientStatus(status);
379
 
                IncrementProgress(m_pProgressIndicator);
380
 
 
381
 
                ::wxMilliSleep(500);
382
 
                ::wxSafeYield(GetParent());
383
 
            }
384
 
 
385
 
            bSuccessfulCondition = NETWORK_STATUS_WANT_CONNECTION != status.network_status;
386
 
            if (bSuccessfulCondition && !CHECK_DEBUG_FLAG(WIZDEBUG_ERRNETDETECTION)) {
387
 
                SetNetworkConnectionDetected(true);
388
 
            } else {
389
 
                SetNetworkConnectionDetected(false);
390
 
            }
391
 
 
392
 
            SetNextState(ACCTMGRPROP_CLEANUP);
393
 
            break;
394
 
        case ACCTMGRPROP_CLEANUP:
395
 
            FinishProgress(m_pProgressIndicator);
396
 
            SetNextState(ACCTMGRPROP_END);
397
 
            break;
398
 
        default:
399
 
            // Allow a glimps of what the result was before advancing to the next page.
400
 
            wxSleep(1);
401
 
            pWAM->EnableNextButton();
402
 
            pWAM->EnableBackButton();
403
 
            pWAM->SimulateNextButton();
404
 
            bPostNewEvent = false;
405
 
            break;
406
 
    }
407
 
 
408
 
    Update();
409
 
 
410
 
    if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
411
 
        CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
412
 
        AddPendingEvent(TransitionEvent);
413
 
    }
414
 
}
415
 
   
416
 
/*!
417
 
 * Gets the previous page.
418
 
 */
419
 
 
420
 
wxWizardPageEx* CAccountManagerPropertiesPage::GetPrev() const
421
 
{
422
 
    return PAGE_TRANSITION_BACK;
423
 
}
424
 
 
425
 
/*!
426
 
 * Gets the next page.
427
 
 */
428
 
 
429
 
wxWizardPageEx* CAccountManagerPropertiesPage::GetNext() const
430
 
{
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);
449
 
    } else {
450
 
        // The project must be down for maintenance
451
 
        return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
452
 
    }
453
 
    return NULL;
454
 
}
455
 
 
456
 
/*!
457
 
 * Should we show tooltips?
458
 
 */
459
 
 
460
 
bool CAccountManagerPropertiesPage::ShowToolTips()
461
 
{
462
 
    return TRUE;
463
 
}
464
 
 
465
 
 
466
 
void CAccountManagerPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
467
 
    m_iBitmapIndex = 1;
468
 
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
469
 
}
470
 
 
471
 
void CAccountManagerPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
472
 
    m_iBitmapIndex += 1;
473
 
    if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
474
 
 
475
 
    wxString str;
476
 
    str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
477
 
 
478
 
    pBitmap->SetBitmap(GetBitmapResource(str));
479
 
    Update();
480
 
}
481
 
 
482
 
void CAccountManagerPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
483
 
    m_iBitmapIndex = 12;
484
 
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
485
 
}
486
 
 
487
 
/*!
488
 
 * Get bitmap resources
489
 
 */
490
 
 
491
 
wxBitmap CAccountManagerPropertiesPage::GetBitmapResource( const wxString& name )
492
 
{
493
 
    // Bitmap retrieval
494
 
    if (name == wxT("res/wizprogress01.xpm"))
495
 
    {
496
 
        wxBitmap bitmap(wizprogress01_xpm);
497
 
        return bitmap;
498
 
    }
499
 
    else if (name == wxT("res/wizprogress02.xpm"))
500
 
    {
501
 
        wxBitmap bitmap(wizprogress02_xpm);
502
 
        return bitmap;
503
 
    }
504
 
    else if (name == wxT("res/wizprogress03.xpm"))
505
 
    {
506
 
        wxBitmap bitmap(wizprogress03_xpm);
507
 
        return bitmap;
508
 
    }
509
 
    else if (name == wxT("res/wizprogress04.xpm"))
510
 
    {
511
 
        wxBitmap bitmap(wizprogress04_xpm);
512
 
        return bitmap;
513
 
    }
514
 
    else if (name == wxT("res/wizprogress05.xpm"))
515
 
    {
516
 
        wxBitmap bitmap(wizprogress05_xpm);
517
 
        return bitmap;
518
 
    }
519
 
    else if (name == wxT("res/wizprogress06.xpm"))
520
 
    {
521
 
        wxBitmap bitmap(wizprogress06_xpm);
522
 
        return bitmap;
523
 
    }
524
 
    else if (name == wxT("res/wizprogress07.xpm"))
525
 
    {
526
 
        wxBitmap bitmap(wizprogress07_xpm);
527
 
        return bitmap;
528
 
    }
529
 
    else if (name == wxT("res/wizprogress08.xpm"))
530
 
    {
531
 
        wxBitmap bitmap(wizprogress08_xpm);
532
 
        return bitmap;
533
 
    }
534
 
    else if (name == wxT("res/wizprogress09.xpm"))
535
 
    {
536
 
        wxBitmap bitmap(wizprogress09_xpm);
537
 
        return bitmap;
538
 
    }
539
 
    else if (name == wxT("res/wizprogress10.xpm"))
540
 
    {
541
 
        wxBitmap bitmap(wizprogress10_xpm);
542
 
        return bitmap;
543
 
    }
544
 
    else if (name == wxT("res/wizprogress11.xpm"))
545
 
    {
546
 
        wxBitmap bitmap(wizprogress11_xpm);
547
 
        return bitmap;
548
 
    }
549
 
    else if (name == wxT("res/wizprogress12.xpm"))
550
 
    {
551
 
        wxBitmap bitmap(wizprogress12_xpm);
552
 
        return bitmap;
553
 
    }
554
 
    return wxNullBitmap;
555
 
}
556
 
 
557
 
/*!
558
 
 * Get icon resources
559
 
 */
560
 
 
561
 
wxIcon CAccountManagerPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
562
 
{
563
 
    // Icon retrieval
564
 
////@begin CAccountManagerPropertiesPage icon retrieval
565
 
    return wxNullIcon;
566
 
////@end CAccountManagerPropertiesPage icon retrieval
567
 
}
 
1
// This file is part of BOINC.
 
2
// http://boinc.berkeley.edu
 
3
// Copyright (C) 2008 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 "AccountManagerPropertiesPage.h"
 
20
#endif
 
21
 
 
22
#include "stdwx.h"
 
23
#include "network.h"
 
24
#include "diagnostics.h"
 
25
#include "util.h"
 
26
#include "mfile.h"
 
27
#include "miofile.h"
 
28
#include "parse.h"
 
29
#include "error_numbers.h"
 
30
#include "wizardex.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"
 
43
 
 
44
 
 
45
////@begin XPM images
 
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"
 
58
////@end XPM images
 
59
 
 
60
/*!
 
61
 * CAccountManagerPropertiesPage custom event definition
 
62
 */
 
63
 
 
64
DEFINE_EVENT_TYPE(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE)
 
65
  
 
66
/*!
 
67
 * CAccountManagerPropertiesPage type definition
 
68
 */
 
69
 
 
70
IMPLEMENT_DYNAMIC_CLASS( CAccountManagerPropertiesPage, wxWizardPageEx )
 
71
 
 
72
/*!
 
73
 * CAccountManagerPropertiesPage event table definition
 
74
 */
 
75
 
 
76
BEGIN_EVENT_TABLE( CAccountManagerPropertiesPage, wxWizardPageEx )
 
77
 
 
78
    EVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE( CAccountManagerPropertiesPage::OnStateChange )
 
79
 
 
80
////@begin CAccountManagerPropertiesPage event table entries
 
81
    EVT_WIZARDEX_PAGE_CHANGED( -1, CAccountManagerPropertiesPage::OnPageChanged )
 
82
    EVT_WIZARDEX_CANCEL( -1, CAccountManagerPropertiesPage::OnCancel )
 
83
 
 
84
////@end CAccountManagerPropertiesPage event table entries
 
85
 
 
86
END_EVENT_TABLE()
 
87
 
 
88
/*!
 
89
 * CAccountManagerPropertiesPage constructors
 
90
 */
 
91
 
 
92
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( )
 
93
{
 
94
}
 
95
 
 
96
CAccountManagerPropertiesPage::CAccountManagerPropertiesPage( CBOINCBaseWizard* parent )
 
97
{
 
98
    Create( parent );
 
99
}
 
100
 
 
101
/*!
 
102
 * CProjectPropertiesPage creator
 
103
 */
 
104
 
 
105
bool CAccountManagerPropertiesPage::Create( CBOINCBaseWizard* parent )
 
106
{
 
107
////@begin CAccountManagerPropertiesPage member initialisation
 
108
    m_pTitleStaticCtrl = NULL;
 
109
    m_pPleaseWaitStaticCtrl = NULL;
 
110
    m_pProgressIndicator = NULL;
 
111
////@end CAccountManagerPropertiesPage member initialisation
 
112
 
 
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;
 
122
    m_iBitmapIndex = 0;
 
123
    m_iCurrentState = ACCTMGRPROP_INIT;
 
124
 
 
125
////@begin CAccountManagerPropertiesPage creation
 
126
    wxWizardPageEx::Create( parent, ID_ACCOUNTMANAGERPROPERTIESPAGE );
 
127
 
 
128
    CreateControls();
 
129
    GetSizer()->Fit(this);
 
130
////@end CAccountManagerPropertiesPage creation
 
131
    return TRUE;
 
132
}
 
133
 
 
134
/*!
 
135
 * Control creation for CProjectPropertiesPage
 
136
 */
 
137
 
 
138
void CAccountManagerPropertiesPage::CreateControls()
 
139
{    
 
140
////@begin CAccountManagerPropertiesPage content construction
 
141
    CAccountManagerPropertiesPage* itemWizardPage36 = this;
 
142
 
 
143
    wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
 
144
    itemWizardPage36->SetSizer(itemBoxSizer37);
 
145
 
 
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);
 
150
 
 
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);
 
154
 
 
155
    itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
 
156
 
 
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);
 
163
 
 
164
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
 
165
 
 
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);
 
170
 
 
171
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
 
172
////@end CAccountManagerPropertiesPage content construction
 
173
}
 
174
 
 
175
/*!
 
176
 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
 
177
 */
 
178
 
 
179
void CAccountManagerPropertiesPage::OnPageChanged( wxWizardExEvent& event )
 
180
{
 
181
    if (event.GetDirection() == false) return;
 
182
 
 
183
    CWizardAttach* pWA = ((CWizardAttach*)GetParent());
 
184
    wxASSERT(m_pTitleStaticCtrl);
 
185
    wxASSERT(m_pPleaseWaitStaticCtrl);
 
186
    wxASSERT(m_pProgressIndicator);
 
187
    wxASSERT(pWA);
 
188
 
 
189
    if (!pWA->m_strProjectName.IsEmpty()) {
 
190
        wxString str;
 
191
 
 
192
        // %s is the project name
 
193
        //    i.e. 'BOINC', 'GridRepublic'
 
194
        str.Printf(_("Communicating with %s."), pWA->m_strProjectName.c_str());
 
195
 
 
196
        m_pTitleStaticCtrl->SetLabel(
 
197
            str
 
198
        );
 
199
    } else {
 
200
        m_pTitleStaticCtrl->SetLabel(
 
201
            _("Communicating with server.")
 
202
        );
 
203
    }
 
204
 
 
205
    m_pPleaseWaitStaticCtrl->SetLabel(
 
206
        _("Please wait...")
 
207
    );
 
208
 
 
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);
 
218
 
 
219
    CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
 
220
    AddPendingEvent(TransitionEvent);
 
221
 
 
222
    Fit();
 
223
}
 
224
 
 
225
/*!
 
226
 * wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
 
227
 */
 
228
 
 
229
void CAccountManagerPropertiesPage::OnCancel( wxWizardExEvent& event ) {
 
230
    PROCESS_CANCELEVENT(event);
 
231
}
 
232
 
 
233
/*!
 
234
 * wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
 
235
 */
 
236
 
 
237
void CAccountManagerPropertiesPage::OnStateChange( CAccountManagerPropertiesPageEvent& WXUNUSED(event) )
 
238
{
 
239
    CMainDocument*  pDoc = wxGetApp().GetDocument();
 
240
    CWizardAttach*  pWA = ((CWizardAttach*)GetParent());
 
241
    PROJECT_CONFIG* pc = &pWA->project_config;
 
242
    CC_STATUS status;
 
243
    wxDateTime dtStartExecutionTime;
 
244
    wxDateTime dtCurrentExecutionTime;
 
245
    wxTimeSpan tsExecutionTime;
 
246
    wxString strBuffer = wxEmptyString;
 
247
    bool bPostNewEvent = true;
 
248
    int  iReturnValue = 0;
 
249
 
 
250
    wxASSERT(pDoc);
 
251
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
 
252
 
 
253
    switch(GetCurrentState()) {
 
254
        case ACCTMGRPROP_INIT:
 
255
            pWA->DisableNextButton();
 
256
            pWA->DisableBackButton();
 
257
            StartProgress(m_pProgressIndicator);
 
258
            SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN);
 
259
            break;
 
260
        case ACCTMGRPROP_RETRPROJECTPROPERTIES_BEGIN:
 
261
            SetNextState(ACCTMGRPROP_RETRPROJECTPROPERTIES_EXECUTE);
 
262
            break;
 
263
        case ACCTMGRPROP_RETRPROJECTPROPERTIES_EXECUTE:
 
264
            // Attempt to retrieve the project's account creation policies
 
265
            
 
266
            // Wait until we are done processing the request.
 
267
            dtStartExecutionTime = wxDateTime::Now();
 
268
            dtCurrentExecutionTime = wxDateTime::Now();
 
269
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
270
            iReturnValue = 0;
 
271
            pc->clear();
 
272
            pc->error_num = ERR_RETRY;
 
273
            while (
 
274
                !iReturnValue &&
 
275
                ((ERR_IN_PROGRESS == pc->error_num) || (ERR_RETRY == pc->error_num)) &&
 
276
                tsExecutionTime.GetSeconds() <= 60 &&
 
277
                !CHECK_CLOSINGINPROGRESS()
 
278
            ) {
 
279
                if (ERR_RETRY == pc->error_num) {
 
280
                    pDoc->rpc.get_project_config(
 
281
                        (const char*)pWA->m_AccountManagerInfoPage->GetProjectURL().mb_str()
 
282
                    );
 
283
                }
 
284
 
 
285
                dtCurrentExecutionTime = wxDateTime::Now();
 
286
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
287
                iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
 
288
                IncrementProgress(m_pProgressIndicator);
 
289
 
 
290
                ::wxMilliSleep(500);
 
291
                ::wxSafeYield(GetParent());
 
292
            }
 
293
 
 
294
            if (
 
295
                !iReturnValue
 
296
                && (!pc->error_num || pc->error_num == ERR_ACCT_CREATION_DISABLED)
 
297
            ) {
 
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());
 
307
 
 
308
                pWA->m_strProjectName = wxString(pc->name.c_str(), wxConvUTF8);
 
309
 
 
310
            } else {
 
311
 
 
312
                SetProjectPropertiesSucceeded(false);
 
313
                SetProjectPropertiesURLFailure(pc->error_num == ERR_FILE_NOT_FOUND);
 
314
 
 
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)
 
320
                );
 
321
                SetProjectPropertiesCommunicationFailure(comm_failure);
 
322
 
 
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)
 
329
                );
 
330
                SetServerReportedError(server_reported_error);
 
331
 
 
332
                if (server_reported_error) {
 
333
                    SetServerReportedError(true);
 
334
 
 
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"));
 
338
                    }
 
339
                    pWA->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
 
340
                } else {
 
341
                    SetServerReportedError(false);
 
342
                }
 
343
            }
 
344
 
 
345
            SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN);
 
346
            break;
 
347
        case ACCTMGRPROP_DETERMINENETWORKSTATUS_BEGIN:
 
348
            SetNextState(ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE);
 
349
            break;
 
350
        case ACCTMGRPROP_DETERMINENETWORKSTATUS_EXECUTE:
 
351
            // Attempt to determine if we are even connected to a network
 
352
 
 
353
            // Wait until we are done processing the request.
 
354
            dtStartExecutionTime = wxDateTime::Now();
 
355
            dtCurrentExecutionTime = wxDateTime::Now();
 
356
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
357
            iReturnValue = 0;
 
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()
 
362
                  )
 
363
            {
 
364
                dtCurrentExecutionTime = wxDateTime::Now();
 
365
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
366
                iReturnValue = pDoc->GetCoreClientStatus(status);
 
367
                IncrementProgress(m_pProgressIndicator);
 
368
 
 
369
                ::wxMilliSleep(500);
 
370
                ::wxSafeYield(GetParent());
 
371
            }
 
372
 
 
373
            SetNetworkConnectionNotDetected(NETWORK_STATUS_WANT_CONNECTION == status.network_status);
 
374
 
 
375
            SetNextState(ACCTMGRPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN);
 
376
            break;
 
377
        case ACCTMGRPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN:
 
378
            SetNextState(ACCTMGRPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE);
 
379
            break;
 
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);
 
385
            break;
 
386
        case ACCTMGRPROP_CLEANUP:
 
387
            FinishProgress(m_pProgressIndicator);
 
388
            SetNextState(ACCTMGRPROP_END);
 
389
            break;
 
390
        default:
 
391
            // Allow a glimps of what the result was before advancing to the next page.
 
392
            wxSleep(1);
 
393
            pWA->EnableNextButton();
 
394
            pWA->EnableBackButton();
 
395
            pWA->SimulateNextButton();
 
396
            bPostNewEvent = false;
 
397
            break;
 
398
    }
 
399
 
 
400
    Update();
 
401
 
 
402
    if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
 
403
        CAccountManagerPropertiesPageEvent TransitionEvent(wxEVT_ACCOUNTMANAGERPROPERTIES_STATECHANGE, this);
 
404
        AddPendingEvent(TransitionEvent);
 
405
    }
 
406
}
 
407
   
 
408
/*!
 
409
 * Gets the previous page.
 
410
 */
 
411
 
 
412
wxWizardPageEx* CAccountManagerPropertiesPage::GetPrev() const
 
413
{
 
414
    return PAGE_TRANSITION_BACK;
 
415
}
 
416
 
 
417
/*!
 
418
 * Gets the next page.
 
419
 */
 
420
 
 
421
wxWizardPageEx* CAccountManagerPropertiesPage::GetNext() const
 
422
{
 
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);
 
444
    } else {
 
445
        // The project must be down for maintenance
 
446
        return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
 
447
    }
 
448
    return NULL;
 
449
}
 
450
 
 
451
/*!
 
452
 * Should we show tooltips?
 
453
 */
 
454
 
 
455
bool CAccountManagerPropertiesPage::ShowToolTips()
 
456
{
 
457
    return TRUE;
 
458
}
 
459
 
 
460
 
 
461
void CAccountManagerPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
 
462
    m_iBitmapIndex = 1;
 
463
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
 
464
}
 
465
 
 
466
void CAccountManagerPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
 
467
    m_iBitmapIndex += 1;
 
468
    if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
 
469
 
 
470
    wxString str;
 
471
    str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
 
472
 
 
473
    pBitmap->SetBitmap(GetBitmapResource(str));
 
474
    Update();
 
475
}
 
476
 
 
477
void CAccountManagerPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
 
478
    m_iBitmapIndex = 12;
 
479
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
 
480
}
 
481
 
 
482
/*!
 
483
 * Get bitmap resources
 
484
 */
 
485
 
 
486
wxBitmap CAccountManagerPropertiesPage::GetBitmapResource( const wxString& name )
 
487
{
 
488
    // Bitmap retrieval
 
489
    if (name == wxT("res/wizprogress01.xpm"))
 
490
    {
 
491
        wxBitmap bitmap(wizprogress01_xpm);
 
492
        return bitmap;
 
493
    }
 
494
    else if (name == wxT("res/wizprogress02.xpm"))
 
495
    {
 
496
        wxBitmap bitmap(wizprogress02_xpm);
 
497
        return bitmap;
 
498
    }
 
499
    else if (name == wxT("res/wizprogress03.xpm"))
 
500
    {
 
501
        wxBitmap bitmap(wizprogress03_xpm);
 
502
        return bitmap;
 
503
    }
 
504
    else if (name == wxT("res/wizprogress04.xpm"))
 
505
    {
 
506
        wxBitmap bitmap(wizprogress04_xpm);
 
507
        return bitmap;
 
508
    }
 
509
    else if (name == wxT("res/wizprogress05.xpm"))
 
510
    {
 
511
        wxBitmap bitmap(wizprogress05_xpm);
 
512
        return bitmap;
 
513
    }
 
514
    else if (name == wxT("res/wizprogress06.xpm"))
 
515
    {
 
516
        wxBitmap bitmap(wizprogress06_xpm);
 
517
        return bitmap;
 
518
    }
 
519
    else if (name == wxT("res/wizprogress07.xpm"))
 
520
    {
 
521
        wxBitmap bitmap(wizprogress07_xpm);
 
522
        return bitmap;
 
523
    }
 
524
    else if (name == wxT("res/wizprogress08.xpm"))
 
525
    {
 
526
        wxBitmap bitmap(wizprogress08_xpm);
 
527
        return bitmap;
 
528
    }
 
529
    else if (name == wxT("res/wizprogress09.xpm"))
 
530
    {
 
531
        wxBitmap bitmap(wizprogress09_xpm);
 
532
        return bitmap;
 
533
    }
 
534
    else if (name == wxT("res/wizprogress10.xpm"))
 
535
    {
 
536
        wxBitmap bitmap(wizprogress10_xpm);
 
537
        return bitmap;
 
538
    }
 
539
    else if (name == wxT("res/wizprogress11.xpm"))
 
540
    {
 
541
        wxBitmap bitmap(wizprogress11_xpm);
 
542
        return bitmap;
 
543
    }
 
544
    else if (name == wxT("res/wizprogress12.xpm"))
 
545
    {
 
546
        wxBitmap bitmap(wizprogress12_xpm);
 
547
        return bitmap;
 
548
    }
 
549
    return wxNullBitmap;
 
550
}
 
551
 
 
552
/*!
 
553
 * Get icon resources
 
554
 */
 
555
 
 
556
wxIcon CAccountManagerPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
 
557
{
 
558
    // Icon retrieval
 
559
////@begin CAccountManagerPropertiesPage icon retrieval
 
560
    return wxNullIcon;
 
561
////@end CAccountManagerPropertiesPage icon retrieval
 
562
}
 
563