summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2009-10-04 22:28:19 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2009-10-04 22:31:43 +0200
commit924e0a887f87ce531bc5bd26cb55e410b7303383 (patch)
treea592304792e8ae877dabaa2062d6bdff1d406f02 /src/gui
parentcff9f1947bac8fa49aaf6f846a6e4335a439ac2e (diff)
downloadmana-client-924e0a887f87ce531bc5bd26cb55e410b7303383.tar.gz
mana-client-924e0a887f87ce531bc5bd26cb55e410b7303383.tar.bz2
mana-client-924e0a887f87ce531bc5bd26cb55e410b7303383.tar.xz
mana-client-924e0a887f87ce531bc5bd26cb55e410b7303383.zip
Introduced Net::LoginHandler::SetEmailOnRegister
This "optional action" specifies whether the server expects to get an email address during registration. It is used now instead of having the general handlers of eAthena and tmwserv set a pointer to an email string on the GUI dialogs (to keep things understandable, the dependency should preferably go one way).
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/changeemaildialog.cpp13
-rw-r--r--src/gui/changeemaildialog.h1
-rw-r--r--src/gui/register.cpp22
-rw-r--r--src/gui/register.h1
4 files changed, 14 insertions, 23 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index 15e54895..45dcc5f8 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -39,11 +39,10 @@
#include <string>
#include <sstream>
-std::string *ChangeEmailDialog::emailPointer = NULL;
-
ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData):
Window(_("Change Email Address"), true, parent),
- mWrongDataNoticeListener(new WrongDataNoticeListener)
+ mWrongDataNoticeListener(new WrongDataNoticeListener),
+ mLoginData(loginData)
{
gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"),
mLoginData->username.c_str()));
@@ -159,15 +158,9 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
// No errors detected, change account password.
mChangeEmailButton->setEnabled(false);
// Set the new email address
- *emailPointer = newFirstEmail;
+ mLoginData->email = newFirstEmail;
state = STATE_CHANGEEMAIL_ATTEMPT;
scheduleDelete();
}
-
}
}
-
-void ChangeEmailDialog::setEmail(std::string *email)
-{
- emailPointer = email;
-}
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index 23aab080..ae9aa6cc 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -73,7 +73,6 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener
WrongDataNoticeListener *mWrongDataNoticeListener;
LoginData *mLoginData;
- static std::string *emailPointer;
};
#endif // GUI_CHANGEEMAIL_H
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 50f63c69..78c79eeb 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -37,6 +37,8 @@
#include "gui/widgets/textfield.h"
#include "net/logindata.h"
+#include "net/net.h"
+#include "net/loginhandler.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -52,24 +54,24 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
mTarget->requestFocus();
}
-std::string *RegisterDialog::useEmail = NULL;
Gender *RegisterDialog::useGender = NULL;
RegisterDialog::RegisterDialog(LoginData *loginData):
Window(_("Register")),
+ mEmailField(0),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(loginData)
{
+ int optionalActions = Net::getLoginHandler()->supportedOptionalActions();
+
gcn::Label *userLabel = new Label(_("Name:"));
gcn::Label *passwordLabel = new Label(_("Password:"));
gcn::Label *confirmLabel = new Label(_("Confirm:"));
- gcn::Label *emailLabel = new Label(_("Email:"));
mUserField = new TextField(loginData->username);
mPasswordField = new PasswordField(loginData->password);
mConfirmField = new PasswordField;
mMaleButton = new RadioButton(_("Male"), "sex", true);
mFemaleButton = new RadioButton(_("Female"), "sex", false);
- mEmailField = new TextField;
mRegisterButton = new Button(_("Register"), "register", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
@@ -85,11 +87,14 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
place(2, 3, mFemaleButton);
}
- if (useEmail)
+ if (optionalActions & Net::LoginHandler::SetEmailOnRegister)
{
+ gcn::Label *emailLabel = new Label(_("Email:"));
+ mEmailField = new TextField;
place(0, 3, emailLabel);
place(1, 3, mEmailField, 3).setPadding(2);
}
+
place(1, 0, mUserField, 3).setPadding(2);
place(1, 1, mPasswordField, 3).setPadding(2);
place(1, 2, mConfirmField, 3).setPadding(2);
@@ -211,8 +216,8 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
if (useGender)
*useGender = mFemaleButton->isSelected() ? GENDER_FEMALE :
GENDER_MALE;
- if (useEmail)
- *useEmail = mEmailField->getText();
+ if (mEmailField)
+ mLoginData->email = mEmailField->getText();
mLoginData->registerLogin = true;
state = STATE_REGISTER_ATTEMPT;
@@ -225,11 +230,6 @@ void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent)
mRegisterButton->setEnabled(canSubmit());
}
-void RegisterDialog::setEmail(std::string *email)
-{
- useEmail = email;
-}
-
void RegisterDialog::setGender(Gender *gender)
{
useGender = gender;
diff --git a/src/gui/register.h b/src/gui/register.h
index 8fe3d9fb..9f22a5bb 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -115,7 +115,6 @@ class RegisterDialog : public Window, public gcn::ActionListener,
LoginData *mLoginData;
- static std::string *useEmail;
static Gender *useGender;
};