From e63db2551051c143681bdb6f254ad4d7d426772f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 2 Aug 2016 17:51:50 +0300 Subject: Remove unused unregister dialog and states for it. --- src/gui/windows/charselectdialog.cpp | 5 -- src/gui/windows/unregisterdialog.cpp | 165 ----------------------------------- src/gui/windows/unregisterdialog.h | 70 --------------- 3 files changed, 240 deletions(-) delete mode 100644 src/gui/windows/unregisterdialog.cpp delete mode 100644 src/gui/windows/unregisterdialog.h (limited to 'src/gui') diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 56b0c5930..860c27570 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -276,11 +276,6 @@ void CharSelectDialog::action(const ActionEvent &event) { client->setState(State::CHANGEEMAIL); } - else if (eventId == "unregister") - { - charServerHandler->clear(); - client->setState(State::UNREGISTER); - } else if (eventId == "try delete character") { if (mDeleteDialog && mDeleteIndex != -1) diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp deleted file mode 100644 index 849ff16a3..000000000 --- a/src/gui/windows/unregisterdialog.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2016 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/windows/unregisterdialog.h" - -#include "client.h" - -#include "gui/windows/okdialog.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/label.h" -#include "gui/widgets/passwordfield.h" - -#include "listeners/wrongdatanoticelistener.h" - -#include "net/logindata.h" -#include "net/loginhandler.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include - -#include "debug.h" - -UnRegisterDialog::UnRegisterDialog(LoginData &data) : - // TRANSLATORS: unregister dialog name - Window(_("Unregister"), Modal_true, nullptr, "unregister.xml"), - ActionListener(), - mLoginData(&data), - mPasswordField(new PasswordField(this, mLoginData->password)), - // TRANSLATORS: unregister dialog. button. - mUnRegisterButton(new Button(this, _("Unregister"), "unregister", this)), - // TRANSLATORS: unregister dialog. button. - mCancelButton(new Button(this, _("Cancel"), "cancel", this)), - mWrongDataNoticeListener(new WrongDataNoticeListener) -{ -} - -void UnRegisterDialog::postInit() -{ - Window::postInit(); - // TRANSLATORS: unregister dialog. label. - Label *const userLabel = new Label(this, strprintf(_("Name: %s"), - mLoginData->username.c_str())); - // TRANSLATORS: unregister dialog. label. - Label *const passwordLabel = new Label(this, _("Password:")); - - const int width = 210; - const int height = 80; - setContentSize(width, height); - - userLabel->setPosition(5, 5); - userLabel->setWidth(width - 5); - mPasswordField->setPosition( - 68, userLabel->getY() + userLabel->getHeight() + 7); - mPasswordField->setWidth(130); - - passwordLabel->setPosition(5, mPasswordField->getY() + 1); - - mCancelButton->setPosition( - width - 5 - mCancelButton->getWidth(), - height - 5 - mCancelButton->getHeight()); - mUnRegisterButton->setPosition( - mCancelButton->getX() - 5 - mUnRegisterButton->getWidth(), - mCancelButton->getY()); - - add(userLabel); - add(passwordLabel); - add(mPasswordField); - add(mUnRegisterButton); - add(mCancelButton); - - center(); - setVisible(Visible_true); - mPasswordField->requestFocus(); - mPasswordField->setActionEventId("cancel"); -} - -UnRegisterDialog::~UnRegisterDialog() -{ - delete2(mWrongDataNoticeListener); -} - -void UnRegisterDialog::action(const ActionEvent &event) -{ - const std::string &eventId = event.getId(); - if (eventId == "cancel") - { - client->setState(State::CHAR_SELECT); - } - else if (eventId == "unregister") - { - const std::string username = mLoginData->username; - const std::string &password = mPasswordField->getText(); - logger->log("UnregisterDialog::unregistered, Username is %s", - username.c_str()); - - std::stringstream errorMsg; - bool error = false; - - const unsigned int min = loginHandler->getMinPasswordLength(); - const unsigned int max = loginHandler->getMaxPasswordLength(); - - if (password.length() < min) - { - // TRANSLATORS: unregister dialog. error message. - errorMsg << strprintf(_("The password needs to be at least %u " - "characters long."), min); - error = true; - } - else if (password.length() > max) - { - // TRANSLATORS: unregister dialog. error message. - errorMsg << strprintf(_("The password needs to be less than " - "%u characters long."), max); - error = true; - } - - if (error) - { - mWrongDataNoticeListener->setTarget(this->mPasswordField); - - OkDialog *const dlg = CREATEWIDGETR(OkDialog, - // TRANSLATORS: unregister dialog. error message. - _("Error"), - errorMsg.str(), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::ERROR, - Modal_true, - ShowCenter_true, - nullptr, - 260); - dlg->addActionListener(mWrongDataNoticeListener); - } - else - { - // No errors detected, unregister the new user. - mUnRegisterButton->setEnabled(false); - mLoginData->password = password; - client->setState(State::UNREGISTER_ATTEMPT); - } - } -} diff --git a/src/gui/windows/unregisterdialog.h b/src/gui/windows/unregisterdialog.h deleted file mode 100644 index aaba439ad..000000000 --- a/src/gui/windows/unregisterdialog.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2016 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WINDOWS_UNREGISTERDIALOG_H -#define GUI_WINDOWS_UNREGISTERDIALOG_H - -#include "gui/widgets/window.h" - -#include "listeners/actionlistener.h" - -class Button; -class LoginData; -class TextField; -class WrongDataNoticeListener; - -/** - * The Unregister dialog. - * - * \ingroup Interface - */ -class UnRegisterDialog final : public Window, - public ActionListener -{ - public: - /** - * Constructor - * - * @see Window::Window - */ - explicit UnRegisterDialog(LoginData &loginData); - - A_DELETE_COPY(UnRegisterDialog) - - ~UnRegisterDialog(); - - void postInit() override final; - - /** - * Called when receiving actions from the widgets. - */ - void action(const ActionEvent &event) override final; - - private: - LoginData *mLoginData A_NONNULLPOINTER; - TextField *mPasswordField A_NONNULLPOINTER; - Button *mUnRegisterButton A_NONNULLPOINTER; - Button *mCancelButton A_NONNULLPOINTER; - WrongDataNoticeListener *mWrongDataNoticeListener A_NONNULLPOINTER; -}; - -#endif // GUI_WINDOWS_UNREGISTERDIALOG_H -- cgit v1.2.3-60-g2f50