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
IMPLEMENT_DYNAMIC_CLASS(CAccountInfoPage,wxWizardPageEx)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( wxID_ANY, CAccountInfoPage::OnPageChanged )
58 EVT_WIZARDEX_PAGE_CHANGING( wxID_ANY, CAccountInfoPage::OnPageChanging )
59 EVT_WIZARDEX_CANCEL( wxID_ANY, 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
CAccountInfoPage(CBOINCBaseWizard * parent)74 CAccountInfoPage::CAccountInfoPage( CBOINCBaseWizard* parent )
75 {
76 Create( parent );
77 }
78
79 /*!
80 * AccountInfoPage creator
81 */
82
Create(CBOINCBaseWizard * parent)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
CreateControls()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(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 #ifdef __WXMAC__
217 //Accessibility
218 HIViewRef buttonView = (HIViewRef)m_pAccountCreateCtrl->GetHandle();
219 HIObjectRef theObject = (HIObjectRef)HIViewGetSuperview(buttonView);
220 HIObjectSetAccessibilityIgnored(theObject, true);
221 #endif
222 ////@end CAccountInfoPage content construction
223
224 }
225
226 /*!
227 * Gets the previous page.
228 */
229
GetPrev() const230 wxWizardPageEx* CAccountInfoPage::GetPrev() const
231 {
232 return PAGE_TRANSITION_BACK;
233 }
234
235 /*!
236 * Gets the next page.
237 */
238
GetNext() const239 wxWizardPageEx* CAccountInfoPage::GetNext() const
240 {
241 if (CHECK_CLOSINGINPROGRESS()) {
242 // Cancel Event Detected
243 return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
244 } else if (IS_ATTACHTOPROJECTWIZARD()) {
245 return PAGE_TRANSITION_NEXT(ID_PROJECTPROCESSINGPAGE);
246 } else if (IS_ACCOUNTMANAGERWIZARD()) {
247 return PAGE_TRANSITION_NEXT(ID_ACCOUNTMANAGERPROCESSINGPAGE);
248 }
249 return NULL;
250 }
251
252 /*!
253 * Should we show tooltips?
254 */
255
ShowToolTips()256 bool CAccountInfoPage::ShowToolTips()
257 {
258 return TRUE;
259 }
260
261 /*!
262 * Get bitmap resources
263 */
264
GetBitmapResource(const wxString & WXUNUSED (name))265 wxBitmap CAccountInfoPage::GetBitmapResource( const wxString& WXUNUSED(name) )
266 {
267 // Bitmap retrieval
268 ////@begin CAccountInfoPage bitmap retrieval
269 return wxNullBitmap;
270 ////@end CAccountInfoPage bitmap retrieval
271 }
272
273 /*!
274 * Get icon resources
275 */
276
GetIconResource(const wxString & WXUNUSED (name))277 wxIcon CAccountInfoPage::GetIconResource( const wxString& WXUNUSED(name) )
278 {
279 // Icon retrieval
280 ////@begin CAccountInfoPage icon retrieval
281 return wxNullIcon;
282 ////@end CAccountInfoPage icon retrieval
283 }
284
285 /*!
286 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_ACCOUNTINFOPAGE
287 */
288
OnPageChanged(wxWizardExEvent &)289 void CAccountInfoPage::OnPageChanged( wxWizardExEvent& /* event */ ) {
290 CWizardAttach* pWA = ((CWizardAttach*)GetParent());
291 CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
292 CSkinWizardATAM* pSkinWizardATAM = wxGetApp().GetSkinManager()->GetWizards()->GetWizardATAM();
293 PROJECT_CONFIG& pc = pWA->project_config;
294 wxString strBaseConfigLocation = wxString(wxT("/Wizards"));
295 wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
296
297 wxASSERT(pSkinAdvanced);
298 wxASSERT(pSkinWizardATAM);
299 wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
300 wxASSERT(wxDynamicCast(pSkinWizardATAM, CSkinWizardATAM));
301
302
303 // We are entering this page, so reterieve the previously used email
304 // address and/or username.
305 pConfig->SetPath(strBaseConfigLocation);
306 m_strAccountEmailAddress = pConfig->Read(wxT("DefaultEmailAddress"));
307 m_strAccountUsername = pConfig->Read(wxT("DefaultUsername"));
308
309 // Setup the desired controls and default values.
310 static bool bRunOnce = true;
311 if (bRunOnce) {
312 bRunOnce = false;
313 if (!IS_ACCOUNTMANAGERWIZARD()) {
314 m_pAccountCreateCtrl->SetValue(true);
315 m_pAccountUseExistingCtrl->SetValue(false);
316 }
317 }
318
319 if (IS_ACCOUNTMANAGERWIZARD()) {
320 if (!(pWA->IsCookieRequired() && !pWA->IsCredentialsDetected())) {
321 m_pCookieDetectionFailedStaticCtrl->Hide();
322 m_pCookieDetectionFailedCtrl->Hide();
323 } else {
324 m_pCookieDetectionFailedStaticCtrl->Show();
325 m_pCookieDetectionFailedCtrl->Show();
326 }
327
328 m_pAccountQuestionStaticCtrl->Hide();
329 m_pAccountCreateCtrl->SetValue(false);
330 m_pAccountCreateCtrl->Hide();
331 m_pAccountUseExistingCtrl->SetValue(true);
332 m_pAccountUseExistingCtrl->Hide();
333 m_pAccountConfirmPasswordStaticCtrl->Hide();
334 m_pAccountConfirmPasswordCtrl->Hide();
335 m_pAccountPasswordRequirmentsStaticCtrl->Hide();
336
337 if (pWA->IsCookieRequired() && !pWA->IsCredentialsDetected()) {
338 m_pAccountManagerLinkLabelStaticCtrl->Hide();
339 m_pAccountForgotPasswordCtrl->Hide();
340 }
341 } else {
342 m_pCookieDetectionFailedStaticCtrl->Hide();
343 m_pCookieDetectionFailedCtrl->Hide();
344 if (pc.account_creation_disabled || pc.client_account_creation_disabled) {
345 m_pAccountCreateCtrl->SetValue(false);
346 m_pAccountCreateCtrl->Hide();
347 m_pAccountUseExistingCtrl->SetValue(true);
348 m_pAccountUseExistingCtrl->Hide();
349 } else {
350 m_pAccountCreateCtrl->Show();
351 m_pAccountCreateCtrl->Enable();
352 m_pAccountUseExistingCtrl->Show();
353 }
354 m_pAccountManagerLinkLabelStaticCtrl->Hide();
355 }
356
357 wxString str;
358 wxString name = wxString(pc.name.c_str(), wxConvUTF8);
359 str.Printf(_("Identify your account at %s"), name.c_str());
360 m_pTitleStaticCtrl->SetLabel(str);
361
362 if (!IS_ACCOUNTMANAGERWIZARD() && !IS_ACCOUNTMANAGERUPDATEWIZARD()) {
363 if (pc.client_account_creation_disabled) {
364 m_pAccountQuestionStaticCtrl->SetLabel(
365 _("Please enter your account information\n(to create an account, visit the project's web site)")
366 );
367 } else if (pc.account_creation_disabled) {
368 m_pAccountQuestionStaticCtrl->SetLabel(
369 _("This project is not currently accepting new accounts.\nYou can add it only if you already have an account.")
370 );
371 } else {
372 m_pAccountQuestionStaticCtrl->SetLabel(
373 _("Are you already running this project?")
374 );
375 }
376 m_pAccountCreateCtrl->SetLabel(
377 _("&No, new user")
378 );
379 m_pAccountUseExistingCtrl->SetLabel(
380 _("&Yes, existing user")
381 );
382 } else {
383 if (pWA->IsCookieRequired() && !pWA->IsCredentialsDetected()) {
384 m_pCookieDetectionFailedStaticCtrl->SetLabel(
385 _("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.")
386 );
387 m_pCookieDetectionFailedCtrl->SetLabel(
388 _("Find login information")
389 );
390 m_pCookieDetectionFailedCtrl->SetURL(
391 pWA->GetCookieFailureURL()
392 );
393 }
394
395 if (pSkinAdvanced->IsBranded() &&
396 !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
397 m_pAccountInformationStaticCtrl->SetLabel(
398 pSkinWizardATAM->GetAccountInfoMessage()
399 );
400 }
401 }
402
403 if (m_pAccountUseExistingCtrl->GetValue()) {
404 m_pAccountConfirmPasswordStaticCtrl->Hide();
405 m_pAccountConfirmPasswordCtrl->Hide();
406 m_pAccountPasswordRequirmentsStaticCtrl->Hide();
407 m_pAccountPasswordStaticCtrl->SetLabel(
408 _("&Password:")
409 );
410 } else {
411 m_pAccountConfirmPasswordStaticCtrl->Show();
412 m_pAccountConfirmPasswordCtrl->Show();
413 m_pAccountPasswordRequirmentsStaticCtrl->Show();
414 m_pAccountPasswordStaticCtrl->SetLabel(
415 _("Choose a &password:")
416 );
417 m_pAccountConfirmPasswordStaticCtrl->SetLabel(
418 _("C&onfirm password:")
419 );
420 }
421
422 if (!pWA->GetProjectName().IsEmpty()) {
423 wxString strQuestion;
424 strQuestion.Printf(
425 _("Are you already running %s?"),
426 pWA->GetProjectName().c_str()
427 );
428 m_pAccountQuestionStaticCtrl->SetLabel(strQuestion);
429 }
430
431 if (pc.uses_username) {
432 if (IS_ACCOUNTMANAGERWIZARD()) {
433 if (pSkinAdvanced->IsBranded() &&
434 !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
435 m_pAccountInformationStaticCtrl->SetLabel(
436 pSkinWizardATAM->GetAccountInfoMessage()
437 );
438 }
439 }
440
441 m_pAccountEmailAddressCtrl->SetValidator(
442 wxTextValidator(wxFILTER_NONE, &m_strAccountEmailAddress)
443 );
444 m_pAccountUsernameCtrl->SetValidator(
445 wxTextValidator(wxFILTER_ASCII, &m_strAccountUsername)
446 );
447
448 m_pAccountEmailAddressStaticCtrl->Hide();
449 m_pAccountEmailAddressCtrl->Hide();
450 m_pAccountUsernameStaticCtrl->Show();
451 m_pAccountUsernameCtrl->Show();
452
453 m_pAccountUsernameStaticCtrl->SetLabel(
454 _("&Username:")
455 );
456 m_pAccountUsernameCtrl->SetValue(m_strAccountUsername);
457 } else {
458 if (IS_ACCOUNTMANAGERWIZARD()) {
459 if (pSkinAdvanced->IsBranded() &&
460 !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
461 m_pAccountInformationStaticCtrl->SetLabel(
462 pSkinWizardATAM->GetAccountInfoMessage()
463 );
464 }
465 }
466
467 if (!pc.ldap_auth) {
468 m_pAccountEmailAddressCtrl->SetValidator(
469 CValidateEmailAddress(&m_strAccountEmailAddress)
470 );
471 }
472 m_pAccountUsernameCtrl->SetValidator(
473 wxTextValidator(wxFILTER_NONE, &m_strAccountUsername)
474 );
475
476 m_pAccountEmailAddressStaticCtrl->Show();
477 m_pAccountEmailAddressCtrl->Show();
478 m_pAccountUsernameStaticCtrl->Hide();
479 m_pAccountUsernameCtrl->Hide();
480
481 if (pc.ldap_auth) {
482 m_pAccountEmailAddressStaticCtrl->SetLabel(
483 _("&Email address or LDAP ID:")
484 );
485 } else {
486 m_pAccountEmailAddressStaticCtrl->SetLabel(
487 _("&Email address:")
488 );
489 }
490 m_pAccountEmailAddressCtrl->SetValue(m_strAccountEmailAddress);
491 }
492
493 if (pc.min_passwd_length) {
494 wxString str2;
495 str2.Printf(_("minimum length %d"), pc.min_passwd_length);
496 m_pAccountPasswordRequirmentsStaticCtrl->SetLabel( str2 );
497 }
498
499
500 if (!IS_ACCOUNTMANAGERWIZARD()) {
501 m_pAccountForgotPasswordCtrl->SetLabel(
502 _("Forgot your password?")
503 );
504 m_pAccountForgotPasswordCtrl->SetURL(
505 wxString(pWA->GetProjectURL() + _T("get_passwd.php"))
506 );
507 } else {
508 m_pAccountManagerLinkLabelStaticCtrl->SetLabel(
509 _("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." )
510 );
511 m_pAccountForgotPasswordCtrl->SetLabel(
512 _("Account manager web site")
513 );
514 m_pAccountForgotPasswordCtrl->SetURL(
515 wxString(pWA->GetProjectURL())
516 );
517 }
518
519 if (pc.uses_username) {
520 m_pAccountUsernameCtrl->SetFocus();
521 } else {
522 m_pAccountEmailAddressCtrl->SetFocus();
523 }
524
525 Fit();
526 }
527
528 /*!
529 * wxEVT_WIZARD_PAGE_CHANGING event handler for ID_ACCOUNTINFOPAGE
530 */
531
OnPageChanging(wxWizardExEvent & event)532 void CAccountInfoPage::OnPageChanging( wxWizardExEvent& event ) {
533 if (event.GetDirection() == false) return;
534
535 CWizardAttach* pWA = ((CWizardAttach*)GetParent());
536 PROJECT_CONFIG& pc = pWA->project_config;
537 wxString strTitle;
538 wxString strMessage = wxT("");
539 bool bDisplayError = false;
540 wxString strBaseConfigLocation = wxString(wxT("/Wizards"));
541 wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
542
543 if (!CHECK_CLOSINGINPROGRESS()) {
544 // We are leaving this page, so store the email address for future
545 // use.
546 pConfig->SetPath(strBaseConfigLocation);
547 pConfig->Write(wxT("DefaultEmailAddress"), m_strAccountEmailAddress);
548 pConfig->Write(wxT("DefaultUsername"), m_strAccountUsername);
549
550 pConfig->Flush();
551
552 // Construct potiental dialog title
553 if (IS_ATTACHTOPROJECTWIZARD()) {
554 strTitle = _("Add project");
555 } else if (IS_ACCOUNTMANAGERWIZARD() && IS_ACCOUNTMANAGERUPDATEWIZARD()) {
556 strTitle = _("Update account manager");
557 } else if (IS_ACCOUNTMANAGERWIZARD()) {
558 strTitle = _("Use account manager");
559 }
560
561 // Verify minimum username length
562 if (!m_pAccountUseExistingCtrl->GetValue()) {
563 if (!(m_pAccountPasswordCtrl->GetValue().Length() > 0)) {
564 if (pc.uses_username) {
565 strMessage.Printf(_("Please enter a user name."));
566 } else {
567 strMessage.Printf(_("Please enter an email address."));
568 }
569 bDisplayError = true;
570 }
571 }
572
573 // Verify minimum password length
574 if (!m_pAccountUseExistingCtrl->GetValue()) {
575 if (m_pAccountPasswordCtrl->GetValue().Length() < (size_t)pc.min_passwd_length) {
576 strMessage.Printf(
577 _("Please enter a password of at least %d characters."),
578 pc.min_passwd_length
579 );
580 bDisplayError = true;
581 }
582 }
583
584 // Verify that the password and confirmation password math.
585 if (!IS_ACCOUNTMANAGERWIZARD() && m_pAccountCreateCtrl->GetValue()) {
586 if (m_pAccountPasswordCtrl->GetValue() != m_pAccountConfirmPasswordCtrl->GetValue()) {
587 strMessage = _("The password and confirmation password do not match. Please type them again.");
588 bDisplayError = true;
589 }
590 }
591
592 if (bDisplayError) {
593
594 wxGetApp().SafeMessageBox(
595 strMessage,
596 strTitle,
597 wxICON_ERROR | wxOK,
598 this
599 );
600 event.Veto();
601
602 } else {
603
604 // Update authoritative data in CWizardAttach
605 pWA->SetAccountEmailAddress(m_strAccountEmailAddress);
606 pWA->SetAccountUsername(m_strAccountUsername);
607 pWA->SetAccountPassword(m_pAccountPasswordCtrl->GetValue());
608
609 }
610 }
611 }
612
613 /*!
614 * wxEVT_WIZARD_CANCEL event handler for ID_ACCOUNTINFOPAGE
615 */
616
OnCancel(wxWizardExEvent & event)617 void CAccountInfoPage::OnCancel( wxWizardExEvent& event ) {
618 PROCESS_CANCELEVENT(event);
619 }
620
621 /*!
622 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ACCOUNTUSEXISTINGBUTTON
623 */
624
OnAccountUseExistingCtrlSelected(wxCommandEvent & WXUNUSED (event))625 void CAccountInfoPage::OnAccountUseExistingCtrlSelected( wxCommandEvent& WXUNUSED(event) ) {
626 CWizardAttach* pWA = ((CWizardAttach*)GetParent());
627 PROJECT_CONFIG& pc = pWA->project_config;
628
629 m_pAccountPasswordStaticCtrl->SetLabel(
630 _("&Password:")
631 );
632 m_pAccountConfirmPasswordStaticCtrl->Hide();
633 m_pAccountConfirmPasswordCtrl->Hide();
634 m_pAccountPasswordRequirmentsStaticCtrl->Hide();
635
636 if (pc.uses_username) {
637 m_pAccountUsernameCtrl->SetFocus();
638 } else {
639 m_pAccountEmailAddressCtrl->SetFocus();
640 }
641
642 Fit();
643 }
644
645 /*!
646 * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ACCOUNTCREATEBUTTON
647 */
648
OnAccountCreateCtrlSelected(wxCommandEvent & WXUNUSED (event))649 void CAccountInfoPage::OnAccountCreateCtrlSelected( wxCommandEvent& WXUNUSED(event) ) {
650 CWizardAttach* pWA = ((CWizardAttach*)GetParent());
651 PROJECT_CONFIG& pc = pWA->project_config;
652
653 m_pAccountPasswordStaticCtrl->SetLabel(
654 _("Choose a &password:")
655 );
656 m_pAccountConfirmPasswordStaticCtrl->Show();
657 m_pAccountConfirmPasswordCtrl->Show();
658 m_pAccountPasswordRequirmentsStaticCtrl->Show();
659
660 if (pc.uses_username) {
661 m_pAccountUsernameCtrl->SetFocus();
662 } else {
663 m_pAccountEmailAddressCtrl->SetFocus();
664 }
665
666 Fit();
667 }
668
669