summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/gui/changepassworddialog.cpp6
-rw-r--r--src/gui/unregisterdialog.cpp1
-rw-r--r--src/main.cpp22
-rw-r--r--src/main.h1
-rw-r--r--src/net/loginhandler.cpp31
-rw-r--r--src/net/logouthandler.cpp2
7 files changed, 62 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 3eae3868..930f6302 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@
be reworked.
* src/localplayer.h, src/localplayer.cpp: limited keyboard walk message
flooding to one every 1/10 sec.
+ * src/main.h, src/main.cpp, src/net/loginhandler.cpp,
+ src/net/logouthandler.cpp, src/gui/unregisterdialog.cpp,
+ src/gui/changepassworddialog.cpp: Made Unregister and change password
+ functionnal, at least client-side.
2008-04-18 David Athay <ko2fan@gmail.com>
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);
diff --git a/src/main.h b/src/main.h
index 3522405f..12f5bf66 100644
--- a/src/main.h
+++ b/src/main.h
@@ -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;