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

« back to all changes in this revision

Viewing changes to clientgui/AccountInfoPage.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 "AccountInfoPage.h"
23
 
#endif
24
 
 
25
 
#include "stdwx.h"
26
 
#include "diagnostics.h"
27
 
#include "util.h"
28
 
#include "mfile.h"
29
 
#include "miofile.h"
30
 
#include "parse.h"
31
 
#include "error_numbers.h"
32
 
#include "wizardex.h"
33
 
#include "error_numbers.h"
34
 
#include "BOINCGUIApp.h"
35
 
#include "SkinManager.h"
36
 
#include "MainDocument.h"
37
 
#include "wx/valgen.h"
38
 
#include "wx/valtext.h"
39
 
#include "hyperlink.h"
40
 
#include "ValidateEmailAddress.h"
41
 
#include "BOINCWizards.h"
42
 
#include "BOINCBaseWizard.h"
43
 
#include "WizardAttachProject.h"
44
 
#include "WizardAccountManager.h"
45
 
#include "ProjectInfoPage.h"
46
 
#include "AccountManagerInfoPage.h"
47
 
#include "AccountInfoPage.h"
48
 
 
49
 
 
50
 
/*!
51
 
 * CAccountInfoPage type definition
52
 
 */
53
 
 
54
 
IMPLEMENT_DYNAMIC_CLASS( CAccountInfoPage, wxWizardPageEx )
55
 
 
56
 
/*!
57
 
 * CAccountInfoPage event table definition
58
 
 */
59
 
 
60
 
BEGIN_EVENT_TABLE( CAccountInfoPage, wxWizardPageEx )
61
 
 
62
 
////@begin CAccountInfoPage event table entries
63
 
    EVT_WIZARDEX_PAGE_CHANGED( -1, CAccountInfoPage::OnPageChanged )
64
 
    EVT_WIZARDEX_PAGE_CHANGING( -1, CAccountInfoPage::OnPageChanging )
65
 
    EVT_WIZARDEX_CANCEL( -1, CAccountInfoPage::OnCancel )
66
 
    EVT_RADIOBUTTON( ID_ACCOUNTCREATECTRL, CAccountInfoPage::OnAccountCreateCtrlSelected )
67
 
    EVT_RADIOBUTTON( ID_ACCOUNTUSEEXISTINGCTRL, CAccountInfoPage::OnAccountUseExistingCtrlSelected )
68
 
////@end CAccountInfoPage event table entries
69
 
 
70
 
END_EVENT_TABLE()
71
 
 
72
 
/*!
73
 
 * CAccountInfoPage constructors
74
 
 */
75
 
 
76
 
CAccountInfoPage::CAccountInfoPage( )
77
 
{
78
 
}
79
 
 
80
 
CAccountInfoPage::CAccountInfoPage( CBOINCBaseWizard* parent )
81
 
{
82
 
    Create( parent );
83
 
}
84
 
 
85
 
/*!
86
 
 * AccountInfoPage creator
87
 
 */
88
 
 
89
 
bool CAccountInfoPage::Create( CBOINCBaseWizard* parent )
90
 
{
91
 
 
92
 
////@begin CAccountInfoPage member initialisation
93
 
    m_pTitleStaticCtrl = NULL;
94
 
    m_pAccountQuestionStaticCtrl = NULL;
95
 
    m_pAccountInformationStaticCtrl = NULL;
96
 
    m_pAccountCreateCtrl = NULL;
97
 
    m_pAccountUseExistingCtrl = NULL;
98
 
    m_pAccountEmailAddressStaticCtrl = NULL;
99
 
    m_pAccountEmailAddressCtrl = NULL;
100
 
    m_pAccountPasswordStaticCtrl = NULL;
101
 
    m_pAccountPasswordCtrl = NULL;
102
 
    m_pAccountConfirmPasswordStaticCtrl = NULL;
103
 
    m_pAccountConfirmPasswordCtrl = NULL;
104
 
    m_pAccountPasswordRequirmentsStaticCtrl = NULL;
105
 
    m_pAccountForgotPasswordCtrl = NULL;
106
 
////@end CAccountInfoPage member initialisation
107
 
 
108
 
////@begin CAccountInfoPage creation
109
 
    wxBitmap wizardBitmap(wxNullBitmap);
110
 
    wxWizardPageEx::Create( parent, ID_ACCOUNTINFOPAGE, wizardBitmap );
111
 
 
112
 
    CreateControls();
113
 
    GetSizer()->Fit(this);
114
 
////@end CAccountInfoPage creation
115
 
 
116
 
    return TRUE;
117
 
}
118
 
 
119
 
/*!
120
 
 * Control creation for AccountInfoPage
121
 
 */
122
 
 
123
 
void CAccountInfoPage::CreateControls()
124
 
{    
125
 
 
126
 
////@begin CAccountInfoPage content construction
127
 
    CAccountInfoPage* itemWizardPage56 = this;
128
 
 
129
 
    wxBoxSizer* itemBoxSizer57 = new wxBoxSizer(wxVERTICAL);
130
 
    itemWizardPage56->SetSizer(itemBoxSizer57);
131
 
 
132
 
    m_pTitleStaticCtrl = new wxStaticText;
133
 
    m_pTitleStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
134
 
    m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana")));
135
 
    itemBoxSizer57->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxGROW|wxALL, 5);
136
 
 
137
 
    m_pAccountQuestionStaticCtrl = new wxStaticText;
138
 
    m_pAccountQuestionStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
139
 
    itemBoxSizer57->Add(m_pAccountQuestionStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
140
 
 
141
 
    wxFlexGridSizer* itemFlexGridSizer61 = new wxFlexGridSizer(1, 2, 0, 0);
142
 
    itemFlexGridSizer61->AddGrowableCol(1);
143
 
    itemBoxSizer57->Add(itemFlexGridSizer61, 0, wxGROW|wxALL, 5);
144
 
 
145
 
    m_pAccountCreateCtrl = new wxRadioButton;
146
 
    m_pAccountCreateCtrl->Create( itemWizardPage56, ID_ACCOUNTCREATECTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
147
 
    m_pAccountCreateCtrl->SetValue(TRUE);
148
 
    itemFlexGridSizer61->Add(m_pAccountCreateCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
149
 
 
150
 
    m_pAccountUseExistingCtrl = new wxRadioButton;
151
 
    m_pAccountUseExistingCtrl->Create( itemWizardPage56, ID_ACCOUNTUSEEXISTINGCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
152
 
    m_pAccountUseExistingCtrl->SetValue(FALSE);
153
 
    itemFlexGridSizer61->Add(m_pAccountUseExistingCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
154
 
 
155
 
    m_pAccountInformationStaticCtrl = new wxStaticText;
156
 
    m_pAccountInformationStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
157
 
    itemBoxSizer57->Add(m_pAccountInformationStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
158
 
 
159
 
    wxFlexGridSizer* itemFlexGridSizer64 = new wxFlexGridSizer(4, 2, 0, 0);
160
 
    itemFlexGridSizer64->AddGrowableCol(1);
161
 
    itemBoxSizer57->Add(itemFlexGridSizer64, 0, wxEXPAND|wxALL, 0);
162
 
 
163
 
    m_pAccountEmailAddressStaticCtrl = new wxStaticText;
164
 
    m_pAccountEmailAddressStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTEMAILADDRESSSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
165
 
    itemFlexGridSizer64->Add(m_pAccountEmailAddressStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
166
 
 
167
 
    m_pAccountEmailAddressCtrl = new wxTextCtrl;
168
 
    m_pAccountEmailAddressCtrl->Create( itemWizardPage56, ID_ACCOUNTEMAILADDRESSCTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 22), 0 );
169
 
    itemFlexGridSizer64->Add(m_pAccountEmailAddressCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5);
170
 
 
171
 
    m_pAccountPasswordStaticCtrl = new wxStaticText;
172
 
    m_pAccountPasswordStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTPASSWORDSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
173
 
    itemFlexGridSizer64->Add(m_pAccountPasswordStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
174
 
 
175
 
    m_pAccountPasswordCtrl = new wxTextCtrl;
176
 
    m_pAccountPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTPASSWORDCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
177
 
    itemFlexGridSizer64->Add(m_pAccountPasswordCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5);
178
 
 
179
 
    m_pAccountConfirmPasswordStaticCtrl = new wxStaticText;
180
 
    m_pAccountConfirmPasswordStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTCONFIRMPASSWORDSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
181
 
    itemFlexGridSizer64->Add(m_pAccountConfirmPasswordStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
182
 
 
183
 
    m_pAccountConfirmPasswordCtrl = new wxTextCtrl;
184
 
    m_pAccountConfirmPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTCONFIRMPASSWORDCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
185
 
    itemFlexGridSizer64->Add(m_pAccountConfirmPasswordCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5);
186
 
 
187
 
    itemFlexGridSizer64->Add( 0, 0 );
188
 
 
189
 
    m_pAccountPasswordRequirmentsStaticCtrl = new wxStaticText;
190
 
    m_pAccountPasswordRequirmentsStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTREQUIREMENTSSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
191
 
    m_pAccountPasswordRequirmentsStaticCtrl->SetFont(wxFont(7, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE));
192
 
    itemFlexGridSizer64->Add(m_pAccountPasswordRequirmentsStaticCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
193
 
 
194
 
    m_pAccountForgotPasswordCtrl = new wxHyperLink;
195
 
    m_pAccountForgotPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTFORGOTPASSWORDCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
196
 
    itemFlexGridSizer64->Add(m_pAccountForgotPasswordCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
197
 
 
198
 
    // Set validators
199
 
    // m_pAccountEmailAddressCtrl is setup when the OnPageChange event is fired since
200
 
    //   it can be a username or an email address.
201
 
    m_pAccountPasswordCtrl->SetValidator( wxTextValidator(wxFILTER_ASCII, &m_strAccountPassword) );
202
 
    m_pAccountConfirmPasswordCtrl->SetValidator( wxTextValidator(wxFILTER_ASCII, &m_strAccountConfirmPassword) );
203
 
////@end CAccountInfoPage content construction
204
 
 
205
 
}
206
 
 
207
 
/*!
208
 
 * Gets the previous page.
209
 
 */
210
 
 
211
 
wxWizardPageEx* CAccountInfoPage::GetPrev() const
212
 
{
213
 
    return PAGE_TRANSITION_BACK;
214
 
}
215
 
 
216
 
/*!
217
 
 * Gets the next page.
218
 
 */
219
 
 
220
 
wxWizardPageEx* CAccountInfoPage::GetNext() const
221
 
{
222
 
    if (CHECK_CLOSINGINPROGRESS()) {
223
 
        // Cancel Event Detected
224
 
        return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
225
 
    } else if (IS_ATTACHTOPROJECTWIZARD()) {
226
 
        return PAGE_TRANSITION_NEXT(ID_PROJECTPROCESSINGPAGE);
227
 
    } else if (IS_ACCOUNTMANAGERWIZARD()) {
228
 
        return PAGE_TRANSITION_NEXT(ID_ACCOUNTMANAGERPROCESSINGPAGE);
229
 
    }
230
 
    return NULL;
231
 
}
232
 
 
233
 
/*!
234
 
 * Should we show tooltips?
235
 
 */
236
 
 
237
 
bool CAccountInfoPage::ShowToolTips()
238
 
{
239
 
    return TRUE;
240
 
}
241
 
 
242
 
/*!
243
 
 * Get bitmap resources
244
 
 */
245
 
 
246
 
wxBitmap CAccountInfoPage::GetBitmapResource( const wxString& WXUNUSED(name) )
247
 
{
248
 
    // Bitmap retrieval
249
 
////@begin CAccountInfoPage bitmap retrieval
250
 
    return wxNullBitmap;
251
 
////@end CAccountInfoPage bitmap retrieval
252
 
}
253
 
 
254
 
/*!
255
 
 * Get icon resources
256
 
 */
257
 
 
258
 
wxIcon CAccountInfoPage::GetIconResource( const wxString& WXUNUSED(name) )
259
 
{
260
 
    // Icon retrieval
261
 
////@begin CAccountInfoPage icon retrieval
262
 
    return wxNullIcon;
263
 
////@end CAccountInfoPage icon retrieval
264
 
}
265
 
  
266
 
/*!
267
 
 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_ACCOUNTINFOPAGE
268
 
 */
269
 
 
270
 
void CAccountInfoPage::OnPageChanged( wxWizardExEvent& event ) {
271
 
    if (event.GetDirection() == false) return;
272
 
 
273
 
        PROJECT_CONFIG&        pc = ((CBOINCBaseWizard*)GetParent())->project_config;
274
 
    CSkinAdvanced*         pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
275
 
    CSkinWizardATAM*       pSkinWizardATAM = wxGetApp().GetSkinManager()->GetWizards()->GetWizardATAM();
276
 
    CWizardAttachProject*  pWAP = ((CWizardAttachProject*)GetParent());
277
 
    CWizardAccountManager* pWAM = ((CWizardAccountManager*)GetParent());
278
 
 
279
 
    wxASSERT(pSkinAdvanced);
280
 
    wxASSERT(pSkinWizardATAM);
281
 
    wxASSERT(m_pTitleStaticCtrl);
282
 
    wxASSERT(m_pAccountQuestionStaticCtrl);
283
 
    wxASSERT(m_pAccountInformationStaticCtrl);
284
 
    wxASSERT(m_pAccountCreateCtrl);
285
 
    wxASSERT(m_pAccountUseExistingCtrl);
286
 
    wxASSERT(m_pAccountEmailAddressStaticCtrl);
287
 
    wxASSERT(m_pAccountEmailAddressCtrl);
288
 
    wxASSERT(m_pAccountPasswordStaticCtrl);
289
 
    wxASSERT(m_pAccountPasswordCtrl);
290
 
    wxASSERT(m_pAccountConfirmPasswordStaticCtrl);
291
 
    wxASSERT(m_pAccountConfirmPasswordCtrl);
292
 
    wxASSERT(m_pAccountPasswordRequirmentsStaticCtrl);
293
 
    wxASSERT(m_pAccountForgotPasswordCtrl);
294
 
    wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
295
 
    wxASSERT(wxDynamicCast(pSkinWizardATAM, CSkinWizardATAM));
296
 
 
297
 
 
298
 
    static bool bRunOnce = true;
299
 
    if (bRunOnce) {
300
 
        bRunOnce = false;
301
 
        if (!IS_ACCOUNTMANAGERWIZARD()) {
302
 
            m_pAccountCreateCtrl->SetValue(true);
303
 
            m_pAccountUseExistingCtrl->SetValue(false);
304
 
        }
305
 
    }
306
 
 
307
 
    if (IS_ACCOUNTMANAGERWIZARD()) {
308
 
        m_pAccountQuestionStaticCtrl->Hide();
309
 
        m_pAccountCreateCtrl->SetValue(false);
310
 
        m_pAccountCreateCtrl->Hide();
311
 
        m_pAccountUseExistingCtrl->SetValue(true);
312
 
        m_pAccountUseExistingCtrl->Hide();
313
 
        m_pAccountConfirmPasswordStaticCtrl->Hide();
314
 
        m_pAccountConfirmPasswordCtrl->Hide();
315
 
        m_pAccountPasswordRequirmentsStaticCtrl->Hide();
316
 
    }
317
 
 
318
 
    if (!IS_ACCOUNTMANAGERWIZARD()) {
319
 
        if (pc.account_creation_disabled || pc.client_account_creation_disabled) {
320
 
            m_pAccountCreateCtrl->SetValue(false);
321
 
            m_pAccountCreateCtrl->Hide();
322
 
            m_pAccountUseExistingCtrl->SetValue(true);
323
 
            m_pAccountUseExistingCtrl->Hide();
324
 
        } else {
325
 
            m_pAccountCreateCtrl->Show();
326
 
            m_pAccountCreateCtrl->Enable();
327
 
            m_pAccountUseExistingCtrl->Show();
328
 
        }
329
 
    }
330
 
 
331
 
    m_pTitleStaticCtrl->SetLabel(
332
 
        _("User information")
333
 
    );
334
 
 
335
 
    if (!IS_ACCOUNTMANAGERWIZARD() && !IS_ACCOUNTMANAGERUPDATEWIZARD()) {
336
 
                if (pc.client_account_creation_disabled) {
337
 
                        m_pAccountQuestionStaticCtrl->SetLabel(
338
 
                                _("Please enter your account information\n(to create an account, visit the project's web site)")
339
 
                        );
340
 
                } else if (pc.account_creation_disabled) {
341
 
                        m_pAccountQuestionStaticCtrl->SetLabel(
342
 
                                _("This project is not currently accepting new accounts.\nYou can attach only if you already have an account.")
343
 
                        );
344
 
                } else {
345
 
                        m_pAccountQuestionStaticCtrl->SetLabel(
346
 
                                _("Are you already running this project?")
347
 
                        );
348
 
                }
349
 
        m_pAccountCreateCtrl->SetLabel(
350
 
            _("&No, new user")
351
 
        );
352
 
        m_pAccountUseExistingCtrl->SetLabel(
353
 
            _("&Yes, existing user")
354
 
        );
355
 
    } else {
356
 
        if (pSkinAdvanced->IsBranded() && 
357
 
            !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
358
 
            m_pAccountInformationStaticCtrl->SetLabel(
359
 
                pSkinWizardATAM->GetAccountInfoMessage()
360
 
            );
361
 
        }
362
 
    }
363
 
 
364
 
    if (m_pAccountUseExistingCtrl->GetValue()) {
365
 
        m_pAccountConfirmPasswordStaticCtrl->Hide();
366
 
        m_pAccountConfirmPasswordCtrl->Hide();
367
 
        m_pAccountPasswordRequirmentsStaticCtrl->Hide();
368
 
        m_pAccountPasswordStaticCtrl->SetLabel(
369
 
            _("&Password:")
370
 
        );
371
 
    } else {
372
 
        m_pAccountConfirmPasswordStaticCtrl->Show();
373
 
        m_pAccountConfirmPasswordCtrl->Show();
374
 
        m_pAccountPasswordRequirmentsStaticCtrl->Show();
375
 
        m_pAccountPasswordStaticCtrl->SetLabel(
376
 
            _("Choose a &password:")
377
 
        );
378
 
        m_pAccountConfirmPasswordStaticCtrl->SetLabel(
379
 
            _("C&onfirm password:")
380
 
        );
381
 
    }
382
 
 
383
 
    if (!((CBOINCBaseWizard*)GetParent())->project_name.IsEmpty()) {
384
 
        wxString strQuestion;
385
 
        strQuestion.Printf(
386
 
            _("Are you already running %s?"),
387
 
            ((CBOINCBaseWizard*)GetParent())->project_name.c_str()
388
 
        );
389
 
        m_pAccountQuestionStaticCtrl->SetLabel(strQuestion);
390
 
    }
391
 
 
392
 
    if (((CBOINCBaseWizard*)GetParent())->project_config.uses_username) {
393
 
        if (IS_ACCOUNTMANAGERWIZARD()) {
394
 
            if (pSkinAdvanced->IsBranded() && 
395
 
                !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
396
 
                m_pAccountInformationStaticCtrl->SetLabel(
397
 
                    pSkinWizardATAM->GetAccountInfoMessage()
398
 
                );
399
 
            }
400
 
        }
401
 
 
402
 
        m_pAccountEmailAddressStaticCtrl->SetLabel(
403
 
            _("&Username:")
404
 
        );
405
 
        m_pAccountEmailAddressCtrl->SetValidator( wxTextValidator(wxFILTER_ASCII, &m_strAccountEmailAddress) );
406
 
    } else {
407
 
        if (IS_ACCOUNTMANAGERWIZARD()) {
408
 
            if (pSkinAdvanced->IsBranded() && 
409
 
                !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
410
 
                m_pAccountInformationStaticCtrl->SetLabel(
411
 
                    pSkinWizardATAM->GetAccountInfoMessage()
412
 
                );
413
 
            }
414
 
        }
415
 
 
416
 
        m_pAccountEmailAddressStaticCtrl->SetLabel(
417
 
            _("&Email address:")
418
 
        );
419
 
        m_pAccountEmailAddressCtrl->SetValidator( CValidateEmailAddress(& m_strAccountEmailAddress) );
420
 
    }
421
 
 
422
 
    if (pc.min_passwd_length) {
423
 
        wxString str;
424
 
        str.Printf(_("minimum length %d"), pc.min_passwd_length);
425
 
        m_pAccountPasswordRequirmentsStaticCtrl->SetLabel( str );
426
 
    }
427
 
 
428
 
    m_pAccountForgotPasswordCtrl->SetLabel(
429
 
        _("Forgot your password?")
430
 
    );
431
 
 
432
 
    if (!IS_ACCOUNTMANAGERWIZARD()) {
433
 
        wxASSERT(pWAP);
434
 
        m_pAccountForgotPasswordCtrl->SetURL(
435
 
            wxString(pWAP->m_ProjectInfoPage->GetProjectURL() + _T("get_passwd.php"))
436
 
        );
437
 
    } else {
438
 
        wxASSERT(pWAM);
439
 
        m_pAccountForgotPasswordCtrl->SetURL(
440
 
            wxString(pWAM->m_AccountManagerInfoPage->GetProjectURL() + _T("get_passwd.php"))
441
 
        );
442
 
    }
443
 
 
444
 
    Fit();
445
 
    m_pAccountEmailAddressCtrl->SetFocus();
446
 
}
447
 
  
448
 
/*!
449
 
 * wxEVT_WIZARD_PAGE_CHANGING event handler for ID_ACCOUNTINFOPAGE
450
 
 */
451
 
 
452
 
void CAccountInfoPage::OnPageChanging( wxWizardExEvent& event )
453
 
{
454
 
    if (event.GetDirection() == false) return;
455
 
 
456
 
    if (!CHECK_CLOSINGINPROGRESS()) {
457
 
        wxString strTitle;
458
 
        if (IS_ATTACHTOPROJECTWIZARD()) {
459
 
            strTitle = _("Attach to project");
460
 
        } else if (IS_ACCOUNTMANAGERWIZARD() && IS_ACCOUNTMANAGERUPDATEWIZARD()) {
461
 
            strTitle = _("Update account manager");
462
 
        } else if (IS_ACCOUNTMANAGERWIZARD()) {
463
 
            strTitle = _("Attach to account manager");
464
 
        }
465
 
        wxString strMessage = wxT("");
466
 
        bool     bDisplayError = false;
467
 
 
468
 
        // Verify minimum password length
469
 
        unsigned int iMinLength = ((CBOINCBaseWizard*)GetParent())->project_config.min_passwd_length;
470
 
        wxString strPassword = m_pAccountPasswordCtrl->GetValue();
471
 
        if (strPassword.Length() < iMinLength) {
472
 
            if (IS_ATTACHTOPROJECTWIZARD()) {
473
 
                strMessage.Printf(
474
 
                    _("The minimum password length for this project is %d. Please enter a different password."),
475
 
                    iMinLength
476
 
                );
477
 
            }
478
 
            if (IS_ACCOUNTMANAGERWIZARD()) {
479
 
                strMessage.Printf(
480
 
                    _("The minimum password length for this account manager is %d. Please enter a different password."),
481
 
                    iMinLength
482
 
                );
483
 
            }
484
 
 
485
 
            bDisplayError = true;
486
 
        }
487
 
 
488
 
        if (!IS_ACCOUNTMANAGERWIZARD() && m_pAccountCreateCtrl->GetValue()) {
489
 
            // Verify that the password and confirmation password math.
490
 
            if (m_pAccountPasswordCtrl->GetValue() != m_pAccountConfirmPasswordCtrl->GetValue()) {
491
 
                strMessage = _("The password and confirmation password do not match. Please type them again.");
492
 
                bDisplayError = true;
493
 
            }
494
 
        }
495
 
 
496
 
        if (bDisplayError) {
497
 
            wxMessageBox(
498
 
                strMessage,
499
 
                strTitle,
500
 
                wxICON_ERROR | wxOK,
501
 
                this
502
 
            );
503
 
            event.Veto();
504
 
        }
505
 
    }
506
 
}
507
 
  
508
 
/*!
509
 
 * wxEVT_WIZARD_CANCEL event handler for ID_ACCOUNTINFOPAGE
510
 
 */
511
 
 
512
 
void CAccountInfoPage::OnCancel( wxWizardExEvent& event ) {
513
 
    PROCESS_CANCELEVENT(event);
514
 
}
515
 
 
516
 
/*!
517
 
 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ACCOUNTUSEXISTINGBUTTON
518
 
 */
519
 
 
520
 
void CAccountInfoPage::OnAccountUseExistingCtrlSelected( wxCommandEvent& WXUNUSED(event) ) {
521
 
    m_pAccountPasswordStaticCtrl->SetLabel(
522
 
        _("&Password:")
523
 
    );
524
 
    m_pAccountConfirmPasswordStaticCtrl->Hide();
525
 
    m_pAccountConfirmPasswordCtrl->Hide();
526
 
    m_pAccountPasswordRequirmentsStaticCtrl->Hide();
527
 
    m_pAccountEmailAddressCtrl->SetFocus();
528
 
    Fit();
529
 
}
530
 
  
531
 
/*!
532
 
 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ACCOUNTCREATEBUTTON
533
 
 */
534
 
 
535
 
void CAccountInfoPage::OnAccountCreateCtrlSelected( wxCommandEvent& WXUNUSED(event) ) {
536
 
    m_pAccountPasswordStaticCtrl->SetLabel(
537
 
        _("Choose a &password:")
538
 
    );
539
 
    m_pAccountConfirmPasswordStaticCtrl->Show();
540
 
    m_pAccountConfirmPasswordCtrl->Show();
541
 
    m_pAccountPasswordRequirmentsStaticCtrl->Show();
542
 
    m_pAccountEmailAddressCtrl->SetFocus();
543
 
    Fit();
544
 
}
 
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 "AccountInfoPage.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 "BOINCGUIApp.h"
 
32
#include "SkinManager.h"
 
33
#include "MainDocument.h"
 
34
#include "wx/valgen.h"
 
35
#include "wx/valtext.h"
 
36
#include "ValidateEmailAddress.h"
 
37
#include "BOINCBaseWizard.h"
 
38
#include "WizardAttach.h"
 
39
#include "ProjectInfoPage.h"
 
40
#include "AccountManagerInfoPage.h"
 
41
#include "AccountInfoPage.h"
 
42
 
 
43
 
 
44
/*!
 
45
 * CAccountInfoPage type definition
 
46
 */
 
47
 
 
48
IMPLEMENT_DYNAMIC_CLASS( CAccountInfoPage, wxWizardPageEx )
 
49
 
 
50
/*!
 
51
 * CAccountInfoPage event table definition
 
52
 */
 
53
 
 
54
BEGIN_EVENT_TABLE( CAccountInfoPage, wxWizardPageEx )
 
55
 
 
56
////@begin CAccountInfoPage event table entries
 
57
    EVT_WIZARDEX_PAGE_CHANGED( -1, CAccountInfoPage::OnPageChanged )
 
58
    EVT_WIZARDEX_PAGE_CHANGING( -1, CAccountInfoPage::OnPageChanging )
 
59
    EVT_WIZARDEX_CANCEL( -1, CAccountInfoPage::OnCancel )
 
60
    EVT_RADIOBUTTON( ID_ACCOUNTCREATECTRL, CAccountInfoPage::OnAccountCreateCtrlSelected )
 
61
    EVT_RADIOBUTTON( ID_ACCOUNTUSEEXISTINGCTRL, CAccountInfoPage::OnAccountUseExistingCtrlSelected )
 
62
////@end CAccountInfoPage event table entries
 
63
 
 
64
END_EVENT_TABLE()
 
65
 
 
66
/*!
 
67
 * CAccountInfoPage constructors
 
68
 */
 
69
 
 
70
CAccountInfoPage::CAccountInfoPage( )
 
71
{
 
72
}
 
73
 
 
74
CAccountInfoPage::CAccountInfoPage( CBOINCBaseWizard* parent )
 
75
{
 
76
    Create( parent );
 
77
}
 
78
 
 
79
/*!
 
80
 * AccountInfoPage creator
 
81
 */
 
82
 
 
83
bool CAccountInfoPage::Create( CBOINCBaseWizard* parent )
 
84
{
 
85
 
 
86
////@begin CAccountInfoPage member initialisation
 
87
    m_pTitleStaticCtrl = NULL;
 
88
    m_pCookieDetectionFailedStaticCtrl = NULL;
 
89
    m_pCookieDetectionFailedCtrl = NULL;
 
90
    m_pAccountQuestionStaticCtrl = NULL;
 
91
    m_pAccountInformationStaticCtrl = NULL;
 
92
    m_pAccountCreateCtrl = NULL;
 
93
    m_pAccountUseExistingCtrl = NULL;
 
94
    m_pAccountEmailAddressStaticCtrl = NULL;
 
95
    m_pAccountEmailAddressCtrl = NULL;
 
96
    m_pAccountPasswordStaticCtrl = NULL;
 
97
    m_pAccountPasswordCtrl = NULL;
 
98
    m_pAccountConfirmPasswordStaticCtrl = NULL;
 
99
    m_pAccountConfirmPasswordCtrl = NULL;
 
100
    m_pAccountPasswordRequirmentsStaticCtrl = NULL;
 
101
    m_pAccountManagerLinkLabelStaticCtrl = NULL;
 
102
    m_pAccountForgotPasswordCtrl = NULL;
 
103
////@end CAccountInfoPage member initialisation
 
104
 
 
105
////@begin CAccountInfoPage creation
 
106
    wxWizardPageEx::Create( parent, ID_ACCOUNTINFOPAGE );
 
107
 
 
108
    CreateControls();
 
109
    GetSizer()->Fit(this);
 
110
////@end CAccountInfoPage creation
 
111
 
 
112
    return TRUE;
 
113
}
 
114
 
 
115
/*!
 
116
 * Control creation for AccountInfoPage
 
117
 */
 
118
 
 
119
void CAccountInfoPage::CreateControls()
 
120
{    
 
121
 
 
122
////@begin CAccountInfoPage content construction
 
123
    CAccountInfoPage* itemWizardPage56 = this;
 
124
 
 
125
    wxBoxSizer* itemBoxSizer57 = new wxBoxSizer(wxVERTICAL);
 
126
    itemWizardPage56->SetSizer(itemBoxSizer57);
 
127
 
 
128
    m_pTitleStaticCtrl = new wxStaticText;
 
129
    m_pTitleStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
130
    m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana")));
 
131
    itemBoxSizer57->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxGROW|wxALL, 5);
 
132
 
 
133
    m_pCookieDetectionFailedStaticCtrl = new wxStaticText;
 
134
    m_pCookieDetectionFailedStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
135
    m_pCookieDetectionFailedStaticCtrl->Hide();
 
136
    itemBoxSizer57->Add(m_pCookieDetectionFailedStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
 
137
 
 
138
    m_pCookieDetectionFailedCtrl = new wxHyperlinkCtrl;
 
139
    m_pCookieDetectionFailedCtrl->Create( itemWizardPage56, ID_ACCOUNTCOOKIEDETECTIONFAILEDCTRL, wxT(" "), wxT(" "), wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxHL_ALIGN_LEFT | wxHL_CONTEXTMENU );
 
140
    m_pCookieDetectionFailedCtrl->Hide();
 
141
    itemBoxSizer57->Add(m_pCookieDetectionFailedCtrl, 0, wxALIGN_LEFT|wxALL, 5);
 
142
 
 
143
    m_pAccountQuestionStaticCtrl = new wxStaticText;
 
144
    m_pAccountQuestionStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
145
    itemBoxSizer57->Add(m_pAccountQuestionStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
 
146
 
 
147
    wxFlexGridSizer* itemFlexGridSizer61 = new wxFlexGridSizer(1, 2, 0, 0);
 
148
    itemFlexGridSizer61->AddGrowableCol(1);
 
149
    itemBoxSizer57->Add(itemFlexGridSizer61, 0, wxGROW|wxALL, 5);
 
150
 
 
151
    m_pAccountCreateCtrl = new wxRadioButton;
 
152
    m_pAccountCreateCtrl->Create( itemWizardPage56, ID_ACCOUNTCREATECTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
 
153
    m_pAccountCreateCtrl->SetValue(TRUE);
 
154
    itemFlexGridSizer61->Add(m_pAccountCreateCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
155
 
 
156
    m_pAccountUseExistingCtrl = new wxRadioButton;
 
157
    m_pAccountUseExistingCtrl->Create( itemWizardPage56, ID_ACCOUNTUSEEXISTINGCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
158
    m_pAccountUseExistingCtrl->SetValue(FALSE);
 
159
    itemFlexGridSizer61->Add(m_pAccountUseExistingCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
160
 
 
161
    m_pAccountInformationStaticCtrl = new wxStaticText;
 
162
    m_pAccountInformationStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
163
    itemBoxSizer57->Add(m_pAccountInformationStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5);
 
164
 
 
165
    wxFlexGridSizer* itemFlexGridSizer64 = new wxFlexGridSizer(4, 2, 0, 0);
 
166
    itemFlexGridSizer64->AddGrowableCol(1);
 
167
    itemBoxSizer57->Add(itemFlexGridSizer64, 0, wxEXPAND|wxALL, 0);
 
168
 
 
169
    m_pAccountEmailAddressStaticCtrl = new wxStaticText;
 
170
    m_pAccountEmailAddressStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTEMAILADDRESSSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
171
    itemFlexGridSizer64->Add(m_pAccountEmailAddressStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
172
 
 
173
    m_pAccountEmailAddressCtrl = new wxTextCtrl;
 
174
    m_pAccountEmailAddressCtrl->Create( itemWizardPage56, ID_ACCOUNTEMAILADDRESSCTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 22), 0 );
 
175
    itemFlexGridSizer64->Add(m_pAccountEmailAddressCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
176
 
 
177
    m_pAccountUsernameStaticCtrl = new wxStaticText;
 
178
    m_pAccountUsernameStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTUSERNAMESTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
179
    itemFlexGridSizer64->Add(m_pAccountUsernameStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
180
 
 
181
    m_pAccountUsernameCtrl = new wxTextCtrl;
 
182
    m_pAccountUsernameCtrl->Create( itemWizardPage56, ID_ACCOUNTUSERNAMECTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 22), 0 );
 
183
    itemFlexGridSizer64->Add(m_pAccountUsernameCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
184
 
 
185
    m_pAccountPasswordStaticCtrl = new wxStaticText;
 
186
    m_pAccountPasswordStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTPASSWORDSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
187
    itemFlexGridSizer64->Add(m_pAccountPasswordStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
188
 
 
189
    m_pAccountPasswordCtrl = new wxTextCtrl;
 
190
    m_pAccountPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTPASSWORDCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
 
191
    itemFlexGridSizer64->Add(m_pAccountPasswordCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
192
 
 
193
    m_pAccountConfirmPasswordStaticCtrl = new wxStaticText;
 
194
    m_pAccountConfirmPasswordStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTCONFIRMPASSWORDSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
195
    itemFlexGridSizer64->Add(m_pAccountConfirmPasswordStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
196
 
 
197
    m_pAccountConfirmPasswordCtrl = new wxTextCtrl;
 
198
    m_pAccountConfirmPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTCONFIRMPASSWORDCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
 
199
    itemFlexGridSizer64->Add(m_pAccountConfirmPasswordCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
200
 
 
201
    itemFlexGridSizer64->Add( 0, 0 );
 
202
 
 
203
    m_pAccountPasswordRequirmentsStaticCtrl = new wxStaticText;
 
204
    m_pAccountPasswordRequirmentsStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTREQUIREMENTSSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
205
    m_pAccountPasswordRequirmentsStaticCtrl->SetFont(wxFont(7, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE));
 
206
    itemFlexGridSizer64->Add(m_pAccountPasswordRequirmentsStaticCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
207
 
 
208
    m_pAccountManagerLinkLabelStaticCtrl = new wxStaticText;
 
209
    m_pAccountManagerLinkLabelStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTLINKLABELSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
210
    itemBoxSizer57->Add(m_pAccountManagerLinkLabelStaticCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
211
 
 
212
    m_pAccountForgotPasswordCtrl = new wxHyperlinkCtrl;
 
213
    m_pAccountForgotPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTFORGOTPASSWORDCTRL, wxT(" "), wxT(" "), wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxHL_ALIGN_LEFT | wxHL_CONTEXTMENU );
 
214
    itemBoxSizer57->Add(m_pAccountForgotPasswordCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
215
 
 
216
    // Set validators
 
217
    // m_pAccountEmailAddressCtrl/m_pAccountUsernameCtrl is setup when the OnPageChange event is fired since
 
218
    //   it can be a username or an email address.
 
219
    m_pAccountEmailAddressCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountEmailAddress) );
 
220
    m_pAccountUsernameCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountUsername) );
 
221
    m_pAccountPasswordCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountPassword) );
 
222
    m_pAccountConfirmPasswordCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountConfirmPassword) );
 
223
    
 
224
#ifdef __WXMAC__
 
225
    //Accessibility
 
226
    HIViewRef buttonView = (HIViewRef)m_pAccountCreateCtrl->GetHandle();
 
227
    HIObjectRef   theObject = (HIObjectRef)HIViewGetSuperview(buttonView);
 
228
    HIObjectSetAccessibilityIgnored(theObject, true);
 
229
#endif
 
230
    ////@end CAccountInfoPage content construction
 
231
 
 
232
}
 
233
 
 
234
/*!
 
235
 * Gets the previous page.
 
236
 */
 
237
 
 
238
wxWizardPageEx* CAccountInfoPage::GetPrev() const
 
239
{
 
240
    return PAGE_TRANSITION_BACK;
 
241
}
 
242
 
 
243
/*!
 
244
 * Gets the next page.
 
245
 */
 
246
 
 
247
wxWizardPageEx* CAccountInfoPage::GetNext() const
 
248
{
 
249
    if (CHECK_CLOSINGINPROGRESS()) {
 
250
        // Cancel Event Detected
 
251
        return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
 
252
    } else if (IS_ATTACHTOPROJECTWIZARD()) {
 
253
        return PAGE_TRANSITION_NEXT(ID_PROJECTPROCESSINGPAGE);
 
254
    } else if (IS_ACCOUNTMANAGERWIZARD()) {
 
255
        return PAGE_TRANSITION_NEXT(ID_ACCOUNTMANAGERPROCESSINGPAGE);
 
256
    }
 
257
    return NULL;
 
258
}
 
259
 
 
260
/*!
 
261
 * Should we show tooltips?
 
262
 */
 
263
 
 
264
bool CAccountInfoPage::ShowToolTips()
 
265
{
 
266
    return TRUE;
 
267
}
 
268
 
 
269
/*!
 
270
 * Get bitmap resources
 
271
 */
 
272
 
 
273
wxBitmap CAccountInfoPage::GetBitmapResource( const wxString& WXUNUSED(name) )
 
274
{
 
275
    // Bitmap retrieval
 
276
////@begin CAccountInfoPage bitmap retrieval
 
277
    return wxNullBitmap;
 
278
////@end CAccountInfoPage bitmap retrieval
 
279
}
 
280
 
 
281
/*!
 
282
 * Get icon resources
 
283
 */
 
284
 
 
285
wxIcon CAccountInfoPage::GetIconResource( const wxString& WXUNUSED(name) )
 
286
{
 
287
    // Icon retrieval
 
288
////@begin CAccountInfoPage icon retrieval
 
289
    return wxNullIcon;
 
290
////@end CAccountInfoPage icon retrieval
 
291
}
 
292
  
 
293
/*!
 
294
 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_ACCOUNTINFOPAGE
 
295
 */
 
296
 
 
297
void CAccountInfoPage::OnPageChanged( wxWizardExEvent& event ) {
 
298
    if (event.GetDirection() == false) return;
 
299
 
 
300
    CWizardAttach*   pWA = ((CWizardAttach*)GetParent());
 
301
    CSkinAdvanced*   pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
 
302
    CSkinWizardATAM* pSkinWizardATAM = wxGetApp().GetSkinManager()->GetWizards()->GetWizardATAM();
 
303
    PROJECT_CONFIG&  pc = pWA->project_config;
 
304
    wxString         strBaseConfigLocation = wxString(wxT("/Wizards"));
 
305
    wxConfigBase*    pConfig = wxConfigBase::Get(FALSE);
 
306
 
 
307
    wxASSERT(pSkinAdvanced);
 
308
    wxASSERT(pSkinWizardATAM);
 
309
    wxASSERT(m_pTitleStaticCtrl);
 
310
    wxASSERT(m_pCookieDetectionFailedStaticCtrl);
 
311
    wxASSERT(m_pCookieDetectionFailedCtrl);
 
312
    wxASSERT(m_pAccountQuestionStaticCtrl);
 
313
    wxASSERT(m_pAccountInformationStaticCtrl);
 
314
    wxASSERT(m_pAccountCreateCtrl);
 
315
    wxASSERT(m_pAccountUseExistingCtrl);
 
316
    wxASSERT(m_pAccountEmailAddressStaticCtrl);
 
317
    wxASSERT(m_pAccountEmailAddressCtrl);
 
318
    wxASSERT(m_pAccountUsernameStaticCtrl);
 
319
    wxASSERT(m_pAccountUsernameCtrl);
 
320
    wxASSERT(m_pAccountPasswordStaticCtrl);
 
321
    wxASSERT(m_pAccountPasswordCtrl);
 
322
    wxASSERT(m_pAccountConfirmPasswordStaticCtrl);
 
323
    wxASSERT(m_pAccountConfirmPasswordCtrl);
 
324
    wxASSERT(m_pAccountPasswordRequirmentsStaticCtrl);
 
325
    wxASSERT(m_pAccountManagerLinkLabelStaticCtrl);
 
326
    wxASSERT(m_pAccountForgotPasswordCtrl);
 
327
    wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
 
328
    wxASSERT(wxDynamicCast(pSkinWizardATAM, CSkinWizardATAM));
 
329
 
 
330
 
 
331
    // We are entering this page, so reterieve the previously used email
 
332
    // address and/or username.
 
333
    pConfig->SetPath(strBaseConfigLocation);
 
334
    m_strAccountEmailAddress = pConfig->Read(wxT("DefaultEmailAddress"));
 
335
    m_strAccountUsername = pConfig->Read(wxT("DefaultUsername"));
 
336
 
 
337
    // Setup the desired controls and default values.
 
338
    static bool bRunOnce = true;
 
339
    if (bRunOnce) {
 
340
        bRunOnce = false;
 
341
        if (!IS_ACCOUNTMANAGERWIZARD()) {
 
342
            m_pAccountCreateCtrl->SetValue(true);
 
343
            m_pAccountUseExistingCtrl->SetValue(false);
 
344
        }
 
345
    }
 
346
 
 
347
    if (IS_ACCOUNTMANAGERWIZARD()) {
 
348
        if (!(pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected)) {
 
349
            m_pCookieDetectionFailedStaticCtrl->Hide();
 
350
            m_pCookieDetectionFailedCtrl->Hide();
 
351
        } else {
 
352
            m_pCookieDetectionFailedStaticCtrl->Show();
 
353
            m_pCookieDetectionFailedCtrl->Show();
 
354
        }
 
355
 
 
356
        m_pAccountQuestionStaticCtrl->Hide();
 
357
        m_pAccountCreateCtrl->SetValue(false);
 
358
        m_pAccountCreateCtrl->Hide();
 
359
        m_pAccountUseExistingCtrl->SetValue(true);
 
360
        m_pAccountUseExistingCtrl->Hide();
 
361
        m_pAccountConfirmPasswordStaticCtrl->Hide();
 
362
        m_pAccountConfirmPasswordCtrl->Hide();
 
363
        m_pAccountPasswordRequirmentsStaticCtrl->Hide();
 
364
 
 
365
        if (pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected) {
 
366
            m_pAccountManagerLinkLabelStaticCtrl->Hide();
 
367
            m_pAccountForgotPasswordCtrl->Hide();
 
368
        }
 
369
    } else {
 
370
        m_pCookieDetectionFailedStaticCtrl->Hide();
 
371
        m_pCookieDetectionFailedCtrl->Hide();
 
372
        if (pc.account_creation_disabled || pc.client_account_creation_disabled) {
 
373
            m_pAccountCreateCtrl->SetValue(false);
 
374
            m_pAccountCreateCtrl->Hide();
 
375
            m_pAccountUseExistingCtrl->SetValue(true);
 
376
            m_pAccountUseExistingCtrl->Hide();
 
377
        } else {
 
378
            m_pAccountCreateCtrl->Show();
 
379
            m_pAccountCreateCtrl->Enable();
 
380
            m_pAccountUseExistingCtrl->Show();
 
381
        }
 
382
        m_pAccountManagerLinkLabelStaticCtrl->Hide();
 
383
    }
 
384
 
 
385
    m_pTitleStaticCtrl->SetLabel(
 
386
        _("Identify your account ")
 
387
    );
 
388
 
 
389
    if (!IS_ACCOUNTMANAGERWIZARD() && !IS_ACCOUNTMANAGERUPDATEWIZARD()) {
 
390
                if (pc.client_account_creation_disabled) {
 
391
                        m_pAccountQuestionStaticCtrl->SetLabel(
 
392
                                _("Please enter your account information\n(to create an account, visit the project's web site)")
 
393
                        );
 
394
                } else if (pc.account_creation_disabled) {
 
395
                        m_pAccountQuestionStaticCtrl->SetLabel(
 
396
                                _("This project is not currently accepting new accounts.\nYou can add it only if you already have an account.")
 
397
                        );
 
398
                } else {
 
399
                        m_pAccountQuestionStaticCtrl->SetLabel(
 
400
                                _("Are you already running this project?")
 
401
                        );
 
402
                }
 
403
        m_pAccountCreateCtrl->SetLabel(
 
404
            _("&No, new user")
 
405
        );
 
406
        m_pAccountUseExistingCtrl->SetLabel(
 
407
            _("&Yes, existing user")
 
408
        );
 
409
    } else {
 
410
        if (pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected) {
 
411
            m_pCookieDetectionFailedStaticCtrl->SetLabel(
 
412
                _("We were not able to set up your account information\nautomatically.\n\nPlease click on the 'Find login information' link\nbelow to find out what to put in the email address and\npassword fields.")
 
413
            );
 
414
            m_pCookieDetectionFailedCtrl->SetLabel(
 
415
                _("Find login information")
 
416
            );
 
417
            m_pCookieDetectionFailedCtrl->SetURL(
 
418
                pWA->m_strCookieFailureURL
 
419
            );
 
420
        }
 
421
 
 
422
        if (pSkinAdvanced->IsBranded() && 
 
423
            !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
 
424
            m_pAccountInformationStaticCtrl->SetLabel(
 
425
                pSkinWizardATAM->GetAccountInfoMessage()
 
426
            );
 
427
        }
 
428
    }
 
429
 
 
430
    if (m_pAccountUseExistingCtrl->GetValue()) {
 
431
        m_pAccountConfirmPasswordStaticCtrl->Hide();
 
432
        m_pAccountConfirmPasswordCtrl->Hide();
 
433
        m_pAccountPasswordRequirmentsStaticCtrl->Hide();
 
434
        m_pAccountPasswordStaticCtrl->SetLabel(
 
435
            _("&Password:")
 
436
        );
 
437
    } else {
 
438
        m_pAccountConfirmPasswordStaticCtrl->Show();
 
439
        m_pAccountConfirmPasswordCtrl->Show();
 
440
        m_pAccountPasswordRequirmentsStaticCtrl->Show();
 
441
        m_pAccountPasswordStaticCtrl->SetLabel(
 
442
            _("Choose a &password:")
 
443
        );
 
444
        m_pAccountConfirmPasswordStaticCtrl->SetLabel(
 
445
            _("C&onfirm password:")
 
446
        );
 
447
    }
 
448
 
 
449
    if (!pWA->GetProjectName().IsEmpty()) {
 
450
        wxString strQuestion;
 
451
        strQuestion.Printf(
 
452
            _("Are you already running %s?"),
 
453
            pWA->GetProjectName().c_str()
 
454
        );
 
455
        m_pAccountQuestionStaticCtrl->SetLabel(strQuestion);
 
456
    }
 
457
 
 
458
    if (pc.uses_username) {
 
459
        if (IS_ACCOUNTMANAGERWIZARD()) {
 
460
            if (pSkinAdvanced->IsBranded() && 
 
461
                !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
 
462
                m_pAccountInformationStaticCtrl->SetLabel(
 
463
                    pSkinWizardATAM->GetAccountInfoMessage()
 
464
                );
 
465
            }
 
466
        }
 
467
 
 
468
        m_pAccountEmailAddressCtrl->SetValidator( 
 
469
            wxTextValidator(wxFILTER_NONE, &m_strAccountEmailAddress)
 
470
        );
 
471
        m_pAccountUsernameCtrl->SetValidator(
 
472
            wxTextValidator(wxFILTER_ASCII, &m_strAccountUsername)
 
473
        );
 
474
 
 
475
        m_pAccountEmailAddressStaticCtrl->Hide();
 
476
        m_pAccountEmailAddressCtrl->Hide();
 
477
        m_pAccountUsernameStaticCtrl->Show();
 
478
        m_pAccountUsernameCtrl->Show();
 
479
 
 
480
        m_pAccountUsernameStaticCtrl->SetLabel(
 
481
            _("&Username:")
 
482
        );
 
483
        m_pAccountUsernameCtrl->SetValue(m_strAccountUsername);
 
484
    } else {
 
485
        if (IS_ACCOUNTMANAGERWIZARD()) {
 
486
            if (pSkinAdvanced->IsBranded() && 
 
487
                !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
 
488
                m_pAccountInformationStaticCtrl->SetLabel(
 
489
                    pSkinWizardATAM->GetAccountInfoMessage()
 
490
                );
 
491
            }
 
492
        }
 
493
 
 
494
        m_pAccountEmailAddressCtrl->SetValidator(
 
495
            CValidateEmailAddress(&m_strAccountEmailAddress)
 
496
        );
 
497
        m_pAccountUsernameCtrl->SetValidator(
 
498
            wxTextValidator(wxFILTER_NONE, &m_strAccountUsername)
 
499
        );
 
500
 
 
501
        m_pAccountEmailAddressStaticCtrl->Show();
 
502
        m_pAccountEmailAddressCtrl->Show();
 
503
        m_pAccountUsernameStaticCtrl->Hide();
 
504
        m_pAccountUsernameCtrl->Hide();
 
505
 
 
506
        m_pAccountEmailAddressStaticCtrl->SetLabel(
 
507
            _("&Email address:")
 
508
        );
 
509
        m_pAccountEmailAddressCtrl->SetValue(m_strAccountEmailAddress);
 
510
    }
 
511
 
 
512
    if (pc.min_passwd_length) {
 
513
        wxString str;
 
514
        str.Printf(_("minimum length %d"), pc.min_passwd_length);
 
515
        m_pAccountPasswordRequirmentsStaticCtrl->SetLabel( str );
 
516
    }
 
517
 
 
518
 
 
519
    if (!IS_ACCOUNTMANAGERWIZARD()) {
 
520
        m_pAccountForgotPasswordCtrl->SetLabel(
 
521
            _("Forgot your password?")
 
522
        );
 
523
        m_pAccountForgotPasswordCtrl->SetURL(
 
524
            wxString(pWA->m_ProjectInfoPage->GetProjectURL() + _T("get_passwd.php"))
 
525
        );
 
526
    } else {
 
527
        m_pAccountManagerLinkLabelStaticCtrl->SetLabel(
 
528
            _("If you have not yet registered with this account manager,\nplease do so before proceeding.  Click on the link below\nto register or to retrieve a forgotten password." )
 
529
        );
 
530
        m_pAccountForgotPasswordCtrl->SetLabel(
 
531
            _("Account manager website")
 
532
        );
 
533
        m_pAccountForgotPasswordCtrl->SetURL(
 
534
            wxString(pWA->m_AccountManagerInfoPage->GetProjectURL())
 
535
        );
 
536
    }
 
537
 
 
538
    if (pc.uses_username) {
 
539
        m_pAccountUsernameCtrl->SetFocus();
 
540
    } else {
 
541
        m_pAccountEmailAddressCtrl->SetFocus();
 
542
    }
 
543
 
 
544
    Fit();
 
545
}
 
546
  
 
547
/*!
 
548
 * wxEVT_WIZARD_PAGE_CHANGING event handler for ID_ACCOUNTINFOPAGE
 
549
 */
 
550
 
 
551
void CAccountInfoPage::OnPageChanging( wxWizardExEvent& event ) {
 
552
    if (event.GetDirection() == false) return;
 
553
 
 
554
    CWizardAttach*         pWA = ((CWizardAttach*)GetParent());
 
555
    PROJECT_CONFIG&        pc = pWA->project_config;
 
556
    wxString               strTitle;
 
557
    wxString               strMessage = wxT("");
 
558
    bool                   bDisplayError = false;
 
559
    wxString               strBaseConfigLocation = wxString(wxT("/Wizards"));
 
560
    wxConfigBase*          pConfig = wxConfigBase::Get(FALSE);
 
561
 
 
562
    if (!CHECK_CLOSINGINPROGRESS()) {
 
563
        // We are leaving this page, so store the email address for future
 
564
        // use.
 
565
        pConfig->SetPath(strBaseConfigLocation);
 
566
        pConfig->Write(wxT("DefaultEmailAddress"), m_strAccountEmailAddress);
 
567
        pConfig->Write(wxT("DefaultUsername"), m_strAccountUsername);
 
568
 
 
569
        // Construct potiental dialog title
 
570
        if (IS_ATTACHTOPROJECTWIZARD()) {
 
571
            strTitle = _("Add project");
 
572
        } else if (IS_ACCOUNTMANAGERWIZARD() && IS_ACCOUNTMANAGERUPDATEWIZARD()) {
 
573
            strTitle = _("Update account manager");
 
574
        } else if (IS_ACCOUNTMANAGERWIZARD()) {
 
575
            strTitle = _("Add account manager");
 
576
        }
 
577
 
 
578
        // Verify minimum password length
 
579
        if (!m_pAccountUseExistingCtrl->GetValue()) {
 
580
            if (m_pAccountPasswordCtrl->GetValue().Length() < (size_t)pc.min_passwd_length) {
 
581
                if (IS_ATTACHTOPROJECTWIZARD()) {
 
582
                    strMessage.Printf(
 
583
                        _("The minimum password length for this project is %d. Please enter a different password."),
 
584
                        pc.min_passwd_length
 
585
                    );
 
586
                }
 
587
                if (IS_ACCOUNTMANAGERWIZARD()) {
 
588
                    strMessage.Printf(
 
589
                        _("The minimum password length for this account manager is %d. Please enter a different password."),
 
590
                        pc.min_passwd_length
 
591
                    );
 
592
                }
 
593
 
 
594
                bDisplayError = true;
 
595
            }
 
596
        }
 
597
 
 
598
        // Verify that the password and confirmation password math.
 
599
        if (!IS_ACCOUNTMANAGERWIZARD() && m_pAccountCreateCtrl->GetValue()) {
 
600
            if (m_pAccountPasswordCtrl->GetValue() != m_pAccountConfirmPasswordCtrl->GetValue()) {
 
601
                strMessage = _("The password and confirmation password do not match. Please type them again.");
 
602
                bDisplayError = true;
 
603
            }
 
604
        }
 
605
 
 
606
        if (bDisplayError) {
 
607
            wxGetApp().SafeMessageBox(
 
608
                strMessage,
 
609
                strTitle,
 
610
                wxICON_ERROR | wxOK,
 
611
                this
 
612
            );
 
613
            event.Veto();
 
614
        }
 
615
    }
 
616
}
 
617
  
 
618
/*!
 
619
 * wxEVT_WIZARD_CANCEL event handler for ID_ACCOUNTINFOPAGE
 
620
 */
 
621
 
 
622
void CAccountInfoPage::OnCancel( wxWizardExEvent& event ) {
 
623
    PROCESS_CANCELEVENT(event);
 
624
}
 
625
 
 
626
/*!
 
627
 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ACCOUNTUSEXISTINGBUTTON
 
628
 */
 
629
 
 
630
void CAccountInfoPage::OnAccountUseExistingCtrlSelected( wxCommandEvent& WXUNUSED(event) ) {
 
631
    CWizardAttach*         pWA = ((CWizardAttach*)GetParent());
 
632
    PROJECT_CONFIG&        pc = pWA->project_config;
 
633
 
 
634
    m_pAccountPasswordStaticCtrl->SetLabel(
 
635
        _("&Password:")
 
636
    );
 
637
    m_pAccountConfirmPasswordStaticCtrl->Hide();
 
638
    m_pAccountConfirmPasswordCtrl->Hide();
 
639
    m_pAccountPasswordRequirmentsStaticCtrl->Hide();
 
640
 
 
641
    if (pc.uses_username) {
 
642
        m_pAccountUsernameCtrl->SetFocus();
 
643
    } else {
 
644
        m_pAccountEmailAddressCtrl->SetFocus();
 
645
    }
 
646
 
 
647
    Fit();
 
648
}
 
649
  
 
650
/*!
 
651
 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ACCOUNTCREATEBUTTON
 
652
 */
 
653
 
 
654
void CAccountInfoPage::OnAccountCreateCtrlSelected( wxCommandEvent& WXUNUSED(event) ) {
 
655
    CWizardAttach*         pWA = ((CWizardAttach*)GetParent());
 
656
    PROJECT_CONFIG&        pc = pWA->project_config;
 
657
 
 
658
    m_pAccountPasswordStaticCtrl->SetLabel(
 
659
        _("Choose a &password:")
 
660
    );
 
661
    m_pAccountConfirmPasswordStaticCtrl->Show();
 
662
    m_pAccountConfirmPasswordCtrl->Show();
 
663
    m_pAccountPasswordRequirmentsStaticCtrl->Show();
 
664
 
 
665
    if (pc.uses_username) {
 
666
        m_pAccountUsernameCtrl->SetFocus();
 
667
    } else {
 
668
        m_pAccountEmailAddressCtrl->SetFocus();
 
669
    }
 
670
 
 
671
    Fit();
 
672
}
 
673