From a3c66a09efc7f3683f0c247f4a2c5035bff83651 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 24 May 2009 21:49:09 +0200 Subject: Add change password dialog to athena client (cherry picked from commit 050103b8d2e3eb23e7aea188a1a269feb7c181ab) --- src/Makefile.am | 4 ++-- src/gui/charselectdialog.cpp | 43 +++++++++++++++++++------------------------ src/gui/charselectdialog.h | 12 ++++-------- src/main.cpp | 2 +- src/main.h | 4 ++-- 5 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 47d27ede..dd9177e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,6 +69,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/buy.h \ gui/buysell.cpp \ gui/buysell.h \ + gui/changepassworddialog.cpp \ + gui/changepassworddialog.h \ gui/charselectdialog.cpp \ gui/charselectdialog.h \ gui/charcreatedialog.cpp \ @@ -366,8 +368,6 @@ tmw_SOURCES += \ gui/buddywindow.h \ gui/changeemaildialog.cpp \ gui/changeemaildialog.h \ - gui/changepassworddialog.cpp \ - gui/changepassworddialog.h \ gui/connection.cpp \ gui/connection.h \ gui/guildlistbox.cpp \ diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 4df0243b..dd91af5c 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -25,17 +25,16 @@ #include "gui/confirmdialog.h" #include "gui/okdialog.h" #include "gui/playerbox.h" +#include "gui/changepassworddialog.h" +#include "net/logindata.h" #ifdef TMWSERV_SUPPORT #include "gui/widgets/radiobutton.h" #include "gui/widgets/slider.h" #include "gui/unregisterdialog.h" -#include "gui/changepassworddialog.h" #include "gui/changeemaildialog.h" -#include "net/logindata.h" - #include "net/tmwserv/accountserver/account.h" #endif @@ -91,36 +90,30 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event) ConfirmDialog::action(event); } -#ifdef TMWSERV_SUPPORT CharSelectDialog::CharSelectDialog(LockedArray *charInfo, LoginData *loginData): Window(_("Account and Character Management")), mCharInfo(charInfo), mCharSelected(false), - mLoginData(loginData) -#else -CharSelectDialog::CharSelectDialog(LockedArray *charInfo, - Gender gender): - Window(_("Select Character")), - mCharInfo(charInfo), - mCharSelected(false), - mGender(gender) +#ifdef EATHENA_SUPPORT + mGender(loginData->sex), #endif + mLoginData(loginData) { mSelectButton = new Button(_("OK"), "ok", this); mCancelButton = new Button(_("Cancel"), "cancel", this); mPreviousButton = new Button(_("Previous"), "previous", this); mNextButton = new Button(_("Next"), "next", this); + mAccountNameLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); mNameLabel = new Label(strprintf(_("Name: %s"), "")); mLevelLabel = new Label(strprintf(_("Level: %d"), 0)); + mChangePasswordButton = new Button(_("Change Password"), "change_password", this); #ifdef TMWSERV_SUPPORT mNewCharButton = new Button(_("New"), "new", this); mDelCharButton = new Button(_("Delete"), "delete", this); mUnRegisterButton = new Button(_("Unregister"), "unregister", this); - mChangePasswordButton = new Button(_("Change Password"), "change_password", this); mChangeEmailButton = new Button(_("Change Email Address"), "change_email", this); - mAccountNameLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); mNameLabel = new Label(strprintf(_("Name: %s"), "")); mLevelLabel = new Label(strprintf(_("Level: %d"), 0)); mMoneyLabel = new Label(strprintf(_("Money: %d"), 0)); @@ -169,13 +162,15 @@ CharSelectDialog::CharSelectDialog(LockedArray *charInfo, ContainerPlacer place; place = getPlacer(0, 0); - + place(0, 0, mAccountNameLabel); + place(0, 1, mChangePasswordButton); + place = getPlacer(0, 1); place(0, 0, mPlayerBox, 1, 6).setPadding(3); - place(1, 0, mNewDelCharButton); - place(1, 1, mNameLabel, 5); - place(1, 2, mLevelLabel, 5); - place(1, 3, mJobLevelLabel, 5); - place(1, 4, mMoneyLabel, 5); + place(1, 0, mNameLabel, 5); + place(1, 1, mLevelLabel, 5); + place(1, 2, mJobLevelLabel, 5); + place(1, 3, mMoneyLabel, 5); + place(1, 4, mNewDelCharButton); place.getCell().matchColWidth(1, 4); place = getPlacer(0, 2); place(0, 0, mPreviousButton); @@ -276,15 +271,15 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) if (pi) mMoney = Units::formatCurrency(pi->getMoney()); } + else if (event.getId() == "change_password") + { + new ChangePasswordDialog(this, mLoginData); + } #ifdef TMWSERV_SUPPORT else if (event.getId() == "unregister") { new UnRegisterDialog(this, mLoginData); } - else if (event.getId() == "change_password") - { - new ChangePasswordDialog(this, mLoginData); - } else if (event.getId() == "change_email") { new ChangeEmailDialog(this, mLoginData); diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index adbf3de1..06ce4b55 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -47,13 +47,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener /** * Constructor. */ -#ifdef TMWSERV_SUPPORT CharSelectDialog(LockedArray *charInfo, LoginData *loginData); -#else - CharSelectDialog(LockedArray *charInfo, - Gender gender); -#endif void action(const gcn::ActionEvent &event); @@ -70,12 +65,16 @@ class CharSelectDialog : public Window, public gcn::ActionListener gcn::Button *mCancelButton; gcn::Button *mPreviousButton; gcn::Button *mNextButton; + gcn::Button *mChangePasswordButton; gcn::Label *mNameLabel; gcn::Label *mLevelLabel; gcn::Label *mMoneyLabel; + gcn::Label *mAccountNameLabel; std::string mMoney; + LoginData *mLoginData; + PlayerBox *mPlayerBox; bool mCharSelected; @@ -84,11 +83,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener gcn::Button *mNewCharButton; gcn::Button *mDelCharButton; gcn::Button *mUnRegisterButton; - gcn::Button *mChangePasswordButton; gcn::Button *mChangeEmailButton; - gcn::Label *mAccountNameLabel; - LoginData *mLoginData; #else gcn::Button *mNewDelCharButton; gcn::Label *mJobLevelLabel; diff --git a/src/main.cpp b/src/main.cpp index c2e74ff3..d1fba313 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1446,7 +1446,7 @@ int main(int argc, char *argv[]) case STATE_CHAR_SELECT: logger->log("State: CHAR_SELECT"); currentDialog = new CharSelectDialog(&charInfo, - loginData.sex); + &loginData); positionDialog(currentDialog, screenWidth, screenHeight); if (((CharSelectDialog*) currentDialog)-> diff --git a/src/main.h b/src/main.h index 75343944..d33ea14d 100644 --- a/src/main.h +++ b/src/main.h @@ -87,6 +87,8 @@ enum State { STATE_GAME, STATE_ERROR, STATE_UPDATE, + STATE_CHANGEPASSWORD_ATTEMPT, + STATE_CHANGEPASSWORD, #ifdef TMWSERV_SUPPORT STATE_CHOOSE_SERVER, STATE_CONNECT_ACCOUNT, @@ -96,8 +98,6 @@ enum State { STATE_ACCOUNTCHANGE_ERROR, STATE_CHANGEEMAIL_ATTEMPT, STATE_CHANGEEMAIL, - STATE_CHANGEPASSWORD_ATTEMPT, - STATE_CHANGEPASSWORD, STATE_UNREGISTER_ATTEMPT, STATE_UNREGISTER, STATE_SWITCH_CHARACTER, -- cgit v1.2.3-70-g09d2 From 2f096639243c5fdddc828771699937751f5ac13b Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Mon, 25 May 2009 05:23:40 +0200 Subject: Add athena netcode for changing account password. (cherry picked from commit ef006ed117bb602a928d33dc0fe90075efd7393f) --- src/main.cpp | 36 ++++++++++++++++++++++++++++++++++-- src/main.h | 2 +- src/net/ea/loginhandler.cpp | 36 +++++++++++++++++++++++++++++++++++- src/net/ea/network.cpp | 2 +- src/net/ea/protocol.h | 2 ++ 5 files changed, 73 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d1fba313..ba6be23a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -710,7 +710,6 @@ struct ErrorListener : public gcn::ActionListener } } errorListener; -#ifdef TMWSERV_SUPPORT struct AccountListener : public gcn::ActionListener { void action(const gcn::ActionEvent &event) @@ -719,6 +718,7 @@ struct AccountListener : public gcn::ActionListener } } accountListener; +#ifdef TMWSERV_SUPPORT struct LoginListener : public gcn::ActionListener { void action(const gcn::ActionEvent &event) @@ -1343,8 +1343,16 @@ int main(int argc, char *argv[]) loadUpdates(); break; - // Those states don't cause a network disconnect + // Those states don't cause a network disconnect case STATE_LOADDATA: + case STATE_CHANGEPASSWORD_ATTEMPT: + case STATE_CHANGEPASSWORD: + case STATE_ACCOUNTCHANGE_ERROR: + break; + + case STATE_CHAR_SELECT: + if (state == STATE_CONNECTING) + network->disconnect(); break; case STATE_ACCOUNT: @@ -1539,6 +1547,30 @@ int main(int argc, char *argv[]) accountLogin(network, &loginData); break; + case STATE_CHANGEPASSWORD_ATTEMPT: + logger->log("State: CHANGE PASSWORD ATTEMPT"); + Net::getLoginHandler()->changePassword(loginData.username, + loginData.password, + loginData.newPassword); + break; + + case STATE_CHANGEPASSWORD: + 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 = ""; + 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; + default: state = STATE_EXIT; break; diff --git a/src/main.h b/src/main.h index d33ea14d..c0d0a5bd 100644 --- a/src/main.h +++ b/src/main.h @@ -89,13 +89,13 @@ enum State { STATE_UPDATE, STATE_CHANGEPASSWORD_ATTEMPT, STATE_CHANGEPASSWORD, + STATE_ACCOUNTCHANGE_ERROR, #ifdef TMWSERV_SUPPORT STATE_CHOOSE_SERVER, STATE_CONNECT_ACCOUNT, STATE_LOGIN_ATTEMPT, STATE_LOGIN_ERROR, STATE_REGISTER_ATTEMPT, - STATE_ACCOUNTCHANGE_ERROR, STATE_CHANGEEMAIL_ATTEMPT, STATE_CHANGEEMAIL, STATE_UNREGISTER_ATTEMPT, diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 31d2c020..8f66343f 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -46,6 +46,7 @@ LoginHandler::LoginHandler() SMSG_UPDATE_HOST, SMSG_LOGIN_DATA, SMSG_LOGIN_ERROR, + SMSG_CHAR_PASSWORD_RESPONSE, 0 }; handledMessages = _messages; @@ -58,6 +59,37 @@ void LoginHandler::handleMessage(MessageIn &msg) switch (msg.getId()) { + case SMSG_CHAR_PASSWORD_RESPONSE: + { + // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short + int errMsg = msg.readInt8(); + // Successful pass change + if (errMsg == 1) + { + state = STATE_CHANGEPASSWORD; + } + // pass change failed + else + { + switch (errMsg) { + case 0: + errorMessage = _("Account not connected. Please login first."); + break; + case 2: + errorMessage = _("Old password incorrect"); + break; + case 3: + errorMessage = _("New password too short"); + break; + default: + errorMessage = _("Unknown error"); + break; + } + state = STATE_ACCOUNTCHANGE_ERROR; + } + } + break; + case SMSG_UPDATE_HOST: int len; @@ -157,7 +189,9 @@ void LoginHandler::changePassword(const std::string &username, const std::string &oldPassword, const std::string &newPassword) { - // TODO + MessageOut outMsg(CMSG_CHAR_PASSWORD_CHANGE); + outMsg.writeString(oldPassword, 24); + outMsg.writeString(newPassword, 24); } void LoginHandler::chooseServer(int server) diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 7b731de3..956d7877 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -40,7 +40,7 @@ short packet_lengths[] = { // #0x0040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -1, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2, + 0, 50, 3, -1, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2, 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6, // #0x0080 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 23, -1, -1, -1, 0, diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h index 0373dd8a..f8caf4c1 100644 --- a/src/net/ea/protocol.h +++ b/src/net/ea/protocol.h @@ -42,6 +42,7 @@ static const int STORAGE_OFFSET = 1; #define SMSG_CHAR_DELETE_SUCCEEDED 0x006f #define SMSG_CHAR_DELETE_FAILED 0x0070 #define SMSG_CHAR_MAP_INFO 0x0071 +#define SMSG_CHAR_PASSWORD_RESPONSE 0x0062 /**< Custom packet reply to password change request */ #define SMSG_MAP_LOGIN_SUCCESS 0x0073 /**< Contains starting location */ #define SMSG_PLAYER_UPDATE_1 0x01d8 @@ -140,6 +141,7 @@ static const int STORAGE_OFFSET = 1; /********************************** * Packets from client to server * **********************************/ +#define CMSG_CHAR_PASSWORD_CHANGE 0x0061 /**< Custom change password packet */ #define CMSG_CHAR_SERVER_CONNECT 0x0065 #define CMSG_CHAR_SELECT 0x0066 #define CMSG_CHAR_CREATE 0x0067 -- cgit v1.2.3-70-g09d2 From 2138841b33b284dd60cf4031ccb87fa5a5b090c8 Mon Sep 17 00:00:00 2001 From: Hong Hao Date: Mon, 25 May 2009 23:47:08 +0800 Subject: Fix CMakeLists.txt Signed-off-by: Hong Hao Signed-off-by: Chuck Miller (cherry picked from commit 873841a6fa12d357a0c345e16d8d9d7dcdeecb69) --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08110c43..76fd3545 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,6 +120,8 @@ SET(SRCS gui/buy.h gui/buysell.cpp gui/buysell.h + gui/changepassworddialog.cpp + gui/changepassworddialog.h gui/charselectdialog.cpp gui/charselectdialog.h gui/charcreatedialog.cpp @@ -462,8 +464,6 @@ SET(SRCS_TMW gui/buddywindow.h gui/changeemaildialog.cpp gui/changeemaildialog.h - gui/changepassworddialog.cpp - gui/changepassworddialog.h gui/connection.cpp gui/connection.h gui/guildlistbox.cpp -- cgit v1.2.3-70-g09d2 From 1db84d9f7feae70a1825cfaad2d114fec069fad8 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Mon, 25 May 2009 19:20:17 +0200 Subject: Nuke some tabs I put in here. (cherry picked from commit 727b32c9a28c4cc086992ea42c464286b6b52a01) --- src/net/ea/loginhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 8f66343f..9b5966f6 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -61,7 +61,7 @@ void LoginHandler::handleMessage(MessageIn &msg) { case SMSG_CHAR_PASSWORD_RESPONSE: { - // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short + // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short int errMsg = msg.readInt8(); // Successful pass change if (errMsg == 1) -- cgit v1.2.3-70-g09d2 From 420a78297fa91a69c2eab5090e7dae6fb2479f5c Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Mon, 25 May 2009 19:24:29 +0200 Subject: Fix some text I forgot to update after snatching it from tmwserv client. (cherry picked from commit e5b8592fb54bff10161706e0583d8d892b4ea4fe) --- src/net/ea/loginhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 9b5966f6..54e31cf3 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -73,7 +73,7 @@ void LoginHandler::handleMessage(MessageIn &msg) { switch (errMsg) { case 0: - errorMessage = _("Account not connected. Please login first."); + errorMessage = _("Account was not found. Please re-login."); break; case 2: errorMessage = _("Old password incorrect"); -- cgit v1.2.3-70-g09d2 From 6c32e0783edd294a06b5b5fee45b9d4d7b14284e Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Mon, 25 May 2009 19:26:16 +0200 Subject: Update code blocks project file. Patch by QOAL (cherry picked from commit 8557f3b2e279bda3f1c58b82c6aa37f9206aeb12) --- tmw.cbp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tmw.cbp b/tmw.cbp index ae26660f..d12f71c6 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -210,14 +210,8 @@