diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2008-04-18 23:04:38 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2008-04-18 23:04:38 +0000 |
commit | 327db845912a5e3857438fc0ad5ed0543f25a79f (patch) | |
tree | e18d8deb05b070c3d0edaddba703cd29c781ff4b /src | |
parent | b0cdf9ffc57c43aa81187ac856d08da7e97955ba (diff) | |
download | mana-client-327db845912a5e3857438fc0ad5ed0543f25a79f.tar.gz mana-client-327db845912a5e3857438fc0ad5ed0543f25a79f.tar.bz2 mana-client-327db845912a5e3857438fc0ad5ed0543f25a79f.tar.xz mana-client-327db845912a5e3857438fc0ad5ed0543f25a79f.zip |
Made 'Unregister' and 'change password' functionnal, at least client-side.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/changepassworddialog.cpp | 6 | ||||
-rw-r--r-- | src/gui/unregisterdialog.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 22 | ||||
-rw-r--r-- | src/main.h | 1 | ||||
-rw-r--r-- | src/net/loginhandler.cpp | 31 | ||||
-rw-r--r-- | src/net/logouthandler.cpp | 2 |
6 files changed, 58 insertions, 5 deletions
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 1a7c043e..ac4b8610 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -101,7 +101,11 @@ ChangePasswordDialog::ChangePasswordDialog(Window *parent, LoginData *loginData) setLocationRelativeTo(getParent()); setVisible(true); - mFirstPassField->requestFocus(); + mOldPassField->requestFocus(); + + mOldPassField->setActionEventId("change_password"); + mFirstPassField->setActionEventId("change_password"); + mSecondPassField->setActionEventId("change_password"); } ChangePasswordDialog::~ChangePasswordDialog() diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 06ba729d..4b8755d5 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -81,6 +81,7 @@ UnRegisterDialog::UnRegisterDialog(Window *parent, LoginData *loginData): setLocationRelativeTo(getParent()); setVisible(true); mPasswordField->requestFocus(); + mPasswordField->setActionEventId("cancel"); } UnRegisterDialog::~UnRegisterDialog() diff --git a/src/main.cpp b/src/main.cpp index 55a3d425..4fc959cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -494,6 +494,14 @@ namespace { state = STATE_CHOOSE_SERVER; } } errorListener; + + struct AccountListener : public gcn::ActionListener + { + void action(const gcn::ActionEvent &event) + { + state = STATE_CHAR_SELECT; + } + } accountListener; } // TODO Find some nice place for these functions @@ -984,15 +992,15 @@ int main(int argc, char *argv[]) logger->log("State: CHANGE PASSWORD"); currentDialog = new OkDialog("Password change", "Password changed successfully!"); + currentDialog->addActionListener(&accountListener); + currentDialog = NULL; // OkDialog deletes itself loginData.password = loginData.newPassword; loginData.newPassword = ""; - state = STATE_LOGIN; break; case STATE_UNREGISTER_ATTEMPT: logger->log("State: UNREGISTER ATTEMPT"); accountUnRegister(&loginData); - loginData.clear(); break; case STATE_UNREGISTER: @@ -1000,12 +1008,20 @@ int main(int argc, char *argv[]) accountServerConnection->disconnect(); currentDialog = new OkDialog("Unregister successful", "Farewell, come back any time ...."); - + loginData.clear(); //The errorlistener sets the state to STATE_CHOOSE_SERVER currentDialog->addActionListener(&errorListener); currentDialog = NULL; // OkDialog deletes itself break; + case STATE_ACCOUNTCHANGE_ERROR: + logger->log("State: ACCOUNT CHANGE ERROR"); + currentDialog = new OkDialog("Error ", errorMessage); + currentDialog->addActionListener(&accountListener); + currentDialog = NULL; // OkDialog deletes itself + break; + + case STATE_ERROR: logger->log("State: ERROR"); currentDialog = new OkDialog("Error", errorMessage); @@ -77,6 +77,7 @@ enum { STATE_LOGIN_ATTEMPT, STATE_REGISTER, STATE_REGISTER_ATTEMPT, + STATE_ACCOUNTCHANGE_ERROR, STATE_ERROR, STATE_CHAR_SELECT, STATE_CHANGEPASSWORD_ATTEMPT, diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index 260c117d..349684bf 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -34,6 +34,7 @@ LoginHandler::LoginHandler() APMSG_LOGIN_RESPONSE, APMSG_REGISTER_RESPONSE, APMSG_RECONNECT_RESPONSE, + APMSG_PASSWORD_CHANGE_RESPONSE, 0 }; handledMessages = _messages; @@ -136,5 +137,35 @@ void LoginHandler::handleMessage(MessageIn &msg) } } break; + + case APMSG_PASSWORD_CHANGE_RESPONSE: + { + int errMsg = msg.readInt8(); + // Successful pass change + if (errMsg == ERRMSG_OK) + { + state = STATE_CHANGEPASSWORD; + } + // pass change failed + else + { + switch (errMsg) { + case ERRMSG_INVALID_ARGUMENT: + errorMessage = "New password incorrect"; + break; + case ERRMSG_FAILURE: + errorMessage = "Old password incorrect"; + break; + case ERRMSG_NO_LOGIN: + errorMessage = "Account not connected. Please login first."; + break; + default: + errorMessage = "Unknown error"; + break; + } + state = STATE_ACCOUNTCHANGE_ERROR; + } + } + break; } } diff --git a/src/net/logouthandler.cpp b/src/net/logouthandler.cpp index c7629490..fb27540f 100644 --- a/src/net/logouthandler.cpp +++ b/src/net/logouthandler.cpp @@ -104,7 +104,7 @@ void LogoutHandler::handleMessage(MessageIn &msg) errorMessage = "Accountserver: Unknown error"; break; } - state = STATE_ERROR; + state = STATE_ACCOUNTCHANGE_ERROR; } } break; |