summaryrefslogtreecommitdiff
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
parent536f18bdaae32831aa92702535586f26d0628a42 (diff)
downloadmana-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.tar.gz
mana-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.tar.bz2
mana-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.tar.xz
mana-34f13f39c61fbfc0a41e5b5d49f9d9619e3f75a3.zip
Made the Email address change work more nicely with the server.
-rw-r--r--ChangeLog2
-rw-r--r--src/gui/changeemaildialog.cpp38
-rw-r--r--src/gui/changeemaildialog.h1
-rw-r--r--src/main.cpp3
-rw-r--r--src/net/accountserver/account.cpp3
-rw-r--r--src/net/accountserver/account.h3
-rw-r--r--src/net/loginhandler.cpp3
-rw-r--r--src/net/protocol.h3
8 files changed, 18 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 4403b3b2..d460bb9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
src/net/protocol.h, src/net/loginhandler.cpp, src/logindata.h,
src/gui/changepassworddialog.cpp: Added client-side Email address
change.
+ * src/net/accountserver/account.h, src/net/accountserver/account.cpp,
+ src/net/protocol.h: Made it work nicely with the server.
2008-04-25 David Athay <ko2fan@gmail.com>
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();
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index 22dc1263..5aa9bca6 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -59,7 +59,6 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener {
void action(const gcn::ActionEvent &event);
private:
- gcn::TextField *mOldEmailField;
gcn::TextField *mFirstEmailField;
gcn::TextField *mSecondEmailField;
diff --git a/src/main.cpp b/src/main.cpp
index 3d1a0e27..59c7f74f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -582,8 +582,7 @@ void accountChangeEmail(LoginData *loginData)
{
Net::registerHandler(&loginHandler);
- Net::AccountServer::Account::changeEmail(loginData->username,
- loginData->newEmail);
+ Net::AccountServer::Account::changeEmail(loginData->newEmail);
}
void switchCharacter(std::string* passToken)
diff --git a/src/net/accountserver/account.cpp b/src/net/accountserver/account.cpp
index 2d8065b5..d1fe6863 100644
--- a/src/net/accountserver/account.cpp
+++ b/src/net/accountserver/account.cpp
@@ -83,8 +83,7 @@ void Net::AccountServer::Account::unregister(const std::string &username,
Net::AccountServer::connection->send(msg);
}
-void Net::AccountServer::Account::changeEmail(const std::string &username,
- const std::string &email)
+void Net::AccountServer::Account::changeEmail(const std::string &email)
{
MessageOut msg(PAMSG_EMAIL_CHANGE);
diff --git a/src/net/accountserver/account.h b/src/net/accountserver/account.h
index c8604717..0cf0758e 100644
--- a/src/net/accountserver/account.h
+++ b/src/net/accountserver/account.h
@@ -44,8 +44,7 @@ namespace Net
void unregister(const std::string &username,
const std::string &password);
- void changeEmail(const std::string &username,
- const std::string &email);
+ void changeEmail(const std::string &email);
void changePassword(const std::string &username,
const std::string &oldPassword,
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp
index 3a5b1c64..6840d90c 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -190,6 +190,9 @@ void LoginHandler::handleMessage(MessageIn &msg)
case ERRMSG_NO_LOGIN:
errorMessage = "Account not connected. Please login first.";
break;
+ case ERRMSG_EMAIL_ALREADY_EXISTS:
+ errorMessage = "The new Email Address already exists.";
+ break;
default:
errorMessage = "Unknown error";
break;
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 76610635..10c89689 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -191,7 +191,8 @@ enum {
ERRMSG_NO_LOGIN, // the user is not yet logged
ERRMSG_NO_CHARACTER_SELECTED, // the user needs a character
ERRMSG_INSUFFICIENT_RIGHTS, // the user is not privileged
- ERRMSG_INVALID_ARGUMENT // part of the received message was invalid
+ ERRMSG_INVALID_ARGUMENT, // part of the received message was invalid
+ ERRMSG_EMAIL_ALREADY_EXISTS // The Email Address already exists
};
// Login specific return values