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

« back to all changes in this revision

Viewing changes to clientgui/WizardAttach.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
// 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 "WizardAttach.h"
 
20
#endif
 
21
 
 
22
#include "stdwx.h"
 
23
#include "diagnostics.h"
 
24
#include "util.h"
 
25
#include "mfile.h"
 
26
#include "miofile.h"
 
27
#include "parse.h"
 
28
#include "error_numbers.h"
 
29
#include "wizardex.h"
 
30
#include "error_numbers.h"
 
31
#include "browser.h"
 
32
#include "BOINCGUIApp.h"
 
33
#include "SkinManager.h"
 
34
#include "MainDocument.h"
 
35
#include "BOINCBaseWizard.h"
 
36
#include "BOINCBaseFrame.h"
 
37
#include "ProjectListCtrl.h"
 
38
#include "WizardAttach.h"
 
39
#include "WelcomePage.h"
 
40
#include "ProjectInfoPage.h"
 
41
#include "ProjectPropertiesPage.h"
 
42
#include "ProjectProcessingPage.h"
 
43
#include "AccountManagerInfoPage.h"
 
44
#include "AccountManagerPropertiesPage.h"
 
45
#include "AccountManagerProcessingPage.h"
 
46
#include "TermsOfUsePage.h"
 
47
#include "AccountInfoPage.h"
 
48
#include "CompletionPage.h"
 
49
#include "CompletionErrorPage.h"
 
50
#include "NotDetectedPage.h"
 
51
#include "UnavailablePage.h"
 
52
#include "NoInternetConnectionPage.h"
 
53
#include "NotFoundPage.h"
 
54
#include "AlreadyExistsPage.h"
 
55
#include "ProxyInfoPage.h"
 
56
#include "ProxyPage.h"
 
57
 
 
58
 
 
59
/*!
 
60
 * CWizardAttach type definition
 
61
 */
 
62
 
 
63
IMPLEMENT_DYNAMIC_CLASS( CWizardAttach, CBOINCBaseWizard )
 
64
 
 
65
/*!
 
66
 * CWizardAttach event table definition
 
67
 */
 
68
 
 
69
BEGIN_EVENT_TABLE( CWizardAttach, CBOINCBaseWizard )
 
70
////@begin CWizardAttach event table entries
 
71
    EVT_WIZARDEX_FINISHED( ID_ATTACHWIZARD, CWizardAttach::OnFinished )
 
72
////@end CWizardAttach event table entries
 
73
END_EVENT_TABLE()
 
74
 
 
75
/*!
 
76
 * CWizardAttach constructors
 
77
 */
 
78
 
 
79
CWizardAttach::CWizardAttach()
 
80
{
 
81
}
 
82
 
 
83
CWizardAttach::CWizardAttach( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, long style ) 
 
84
{
 
85
    Create(parent, id, title, pos, style);
 
86
}
 
87
 
 
88
/*!
 
89
 * CWizardAttach creator
 
90
 */
 
91
 
 
92
bool CWizardAttach::Create( wxWindow* parent, wxWindowID id, const wxString& /* title */, const wxPoint& pos, long style )
 
93
{
 
94
 
 
95
////@begin CWizardAttach member initialisation
 
96
    m_WelcomePage = NULL;
 
97
    m_ProjectInfoPage = NULL;
 
98
    m_ProjectPropertiesPage = NULL;
 
99
    m_ProjectProcessingPage = NULL;
 
100
    m_AccountManagerInfoPage = NULL;
 
101
    m_AccountManagerPropertiesPage = NULL;
 
102
    m_AccountManagerProcessingPage = NULL;
 
103
    m_TermsOfUsePage = NULL;
 
104
    m_AccountInfoPage = NULL;
 
105
    m_CompletionPage = NULL;
 
106
    m_CompletionErrorPage = NULL;
 
107
    m_ErrNotDetectedPage = NULL;
 
108
    m_ErrUnavailablePage = NULL;
 
109
    m_ErrNoInternetConnectionPage = NULL;
 
110
    m_ErrNotFoundPage = NULL;
 
111
    m_ErrAlreadyExistsPage = NULL;
 
112
    m_ErrProxyInfoPage = NULL;
 
113
    m_ErrProxyPage = NULL;
 
114
////@end CWizardAttach member initialisation
 
115
  
 
116
    // Cancel Checking
 
117
    m_bCancelInProgress = false;
 
118
 
 
119
    // Wizard Detection
 
120
    IsAttachToProjectWizard = true;
 
121
    IsAccountManagerWizard = false;
 
122
    IsAccountManagerUpdateWizard = false;
 
123
 
 
124
    // Global wizard status
 
125
    project_config.clear();
 
126
    account_in.clear();
 
127
    account_out.clear();
 
128
    account_created_successfully = false;
 
129
    attached_to_project_successfully = false;
 
130
    close_when_completed = false;
 
131
    m_strProjectName.Empty();
 
132
    m_strProjectUrl.Empty();
 
133
    m_strProjectAuthenticator.Empty();
 
134
    m_strTeamName.Empty();
 
135
    m_strReturnURL.Empty();
 
136
    m_bCredentialsCached = false;
 
137
    m_bCredentialsDetected = false;
 
138
    m_bCookieRequired = false;
 
139
    m_strCookieFailureURL.Empty();
 
140
 
 
141
 
 
142
    CSkinAdvanced*  pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
 
143
    CSkinWizardATP* pSkinWizardATP = wxGetApp().GetSkinManager()->GetWizards()->GetWizardATP();
 
144
 
 
145
    wxASSERT(pSkinAdvanced);
 
146
    wxASSERT(pSkinWizardATP);
 
147
    wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
 
148
    wxASSERT(wxDynamicCast(pSkinWizardATP, CSkinWizardATP));
 
149
 
 
150
 
 
151
    wxString strTitle;
 
152
    if (!pSkinWizardATP->GetWizardTitle().IsEmpty()) {
 
153
        strTitle = pSkinWizardATP->GetWizardTitle();
 
154
    } else {
 
155
        strTitle = pSkinAdvanced->GetApplicationName();
 
156
    }
 
157
 
 
158
////@begin CWizardAttach creation
 
159
    CBOINCBaseWizard::Create( parent, id, strTitle, pos, style );
 
160
 
 
161
    CreateControls();
 
162
////@end CWizardAttach creation
 
163
 
 
164
    return TRUE;
 
165
}
 
166
 
 
167
/*!
 
168
 * Control creation for CWizardAttach
 
169
 */
 
170
 
 
171
void CWizardAttach::CreateControls()
 
172
{    
 
173
    wxLogTrace(wxT("Function Start/End"), wxT("CWizardAttach::CreateControls - Function Begin"));
 
174
 
 
175
////@begin CWizardAttach content construction
 
176
    CWizardAttach* itemWizard1 = this;
 
177
 
 
178
    m_WelcomePage = new CWelcomePage;
 
179
    m_WelcomePage->Create( itemWizard1 );
 
180
    GetPageAreaSizer()->Add(m_WelcomePage);
 
181
 
 
182
    m_AccountManagerInfoPage = new CAccountManagerInfoPage;
 
183
    m_AccountManagerInfoPage->Create( itemWizard1 );
 
184
    GetPageAreaSizer()->Add(m_AccountManagerInfoPage);
 
185
 
 
186
    m_AccountManagerPropertiesPage = new CAccountManagerPropertiesPage;
 
187
    m_AccountManagerPropertiesPage->Create( itemWizard1 );
 
188
    GetPageAreaSizer()->Add(m_AccountManagerPropertiesPage);
 
189
 
 
190
    m_AccountManagerProcessingPage = new CAccountManagerProcessingPage;
 
191
    m_AccountManagerProcessingPage->Create( itemWizard1 );
 
192
    GetPageAreaSizer()->Add(m_AccountManagerProcessingPage);
 
193
 
 
194
    m_ProjectInfoPage = new CProjectInfoPage;
 
195
    m_ProjectInfoPage->Create( itemWizard1 );
 
196
    GetPageAreaSizer()->Add(m_ProjectInfoPage);
 
197
 
 
198
    m_ProjectPropertiesPage = new CProjectPropertiesPage;
 
199
    m_ProjectPropertiesPage->Create( itemWizard1 );
 
200
    GetPageAreaSizer()->Add(m_ProjectPropertiesPage);
 
201
 
 
202
    m_ProjectProcessingPage = new CProjectProcessingPage;
 
203
    m_ProjectProcessingPage->Create( itemWizard1 );
 
204
    GetPageAreaSizer()->Add(m_ProjectProcessingPage);
 
205
 
 
206
    m_AccountInfoPage = new CAccountInfoPage;
 
207
    m_AccountInfoPage->Create( itemWizard1 );
 
208
    GetPageAreaSizer()->Add(m_AccountInfoPage);
 
209
 
 
210
    m_TermsOfUsePage = new CTermsOfUsePage;
 
211
    m_TermsOfUsePage->Create( itemWizard1 );
 
212
    GetPageAreaSizer()->Add(m_TermsOfUsePage);
 
213
 
 
214
    m_CompletionPage = new CCompletionPage;
 
215
    m_CompletionPage->Create( itemWizard1 );
 
216
    GetPageAreaSizer()->Add(m_CompletionPage);
 
217
 
 
218
    m_CompletionErrorPage = new CCompletionErrorPage;
 
219
    m_CompletionErrorPage->Create( itemWizard1 );
 
220
    GetPageAreaSizer()->Add(m_CompletionErrorPage);
 
221
 
 
222
    m_ErrNotDetectedPage = new CErrNotDetectedPage;
 
223
    m_ErrNotDetectedPage->Create( itemWizard1 );
 
224
    GetPageAreaSizer()->Add(m_ErrNotDetectedPage);
 
225
 
 
226
    m_ErrUnavailablePage = new CErrUnavailablePage;
 
227
    m_ErrUnavailablePage->Create( itemWizard1 );
 
228
    GetPageAreaSizer()->Add(m_ErrUnavailablePage);
 
229
 
 
230
    m_ErrNoInternetConnectionPage = new CErrNoInternetConnectionPage;
 
231
    m_ErrNoInternetConnectionPage->Create( itemWizard1 );
 
232
    GetPageAreaSizer()->Add(m_ErrNoInternetConnectionPage);
 
233
 
 
234
    m_ErrNotFoundPage = new CErrNotFoundPage;
 
235
    m_ErrNotFoundPage->Create( itemWizard1 );
 
236
    GetPageAreaSizer()->Add(m_ErrNotFoundPage);
 
237
 
 
238
    m_ErrAlreadyExistsPage = new CErrAlreadyExistsPage;
 
239
    m_ErrAlreadyExistsPage->Create( itemWizard1 );
 
240
    GetPageAreaSizer()->Add(m_ErrAlreadyExistsPage);
 
241
 
 
242
    m_ErrProxyInfoPage = new CErrProxyInfoPage;
 
243
    m_ErrProxyInfoPage->Create( itemWizard1 );
 
244
    GetPageAreaSizer()->Add(m_ErrProxyInfoPage);
 
245
 
 
246
    m_ErrProxyPage = new CErrProxyPage;
 
247
    m_ErrProxyPage->Create( itemWizard1 );
 
248
    GetPageAreaSizer()->Add(m_ErrProxyPage);
 
249
 
 
250
////@end CWizardAttach content construction
 
251
 
 
252
    wxLogTrace(wxT("Function Status"), wxT("CWizardAttach::CreateControls - Begin Page Map"));
 
253
 
 
254
    wxLogTrace(
 
255
        wxT("Function Status"),
 
256
        wxT("CWizardAttach::CreateControls -     m_WelcomePage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
257
        m_WelcomePage->GetId(), m_WelcomePage, m_WelcomePage->GetBestSize().GetHeight(), m_WelcomePage->GetBestSize().GetWidth()
 
258
    );
 
259
    wxLogTrace(
 
260
        wxT("Function Status"), 
 
261
        wxT("CWizardAttach::CreateControls -     m_ProjectInfoPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
262
        m_ProjectInfoPage->GetId(), m_ProjectInfoPage, m_ProjectInfoPage->GetBestSize().GetHeight(), m_ProjectInfoPage->GetBestSize().GetWidth()
 
263
    );
 
264
    wxLogTrace(
 
265
        wxT("Function Status"),
 
266
        wxT("CWizardAttach::CreateControls -     m_ProjectPropertiesPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
267
        m_ProjectPropertiesPage->GetId(), m_ProjectPropertiesPage, m_ProjectPropertiesPage->GetBestSize().GetHeight(), m_ProjectPropertiesPage->GetBestSize().GetWidth()
 
268
    );
 
269
    wxLogTrace(
 
270
        wxT("Function Status"),
 
271
        wxT("CWizardAttach::CreateControls -     m_ProjectProcessingPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
272
        m_ProjectProcessingPage->GetId(), m_ProjectProcessingPage, m_ProjectProcessingPage->GetBestSize().GetHeight(), m_ProjectProcessingPage->GetBestSize().GetWidth()
 
273
    );
 
274
    wxLogTrace(
 
275
        wxT("Function Status"),
 
276
        wxT("CWizardAttach::CreateControls -     m_AccountManagerInfoPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
277
        m_AccountManagerInfoPage->GetId(), m_AccountManagerInfoPage, m_AccountManagerInfoPage->GetBestSize().GetHeight(), m_AccountManagerInfoPage->GetBestSize().GetWidth()
 
278
    );
 
279
    wxLogTrace(
 
280
        wxT("Function Status"),
 
281
        wxT("CWizardAttach::CreateControls -     m_AccountManagerPropertiesPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
282
        m_AccountManagerPropertiesPage->GetId(), m_AccountManagerPropertiesPage, m_AccountManagerPropertiesPage->GetBestSize().GetHeight(), m_AccountManagerPropertiesPage->GetBestSize().GetWidth()
 
283
    );
 
284
    wxLogTrace(
 
285
        wxT("Function Status"),
 
286
        wxT("CWizardAttach::CreateControls -     m_AccountManagerProcessingPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
287
        m_AccountManagerProcessingPage->GetId(), m_AccountManagerProcessingPage, m_AccountManagerProcessingPage->GetBestSize().GetHeight(), m_AccountManagerProcessingPage->GetBestSize().GetWidth()
 
288
    );
 
289
    wxLogTrace(
 
290
        wxT("Function Status"),
 
291
        wxT("CWizardAttach::CreateControls -     m_TermsOfUsePage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
292
        m_TermsOfUsePage->GetId(), m_TermsOfUsePage, m_TermsOfUsePage->GetBestSize().GetHeight(), m_TermsOfUsePage->GetBestSize().GetWidth()
 
293
    );
 
294
    wxLogTrace(
 
295
        wxT("Function Status"),
 
296
        wxT("CWizardAttach::CreateControls -     m_AccountInfoPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
297
        m_AccountInfoPage->GetId(), m_AccountInfoPage, m_AccountInfoPage->GetBestSize().GetHeight(), m_AccountInfoPage->GetBestSize().GetWidth()
 
298
    );
 
299
    wxLogTrace(
 
300
        wxT("Function Status"),
 
301
        wxT("CWizardAttach::CreateControls -     m_CompletionPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
302
        m_CompletionPage->GetId(), m_CompletionPage, m_CompletionPage->GetBestSize().GetHeight(), m_CompletionPage->GetBestSize().GetWidth()
 
303
    );
 
304
    wxLogTrace(
 
305
        wxT("Function Status"),
 
306
        wxT("CWizardAttach::CreateControls -     m_CompletionErrorPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
307
        m_CompletionErrorPage->GetId(), m_CompletionErrorPage, m_CompletionErrorPage->GetBestSize().GetHeight(), m_CompletionErrorPage->GetBestSize().GetWidth()
 
308
    );
 
309
    wxLogTrace(
 
310
        wxT("Function Status"),
 
311
        wxT("CWizardAttach::CreateControls -     m_ErrNotDetectedPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
312
        m_ErrNotDetectedPage->GetId(), m_ErrNotDetectedPage, m_ErrNotDetectedPage->GetBestSize().GetHeight(), m_ErrNotDetectedPage->GetBestSize().GetWidth()
 
313
    );
 
314
    wxLogTrace(
 
315
        wxT("Function Status"),
 
316
        wxT("CWizardAttach::CreateControls -     m_ErrUnavailablePage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
317
        m_ErrUnavailablePage->GetId(), m_ErrUnavailablePage, m_ErrUnavailablePage->GetBestSize().GetHeight(), m_ErrUnavailablePage->GetBestSize().GetWidth()
 
318
    );
 
319
    wxLogTrace(
 
320
        wxT("Function Status"),
 
321
        wxT("CWizardAttach::CreateControls -     m_ErrNoInternetConnectionPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
322
        m_ErrNoInternetConnectionPage->GetId(), m_ErrNoInternetConnectionPage, m_ErrNoInternetConnectionPage->GetBestSize().GetHeight(), m_ErrNoInternetConnectionPage->GetBestSize().GetWidth()
 
323
    );
 
324
    wxLogTrace(
 
325
        wxT("Function Status"),
 
326
        wxT("CWizardAttach::CreateControls -     m_ErrNotFoundPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
327
        m_ErrNotFoundPage->GetId(), m_ErrNotFoundPage, m_ErrNotFoundPage->GetBestSize().GetHeight(), m_ErrNotFoundPage->GetBestSize().GetWidth()
 
328
    );
 
329
    wxLogTrace(
 
330
        wxT("Function Status"),
 
331
        wxT("CWizardAttach::CreateControls -     m_ErrAlreadyExistsPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
332
        m_ErrAlreadyExistsPage->GetId(), m_ErrAlreadyExistsPage, m_ErrAlreadyExistsPage->GetBestSize().GetHeight(), m_ErrAlreadyExistsPage->GetBestSize().GetWidth()
 
333
    );
 
334
    wxLogTrace(
 
335
        wxT("Function Status"),
 
336
        wxT("CWizardAttach::CreateControls -     m_ErrProxyInfoPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
337
        m_ErrProxyInfoPage->GetId(), m_ErrProxyInfoPage, m_ErrProxyInfoPage->GetBestSize().GetHeight(), m_ErrProxyInfoPage->GetBestSize().GetWidth()
 
338
    );
 
339
    wxLogTrace(
 
340
        wxT("Function Status"),
 
341
        wxT("CWizardAttach::CreateControls -     m_ErrProxyPage = id: '%d', location: '%p', height: '%d', width: '%d'"),
 
342
        m_ErrProxyPage->GetId(), m_ErrProxyPage, m_ErrProxyPage->GetBestSize().GetHeight(), m_ErrProxyPage->GetBestSize().GetWidth()
 
343
    );
 
344
 
 
345
    wxLogTrace(wxT("Function Status"), wxT("CWizardAttach::CreateControls - End Page Map"));
 
346
    wxLogTrace(wxT("Function Start/End"), wxT("CWizardAttach::CreateControls - Function End"));
 
347
}
 
348
 
 
349
/*!
 
350
 * Runs the wizard.
 
351
 */
 
352
bool CWizardAttach::Run(
 
353
    wxString& WXUNUSED(strName), wxString& strURL, wxString& strTeamName,
 
354
    bool bCredentialsCached
 
355
) {
 
356
    m_strTeamName = strTeamName;
 
357
 
 
358
    if (strURL.Length()) {
 
359
        m_ProjectInfoPage->SetProjectURL( strURL );
 
360
        m_bCredentialsCached = bCredentialsCached;
 
361
    }
 
362
 
 
363
    // If credentials are not cached, then we should try one last place to look up the
 
364
    //   authenticator.  Some projects will set a "Setup" cookie off of their URL with a
 
365
    //   pretty short timeout.  Lets take a crack at detecting it.
 
366
    //
 
367
    if (!strURL.IsEmpty() && !bCredentialsCached) {
 
368
        std::string url = std::string(strURL.mb_str());
 
369
        std::string authenticator;
 
370
 
 
371
        if (detect_setup_authenticator(url, authenticator)) {
 
372
            m_bCredentialsDetected = true;
 
373
            close_when_completed = true;
 
374
            SetProjectAuthenticator(wxString(authenticator.c_str(), wxConvUTF8));
 
375
        }
 
376
    }
 
377
 
 
378
    if (strURL.Length() && m_ProjectPropertiesPage) {
 
379
        return RunWizard(m_ProjectPropertiesPage);
 
380
    } else if (m_WelcomePage) {
 
381
        return RunWizard(m_WelcomePage);
 
382
    }
 
383
 
 
384
    return FALSE;
 
385
}
 
386
 
 
387
 
 
388
bool CWizardAttach::SyncToAccountManager() {
 
389
    ACCT_MGR_INFO ami;
 
390
    CMainDocument* pDoc = wxGetApp().GetDocument();
 
391
 
 
392
    wxASSERT(pDoc);
 
393
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
 
394
 
 
395
    IsAttachToProjectWizard = false;
 
396
    IsAccountManagerWizard = true;
 
397
 
 
398
    pDoc->rpc.acct_mgr_info(ami);
 
399
 
 
400
    if (ami.acct_mgr_url.size()) {
 
401
        m_AccountManagerInfoPage->SetProjectURL( 
 
402
            wxString(ami.acct_mgr_url.c_str(), wxConvUTF8)
 
403
        );
 
404
        m_bCredentialsCached = ami.have_credentials;
 
405
        m_bCookieRequired = ami.cookie_required;
 
406
        m_strCookieFailureURL = wxString(ami.cookie_failure_url.c_str(), wxConvUTF8);
 
407
 
 
408
        if (m_bCredentialsCached) {
 
409
            IsAccountManagerUpdateWizard = true;
 
410
        }
 
411
    }
 
412
 
 
413
    if (ami.acct_mgr_url.size() && !m_bCredentialsCached) {
 
414
        std::string login;
 
415
        std::string password_hash;
 
416
        std::string return_url;
 
417
 
 
418
        if (detect_account_manager_credentials(ami.acct_mgr_url, login, password_hash, return_url)) {
 
419
            wxString strLogin;
 
420
            wxString strPasswordHash;
 
421
            wxString strReturnURL;
 
422
 
 
423
            strLogin = wxURL::Unescape( wxString(login.c_str(), wxConvUTF8) );
 
424
            strPasswordHash = wxURL::Unescape( wxString(password_hash.c_str(), wxConvUTF8) );
 
425
            strReturnURL = wxURL::Unescape( wxString(return_url.c_str(), wxConvUTF8) );
 
426
 
 
427
            m_AccountInfoPage->SetAccountEmailAddress( strLogin );
 
428
            m_AccountInfoPage->SetAccountPassword(
 
429
                wxString(_T("hash:")) +
 
430
                strPasswordHash
 
431
            );
 
432
            m_strReturnURL = strReturnURL;
 
433
            m_bCredentialsDetected = true;
 
434
        }
 
435
    }
 
436
 
 
437
    if (m_AccountManagerPropertiesPage) {
 
438
        return RunWizard(m_AccountManagerPropertiesPage);
 
439
    }
 
440
 
 
441
    return FALSE;
 
442
}
 
443
 
 
444
/*!
 
445
 * Should we show tooltips?
 
446
 */
 
447
 
 
448
bool CWizardAttach::ShowToolTips()
 
449
{
 
450
    return TRUE;
 
451
}
 
452
 
 
453
/*!
 
454
 * Get bitmap resources
 
455
 */
 
456
 
 
457
wxBitmap CWizardAttach::GetBitmapResource( const wxString& WXUNUSED(name) )
 
458
{
 
459
    // Bitmap retrieval
 
460
////@begin CWizardAttach bitmap retrieval
 
461
    return wxNullBitmap;
 
462
////@end CWizardAttach bitmap retrieval
 
463
}
 
464
 
 
465
/*!
 
466
 * Get icon resources
 
467
 */
 
468
 
 
469
wxIcon CWizardAttach::GetIconResource( const wxString& WXUNUSED(name) )
 
470
{
 
471
    // Icon retrieval
 
472
////@begin CWizardAttach icon retrieval
 
473
    return wxNullIcon;
 
474
////@end CWizardAttach icon retrieval
 
475
}
 
476
 
 
477
/*!
 
478
 * Determine if the wizard page has a next page
 
479
 */
 
480
 
 
481
bool CWizardAttach::HasNextPage( wxWizardPageEx* page )
 
482
{
 
483
    bool bNoNextPageDetected = false;
 
484
 
 
485
    bNoNextPageDetected |= (page == m_CompletionPage);
 
486
    bNoNextPageDetected |= (page == m_CompletionErrorPage);
 
487
    bNoNextPageDetected |= (page == m_ErrNotDetectedPage);
 
488
    bNoNextPageDetected |= (page == m_ErrUnavailablePage);
 
489
    bNoNextPageDetected |= (page == m_ErrNoInternetConnectionPage);
 
490
    bNoNextPageDetected |= (page == m_ErrAlreadyExistsPage);
 
491
 
 
492
    if (bNoNextPageDetected)
 
493
        return false;
 
494
    return true;
 
495
}
 
496
  
 
497
/*!
 
498
 * Determine if the wizard page has a previous page
 
499
 */
 
500
 
 
501
bool CWizardAttach::HasPrevPage( wxWizardPageEx* page )
 
502
{
 
503
    if ((page == m_WelcomePage) || (page == m_CompletionPage) || (page == m_CompletionErrorPage))
 
504
        return false;
 
505
    return true;
 
506
}
 
507
 
 
508
/*!
 
509
 * Remove the page transition from the stack.
 
510
 */
 
511
wxWizardPageEx* CWizardAttach::_PopPageTransition() {
 
512
    wxWizardPageEx* pPage = NULL;
 
513
    if (GetCurrentPage()) {
 
514
        if (m_PageTransition.size() > 0) {
 
515
            pPage = m_PageTransition.top();
 
516
            m_PageTransition.pop();
 
517
            if ((pPage == m_ProjectPropertiesPage) || (pPage == m_ProjectProcessingPage) ||
 
518
                (pPage == m_AccountManagerPropertiesPage) || (pPage == m_AccountManagerProcessingPage)) 
 
519
            {
 
520
                // We want to go back to the page before we attempted to communicate
 
521
                //   with any server.
 
522
                pPage = m_PageTransition.top();
 
523
                m_PageTransition.pop();
 
524
            }
 
525
            wxASSERT(pPage);
 
526
            return pPage;
 
527
        }
 
528
    }
 
529
    return NULL;
 
530
}
 
531
 
 
532
/*!
 
533
 * Add the page transition to the stack.
 
534
 */
 
535
wxWizardPageEx* CWizardAttach::_PushPageTransition( wxWizardPageEx* pCurrentPage, unsigned long ulPageID ) {
 
536
    if (GetCurrentPage()) {
 
537
        wxWizardPageEx* pPage = NULL;
 
538
 
 
539
        if (ID_WELCOMEPAGE == ulPageID)
 
540
            pPage = m_WelcomePage;
 
541
 
 
542
        if (ID_PROJECTINFOPAGE == ulPageID)
 
543
            pPage = m_ProjectInfoPage;
 
544
 
 
545
        if (ID_PROJECTPROPERTIESPAGE == ulPageID)
 
546
            pPage = m_ProjectPropertiesPage;
 
547
 
 
548
        if (ID_PROJECTPROCESSINGPAGE == ulPageID)
 
549
            pPage = m_ProjectProcessingPage;
 
550
 
 
551
        if (ID_ACCOUNTMANAGERINFOPAGE == ulPageID)
 
552
            pPage = m_AccountManagerInfoPage;
 
553
 
 
554
        if (ID_ACCOUNTMANAGERPROPERTIESPAGE == ulPageID)
 
555
            pPage = m_AccountManagerPropertiesPage;
 
556
 
 
557
        if (ID_ACCOUNTMANAGERPROCESSINGPAGE == ulPageID)
 
558
            pPage = m_AccountManagerProcessingPage;
 
559
 
 
560
        if (ID_TERMSOFUSEPAGE == ulPageID)
 
561
            pPage = m_TermsOfUsePage;
 
562
 
 
563
        if (ID_ACCOUNTINFOPAGE == ulPageID)
 
564
            pPage = m_AccountInfoPage;
 
565
 
 
566
        if (ID_COMPLETIONPAGE == ulPageID)
 
567
            pPage = m_CompletionPage;
 
568
 
 
569
        if (ID_COMPLETIONERRORPAGE == ulPageID)
 
570
            pPage = m_CompletionErrorPage;
 
571
 
 
572
        if (ID_ERRNOTDETECTEDPAGE == ulPageID)
 
573
            pPage = m_ErrNotDetectedPage;
 
574
 
 
575
        if (ID_ERRUNAVAILABLEPAGE == ulPageID)
 
576
            pPage = m_ErrUnavailablePage;
 
577
 
 
578
        if (ID_ERRNOINTERNETCONNECTIONPAGE == ulPageID)
 
579
            pPage = m_ErrNoInternetConnectionPage;
 
580
 
 
581
        if (ID_ERRNOTFOUNDPAGE == ulPageID)
 
582
            pPage = m_ErrNotFoundPage;
 
583
 
 
584
        if (ID_ERRALREADYEXISTSPAGE == ulPageID)
 
585
            pPage = m_ErrAlreadyExistsPage;
 
586
 
 
587
        if (ID_ERRPROXYINFOPAGE == ulPageID)
 
588
            pPage = m_ErrProxyInfoPage;
 
589
 
 
590
        if (ID_ERRPROXYPAGE == ulPageID)
 
591
            pPage = m_ErrProxyPage;
 
592
 
 
593
        if (pPage) {
 
594
            if (m_PageTransition.size() == 0) {
 
595
                m_PageTransition.push(NULL);
 
596
            }
 
597
            if (m_PageTransition.top() != pCurrentPage) {
 
598
                m_PageTransition.push(pCurrentPage);
 
599
            }
 
600
            return pPage;
 
601
        }
 
602
    }
 
603
    return NULL;
 
604
}
 
605
  
 
606
void CWizardAttach::_ProcessCancelEvent( wxWizardExEvent& event ) {
 
607
 
 
608
    bool bCancelWithoutNextPage = false;
 
609
    wxWizardPageEx* page = GetCurrentPage();
 
610
 
 
611
    int iRetVal = wxGetApp().SafeMessageBox(
 
612
        _("Do you really want to cancel?"), 
 
613
        _("Question"),
 
614
        wxICON_QUESTION | wxYES_NO,
 
615
        this
 
616
    );
 
617
 
 
618
    // Reenable the next and back buttons if they have been disabled
 
619
    GetNextButton()->Enable();
 
620
    GetBackButton()->Enable();
 
621
 
 
622
    // Page specific rules - Disable the validator(s)
 
623
    if (wxYES == iRetVal) {
 
624
        if ((page == m_ProjectInfoPage) || (page == m_AccountManagerInfoPage)) {
 
625
            m_ProjectInfoPage->m_pProjectUrlCtrl->SetValidator(wxDefaultValidator);
 
626
        } else if (page == m_AccountInfoPage) {
 
627
            m_AccountInfoPage->m_pAccountEmailAddressCtrl->SetValidator(wxDefaultValidator);
 
628
            m_AccountInfoPage->m_pAccountPasswordCtrl->SetValidator(wxDefaultValidator);
 
629
            if (IsAttachToProjectWizard) {
 
630
                m_AccountInfoPage->m_pAccountConfirmPasswordCtrl->SetValidator(wxDefaultValidator);
 
631
            }
 
632
        } else if (page == m_ErrProxyPage) {
 
633
            m_ErrProxyPage->m_pProxyHTTPServerCtrl->SetValidator(wxDefaultValidator);
 
634
            m_ErrProxyPage->m_pProxyHTTPPortCtrl->SetValidator(wxDefaultValidator);
 
635
            m_ErrProxyPage->m_pProxyHTTPUsernameCtrl->SetValidator(wxDefaultValidator);
 
636
            m_ErrProxyPage->m_pProxyHTTPPasswordCtrl->SetValidator(wxDefaultValidator);
 
637
            m_ErrProxyPage->m_pProxySOCKSServerCtrl->SetValidator(wxDefaultValidator);
 
638
            m_ErrProxyPage->m_pProxySOCKSPortCtrl->SetValidator(wxDefaultValidator);
 
639
            m_ErrProxyPage->m_pProxySOCKSUsernameCtrl->SetValidator(wxDefaultValidator);
 
640
            m_ErrProxyPage->m_pProxySOCKSPasswordCtrl->SetValidator(wxDefaultValidator);
 
641
        }
 
642
    }
 
643
 
 
644
    // Generic rules
 
645
    bCancelWithoutNextPage |= (page == m_ErrNotDetectedPage);
 
646
    bCancelWithoutNextPage |= (page == m_ErrUnavailablePage);
 
647
    bCancelWithoutNextPage |= (page == m_ErrNoInternetConnectionPage);
 
648
    if (IsAttachToProjectWizard) {
 
649
        bCancelWithoutNextPage |= (page == m_ErrAlreadyExistsPage);
 
650
    } else {
 
651
        bCancelWithoutNextPage |= (page == m_WelcomePage);
 
652
    }
 
653
    if (wxYES != iRetVal) {
 
654
        event.Veto();
 
655
    }
 
656
}
 
657
 
 
658
/*!
 
659
 * wxEVT_WIZARD_FINISHED event handler for ID_ATTACHPROJECTWIZARD
 
660
 */
 
661
 
 
662
void CWizardAttach::OnFinished( wxWizardExEvent& event ) {
 
663
 
 
664
    if (IsAccountManagerWizard) {
 
665
        // Attached to an account manager
 
666
        if (!m_strReturnURL.empty() && GetAttachedToProjectSuccessfully()) {
 
667
            wxLaunchDefaultBrowser(m_strReturnURL);
 
668
        }
 
669
    } else {
 
670
        // Attached to a project
 
671
        if (GetAccountCreatedSuccessfully() && GetAttachedToProjectSuccessfully()) {
 
672
            wxLaunchDefaultBrowser(GetProjectURL() + wxT("account_finish.php?auth=") + GetProjectAuthenticator());
 
673
        }
 
674
    }
 
675
 
 
676
    // Let the framework clean things up.
 
677
    event.Skip();
 
678
}
 
679