UIRegistrationWzd.cpp revision 05c5026f0db24362b610bf7c6749e91daa870fb3
/* $Id$ */
/** @file
*
* VBox frontends: Qt4 GUI ("VirtualBox"):
* UIRegistrationWzd class implementation
*/
/*
* Copyright (C) 2008-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/* Global includes */
#include <QTimer>
#include <QUrl>
/* Local includes */
#include "UIRegistrationWzd.h"
#include "VBoxGlobal.h"
#include "VBoxProblemReporter.h"
#include "QIHttp.h"
/**
*/
class RegistrationData
{
public:
{
}
bool isRegistered() const { return m_bRegistered; }
private:
{
return;
/* Decoding number of left tries */
{
bool ok = false;
if (!ok)
return;
m_bValid = true;
return;
}
/* Decoding CRC32 */
{
uCrcNeed <<= 8;
}
/* Decoding data */
/* Check the CRC32 */
return;
/* Split values list */
/* Ignore the old format */
return;
/* Result value */
m_bValid = true;
m_bRegistered = true;
m_strAccount = list[0];
}
{
if (strAccount.isEmpty())
return;
/* Encoding data */
{
m_strData += strCurPair;
}
/* Enconding CRC32 */
{
uCrcNow >>= 8;
}
m_strData += strCrcData;
}
{
/* Filling CRC32 table */
for (int i = 0; i < 256; ++ i)
{
uTemp = i;
for (int j = 8; j > 0; -- j)
{
if (uTemp & 1)
else
uTemp >>= 1;
};
}
/* CRC32 calculation */
uCrc32 = 0xffffffff;
for (int i = 0; i < iSize; ++ i)
{
}
return uCrc32;
};
bool m_bValid : 1;
bool m_bRegistered : 1;
};
/**
* This class is used to perform the registration actions.
*/
class RegistrationEngine : public QEventLoop
{
public:
{
/* Registration address */
/* HTTP Engine */
/* Initial values */
m_bPresent = false;
m_bResult = false;
}
{
/* Case for present account */
resetFields();
m_bPresent = true;
}
{
/* Case for account creation */
resetFields();
m_bPresent = false;
}
int start()
{
/* Request handshake */
}
bool result() const
{
return m_bResult;
}
private slots:
void sltHandshakeStart()
{
/* Compose query */
/* Handshake */
}
void sltHandshakeResponse(bool bError)
{
/* Block all the other incoming signals */
m_pHttp->disconnect(this);
/* Process error if present */
if (bError)
/* Read received key */
/* Verifying key correctness */
/* Request registration */
}
void sltRegistrationStart()
{
/* Compose query */
/* Basic set */
if (m_bPresent)
{
/* Set for present account */
}
else
{
/* Set for account creation */
}
/* Registration */
}
void sltRegistrationResponse(bool bError)
{
/* Block all the other incoming signals */
m_pHttp->disconnect(this);
/* Process error if present */
if (bError)
/* Read received result */
/* Show registration result */
/* Set result */
/* Allows all the queued events to be processed before leaving loop */
}
private:
void resetFields()
{
m_bResult = false;
m_bPresent = false;
m_strVersion = QString();
m_strPlatform = QString();
m_strOldEmail = QString();
m_strOldPassword = QString();
m_strNewEmail = QString();
m_strNewPassword = QString();
m_strNewFirstName = QString();
m_strNewLastName = QString();
m_strNewCompany = QString();
m_strNewCountry = QString();
}
{
/* Show reason if present */
/* Result = FAILED */
m_bResult = false;
/* Allows all the queued events to be processed before leaving loop */
}
bool m_bResult;
bool m_bPresent;
};
/* Check if registration dialog necessary */
bool UIRegistrationWzd::hasToBeShown()
{
RegistrationData data(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RegistrationData), false);
}
: QIWizard(0)
{
/* Store external pointer to this dialog */
*m_ppThis = this;
/* Apply window icons */
":/register_32px.png", ":/register_16px.png"));
/* Create & add page */
/* Initial translate */
/* Initial translate all pages */
/* Resize to 'golden ratio' */
#ifdef Q_WS_MAC
/* Assign background image */
assignBackground(":/vmw_new_user_bg.png");
#else /* Q_WS_MAC */
/* Assign watermark */
assignWatermark(":/vmw_new_user.png");
#endif /* Q_WS_MAC */
/* Setup 'closing' connection if main window is VBoxSelectorWnd: */
}
{
/* Erase dialog handle in config file */
/* Erase external pointer to this dialog */
*m_ppThis = 0;
}
void UIRegistrationWzd::retranslateUi()
{
/* Wizard title */
}
void UIRegistrationWzd::reject()
{
/* Decrement the triesLeft */
RegistrationData data(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RegistrationData), false);
{
if (cTriesLeft)
{
-- cTriesLeft;
vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_RegistrationData, QString("triesLeft=%1").arg(cTriesLeft));
}
}
/* And close the dialog */
}
{
/* Decorate page */
/* Setup fields validations */
/* E-mail address is validated according to RFC2821, RFC2822,
"[a-zA-Z0-9_\\-!#$%\\*/?|^{}`~&'\\+=])|"
"(\"([\\x0001-\\x0008,\\x000B,\\x000C,\\x000E-\\x0019,\\x007F,"
"\\x0021,\\x0023-\\x005B,\\x005D-\\x007E,"
"\\x0009,\\x0020]|"
"(\\\\[\\x0001-\\x0009,\\x000B,\\x000C,"
"\\x000E-\\x007F]))*\"))"
"@"
"[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*");
/* New accounts *must* have a valid email as user name. This not the case
* for old existing accounts. So we don't force the email format, so that
* old accounts could be used for registration also. */
/* Populate countries list */
/* Setup connections */
connect(m_pLeNewConfirmPassword, SIGNAL(textEdited(const QString &)), this, SIGNAL(completeChanged()));
/* Initial values */
m_pRbPresent->click();
RegistrationData data(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RegistrationData), false);
/* Fill and translate */
}
void UIRegistrationWzdPage1::retranslateUi()
{
/* Translate uic generated strings */
/* Wizard page 1 title */
/* Translate the first element of countries list */
}
bool UIRegistrationWzdPage1::isComplete() const
{
if (m_pRbPresent->isChecked())
{
/* Check for fields correctness */
return false;
}
if (m_pRbCreate->isChecked())
{
/* Check for fields correctness */
!isFieldValid (m_pLeNewEmail) ||
return false;
/* Check for password correctness */
return false;
}
return true;
}
bool UIRegistrationWzdPage1::validatePage()
{
/* Create registration engine */
RegistrationEngine engine(this);
/* Initialize registration engine */
if (m_pRbPresent->isChecked())
{
}
if (m_pRbCreate->isChecked())
{
}
/* Disable wizard */
wizard()->setEnabled(false);
/* Set busy cursor */
/* Perform registration routine */
/* Restore cursor */
unsetCursor();
/* Enable wizard */
wizard()->setEnabled(true);
/* Save accepted account name */
{
/* Store registration data */
}
}
{
}
{
list << "Afghanistan"
<< "Albania"
<< "Algeria"
<< "American Samoa"
<< "Andorra"
<< "Angola"
<< "Anguilla"
<< "Antarctica"
<< "Antigua & Barbuda"
<< "Argentina"
<< "Armenia"
<< "Aruba"
<< "Ascension Island"
<< "Australia"
<< "Austria"
<< "Azerbaijan"
<< "Bahamas"
<< "Bahrain"
<< "Bangladesh"
<< "Barbados"
<< "Belarus"
<< "Belgium"
<< "Belize"
<< "Benin"
<< "Bermuda"
<< "Bhutan"
<< "Bolivia"
<< "Bosnia and Herzegovina"
<< "Botswana"
<< "Bouvet Island"
<< "Brazil"
<< "British Indian Ocean Territory"
<< "Brunei Darussalam"
<< "Bulgaria"
<< "Burkina Faso"
<< "Burundi"
<< "Cambodia"
<< "Cameroon"
<< "Canada"
<< "Cape Verde"
<< "Cayman Islands"
<< "Central African Republic"
<< "Chad"
<< "Chile"
<< "China"
<< "Christmas Island"
<< "Cocos (Keeling) Islands"
<< "Colombia"
<< "Comoros"
<< "Congo, Democratic People's Republic"
<< "Congo, Republic of"
<< "Cook Islands"
<< "Costa Rica"
<< "Cote d'Ivoire"
<< "Cyprus"
<< "Czech Republic"
<< "Denmark"
<< "Djibouti"
<< "Dominica"
<< "Dominican Republic"
<< "East Timor"
<< "Ecuador"
<< "Egypt"
<< "El Salvador"
<< "Equatorial Guinea"
<< "Eritrea"
<< "Estonia"
<< "Ethiopia"
<< "Falkland Islands (Malvina)"
<< "Faroe Islands"
<< "Fiji"
<< "Finland"
<< "France"
<< "French Guiana"
<< "French Polynesia"
<< "French Southern Territories"
<< "Gabon"
<< "Gambia"
<< "Georgia"
<< "Germany"
<< "Ghana"
<< "Gibraltar"
<< "Greece"
<< "Greenland"
<< "Grenada"
<< "Guadeloupe"
<< "Guam"
<< "Guatemala"
<< "Guernsey"
<< "Guinea"
<< "Guinea-Bissau"
<< "Guyana"
<< "Haiti"
<< "Heard and McDonald Islands"
<< "Holy See (City Vatican State)"
<< "Honduras"
<< "Hong Kong"
<< "Hungary"
<< "Iceland"
<< "India"
<< "Indonesia"
<< "Iraq"
<< "Ireland"
<< "Isle of Man"
<< "Israel"
<< "Italy"
<< "Jamaica"
<< "Japan"
<< "Jersey"
<< "Jordan"
<< "Kazakhstan"
<< "Kenya"
<< "Kiribati"
<< "Korea, Republic of"
<< "Kuwait"
<< "Kyrgyzstan"
<< "Lao People's Democratic Republic"
<< "Latvia"
<< "Lebanon"
<< "Lesotho"
<< "Liberia"
<< "Libyan Arab Jamahiriya"
<< "Liechtenstein"
<< "Lithuania"
<< "Luxembourg"
<< "Macau"
<< "Macedonia, Former Yugoslav Republic"
<< "Madagascar"
<< "Malawi"
<< "Malaysia"
<< "Maldives"
<< "Mali"
<< "Malta"
<< "Marshall Islands"
<< "Martinique"
<< "Mauritania"
<< "Mauritius"
<< "Mayotte"
<< "Mexico"
<< "Micronesia, Federal State of"
<< "Moldova, Republic of"
<< "Monaco"
<< "Mongolia"
<< "Montenegro"
<< "Montserrat"
<< "Morocco"
<< "Mozambique"
<< "Namibia"
<< "Nauru"
<< "Nepal"
<< "Netherlands"
<< "Netherlands Antilles"
<< "New Caledonia"
<< "New Zealand"
<< "Nicaragua"
<< "Niger"
<< "Nigeria"
<< "Niue"
<< "Norfolk Island"
<< "Northern Mariana Island"
<< "Norway"
<< "Oman"
<< "Pakistan"
<< "Palau"
<< "Panama"
<< "Papua New Guinea"
<< "Paraguay"
<< "Peru"
<< "Philippines"
<< "Pitcairn Island"
<< "Poland"
<< "Portugal"
<< "Puerto Rico"
<< "Qatar"
<< "Reunion Island"
<< "Romania"
<< "Russian Federation"
<< "Rwanda"
<< "Saint Kitts and Nevis"
<< "Saint Lucia"
<< "Saint Vincent and the Grenadines"
<< "San Marino"
<< "Sao Tome & Principe"
<< "Saudi Arabia"
<< "Senegal"
<< "Serbia"
<< "Seychelles"
<< "Sierra Leone"
<< "Singapore"
<< "Slovak Republic"
<< "Slovenia"
<< "Solomon Islands"
<< "Somalia"
<< "South Africa"
<< "South Georgia and the South Sandwich Islands"
<< "Spain"
<< "Sri Lanka"
<< "St Pierre and Miquelon"
<< "St. Helena"
<< "Suriname"
<< "Svalbard And Jan Mayen Island"
<< "Swaziland"
<< "Sweden"
<< "Switzerland"
<< "Taiwan"
<< "Tajikistan"
<< "Tanzania"
<< "Thailand"
<< "Togo"
<< "Tokelau"
<< "Tonga"
<< "Trinidad and Tobago"
<< "Tunisia"
<< "Turkey"
<< "Turkmenistan"
<< "Turks and Ciacos Islands"
<< "Tuvalu"
<< "US Minor Outlying Islands"
<< "Uganda"
<< "Ukraine"
<< "United Arab Emirates"
<< "United Kingdom"
<< "United States"
<< "Uruguay"
<< "Uzbekistan"
<< "Vanuatu"
<< "Venezuela"
<< "Vietnam"
<< "Virgin Island (British)"
<< "Virgin Islands (USA)"
<< "Wallis And Futuna Islands"
<< "Western Sahara"
<< "Western Samoa"
<< "Yemen"
<< "Zambia"
<< "Zimbabwe";
}
{
{
int iPosition;
}
{
return pComboBox->currentIndex() > 0;
}
return false;
}
#include "UIRegistrationWzd.moc"