summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/listeners/requesttradelistener.h51
-rw-r--r--src/net/ea/tradehandler.cpp14
4 files changed, 56 insertions, 11 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index aee55c68b..0089e923d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -876,6 +876,7 @@ SET(SRCS
listeners/playerrelationslistener.h
listeners/renamelistener.cpp
listeners/renamelistener.h
+ listeners/requesttradelistener.h
position.cpp
position.h
resources/map/properties.h
diff --git a/src/Makefile.am b/src/Makefile.am
index dc9bac05d..c0d6d8a31 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -982,6 +982,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
listeners/playerrelationslistener.h \
listeners/renamelistener.cpp \
listeners/renamelistener.h \
+ listeners/requesttradelistener.h \
position.cpp \
position.h \
resources/map/properties.h \
diff --git a/src/listeners/requesttradelistener.h b/src/listeners/requesttradelistener.h
new file mode 100644
index 000000000..54cbce8de
--- /dev/null
+++ b/src/listeners/requesttradelistener.h
@@ -0,0 +1,51 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * 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 "being/playerrelations.h"
+
+#include "gui/windows/confirmdialog.h"
+
+#include "net/tradehandler.h"
+
+#include "listeners/actionlistener.h"
+
+#include <string>
+
+#include "localconsts.h"
+
+extern std::string tradePartnerName;
+extern ConfirmDialog *confirmDlg;
+
+/**
+ * Listener for request trade dialogs
+ */
+struct RequestTradeListener final : public ActionListener
+{
+ void action(const ActionEvent &event)
+ {
+ confirmDlg = nullptr;
+ const std::string &eventId = event.getId();
+ if (eventId == "ignore")
+ player_relations.ignoreTrade(tradePartnerName);
+ Net::getTradeHandler()->respond(eventId == "yes");
+ }
+};
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 19e597967..48d80c9ee 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -39,6 +39,8 @@
#include "net/ea/eaprotocol.h"
+#include "listeners/requesttradelistener.h"
+
#include "debug.h"
extern std::string tradePartnerName;
@@ -49,17 +51,7 @@ ConfirmDialog *confirmDlg = nullptr;
*/
namespace
{
- struct RequestTradeListener : public ActionListener
- {
- void action(const ActionEvent &event)
- {
- confirmDlg = nullptr;
- const std::string &eventId = event.getId();
- if (eventId == "ignore")
- player_relations.ignoreTrade(tradePartnerName);
- Net::getTradeHandler()->respond(eventId == "yes");
- }
- } listener;
+ RequestTradeListener listener;
} // namespace
namespace Ea