summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/logindialog.cpp34
-rw-r--r--src/gui/serverdialog.cpp7
2 files changed, 35 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")
{
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;