summaryrefslogtreecommitdiff
path: root/src/gui/changeemaildialog.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2008-04-25 23:47:50 +0000
committerYohann Ferreira <bertram@cegetel.net>2008-04-25 23:47:50 +0000
commit34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3 (patch)
tree6cc3726f1bf85edc69629042b322a8b4e4b6af86 /src/gui/changeemaildialog.cpp
parent536f18bdaae32831aa92702535586f26d0628a42 (diff)
downloadmana-client-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.tar.gz
mana-client-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.tar.bz2
mana-client-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.tar.xz
mana-client-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.zip
Made the Email address change work more nicely with the server.
Diffstat (limited to 'src/gui/changeemaildialog.cpp')
-rw-r--r--src/gui/changeemaildialog.cpp38
1 files changed, 8 insertions, 30 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index bb0329e6..94253d31 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -47,31 +47,21 @@ ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData):
{
gcn::Label *accountLabel = new gcn::Label(strprintf(_("Account: %s"),
mLoginData->username.c_str()));
- gcn::Label *oldEmailLabel = new gcn::Label(_("Current Email:"));
gcn::Label *newEmailLabel = new gcn::Label(_("Type New Email Address twice:"));
- mOldEmailField = new TextField();
mFirstEmailField = new TextField();
mSecondEmailField = new TextField();
mChangeEmailButton = new Button(_("Change Email Address"), "change_email", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
const int width = 200;
- const int height = 170;
+ const int height = 130;
setContentSize(width, height);
accountLabel->setPosition(5, 5);
accountLabel->setWidth(130);
- oldEmailLabel->setPosition(
- 5, accountLabel->getY() + accountLabel->getHeight() + 7);
- oldEmailLabel->setWidth(130);
-
- mOldEmailField->setPosition(
- 5, oldEmailLabel->getY() + oldEmailLabel->getHeight() + 7);
- mOldEmailField->setWidth(width - 5);
- mOldEmailField->setWidth(130);
newEmailLabel->setPosition(
- 5, mOldEmailField->getY() + mOldEmailField->getHeight() + 7);
+ 5, accountLabel->getY() + accountLabel->getHeight() + 7);
newEmailLabel->setWidth(width - 5);
mFirstEmailField->setPosition(
@@ -90,8 +80,6 @@ ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData):
mCancelButton->getY());
add(accountLabel);
- add(oldEmailLabel);
- add(mOldEmailField);
add(newEmailLabel);
add(mFirstEmailField);
add(mSecondEmailField);
@@ -100,9 +88,8 @@ ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData):
setLocationRelativeTo(getParent());
setVisible(true);
- mOldEmailField->requestFocus();
+ mFirstEmailField->requestFocus();
- mOldEmailField->setActionEventId("change_email");
mFirstEmailField->setActionEventId("change_email");
mSecondEmailField->setActionEventId("change_email");
}
@@ -123,7 +110,6 @@ ChangeEmailDialog::action(const gcn::ActionEvent &event)
{
const std::string username = mLoginData->username.c_str();
- const std::string oldEmail = mOldEmailField->getText();
const std::string newFirstEmail = mFirstEmailField->getText();
const std::string newSecondEmail = mSecondEmailField->getText();
logger->log("ChangeEmailDialog::Email change, Username is %s",
@@ -132,20 +118,13 @@ ChangeEmailDialog::action(const gcn::ActionEvent &event)
std::stringstream errorMsg;
int error = 0;
- // Checking current Email
- if (oldEmail.empty())
- {
- // First email address too short
- errorMsg << "Please type your Email address.";
- error = 1;
- }
- else if (newFirstEmail.length() < LEN_MIN_PASSWORD)
+ if (newFirstEmail.length() < LEN_MIN_PASSWORD)
{
// First email address too short
errorMsg << "The new email address needs to be at least "
<< LEN_MIN_PASSWORD
<< " characters long.";
- error = 2;
+ error = 1;
}
else if (newFirstEmail.length() > LEN_MAX_PASSWORD - 1 )
{
@@ -153,7 +132,7 @@ ChangeEmailDialog::action(const gcn::ActionEvent &event)
errorMsg << "The new email address needs to be less than "
<< LEN_MAX_PASSWORD
<< " characters long.";
- error = 2;
+ error = 1;
}
else if (newFirstEmail != newSecondEmail)
{
@@ -166,11 +145,11 @@ ChangeEmailDialog::action(const gcn::ActionEvent &event)
{
if (error == 1)
{
- mWrongDataNoticeListener->setTarget(this->mOldEmailField);
+ mWrongDataNoticeListener->setTarget(this->mFirstEmailField);
}
else if (error == 2)
{
- mWrongDataNoticeListener->setTarget(this->mFirstEmailField);
+ mWrongDataNoticeListener->setTarget(this->mSecondEmailField);
}
OkDialog *dlg = new OkDialog("Error", errorMsg.str());
@@ -181,7 +160,6 @@ ChangeEmailDialog::action(const gcn::ActionEvent &event)
// No errors detected, change account password.
mChangeEmailButton->setEnabled(false);
// Set the new email address
- mLoginData->email = oldEmail;
mLoginData->newEmail = newFirstEmail;
state = STATE_CHANGEEMAIL_ATTEMPT;
scheduleDelete();