diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-25 01:42:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-25 01:42:53 +0300 |
commit | 10f59701112130cf953a2af7ef4ae82d9d823fe6 (patch) | |
tree | 32f84fd57dde0e3ace791bae116163659d19170e /src/gui/logindialog.cpp | |
parent | 4e95f451a793dbac5dbc31361cdc5049de48c3cc (diff) | |
download | manaverse-10f59701112130cf953a2af7ef4ae82d9d823fe6.tar.gz manaverse-10f59701112130cf953a2af7ef4ae82d9d823fe6.tar.bz2 manaverse-10f59701112130cf953a2af7ef4ae82d9d823fe6.tar.xz manaverse-10f59701112130cf953a2af7ef4ae82d9d823fe6.zip |
Add support for register from browser on servers with disabled registration.
Diffstat (limited to 'src/gui/logindialog.cpp')
-rw-r--r-- | src/gui/logindialog.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index e971aa5bc..00c5ab54d 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -27,6 +27,7 @@ #include "keydata.h" #include "keyevent.h" +#include "gui/confirmdialog.h" #include "gui/okdialog.h" #include "gui/sdlinput.h" @@ -43,12 +44,23 @@ #include "utils/gettext.h" #include "utils/paths.h" +#include "utils/process.h" #include "debug.h" std::string LoginDialog::savedPassword(""); std::string LoginDialog::savedPasswordKey(""); +struct OpenUrlListener : public gcn::ActionListener +{ + void action(const gcn::ActionEvent &event) + { + if (event.getId() == "yes") + openBrowser(url); + } + + std::string url; +} urlListener; const char *UPDATE_TYPE_TEXT[3] = { @@ -221,8 +233,8 @@ LoginDialog::LoginDialog(LoginData *const data, std::string serverName, mPassField->requestFocus(); mLoginButton->setEnabled(canSubmit()); - mRegisterButton->setEnabled(Net::getLoginHandler() - ->isRegistrationEnabled()); + mRegisterButton->setEnabled(Net::getLoginHandler()->isRegistrationEnabled() + || !mLoginData->registerUrl.empty()); } LoginDialog::~LoginDialog() @@ -299,10 +311,20 @@ void LoginDialog::action(const gcn::ActionEvent &event) } else if (event.getId() == "register") { - mLoginData->username = mUserField->getText(); - mLoginData->password = mPassField->getText(); - - Client::setState(STATE_REGISTER_PREP); + if (Net::getLoginHandler()->isRegistrationEnabled()) + { + mLoginData->username = mUserField->getText(); + mLoginData->password = mPassField->getText(); + Client::setState(STATE_REGISTER_PREP); + } + else if (!mLoginData->registerUrl.empty()) + { + const std::string &url = mLoginData->registerUrl; + urlListener.url = url; + ConfirmDialog *const confirmDlg = new ConfirmDialog( + _("Open register url"), url, false, true); + confirmDlg->addActionListener(&urlListener); + } } else if (event.getId() == "customhost") { |