Commit 11857a92 authored by Shashwat Jolly's avatar Shashwat Jolly
Browse files

Remove encryption password page from config wizard

Encryption passwords are not needed in EteSync 2.0
parent 82fe9e60
......@@ -27,7 +27,6 @@ SetupWizard::SetupWizard(EteSyncClientState *clientState, QWidget *parent)
setWindowTitle(i18nc("@title:window", "EteSync configuration wizard"));
setWindowIcon(QIcon::fromTheme(QStringLiteral("akonadi-etesync")));
setPage(W_LoginPage, new LoginPage);
setPage(W_EncryptionPasswordPage, new EncryptionPasswordPage);
disconnect(button(QWizard::NextButton), SIGNAL(clicked()), this, SLOT(next()));
connect(button(QWizard::NextButton), SIGNAL(clicked()), this, SLOT(manualNext()));
......@@ -72,7 +71,7 @@ LoginPage::LoginPage(QWidget *parent)
layout->addWidget(mLoginLabel);
mUserName = new QLineEdit;
layout->addRow(i18n("Email:"), mUserName);
layout->addRow(i18n("Username:"), mUserName);
registerField(QStringLiteral("credentialsUserName*"), mUserName);
mPassword = new KPasswordLineEdit;
......@@ -112,10 +111,7 @@ void LoginPage::initializePage()
int LoginPage::nextId() const
{
if (mIsInitialized) {
return -1;
}
return SetupWizard::W_EncryptionPasswordPage;
return -1;
}
bool LoginPage::validatePage()
......@@ -134,61 +130,5 @@ bool LoginPage::validatePage()
return false;
}
if (!mUserInfoResult) {
if (mErrorCode == EteSyncErrorCode::ETESYNC_ERROR_CODE_NOT_FOUND) {
wizard()->setProperty("initAccount", true);
return true;
}
mLoginLabel->setText(i18n(charArrFromQString(mErrorMessage)));
return false;
}
return true;
}
EncryptionPasswordPage::EncryptionPasswordPage(QWidget *parent)
: QWizardPage(parent)
{
setTitle(i18n("Encryption password"));
setSubTitle(i18n("Enter the encryption password for your EteSync account"));
QFormLayout *layout = new QFormLayout(this);
mEncryptionPasswordLabel = new QLabel;
mEncryptionPasswordLabel->setWordWrap(true);
layout->addWidget(mEncryptionPasswordLabel);
mEncryptionPassword = new KPasswordLineEdit;
layout->addRow(i18n("Encryption Password:"), mEncryptionPassword);
registerField(QStringLiteral("credentialsEncryptionPassword*"), mEncryptionPassword, "password", SIGNAL(passwordChanged(QString)));
}
int EncryptionPasswordPage::nextId() const
{
return -1;
}
void EncryptionPasswordPage::initializePage()
{
const auto initAccount = wizard()->property("initAccount");
if (initAccount.isValid() && initAccount.toBool()) {
setSubTitle(i18n("Welcome to EteSync! Please set your encryption password below, and make sure you got it right, as it can't be recovered if lost!"));
}
}
bool EncryptionPasswordPage::validatePage()
{
const QString encryptionPassword = field(QStringLiteral("credentialsEncryptionPassword")).toString();
const auto initAccount = wizard()->property("initAccount");
if (initAccount.isValid() && initAccount.toBool()) {
return static_cast<SetupWizard *>(wizard())->mClientState->initAccount(encryptionPassword);
}
const bool keypairResult = static_cast<SetupWizard *>(wizard())->mClientState->initKeypair(encryptionPassword);
if (!keypairResult) {
if (etesync_get_error_code() == ETESYNC_ERROR_CODE_ENCRYPTION_MAC) {
mEncryptionPasswordLabel->setText(i18n("Incorrect encryption password. Please try again."));
} else {
mEncryptionPasswordLabel->setText(i18n(CharPtr(etesync_get_error_message()).get()));
}
}
return keypairResult;
}
......@@ -28,8 +28,7 @@ public:
enum
{
W_LoginPage,
W_EncryptionPasswordPage
W_LoginPage
};
EteSyncClientState *mClientState = nullptr;
......@@ -61,11 +60,6 @@ public:
mLoginResult = loginResult;
}
void setUserInfoResult(bool userInfoResult)
{
mUserInfoResult = userInfoResult;
}
void setErrorCode(int errorCode)
{
mErrorCode = errorCode;
......@@ -85,22 +79,8 @@ private:
QProgressBar *mProgressBar;
bool mIsInitialized = false;
bool mLoginResult = false;
bool mUserInfoResult = false;
int mErrorCode;
QString mErrorMessage;
};
class EncryptionPasswordPage : public QWizardPage
{
public:
explicit EncryptionPasswordPage(QWidget *parent = nullptr);
int nextId() const override;
void initializePage() override;
bool validatePage() override;
private:
KPasswordLineEdit *mEncryptionPassword = nullptr;
QLabel *mEncryptionPasswordLabel = nullptr;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment