VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/VBoxRegistrationDlg.cpp@ 24687

Last change on this file since 24687 was 24687, checked in by vboxsync, 15 years ago

FE/Qt4: Registration Dialog: Country list updated to current SUNs list for 2009/11/16.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 23.1 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt4 GUI ("VirtualBox"):
4 * VBoxRegistrationDlg class implementation
5 */
6
7/*
8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#include "QIHttp.h"
24#include "VBoxGlobal.h"
25#include "VBoxProblemReporter.h"
26#include "VBoxRegistrationDlg.h"
27
28/* Qt includes */
29#include <QTimer>
30
31/**
32 * This class is used to encode/decode the registration data.
33 */
34class VBoxRegistrationData
35{
36public:
37
38 VBoxRegistrationData (const QString &aString, bool aEncode)
39 : mIsValid (aEncode), mIsRegistered (aEncode)
40 , mTriesLeft (3 /* the initial tries value */)
41 {
42 aEncode ? encode (aString) : decode (aString);
43 }
44
45 bool isValid() const { return mIsValid; }
46 bool isRegistered() const { return mIsRegistered; }
47
48 const QString &data() const { return mData; }
49 const QString &account() const { return mAccount; }
50
51 uint triesLeft() const { return mTriesLeft; }
52
53private:
54
55 void decode (const QString &aData)
56 {
57 if (aData.isEmpty())
58 return;
59
60 mData = aData;
61
62 /* Decoding number of left tries */
63 if (mData.startsWith ("triesLeft="))
64 {
65 bool ok = false;
66 uint triesLeft = mData.section ('=', 1, 1).toUInt (&ok);
67 if (!ok)
68 return;
69 mTriesLeft = triesLeft;
70 mIsValid = true;
71 return;
72 }
73
74 /* Decoding CRC32 */
75 QString data = mData;
76 QString crcData = data.right (2 * sizeof (ulong));
77 ulong crcNeed = 0;
78 for (long i = 0; i < crcData.length(); i += 2)
79 {
80 crcNeed <<= 8;
81 uchar curByte = (uchar) crcData.mid (i, 2).toUShort (0, 16);
82 crcNeed += curByte;
83 }
84 data.truncate (data.length() - 2 * sizeof (ulong));
85
86 /* Decoding data */
87 QString result;
88 for (long i = 0; i < data.length(); i += 4)
89 result += QChar (data.mid (i, 4).toUShort (0, 16));
90 ulong crcNow = crc32 ((uchar*)result.toAscii().constData(), result.length());
91
92 /* Check the CRC32 */
93 if (crcNeed != crcNow)
94 return;
95
96 /* Split values list */
97 QStringList list (result.split ("|"));
98
99 /* Ignore the old format */
100 if (list.size() > 1)
101 return;
102
103 /* Result value */
104 mIsValid = true;
105 mIsRegistered = true;
106 mAccount = list [0];
107 }
108
109 void encode (const QString &aAccount)
110 {
111 if (aAccount.isEmpty())
112 return;
113
114 mAccount = aAccount;
115
116 /* Encoding data */
117 QString data = QString ("%1").arg (mAccount);
118 mData = QString::null;
119 for (long i = 0; i < data.length(); ++ i)
120 {
121 QString curPair = QString::number (data.at (i).unicode(), 16);
122 while (curPair.length() < 4)
123 curPair.prepend ('0');
124 mData += curPair;
125 }
126
127 /* Enconding CRC32 */
128 ulong crcNow = crc32 ((uchar*)data.toAscii().constData(), data.length());
129 QString crcData;
130 for (ulong i = 0; i < sizeof (ulong); ++ i)
131 {
132 ushort curByte = crcNow & 0xFF;
133 QString curPair = QString::number (curByte, 16);
134 if (curPair.length() == 1)
135 curPair.prepend ("0");
136 crcData = curPair + crcData;
137 crcNow >>= 8;
138 }
139
140 mData += crcData;
141 }
142
143 ulong crc32 (unsigned char *aBufer, int aSize)
144 {
145 /* Filling CRC32 table */
146 ulong crc32;
147 ulong crc_table [256];
148 ulong temp;
149 for (int i = 0; i < 256; ++ i)
150 {
151 temp = i;
152 for (int j = 8; j > 0; -- j)
153 {
154 if (temp & 1)
155 temp = (temp >> 1) ^ 0xedb88320;
156 else
157 temp >>= 1;
158 };
159 crc_table [i] = temp;
160 }
161
162 /* CRC32 calculation */
163 crc32 = 0xffffffff;
164 for (int i = 0; i < aSize; ++ i)
165 {
166 crc32 = crc_table [(crc32 ^ (*aBufer ++)) & 0xff] ^ (crc32 >> 8);
167 }
168 crc32 = crc32 ^ 0xffffffff;
169 return crc32;
170 };
171
172 bool mIsValid : 1;
173 bool mIsRegistered : 1;
174
175 uint mTriesLeft;
176
177 QString mAccount;
178 QString mData;
179};
180
181/* Static member to check if registration dialog necessary. */
182bool VBoxRegistrationDlg::hasToBeShown()
183{
184 VBoxRegistrationData data (vboxGlobal().virtualBox().
185 GetExtraData (VBoxDefs::GUI_RegistrationData), false);
186
187 return (!data.isValid()) ||
188 (!data.isRegistered() && data.triesLeft() > 0);
189}
190
191VBoxRegistrationDlg::VBoxRegistrationDlg (VBoxRegistrationDlg **aSelf, QWidget * /* aParent */)
192 : QIWithRetranslateUI <QIAbstractWizard> (0)
193 , mSelf (aSelf)
194 , mWvalReg (0)
195 , mUrl ("http://registration.virtualbox.org/register763.php")
196 , mHttp (new QIHttp (this, mUrl.host()))
197{
198 /* Store external pointer to this dialog */
199 *mSelf = this;
200
201 /* Apply UI decorations */
202 Ui::VBoxRegistrationDlg::setupUi (this);
203
204 /* Apply window icons */
205 setWindowIcon (vboxGlobal().iconSetFull (QSize (32, 32), QSize (16, 16),
206 ":/register_32px.png", ":/register_16px.png"));
207
208 /* Setup widgets */
209 QSizePolicy sp (mTextRegInfo->sizePolicy());
210 sp.setHeightForWidth (true);
211 mTextRegInfo->setSizePolicy (sp);
212
213 /* Initialize wizard hdr */
214 initializeWizardHdr();
215
216 /* Setup validations for line-edit fields */
217 QRegExp nameExp ("[\\S\\s]+");
218 /* E-mail address is validated according to RFC2821, RFC2822,
219 * see http://en.wikipedia.org/wiki/E-mail_address */
220 QRegExp emailExp ("(([a-zA-Z0-9_\\-\\.!#$%\\*/?|^{}`~&'\\+=]*"
221 "[a-zA-Z0-9_\\-!#$%\\*/?|^{}`~&'\\+=])|"
222 "(\"([\\x0001-\\x0008,\\x000B,\\x000C,\\x000E-\\x0019,\\x007F,"
223 "\\x0021,\\x0023-\\x005B,\\x005D-\\x007E,"
224 "\\x0009,\\x0020]|"
225 "(\\\\[\\x0001-\\x0009,\\x000B,\\x000C,"
226 "\\x000E-\\x007F]))*\"))"
227 "@"
228 "[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*");
229 QRegExp passwordExp ("[a-zA-Z0-9_\\-\\+=`~!@#$%^&\\*\\(\\)?\\[\\]:;,\\./]+");
230
231 mLeOldEmail->setMaxLength (50);
232 /* New accounts *must* have a valid email as user name. Thats not the case
233 * for old existing accounts. So we don't force the email format, so that
234 * old accounts could be used for registration also. */
235 mLeOldEmail->setValidator (new QRegExpValidator (nameExp, this));
236
237 mLeOldPassword->setMaxLength (20);
238 mLeOldPassword->setValidator (new QRegExpValidator (passwordExp, this));
239
240 mLeNewFirstName->setMaxLength (50);
241 mLeNewFirstName->setValidator (new QRegExpValidator (nameExp, this));
242
243 mLeNewLastName->setMaxLength (50);
244 mLeNewLastName->setValidator (new QRegExpValidator (nameExp, this));
245
246 mLeNewCompany->setMaxLength (50);
247 mLeNewCompany->setValidator (new QRegExpValidator (nameExp, this));
248
249 mLeNewEmail->setMaxLength (50);
250 mLeNewEmail->setValidator (new QRegExpValidator (emailExp, this));
251
252 mLeNewPassword->setMaxLength (20);
253 mLeNewPassword->setValidator (new QRegExpValidator (passwordExp, this));
254
255 mLeNewPassword2->setMaxLength (20);
256 mLeNewPassword2->setValidator (new QRegExpValidator (passwordExp, this));
257
258 populateCountries();
259
260 /* Setup validation */
261 mWvalReg = new QIWidgetValidator (mPageReg, this);
262 connect (mWvalReg, SIGNAL (validityChanged (const QIWidgetValidator *)),
263 this, SLOT (enableNext (const QIWidgetValidator *)));
264 connect (mWvalReg, SIGNAL (isValidRequested (QIWidgetValidator *)),
265 this, SLOT (revalidate (QIWidgetValidator *)));
266
267 connect (mRbOld, SIGNAL (toggled (bool)), this, SLOT (radioButtonToggled()));
268 connect (mRbNew, SIGNAL (toggled (bool)), this, SLOT (radioButtonToggled()));
269 connect (mCbNewCountry, SIGNAL (currentIndexChanged (int)), mWvalReg, SLOT (revalidate()));
270
271 /* Setup other connections */
272 connect (vboxGlobal().mainWindow(), SIGNAL (closing()), this, SLOT (reject()));
273
274 /* Setup initial dialog parameters. */
275 VBoxRegistrationData data (vboxGlobal().virtualBox().
276 GetExtraData (VBoxDefs::GUI_RegistrationData), false);
277 mLeOldEmail->setText (data.account());
278
279 radioButtonToggled();
280
281 /* Initialize wizard hdr */
282 initializeWizardFtr();
283
284 retranslateUi();
285
286 /* Fix minimum possible size */
287 resize (minimumSizeHint());
288 qApp->processEvents();
289 setFixedSize (size());
290}
291
292VBoxRegistrationDlg::~VBoxRegistrationDlg()
293{
294 /* Erase dialog handle in config file. */
295 vboxGlobal().virtualBox().SetExtraData (VBoxDefs::GUI_RegistrationDlgWinID,
296 QString::null);
297
298 /* Erase external pointer to this dialog. */
299 *mSelf = 0;
300}
301
302void VBoxRegistrationDlg::retranslateUi()
303{
304 /* Translate uic generated strings */
305 Ui::VBoxRegistrationDlg::retranslateUi (this);
306
307 /* Translate the first element of countries list */
308 mCbNewCountry->setItemText (0, tr ("Select Country/Territory"));
309}
310
311void VBoxRegistrationDlg::radioButtonToggled()
312{
313 QRadioButton *current = mRbOld->isChecked() ? mRbOld : mRbNew;
314
315 mLeOldEmail->setEnabled (current == mRbOld);
316 mLeOldPassword->setEnabled (current == mRbOld);
317 mLeNewFirstName->setEnabled (current == mRbNew);
318 mLeNewLastName->setEnabled (current == mRbNew);
319 mLeNewCompany->setEnabled (current == mRbNew);
320 mCbNewCountry->setEnabled (current == mRbNew);
321 mLeNewEmail->setEnabled (current == mRbNew);
322 mLeNewPassword->setEnabled (current == mRbNew);
323 mLeNewPassword2->setEnabled (current == mRbNew);
324
325 mWvalReg->revalidate();
326}
327
328/* Post the handshake request into the register site. */
329void VBoxRegistrationDlg::accept()
330{
331 /* Disable control elements */
332 mLeOldEmail->setEnabled (false);
333 mLeOldPassword->setEnabled (false);
334 mLeNewFirstName->setEnabled (false);
335 mLeNewLastName->setEnabled (false);
336 mLeNewCompany->setEnabled (false);
337 mCbNewCountry->setEnabled (false);
338 mLeNewEmail->setEnabled (false);
339 mLeNewPassword->setEnabled (false);
340 mLeNewPassword2->setEnabled (false);
341 finishButton()->setEnabled (false);
342 cancelButton()->setEnabled (false);
343
344 /* Set busy cursor */
345 setCursor (QCursor (Qt::BusyCursor));
346
347 /* Perform connection handshake */
348 QTimer::singleShot (0, this, SLOT (handshakeStart()));
349}
350
351void VBoxRegistrationDlg::reject()
352{
353 /* Decrement the triesLeft. */
354 VBoxRegistrationData data (vboxGlobal().virtualBox().
355 GetExtraData (VBoxDefs::GUI_RegistrationData), false);
356 if (!data.isValid() || !data.isRegistered())
357 {
358 uint triesLeft = data.triesLeft();
359 if (triesLeft)
360 {
361 -- triesLeft;
362 vboxGlobal().virtualBox().SetExtraData (VBoxDefs::GUI_RegistrationData,
363 QString ("triesLeft=%1")
364 .arg (triesLeft));
365 }
366 }
367
368 QIAbstractWizard::reject();
369}
370
371void VBoxRegistrationDlg::reinit()
372{
373 /* Read all the dirty data */
374 mHttp->disconnect (this);
375 mHttp->readAll();
376
377 /* Enable control elements */
378 radioButtonToggled();
379 finishButton()->setEnabled (true);
380 cancelButton()->setEnabled (true);
381
382 /* Return 'default' attribute loosed
383 * when button was disabled... */
384 finishButton()->setDefault (true);
385 finishButton()->setFocus();
386
387 /* Unset busy cursor */
388 unsetCursor();
389}
390
391void VBoxRegistrationDlg::handshakeStart()
392{
393 /* Compose query */
394 QUrl url (mUrl);
395 url.addQueryItem ("version", vboxGlobal().virtualBox().GetVersion());
396
397 /* Handshake */
398 connect (mHttp, SIGNAL (allIsDone (bool)), this, SLOT (handshakeResponse (bool)));
399 mHttp->post (url.toEncoded());
400}
401
402void VBoxRegistrationDlg::handshakeResponse (bool aError)
403{
404 /* Block all the other incoming signals */
405 mHttp->disconnect (this);
406
407 /* Process error if present */
408 if (aError)
409 return abortRequest (mHttp->errorString());
410
411 /* Read received data */
412 mKey = mHttp->readAll();
413
414 /* Verifying key correctness */
415 if (QString (mKey).indexOf (QRegExp ("^[a-zA-Z0-9]{32}$")))
416 return abortRequest (tr ("Could not perform connection handshake."));
417
418 /* Perform registration */
419 QTimer::singleShot (0, this, SLOT (registrationStart()));
420}
421
422void VBoxRegistrationDlg::registrationStart()
423{
424 /* Compose query */
425 QUrl url (mUrl);
426
427 /* Basic set */
428 url.addQueryItem ("version", vboxGlobal().virtualBox().GetVersion());
429 url.addQueryItem ("key", mKey);
430 url.addQueryItem ("platform", vboxGlobal().platformInfo());
431
432 if (mRbOld->isChecked())
433 {
434 /* Light set */
435 url.addQueryItem ("email", mLeOldEmail->text());
436 url.addQueryItem ("password", mLeOldPassword->text());
437 }
438 else if (mRbNew->isChecked())
439 {
440 /* Full set */
441 url.addQueryItem ("email", mLeNewEmail->text());
442 url.addQueryItem ("password", mLeNewPassword->text());
443 url.addQueryItem ("firstname", mLeNewFirstName->text());
444 url.addQueryItem ("lastname", mLeNewLastName->text());
445 url.addQueryItem ("company", mLeNewCompany->text());
446 url.addQueryItem ("country", mCbNewCountry->currentText());
447 }
448
449 /* Registration */
450 connect (mHttp, SIGNAL (allIsDone (bool)), this, SLOT (registrationResponse (bool)));
451 mHttp->post (url.toEncoded());
452}
453
454void VBoxRegistrationDlg::registrationResponse (bool aError)
455{
456 /* Block all the other incoming signals */
457 mHttp->disconnect (this);
458
459 /* Process error if present */
460 if (aError)
461 return abortRequest (mHttp->errorString());
462
463 /* Read received data */
464 QString data (mHttp->readAll());
465
466 /* Show registration result */
467 vboxProblem().showRegisterResult (this, data);
468
469 /* Close the dialog */
470 data == "OK" ? finish() : reinit();
471}
472
473void VBoxRegistrationDlg::revalidate (QIWidgetValidator *aWval)
474{
475 bool valid = true;
476
477 if (mRbOld->isChecked())
478 {
479 /* Check for fields correctness */
480 if (!isFieldValid (mLeOldEmail) || !isFieldValid (mLeOldPassword))
481 valid = false;
482 }
483 if (mRbNew->isChecked())
484 {
485 /* Check for fields correctness */
486 if (!isFieldValid (mLeNewFirstName) || !isFieldValid (mLeNewLastName) ||
487 !isFieldValid (mLeNewCompany) || !isFieldValid (mCbNewCountry) ||
488 !isFieldValid (mLeNewEmail) ||
489 !isFieldValid (mLeNewPassword) || !isFieldValid (mLeNewPassword2))
490 valid = false;
491
492 /* Check for password correctness */
493 if (mLeNewPassword->text() != mLeNewPassword2->text())
494 valid = false;
495 }
496
497 aWval->setOtherValid (valid);
498}
499
500void VBoxRegistrationDlg::enableNext (const QIWidgetValidator *aWval)
501{
502 /* Validate all the subscribed widgets */
503 aWval->isValid();
504 /* But control dialog only with necessary */
505 finishButton()->setEnabled (aWval->isOtherValid());
506 /* Return 'default' attribute loosed
507 * when button was disabled... */
508 finishButton()->setDefault (true);
509}
510
511void VBoxRegistrationDlg::onPageShow()
512{
513 Assert (mPageStack->currentWidget() == mPageReg);
514 mLeOldEmail->setFocus();
515}
516
517void VBoxRegistrationDlg::populateCountries()
518{
519 QStringList list ("Empty");
520 list << "Afghanistan"
521 << "Albania"
522 << "Algeria"
523 << "American Samoa"
524 << "Andorra"
525 << "Angola"
526 << "Anguilla"
527 << "Antartica"
528 << "Antigua & Barbuda"
529 << "Argentina"
530 << "Armenia"
531 << "Aruba"
532 << "Ascension Island"
533 << "Australia"
534 << "Austria"
535 << "Azerbaijan"
536 << "Bahamas"
537 << "Bahrain"
538 << "Bangladesh"
539 << "Barbados"
540 << "Belarus"
541 << "Belgium"
542 << "Belize"
543 << "Benin"
544 << "Bermuda"
545 << "Bhutan"
546 << "Bolivia"
547 << "Bosnia and Herzegovina"
548 << "Botswana"
549 << "Bouvet Island"
550 << "Brazil"
551 << "British Indian Ocean Territory"
552 << "Brunei Darussalam"
553 << "Bulgaria"
554 << "Burkina Faso"
555 << "Burundi"
556 << "Cambodia"
557 << "Cameroon"
558 << "Canada"
559 << "Cape Verde"
560 << "Cayman Islands"
561 << "Central African Republic"
562 << "Chad"
563 << "Chile"
564 << "China"
565 << "Christmas Island"
566 << "Cocos (Keeling) Islands"
567 << "Colombia"
568 << "Comoros"
569 << "Congo, Democratic People's Republic"
570 << "Congo, Republic of"
571 << "Cook Islands"
572 << "Costa Rica"
573 << "Cote d'Ivoire"
574 << "Croatia/Hrvatska"
575 << "Cyprus"
576 << "Czech Republic"
577 << "Denmark"
578 << "Djibouti"
579 << "Dominica"
580 << "Dominican Republic"
581 << "East Timor"
582 << "Ecuador"
583 << "Egypt"
584 << "El Salvador"
585 << "Equatorial Guinea"
586 << "Eritrea"
587 << "Estonia"
588 << "Ethiopia"
589 << "Falkland Islands (Malvina)"
590 << "Faroe Islands"
591 << "Fiji"
592 << "Finland"
593 << "France"
594 << "French Guiana"
595 << "French Polynesia"
596 << "French Southern Territories"
597 << "Gabon"
598 << "Gambia"
599 << "Georgia"
600 << "Germany"
601 << "Ghana"
602 << "Gibraltar"
603 << "Greece"
604 << "Greenland"
605 << "Grenada"
606 << "Guadeloupe"
607 << "Guam"
608 << "Guatemala"
609 << "Guernsey"
610 << "Guinea"
611 << "Guinea-Bissau"
612 << "Guyana"
613 << "Haiti"
614 << "Heard and McDonald Islands"
615 << "Holy See (City Vatican State)"
616 << "Honduras"
617 << "Hong Kong"
618 << "Hungary"
619 << "Iceland"
620 << "India"
621 << "Indonesia"
622 << "Iraq"
623 << "Ireland"
624 << "Isle of Man"
625 << "Israel"
626 << "Italy"
627 << "Jamaica"
628 << "Japan"
629 << "Jersey"
630 << "Jordan"
631 << "Kazakhstan"
632 << "Kenya"
633 << "Kiribati"
634 << "Korea, Republic of"
635 << "Kuwait"
636 << "Kyrgyzstan"
637 << "Lao People's Democratic Republic"
638 << "Latvia"
639 << "Lebanon"
640 << "Lesotho"
641 << "Liberia"
642 << "Libyan Arab Jamahiriya"
643 << "Liechtenstein"
644 << "Lithuania"
645 << "Luxembourg"
646 << "Macau"
647 << "Macedonia, Former Yugoslav Republic"
648 << "Madagascar"
649 << "Malawi"
650 << "Malaysia"
651 << "Maldives"
652 << "Mali"
653 << "Malta"
654 << "Marshall Islands"
655 << "Martinique"
656 << "Mauritania"
657 << "Mauritius"
658 << "Mayotte"
659 << "Mexico"
660 << "Micronesia, Federal State of"
661 << "Moldova, Republic of"
662 << "Monaco"
663 << "Mongolia"
664 << "Montenegro"
665 << "Montserrat"
666 << "Morocco"
667 << "Mozambique"
668 << "Namibia"
669 << "Nauru"
670 << "Nepal"
671 << "Netherlands"
672 << "Netherlands Antilles"
673 << "New Caledonia"
674 << "New Zealand"
675 << "Nicaragua"
676 << "Niger"
677 << "Nigeria"
678 << "Niue"
679 << "Norfolk Island"
680 << "Northern Mariana Island"
681 << "Norway"
682 << "Oman"
683 << "Pakistan"
684 << "Palau"
685 << "Panama"
686 << "Papua New Guinea"
687 << "Paraguay"
688 << "Peru"
689 << "Philippines"
690 << "Pitcairn Island"
691 << "Poland"
692 << "Portugal"
693 << "Puerto Rico"
694 << "Qatar"
695 << "Reunion Island"
696 << "Romania"
697 << "Russian Federation"
698 << "Rwanda"
699 << "Saint Kitts and Nevis"
700 << "Saint Lucia"
701 << "Saint Vincent and the Grenadines"
702 << "San Marino"
703 << "Sao Tome & Principe"
704 << "Saudi Arabia"
705 << "Senegal"
706 << "Serbia"
707 << "Seychelles"
708 << "Sierra Leone"
709 << "Singapore"
710 << "Slovak Republic"
711 << "Slovenia"
712 << "Solomon Islands"
713 << "Somalia"
714 << "South Africa"
715 << "South Georgia and the South Sandwich Islands"
716 << "Spain"
717 << "Sri Lanka"
718 << "St Pierre and Miquelon"
719 << "St. Helena"
720 << "Suriname"
721 << "Svalbard And Jan Mayen Island"
722 << "Swaziland"
723 << "Sweden"
724 << "Switzerland"
725 << "Taiwan"
726 << "Tajikistan"
727 << "Tanzania"
728 << "Thailand"
729 << "Togo"
730 << "Tokelau"
731 << "Tonga"
732 << "Trinidad and Tobago"
733 << "Tunisia"
734 << "Turkey"
735 << "Turkmenistan"
736 << "Turks and Ciacos Islands"
737 << "Tuvalu"
738 << "US Minor Outlying Islands"
739 << "Uganda"
740 << "Ukraine"
741 << "United Arab Emirates"
742 << "United Kingdom"
743 << "United States"
744 << "Uruguay"
745 << "Uzbekistan"
746 << "Vanuatu"
747 << "Venezuela"
748 << "Vietnam"
749 << "Virgin Island (British)"
750 << "Virgin Islands (USA)"
751 << "Wallis And Futuna Islands"
752 << "Western Sahara"
753 << "Western Samoa"
754 << "Yemen"
755 << "Zambia"
756 << "Zimbabwe";
757 mCbNewCountry->addItems (list);
758}
759
760/* This wrapper displays an error message box (unless aReason is QString::null)
761 * with the cause of the request-send procedure termination. After the message
762 * box dismissed, the registration dialog signals to close itself on the next
763 * event loop iteration. */
764void VBoxRegistrationDlg::abortRequest (const QString &aReason)
765{
766 if (!aReason.isNull())
767 vboxProblem().cannotConnectRegister (this, mUrl.toString(), aReason);
768
769 /* Allows all the queued signals to be processed before quit. */
770 QTimer::singleShot (0, this, SLOT (reinit()));
771}
772
773void VBoxRegistrationDlg::finish()
774{
775 QString acc (mRbOld->isChecked() ? mLeOldEmail->text() :
776 mRbNew->isChecked() ? mLeNewEmail->text() : QString::null);
777
778 VBoxRegistrationData data (acc, true);
779 vboxGlobal().virtualBox().SetExtraData (VBoxDefs::GUI_RegistrationData,
780 data.data());
781
782 QIAbstractWizard::accept();
783}
784
785bool VBoxRegistrationDlg::isFieldValid (QWidget *aWidget) const
786{
787 if (QLineEdit *le = qobject_cast <QLineEdit*> (aWidget))
788 {
789 QString text (le->text());
790 int position;
791 return le->validator()->validate (text, position) == QValidator::Acceptable;
792 }
793 else if (QComboBox *cb = qobject_cast <QComboBox*> (aWidget))
794 {
795 return cb->currentIndex() > 0;
796 }
797 return false;
798}
799
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette