summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-31 16:53:06 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:54 +0300
commit8ad8da325107ef1b33bd6c3ed985859e7edb78ae (patch)
tree3dd76adef5e6dbe7da8db925ffa42ebbf21eb638 /src
parent8cc52b6e9cf46643cc6300df844e70b8dcb85212 (diff)
downloadmv-8ad8da325107ef1b33bd6c3ed985859e7edb78ae.tar.gz
mv-8ad8da325107ef1b33bd6c3ed985859e7edb78ae.tar.bz2
mv-8ad8da325107ef1b33bd6c3ed985859e7edb78ae.tar.xz
mv-8ad8da325107ef1b33bd6c3ed985859e7edb78ae.zip
add basic implimentation for set pincode.
For now it not sending pincode to server.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/client.cpp1
-rw-r--r--src/gui/windows/charselectdialog.cpp10
-rw-r--r--src/listeners/pincodelistener.cpp37
-rw-r--r--src/listeners/pincodelistener.h36
-rw-r--r--src/net/charserverhandler.h2
-rw-r--r--src/net/eathena/charserverhandler.cpp18
-rw-r--r--src/net/eathena/charserverhandler.h7
-rw-r--r--src/net/tmwa/charserverhandler.h3
10 files changed, 114 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 16f20e6c3..e51b6b274 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1065,6 +1065,8 @@ SET(SRCS
events/mouseeventtype.h
listeners/mouselistener.h
listeners/openurllistener.h
+ listeners/pincodelistener.cpp
+ listeners/pincodelistener.h
listeners/playerdeathlistener.h
listeners/playerlistener.cpp
listeners/playerlistener.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 0d93d6be8..b0e559a49 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -203,6 +203,8 @@ manaplus_SOURCES += events/actionevent.h \
events/mouseeventtype.h \
listeners/mouselistener.h \
listeners/openurllistener.h \
+ listeners/pincodelistener.cpp \
+ listeners/pincodelistener.h \
listeners/playerdeathlistener.h \
listeners/playerlistener.cpp \
listeners/playerlistener.h \
diff --git a/src/client.cpp b/src/client.cpp
index a816c8f1c..53115528f 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -972,6 +972,7 @@ int Client::gameExec()
// Get rid of the dialog of the previous state
delete2(mCurrentDialog);
+
// State has changed, while the quitDialog was active, it might
// not be correct anymore
if (mQuitDialog)
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 134aa2712..2d45e47ca 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -32,10 +32,13 @@
#include "being/attributes.h"
+#include "listeners/pincodelistener.h"
+
#include "gui/dialogtype.h"
#include "gui/windows/charcreatedialog.h"
#include "gui/windows/chardeleteconfirm.h"
+#include "gui/windows/editdialog.h"
#include "gui/windows/logindialog.h"
#include "gui/windows/okdialog.h"
#include "gui/windows/textdialog.h"
@@ -177,6 +180,13 @@ void CharSelectDialog::postInit()
{
setVisible(true);
requestFocus();
+ if (Net::getCharServerHandler()->isNeedCreatePin())
+ {
+ EditDialog *const dialog = new EditDialog(
+ _("Please set new pincode"), "", "OK");
+ dialog->postInit();
+ dialog->addActionListener(&pincodeListener);
+ }
}
void CharSelectDialog::action(const ActionEvent &event)
diff --git a/src/listeners/pincodelistener.cpp b/src/listeners/pincodelistener.cpp
new file mode 100644
index 000000000..7c9c20b71
--- /dev/null
+++ b/src/listeners/pincodelistener.cpp
@@ -0,0 +1,37 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "listeners/pincodelistener.h"
+
+#include "gui/windows/editdialog.h"
+
+#include "debug.h"
+
+PincodeListener pincodeListener;
+
+void PincodeListener::action(const ActionEvent &event)
+{
+ EditDialog *const dialog = dynamic_cast<EditDialog*>(event.getSource());
+ if (dialog)
+ {
+ const std::string pincode = dialog->getMsg();
+ // here need send pin code to server
+ }
+}
diff --git a/src/listeners/pincodelistener.h b/src/listeners/pincodelistener.h
new file mode 100644
index 000000000..3045db549
--- /dev/null
+++ b/src/listeners/pincodelistener.h
@@ -0,0 +1,36 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LISTENERS_PINCODELISTENER_H
+#define LISTENERS_PINCODELISTENER_H
+
+#include "listeners/actionlistener.h"
+
+#include "localconsts.h"
+
+class PincodeListener final : public ActionListener
+{
+ public:
+ void action(const ActionEvent &event) override final;
+};
+
+extern PincodeListener pincodeListener;
+
+#endif // LISTENERS_PINCODELISTENER_H
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index 8f78905c6..6a0125e1d 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -73,6 +73,8 @@ class CharServerHandler notfinal
virtual void clear() = 0;
+ virtual bool isNeedCreatePin() const = 0;
+
protected:
CharServerHandler() :
mCharacters(),
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index af3c012dd..7d6e2e74c 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -28,6 +28,8 @@
#include "being/attributes.h"
+#include "gui/windows/editdialog.h"
+
#include "net/character.h"
#include "net/logindata.h"
#include "net/net.h"
@@ -45,6 +47,9 @@
#include "resources/db/itemdb.h"
#include "utils/dtor.h"
+#include "utils/gettext.h"
+
+#include "listeners/pincodelistener.h"
#include "debug.h"
@@ -58,7 +63,9 @@ extern ServerInfo mapServer;
CharServerHandler::CharServerHandler() :
MessageHandler(),
- Ea::CharServerHandler()
+ Ea::CharServerHandler(),
+ mPinSeed(0),
+ mNeedCreatePin(false)
{
static const uint16_t _messages[] =
{
@@ -378,7 +385,7 @@ void CharServerHandler::processChangeMapServer(Net::MessageIn &msg)
void CharServerHandler::processPincodeStatus(Net::MessageIn &msg)
{
- msg.readInt32("pincode seed");
+ const uint32_t seed = msg.readInt32("pincode seed");
msg.readInt32("account id");
const uint16_t state = static_cast<uint16_t>(msg.readInt16("state"));
switch (state)
@@ -388,11 +395,14 @@ void CharServerHandler::processPincodeStatus(Net::MessageIn &msg)
case 1: // ask for pin
break;
case 2: // create new pin
+ case 4: // create new pin?
+ {
+ mPinSeed = seed;
+ mNeedCreatePin = true;
break;
+ }
case 3: // pin must be changed
break;
- case 4: // create new pin?
- break;
case 5: // client show error?
break;
case 6: // Unable to use your KSSN number
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
index 9a58a50e7..e647a6d60 100644
--- a/src/net/eathena/charserverhandler.h
+++ b/src/net/eathena/charserverhandler.h
@@ -63,12 +63,19 @@ class CharServerHandler final : public MessageHandler,
void processChangeMapServer(Net::MessageIn &msg);
+ bool isNeedCreatePin() const A_WARN_UNUSED
+ { return mNeedCreatePin; }
+
protected:
void readPlayerData(Net::MessageIn &msg,
Net::Character *const character,
const bool) const override final;
void processPincodeStatus(Net::MessageIn &msg);
+
+ private:
+ uint32_t mPinSeed;
+ bool mNeedCreatePin;
};
} // namespace EAthena
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index 062360800..35a4585e3 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -63,6 +63,9 @@ class CharServerHandler final : public MessageHandler,
void processChangeMapServer(Net::MessageIn &msg);
+ bool isNeedCreatePin() const
+ { return false; }
+
protected:
void readPlayerData(Net::MessageIn &msg,
Net::Character *const character,