summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-25 01:42:53 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-25 01:42:53 +0300
commit10f59701112130cf953a2af7ef4ae82d9d823fe6 (patch)
tree32f84fd57dde0e3ace791bae116163659d19170e /src
parent4e95f451a793dbac5dbc31361cdc5049de48c3cc (diff)
downloadmanaverse-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')
-rw-r--r--src/client.cpp1
-rw-r--r--src/gui/logindialog.cpp34
-rw-r--r--src/gui/serverdialog.cpp7
-rw-r--r--src/net/logindata.h3
-rw-r--r--src/net/serverinfo.h3
5 files changed, 42 insertions, 6 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 8180b22c1..2ec9c183c 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1023,6 +1023,7 @@ int Client::gameExec()
{
mServerName = mCurrentServer.hostname;
initServerConfig(mCurrentServer.hostname);
+ loginData.registerUrl = mCurrentServer.registerUrl;
if (mOptions.username.empty())
{
if (loginData.remember)
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")
{
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 2f0610999..ec97b73c6 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -362,6 +362,7 @@ void ServerDialog::connectToSelectedServer()
mServerInfo->type = server.type;
mServerInfo->name = server.name;
mServerInfo->description = server.description;
+ mServerInfo->registerUrl = server.registerUrl;
mServerInfo->save = true;
if (chatLogger)
@@ -631,6 +632,11 @@ void ServerDialog::loadServers(const bool addNew)
server.description = reinterpret_cast<const char*>(
subNode->xmlChildrenNode->content);
}
+ else if (xmlNameEqual(subNode, "registerurl"))
+ {
+ server.registerUrl = reinterpret_cast<const char*>(
+ subNode->xmlChildrenNode->content);
+ }
}
server.version.first = gui->getFont()->getWidth(version);
@@ -648,6 +654,7 @@ void ServerDialog::loadServers(const bool addNew)
mServers[i].name = server.name;
mServers[i].version = server.version;
mServers[i].description = server.description;
+ mServers[i].registerUrl = server.registerUrl;
mServersListModel->setVersionString(i, version);
found = true;
break;
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 1aed31b19..ed29f7736 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -38,6 +38,7 @@ class LoginData final
updateType(0),
email(""),
captchaResponse(""),
+ registerUrl(""),
gender(GENDER_UNSPECIFIED),
remember(false),
registerLogin(false)
@@ -65,6 +66,7 @@ class LoginData final
std::string email;
std::string captchaResponse;
+ std::string registerUrl;
Gender gender;
@@ -84,6 +86,7 @@ class LoginData final
updateType = Upd_Normal;
email.clear();
captchaResponse.clear();
+ registerUrl.clear();
gender = GENDER_UNSPECIFIED;
lastLogin.clear();
resetCharacterSlots();
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index d58bd3286..ed9e699b0 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -50,6 +50,7 @@ public:
unsigned short port;
std::string description;
+ std::string registerUrl;
VersionString version;
bool save;
@@ -68,6 +69,7 @@ public:
hostname(info.hostname),
port(info.port),
description(info.description),
+ registerUrl(info.registerUrl),
save(info.save)
{
version.first = info.version.first;
@@ -86,6 +88,7 @@ public:
hostname.clear();
port = 0;
description.clear();
+ registerUrl.clear();
version.first = 0;
version.second.clear();
save = false;