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

« back to all changes in this revision

Viewing changes to clientgui/ProjectPropertiesPage.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 "ProjectPropertiesPage.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 "WizardAttachProject.h"
41
 
#include "ProjectPropertiesPage.h"
42
 
#include "ProjectInfoPage.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
 
 * CProjectPropertiesPage custom event definition
64
 
 */
65
 
 
66
 
DEFINE_EVENT_TYPE(wxEVT_PROJECTPROPERTIES_STATECHANGE)
67
 
  
68
 
/*!
69
 
 * CProjectPropertiesPage type definition
70
 
 */
71
 
 
72
 
IMPLEMENT_DYNAMIC_CLASS( CProjectPropertiesPage, wxWizardPageEx )
73
 
 
74
 
/*!
75
 
 * CProjectPropertiesPage event table definition
76
 
 */
77
 
 
78
 
BEGIN_EVENT_TABLE( CProjectPropertiesPage, wxWizardPageEx )
79
 
 
80
 
    EVT_PROJECTPROPERTIES_STATECHANGE( CProjectPropertiesPage::OnStateChange )
81
 
 
82
 
////@begin CProjectPropertiesPage event table entries
83
 
    EVT_WIZARDEX_PAGE_CHANGED( -1, CProjectPropertiesPage::OnPageChanged )
84
 
    EVT_WIZARDEX_CANCEL( -1, CProjectPropertiesPage::OnCancel )
85
 
 
86
 
////@end CProjectPropertiesPage event table entries
87
 
 
88
 
END_EVENT_TABLE()
89
 
 
90
 
/*!
91
 
 * CProjectPropertiesPage constructors
92
 
 */
93
 
 
94
 
CProjectPropertiesPage::CProjectPropertiesPage( )
95
 
{
96
 
}
97
 
 
98
 
CProjectPropertiesPage::CProjectPropertiesPage( CBOINCBaseWizard* parent )
99
 
{
100
 
    Create( parent );
101
 
}
102
 
 
103
 
/*!
104
 
 * WizardPage creator
105
 
 */
106
 
 
107
 
bool CProjectPropertiesPage::Create( CBOINCBaseWizard* parent )
108
 
{
109
 
////@begin CProjectPropertiesPage member initialisation
110
 
    m_pTitleStaticCtrl = NULL;
111
 
    m_pProgressIndicator = NULL;
112
 
////@end CProjectPropertiesPage member initialisation
113
 
 
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;
121
 
    m_iBitmapIndex = 0;
122
 
    m_iCurrentState = PROJPROP_INIT;
123
 
 
124
 
////@begin CProjectPropertiesPage creation
125
 
    wxBitmap wizardBitmap(wxNullBitmap);
126
 
    wxWizardPageEx::Create( parent, ID_PROJECTPROPERTIESPAGE, wizardBitmap );
127
 
 
128
 
    CreateControls();
129
 
    GetSizer()->Fit(this);
130
 
////@end CProjectPropertiesPage creation
131
 
 
132
 
    return TRUE;
133
 
}
134
 
 
135
 
/*!
136
 
 * Control creation for WizardPage
137
 
 */
138
 
 
139
 
void CProjectPropertiesPage::CreateControls()
140
 
{    
141
 
////@begin CProjectPropertiesPage content construction
142
 
    CProjectPropertiesPage* 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
 
    itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
153
 
 
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);
160
 
 
161
 
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
162
 
 
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);
167
 
 
168
 
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
169
 
////@end CProjectPropertiesPage content construction
170
 
}
171
 
 
172
 
/*!
173
 
 * Gets the previous page.
174
 
 */
175
 
 
176
 
wxWizardPageEx* CProjectPropertiesPage::GetPrev() const
177
 
{
178
 
    return PAGE_TRANSITION_BACK;
179
 
}
180
 
 
181
 
/*!
182
 
 * Gets the next page.
183
 
 */
184
 
 
185
 
wxWizardPageEx* CProjectPropertiesPage::GetNext() const
186
 
{
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);
208
 
    } else {
209
 
        // The project must be down for maintenance
210
 
        return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
211
 
    }
212
 
    return NULL;
213
 
}
214
 
 
215
 
/*!
216
 
 * Should we show tooltips?
217
 
 */
218
 
 
219
 
bool CProjectPropertiesPage::ShowToolTips()
220
 
{
221
 
    return TRUE;
222
 
}
223
 
 
224
 
void CProjectPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
225
 
    m_iBitmapIndex = 1;
226
 
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
227
 
}
228
 
 
229
 
void CProjectPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
230
 
    m_iBitmapIndex += 1;
231
 
    if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
232
 
 
233
 
    wxString str;
234
 
    str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
235
 
 
236
 
    pBitmap->SetBitmap(GetBitmapResource(str));
237
 
    Update();
238
 
}
239
 
 
240
 
void CProjectPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
241
 
    m_iBitmapIndex = 12;
242
 
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
243
 
}
244
 
 
245
 
/*!
246
 
 * Get bitmap resources
247
 
 */
248
 
 
249
 
wxBitmap CProjectPropertiesPage::GetBitmapResource( const wxString& name )
250
 
{
251
 
    // Bitmap retrieval
252
 
    if (name == wxT("res/wizprogress01.xpm"))
253
 
    {
254
 
        wxBitmap bitmap(wizprogress01_xpm);
255
 
        return bitmap;
256
 
    }
257
 
    else if (name == wxT("res/wizprogress02.xpm"))
258
 
    {
259
 
        wxBitmap bitmap(wizprogress02_xpm);
260
 
        return bitmap;
261
 
    }
262
 
    else if (name == wxT("res/wizprogress03.xpm"))
263
 
    {
264
 
        wxBitmap bitmap(wizprogress03_xpm);
265
 
        return bitmap;
266
 
    }
267
 
    else if (name == wxT("res/wizprogress04.xpm"))
268
 
    {
269
 
        wxBitmap bitmap(wizprogress04_xpm);
270
 
        return bitmap;
271
 
    }
272
 
    else if (name == wxT("res/wizprogress05.xpm"))
273
 
    {
274
 
        wxBitmap bitmap(wizprogress05_xpm);
275
 
        return bitmap;
276
 
    }
277
 
    else if (name == wxT("res/wizprogress06.xpm"))
278
 
    {
279
 
        wxBitmap bitmap(wizprogress06_xpm);
280
 
        return bitmap;
281
 
    }
282
 
    else if (name == wxT("res/wizprogress07.xpm"))
283
 
    {
284
 
        wxBitmap bitmap(wizprogress07_xpm);
285
 
        return bitmap;
286
 
    }
287
 
    else if (name == wxT("res/wizprogress08.xpm"))
288
 
    {
289
 
        wxBitmap bitmap(wizprogress08_xpm);
290
 
        return bitmap;
291
 
    }
292
 
    else if (name == wxT("res/wizprogress09.xpm"))
293
 
    {
294
 
        wxBitmap bitmap(wizprogress09_xpm);
295
 
        return bitmap;
296
 
    }
297
 
    else if (name == wxT("res/wizprogress10.xpm"))
298
 
    {
299
 
        wxBitmap bitmap(wizprogress10_xpm);
300
 
        return bitmap;
301
 
    }
302
 
    else if (name == wxT("res/wizprogress11.xpm"))
303
 
    {
304
 
        wxBitmap bitmap(wizprogress11_xpm);
305
 
        return bitmap;
306
 
    }
307
 
    else if (name == wxT("res/wizprogress12.xpm"))
308
 
    {
309
 
        wxBitmap bitmap(wizprogress12_xpm);
310
 
        return bitmap;
311
 
    }
312
 
    return wxNullBitmap;
313
 
}
314
 
 
315
 
/*!
316
 
 * Get icon resources
317
 
 */
318
 
 
319
 
wxIcon CProjectPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
320
 
{
321
 
    // Icon retrieval
322
 
////@begin CProjectPropertiesPage icon retrieval
323
 
    return wxNullIcon;
324
 
////@end CProjectPropertiesPage icon retrieval
325
 
}
326
 
 
327
 
/*!
328
 
 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
329
 
 */
330
 
 
331
 
void CProjectPropertiesPage::OnPageChanged( wxWizardExEvent& event ) {
332
 
    if (event.GetDirection() == false) return;
333
 
 
334
 
    wxASSERT(m_pTitleStaticCtrl);
335
 
    wxASSERT(m_pProgressIndicator);
336
 
 
337
 
    m_pTitleStaticCtrl->SetLabel(
338
 
        _("Communicating with project\nPlease wait...")
339
 
    );
340
 
 
341
 
    SetProjectPropertiesSucceeded(false);
342
 
    SetProjectPropertiesURLFailure(false);
343
 
    SetProjectAccountCreationDisabled(false);
344
 
    SetProjectClientAccountCreationDisabled(false);
345
 
    SetNetworkConnectionDetected(false);
346
 
    SetNextState(PROJPROP_INIT);
347
 
 
348
 
    CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
349
 
    AddPendingEvent(TransitionEvent);
350
 
 
351
 
    Fit();
352
 
}
353
 
  
354
 
/*!
355
 
 * wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
356
 
 */
357
 
 
358
 
void CProjectPropertiesPage::OnCancel( wxWizardExEvent& event ) {
359
 
    PROCESS_CANCELEVENT(event);
360
 
}
361
 
 
362
 
/*!
363
 
 * wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
364
 
 */
365
 
 
366
 
void CProjectPropertiesPage::OnStateChange( CProjectPropertiesPageEvent& WXUNUSED(event) )
367
 
{
368
 
    CMainDocument* pDoc        = wxGetApp().GetDocument();
369
 
    CWizardAttachProject* pWAP = ((CWizardAttachProject*)GetParent());
370
 
    PROJECT_CONFIG* pc         = &((CWizardAttachProject*)GetParent())->project_config;
371
 
    CC_STATUS status;
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;
379
 
 
380
 
    wxASSERT(pDoc);
381
 
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
382
 
 
383
 
    switch(GetCurrentState()) {
384
 
        case PROJPROP_INIT:
385
 
            pWAP->DisableNextButton();
386
 
            pWAP->DisableBackButton();
387
 
            StartProgress(m_pProgressIndicator);
388
 
            SetNextState(PROJPROP_RETRPROJECTPROPERTIES_BEGIN);
389
 
            break;
390
 
        case PROJPROP_RETRPROJECTPROPERTIES_BEGIN:
391
 
            SetNextState(PROJPROP_RETRPROJECTPROPERTIES_EXECUTE);
392
 
            break;
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()
397
 
            );
398
 
 
399
 
            // Wait until we are done processing the request.
400
 
            dtStartExecutionTime = wxDateTime::Now();
401
 
            dtCurrentExecutionTime = wxDateTime::Now();
402
 
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
403
 
            iReturnValue = 0;
404
 
            pc->clear();
405
 
            pc->error_num = ERR_IN_PROGRESS;
406
 
            while ((!iReturnValue && (ERR_IN_PROGRESS == pc->error_num)) &&
407
 
                   tsExecutionTime.GetSeconds() <= 60 &&
408
 
                   !CHECK_CLOSINGINPROGRESS()
409
 
                  )
410
 
            {
411
 
                dtCurrentExecutionTime = wxDateTime::Now();
412
 
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
413
 
                iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
414
 
                IncrementProgress(m_pProgressIndicator);
415
 
 
416
 
                ::wxMilliSleep(500);
417
 
                ::wxSafeYield(GetParent());
418
 
            }
419
 
 
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);
430
 
 
431
 
                bSuccessfulCondition = pc->account_creation_disabled;
432
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRACCOUNTCREATIONDISABLED)) {
433
 
                    SetProjectAccountCreationDisabled(true);
434
 
                } else {
435
 
                    SetProjectAccountCreationDisabled(false);
436
 
                }
437
 
 
438
 
                bSuccessfulCondition = 
439
 
                    (ERR_ALREADY_ATTACHED == pDoc->rpc.project_attach(
440
 
                        (const char*)pWAP->m_ProjectInfoPage->GetProjectURL().mb_str(),
441
 
                        "", "")
442
 
                    );
443
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTALREADYATTACHED)) {
444
 
                    SetProjectAlreadyAttached(true);
445
 
                } else {
446
 
                    SetProjectAlreadyAttached(false);
447
 
                }
448
 
 
449
 
                bSuccessfulCondition = pc->client_account_creation_disabled;
450
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRCLIENTACCOUNTCREATIONDISABLED)) {
451
 
                    SetProjectClientAccountCreationDisabled(true);
452
 
                } else {
453
 
                    SetProjectClientAccountCreationDisabled(false);
454
 
                }
455
 
 
456
 
                bSuccessfulCondition = !pc->terms_of_use.empty();
457
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRTERMSOFUSEREQUIRED)) {
458
 
                    SetTermsOfUseRequired(true);
459
 
                } else {
460
 
                    SetTermsOfUseRequired(false);
461
 
                }
462
 
 
463
 
                SetNextState(PROJPROP_CLEANUP);
464
 
            } else {
465
 
                SetProjectPropertiesSucceeded(false);
466
 
 
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);
473
 
                } else {
474
 
                    SetProjectPropertiesURLFailure(false);
475
 
                }
476
 
 
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)) &&
481
 
                    (!iReturnValue);
482
 
                if (bSuccessfulCondition || CHECK_DEBUG_FLAG(WIZDEBUG_ERRPROJECTPROPERTIESURL)) {
483
 
                    SetServerReportedError(true);
484
 
 
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"));
488
 
                    }
489
 
                    pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
490
 
 
491
 
                } else {
492
 
                    SetServerReportedError(false);
493
 
                }
494
 
 
495
 
                SetNextState(PROJPROP_DETERMINENETWORKSTATUS_BEGIN);
496
 
            }
497
 
            break;
498
 
        case PROJPROP_DETERMINENETWORKSTATUS_BEGIN:
499
 
            SetNextState(PROJPROP_DETERMINENETWORKSTATUS_EXECUTE);
500
 
            break;
501
 
        case PROJPROP_DETERMINENETWORKSTATUS_EXECUTE:
502
 
            // Attempt to determine if we are even connected to a network
503
 
 
504
 
            // Wait until we are done processing the request.
505
 
            dtStartExecutionTime = wxDateTime::Now();
506
 
            dtCurrentExecutionTime = wxDateTime::Now();
507
 
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
508
 
            iReturnValue = 0;
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()
513
 
                  )
514
 
            {
515
 
                dtCurrentExecutionTime = wxDateTime::Now();
516
 
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
517
 
                iReturnValue = pDoc->GetCoreClientStatus(status);
518
 
                IncrementProgress(m_pProgressIndicator);
519
 
 
520
 
                ::wxMilliSleep(500);
521
 
                ::wxSafeYield(GetParent());
522
 
            }
523
 
 
524
 
            bSuccessfulCondition = NETWORK_STATUS_WANT_CONNECTION != status.network_status;
525
 
            if (bSuccessfulCondition && !CHECK_DEBUG_FLAG(WIZDEBUG_ERRNETDETECTION)) {
526
 
                SetNetworkConnectionDetected(true);
527
 
            } else {
528
 
                SetNetworkConnectionDetected(false);
529
 
            }
530
 
            SetNextState(PROJPROP_CLEANUP);
531
 
 
532
 
            break;
533
 
        case PROJPROP_CLEANUP:
534
 
            FinishProgress(m_pProgressIndicator);
535
 
            SetNextState(PROJPROP_END);
536
 
            break;
537
 
        default:
538
 
            // Allow a glimps of what the result was before advancing to the next page.
539
 
            wxSleep(1);
540
 
            pWAP->EnableNextButton();
541
 
            pWAP->EnableBackButton();
542
 
            pWAP->SimulateNextButton();
543
 
            bPostNewEvent = false;
544
 
            break;
545
 
    }
546
 
 
547
 
    Update();
548
 
 
549
 
    if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
550
 
        CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
551
 
        AddPendingEvent(TransitionEvent);
552
 
    }
553
 
}
 
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 "ProjectPropertiesPage.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 "WizardAttach.h"
 
37
#include "ProjectPropertiesPage.h"
 
38
#include "ProjectInfoPage.h"
 
39
#include "CompletionErrorPage.h"
 
40
#include "TermsOfUsePage.h"
 
41
 
 
42
 
 
43
////@begin XPM images
 
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"
 
56
////@end XPM images
 
57
 
 
58
/*!
 
59
 * CProjectPropertiesPage custom event definition
 
60
 */
 
61
 
 
62
DEFINE_EVENT_TYPE(wxEVT_PROJECTPROPERTIES_STATECHANGE)
 
63
  
 
64
/*!
 
65
 * CProjectPropertiesPage type definition
 
66
 */
 
67
 
 
68
IMPLEMENT_DYNAMIC_CLASS( CProjectPropertiesPage, wxWizardPageEx )
 
69
 
 
70
/*!
 
71
 * CProjectPropertiesPage event table definition
 
72
 */
 
73
 
 
74
BEGIN_EVENT_TABLE( CProjectPropertiesPage, wxWizardPageEx )
 
75
 
 
76
    EVT_PROJECTPROPERTIES_STATECHANGE( CProjectPropertiesPage::OnStateChange )
 
77
 
 
78
////@begin CProjectPropertiesPage event table entries
 
79
    EVT_WIZARDEX_PAGE_CHANGED( -1, CProjectPropertiesPage::OnPageChanged )
 
80
    EVT_WIZARDEX_CANCEL( -1, CProjectPropertiesPage::OnCancel )
 
81
 
 
82
////@end CProjectPropertiesPage event table entries
 
83
 
 
84
END_EVENT_TABLE()
 
85
 
 
86
/*!
 
87
 * CProjectPropertiesPage constructors
 
88
 */
 
89
 
 
90
CProjectPropertiesPage::CProjectPropertiesPage( )
 
91
{
 
92
}
 
93
 
 
94
CProjectPropertiesPage::CProjectPropertiesPage( CBOINCBaseWizard* parent )
 
95
{
 
96
    Create( parent );
 
97
}
 
98
 
 
99
/*!
 
100
 * WizardPage creator
 
101
 */
 
102
 
 
103
bool CProjectPropertiesPage::Create( CBOINCBaseWizard* parent )
 
104
{
 
105
////@begin CProjectPropertiesPage member initialisation
 
106
    m_pTitleStaticCtrl = NULL;
 
107
    m_pProgressIndicator = NULL;
 
108
////@end CProjectPropertiesPage member initialisation
 
109
 
 
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;
 
118
    m_iBitmapIndex = 0;
 
119
    m_iCurrentState = PROJPROP_INIT;
 
120
 
 
121
////@begin CProjectPropertiesPage creation
 
122
    wxWizardPageEx::Create( parent, ID_PROJECTPROPERTIESPAGE );
 
123
 
 
124
    CreateControls();
 
125
    GetSizer()->Fit(this);
 
126
////@end CProjectPropertiesPage creation
 
127
 
 
128
    return TRUE;
 
129
}
 
130
 
 
131
/*!
 
132
 * Control creation for WizardPage
 
133
 */
 
134
 
 
135
void CProjectPropertiesPage::CreateControls()
 
136
{    
 
137
////@begin CProjectPropertiesPage content construction
 
138
    CProjectPropertiesPage* itemWizardPage36 = this;
 
139
 
 
140
    wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxVERTICAL);
 
141
    itemWizardPage36->SetSizer(itemBoxSizer37);
 
142
 
 
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);
 
147
 
 
148
    itemBoxSizer37->Add(5, 80, 0, wxALIGN_LEFT|wxALL, 5);
 
149
 
 
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);
 
156
 
 
157
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
 
158
 
 
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);
 
163
 
 
164
    itemFlexGridSizer40->Add(5, 5, 0, wxGROW|wxGROW|wxALL, 5);
 
165
////@end CProjectPropertiesPage content construction
 
166
}
 
167
 
 
168
/*!
 
169
 * Gets the previous page.
 
170
 */
 
171
 
 
172
wxWizardPageEx* CProjectPropertiesPage::GetPrev() const
 
173
{
 
174
    return PAGE_TRANSITION_BACK;
 
175
}
 
176
 
 
177
/*!
 
178
 * Gets the next page.
 
179
 */
 
180
 
 
181
wxWizardPageEx* CProjectPropertiesPage::GetNext() const
 
182
{
 
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);
 
204
    } else {
 
205
        // The project must be down for maintenance
 
206
        return PAGE_TRANSITION_NEXT(ID_ERRUNAVAILABLEPAGE);
 
207
    }
 
208
    return NULL;
 
209
}
 
210
 
 
211
/*!
 
212
 * Should we show tooltips?
 
213
 */
 
214
 
 
215
bool CProjectPropertiesPage::ShowToolTips()
 
216
{
 
217
    return TRUE;
 
218
}
 
219
 
 
220
void CProjectPropertiesPage::StartProgress(wxStaticBitmap* pBitmap) {
 
221
    m_iBitmapIndex = 1;
 
222
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress01.xpm")));
 
223
}
 
224
 
 
225
void CProjectPropertiesPage::IncrementProgress(wxStaticBitmap* pBitmap) {
 
226
    m_iBitmapIndex += 1;
 
227
    if (12 < m_iBitmapIndex) m_iBitmapIndex = 1;
 
228
 
 
229
    wxString str;
 
230
    str.Printf(wxT("res/wizprogress%02d.xpm"), m_iBitmapIndex);
 
231
 
 
232
    pBitmap->SetBitmap(GetBitmapResource(str));
 
233
    Update();
 
234
}
 
235
 
 
236
void CProjectPropertiesPage::FinishProgress(wxStaticBitmap* pBitmap) {
 
237
    m_iBitmapIndex = 12;
 
238
    pBitmap->SetBitmap(GetBitmapResource(wxT("res/wizprogress12.xpm")));
 
239
}
 
240
 
 
241
/*!
 
242
 * Get bitmap resources
 
243
 */
 
244
 
 
245
wxBitmap CProjectPropertiesPage::GetBitmapResource( const wxString& name )
 
246
{
 
247
    // Bitmap retrieval
 
248
    if (name == wxT("res/wizprogress01.xpm"))
 
249
    {
 
250
        wxBitmap bitmap(wizprogress01_xpm);
 
251
        return bitmap;
 
252
    }
 
253
    else if (name == wxT("res/wizprogress02.xpm"))
 
254
    {
 
255
        wxBitmap bitmap(wizprogress02_xpm);
 
256
        return bitmap;
 
257
    }
 
258
    else if (name == wxT("res/wizprogress03.xpm"))
 
259
    {
 
260
        wxBitmap bitmap(wizprogress03_xpm);
 
261
        return bitmap;
 
262
    }
 
263
    else if (name == wxT("res/wizprogress04.xpm"))
 
264
    {
 
265
        wxBitmap bitmap(wizprogress04_xpm);
 
266
        return bitmap;
 
267
    }
 
268
    else if (name == wxT("res/wizprogress05.xpm"))
 
269
    {
 
270
        wxBitmap bitmap(wizprogress05_xpm);
 
271
        return bitmap;
 
272
    }
 
273
    else if (name == wxT("res/wizprogress06.xpm"))
 
274
    {
 
275
        wxBitmap bitmap(wizprogress06_xpm);
 
276
        return bitmap;
 
277
    }
 
278
    else if (name == wxT("res/wizprogress07.xpm"))
 
279
    {
 
280
        wxBitmap bitmap(wizprogress07_xpm);
 
281
        return bitmap;
 
282
    }
 
283
    else if (name == wxT("res/wizprogress08.xpm"))
 
284
    {
 
285
        wxBitmap bitmap(wizprogress08_xpm);
 
286
        return bitmap;
 
287
    }
 
288
    else if (name == wxT("res/wizprogress09.xpm"))
 
289
    {
 
290
        wxBitmap bitmap(wizprogress09_xpm);
 
291
        return bitmap;
 
292
    }
 
293
    else if (name == wxT("res/wizprogress10.xpm"))
 
294
    {
 
295
        wxBitmap bitmap(wizprogress10_xpm);
 
296
        return bitmap;
 
297
    }
 
298
    else if (name == wxT("res/wizprogress11.xpm"))
 
299
    {
 
300
        wxBitmap bitmap(wizprogress11_xpm);
 
301
        return bitmap;
 
302
    }
 
303
    else if (name == wxT("res/wizprogress12.xpm"))
 
304
    {
 
305
        wxBitmap bitmap(wizprogress12_xpm);
 
306
        return bitmap;
 
307
    }
 
308
    return wxNullBitmap;
 
309
}
 
310
 
 
311
/*!
 
312
 * Get icon resources
 
313
 */
 
314
 
 
315
wxIcon CProjectPropertiesPage::GetIconResource( const wxString& WXUNUSED(name) )
 
316
{
 
317
    // Icon retrieval
 
318
////@begin CProjectPropertiesPage icon retrieval
 
319
    return wxNullIcon;
 
320
////@end CProjectPropertiesPage icon retrieval
 
321
}
 
322
 
 
323
/*!
 
324
 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTPROPERTIESPAGE
 
325
 */
 
326
 
 
327
void CProjectPropertiesPage::OnPageChanged( wxWizardExEvent& event ) {
 
328
    if (event.GetDirection() == false) return;
 
329
 
 
330
    wxASSERT(m_pTitleStaticCtrl);
 
331
    wxASSERT(m_pProgressIndicator);
 
332
 
 
333
    m_pTitleStaticCtrl->SetLabel(
 
334
        _("Communicating with project\nPlease wait...")
 
335
    );
 
336
 
 
337
    SetProjectPropertiesSucceeded(false);
 
338
    SetProjectPropertiesURLFailure(false);
 
339
    SetProjectPropertiesCommunicationFailure(false);
 
340
    SetProjectAccountCreationDisabled(false);
 
341
    SetProjectClientAccountCreationDisabled(false);
 
342
    SetNetworkConnectionNotDetected(false);
 
343
    SetNextState(PROJPROP_INIT);
 
344
 
 
345
    CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
 
346
    AddPendingEvent(TransitionEvent);
 
347
 
 
348
    Fit();
 
349
}
 
350
  
 
351
/*!
 
352
 * wxEVT_WIZARD_CANCEL event handler for ID_PROJECTPROPERTIESPAGE
 
353
 */
 
354
 
 
355
void CProjectPropertiesPage::OnCancel( wxWizardExEvent& event ) {
 
356
    PROCESS_CANCELEVENT(event);
 
357
}
 
358
 
 
359
/*!
 
360
 * wxEVT_PROJECTPROPERTIES_STATECHANGE event handler for ID_PROJECTPROPERTIESPAGE
 
361
 */
 
362
 
 
363
void CProjectPropertiesPage::OnStateChange( CProjectPropertiesPageEvent& WXUNUSED(event) )
 
364
{
 
365
    CMainDocument* pDoc = wxGetApp().GetDocument();
 
366
    CWizardAttach* pWAP = ((CWizardAttach*)GetParent());
 
367
    PROJECT_CONFIG* pc  = &pWAP->project_config;
 
368
    CC_STATUS status;
 
369
    wxDateTime dtStartExecutionTime;
 
370
    wxDateTime dtCurrentExecutionTime;
 
371
    wxTimeSpan tsExecutionTime;
 
372
    wxString strBuffer = wxEmptyString;
 
373
    bool bPostNewEvent = true;
 
374
    int  iReturnValue = 0;
 
375
 
 
376
    wxASSERT(pDoc);
 
377
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
 
378
 
 
379
    switch(GetCurrentState()) {
 
380
        case PROJPROP_INIT:
 
381
            pWAP->DisableNextButton();
 
382
            pWAP->DisableBackButton();
 
383
            StartProgress(m_pProgressIndicator);
 
384
            SetNextState(PROJPROP_RETRPROJECTPROPERTIES_BEGIN);
 
385
            break;
 
386
        case PROJPROP_RETRPROJECTPROPERTIES_BEGIN:
 
387
            SetNextState(PROJPROP_RETRPROJECTPROPERTIES_EXECUTE);
 
388
            break;
 
389
        case PROJPROP_RETRPROJECTPROPERTIES_EXECUTE:
 
390
            // Attempt to retrieve the project's account creation policies
 
391
 
 
392
            // Wait until we are done processing the request.
 
393
            dtStartExecutionTime = wxDateTime::Now();
 
394
            dtCurrentExecutionTime = wxDateTime::Now();
 
395
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
396
            iReturnValue = 0;
 
397
            pc->clear();
 
398
            pc->error_num = ERR_RETRY;
 
399
            while (
 
400
                !iReturnValue &&
 
401
                ((ERR_IN_PROGRESS == pc->error_num) || (ERR_RETRY == pc->error_num)) &&
 
402
                tsExecutionTime.GetSeconds() <= 60 &&
 
403
                !CHECK_CLOSINGINPROGRESS()
 
404
            ) {
 
405
                if (ERR_RETRY == pc->error_num) {
 
406
                    pDoc->rpc.get_project_config(
 
407
                        (const char*)pWAP->m_ProjectInfoPage->GetProjectURL().mb_str()
 
408
                    );
 
409
                }
 
410
 
 
411
                dtCurrentExecutionTime = wxDateTime::Now();
 
412
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
413
                iReturnValue = pDoc->rpc.get_project_config_poll(*pc);
 
414
                IncrementProgress(m_pProgressIndicator);
 
415
 
 
416
                ::wxMilliSleep(500);
 
417
                ::wxSafeYield(GetParent());
 
418
            }
 
419
 
 
420
            if (
 
421
                !iReturnValue
 
422
                && (!pc->error_num || pc->error_num == ERR_ACCT_CREATION_DISABLED)
 
423
            ) {
 
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.
 
430
                //
 
431
                SetProjectPropertiesSucceeded(true);
 
432
                SetProjectAccountCreationDisabled(pc->account_creation_disabled);
 
433
                SetProjectClientAccountCreationDisabled(pc->client_account_creation_disabled);
 
434
                SetTermsOfUseRequired(!pc->terms_of_use.empty());
 
435
 
 
436
            } else {
 
437
 
 
438
                SetProjectPropertiesSucceeded(false);
 
439
                SetProjectPropertiesURLFailure(pc->error_num == ERR_FILE_NOT_FOUND);
 
440
 
 
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)
 
446
                );
 
447
                SetProjectPropertiesCommunicationFailure(comm_failure);
 
448
 
 
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)
 
455
                );
 
456
                SetServerReportedError(server_reported_error);
 
457
 
 
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"));
 
462
                    }
 
463
                    pWAP->m_CompletionErrorPage->m_pServerMessagesCtrl->SetLabel(strBuffer);
 
464
                }
 
465
            }
 
466
 
 
467
            SetNextState(PROJPROP_DETERMINENETWORKSTATUS_BEGIN);
 
468
            break;
 
469
        case PROJPROP_DETERMINENETWORKSTATUS_BEGIN:
 
470
            SetNextState(PROJPROP_DETERMINENETWORKSTATUS_EXECUTE);
 
471
            break;
 
472
        case PROJPROP_DETERMINENETWORKSTATUS_EXECUTE:
 
473
            // Attempt to determine if we are even connected to a network
 
474
 
 
475
            // Wait until we are done processing the request.
 
476
            dtStartExecutionTime = wxDateTime::Now();
 
477
            dtCurrentExecutionTime = wxDateTime::Now();
 
478
            tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
479
            iReturnValue = 0;
 
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()
 
484
                  )
 
485
            {
 
486
                dtCurrentExecutionTime = wxDateTime::Now();
 
487
                tsExecutionTime = dtCurrentExecutionTime - dtStartExecutionTime;
 
488
                iReturnValue = pDoc->GetCoreClientStatus(status);
 
489
                IncrementProgress(m_pProgressIndicator);
 
490
 
 
491
                ::wxMilliSleep(500);
 
492
                ::wxSafeYield(GetParent());
 
493
            }
 
494
 
 
495
            SetNetworkConnectionNotDetected(NETWORK_STATUS_WANT_CONNECTION == status.network_status);
 
496
 
 
497
            SetNextState(PROJPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN);
 
498
            break;
 
499
        case PROJPROP_DETERMINEACCOUNTINFOSTATUS_BEGIN:
 
500
            SetNextState(PROJPROP_DETERMINEACCOUNTINFOSTATUS_EXECUTE);
 
501
            break;
 
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);
 
506
 
 
507
            SetNextState(PROJPROP_CLEANUP);
 
508
            break;
 
509
        case PROJPROP_CLEANUP:
 
510
            FinishProgress(m_pProgressIndicator);
 
511
            SetNextState(PROJPROP_END);
 
512
            break;
 
513
        default:
 
514
            // Allow a glimps of what the result was before advancing to the next page.
 
515
            wxSleep(1);
 
516
            pWAP->EnableNextButton();
 
517
            pWAP->EnableBackButton();
 
518
            pWAP->SimulateNextButton();
 
519
            bPostNewEvent = false;
 
520
            break;
 
521
    }
 
522
 
 
523
    Update();
 
524
 
 
525
    if (bPostNewEvent && !CHECK_CLOSINGINPROGRESS()) {
 
526
        CProjectPropertiesPageEvent TransitionEvent(wxEVT_PROJECTPROPERTIES_STATECHANGE, this);
 
527
        AddPendingEvent(TransitionEvent);
 
528
    }
 
529
}
 
530