summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-23 20:34:31 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-23 20:55:58 +0300
commit79864826790a33a3583819fe02893eed010381d9 (patch)
tree33b90cf3613900c9de45715e5fea69a721d26f10 /src
parent4da8a6304b5b7bb4d2b655ed3471c0ff4a7d610a (diff)
downloadplus-79864826790a33a3583819fe02893eed010381d9.tar.gz
plus-79864826790a33a3583819fe02893eed010381d9.tar.bz2
plus-79864826790a33a3583819fe02893eed010381d9.tar.xz
plus-79864826790a33a3583819fe02893eed010381d9.zip
Add mailqueuetype enum for mail queue types.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/actions/commands.cpp8
-rw-r--r--src/enums/resources/mailqueuetype.h35
-rw-r--r--src/net/eathena/mail2handler.cpp15
-rw-r--r--src/net/eathena/mail2handler.h9
-rw-r--r--src/net/eathena/mail2recv.cpp22
-rw-r--r--src/net/mail2handler.h11
-rw-r--r--src/net/tmwa/mail2handler.cpp10
-rw-r--r--src/net/tmwa/mail2handler.h9
-rw-r--r--src/resources/mailqueue.h6
11 files changed, 86 insertions, 41 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6ef09d849..71ab89d2b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -701,6 +701,7 @@ SET(SRCS
enums/resources/frametype.h
enums/resources/imageposition.h
enums/resources/imagetype.h
+ enums/resources/mailqueuetype.h
enums/resources/map/maplayertype.h
enums/resources/item/itemdbtype.h
enums/resources/item/itemsoundevent.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 3e498f10c..455274823 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1459,6 +1459,7 @@ SRC = ${BASE_SRC} \
enums/resources/frametype.h \
enums/resources/imageposition.h \
enums/resources/imagetype.h \
+ enums/resources/mailqueuetype.h \
enums/resources/map/maplayertype.h \
enums/resources/item/itemdbtype.h \
enums/resources/item/itemsoundevent.h \
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 18560f8df..557d7891a 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -567,14 +567,12 @@ impHandler(sendMail)
{
if (settings.enableNewMailSystem)
{
- if (mail2Handler->queueSendMail(name,
+ mail2Handler->queueCheckName(MailQueueType::SendMail,
+ name,
// TRANSLATORS: quick mail message caption
_("Quick message"),
text,
- 0))
- {
- mail2Handler->requestCheckName(name);
- }
+ 0);
}
else
{
diff --git a/src/enums/resources/mailqueuetype.h b/src/enums/resources/mailqueuetype.h
new file mode 100644
index 000000000..c4fb6162f
--- /dev/null
+++ b/src/enums/resources/mailqueuetype.h
@@ -0,0 +1,35 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012-2017 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 ENUMS_RESOURCES_MAILQUEUETYPE_H
+#define ENUMS_RESOURCES_MAILQUEUETYPE_H
+
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(MailQueueType)
+{
+ Unknown = 0,
+ SendMail = 1,
+ EditMail = 2,
+ ValidateTO = 3
+}
+enumEnd(MailQueueType);
+
+#endif // ENUMS_RESOURCES_MAILQUEUETYPE_H
diff --git a/src/net/eathena/mail2handler.cpp b/src/net/eathena/mail2handler.cpp
index f3ed3201d..1b19e4823 100644
--- a/src/net/eathena/mail2handler.cpp
+++ b/src/net/eathena/mail2handler.cpp
@@ -140,21 +140,20 @@ void Mail2Handler::sendMail(const std::string &to,
outMsg.writeString(body, bodySz, "body");
}
-bool Mail2Handler::queueSendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const
+void Mail2Handler::queueCheckName(const MailQueueTypeT type,
+ const std::string &to,
+ const std::string &title,
+ const std::string &body,
+ const int64_t &money) const
{
- if (!Mail2Recv::mMailQueue.empty())
- return false;
MailQueue *const mail = new MailQueue;
mail->to = to;
mail->title = title;
mail->body = body;
mail->money = money;
- mail->sendMail = true;
+ mail->type = type;
Mail2Recv::mMailQueue.push(mail);
- return true;
+ requestCheckName(to);
}
void Mail2Handler::nextPage(const MailOpenTypeT openType,
diff --git a/src/net/eathena/mail2handler.h b/src/net/eathena/mail2handler.h
index 8e450da9d..0b7957375 100644
--- a/src/net/eathena/mail2handler.h
+++ b/src/net/eathena/mail2handler.h
@@ -48,10 +48,11 @@ class Mail2Handler final : public Net::Mail2Handler
const std::string &body,
const int64_t &money) const override final;
- bool queueSendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const override final;
+ void queueCheckName(const MailQueueTypeT type,
+ const std::string &to,
+ const std::string &title,
+ const std::string &body,
+ const int64_t &money) const override final;
void nextPage(const MailOpenTypeT openType,
const int64_t mailId) const override final;
diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp
index 1af7d47e2..04f7751a3 100644
--- a/src/net/eathena/mail2recv.cpp
+++ b/src/net/eathena/mail2recv.cpp
@@ -116,16 +116,20 @@ void Mail2Recv::processCheckNameResult(Net::MessageIn &msg)
delete mail;
return;
}
- if (mail->sendMail)
+ switch (mail->type)
{
- mail2Handler->sendMail(mail->to,
- mail->title,
- mail->body,
- mail->money);
- }
- else
- {
- reportAlways("Not implemented yet.");
+ case MailQueueType::SendMail:
+ mail2Handler->sendMail(mail->to,
+ mail->title,
+ mail->body,
+ mail->money);
+ break;
+ case MailQueueType::Unknown:
+ case MailQueueType::EditMail:
+ case MailQueueType::ValidateTO:
+ default:
+ reportAlways("Not implemented yet.");
+ break;
}
delete mail;
}
diff --git a/src/net/mail2handler.h b/src/net/mail2handler.h
index 2fd0f594c..47b441f77 100644
--- a/src/net/mail2handler.h
+++ b/src/net/mail2handler.h
@@ -23,6 +23,8 @@
#include "enums/net/mailopentype.h"
+#include "enums/resources/mailqueuetype.h"
+
#include <string>
#include "localconsts.h"
@@ -56,10 +58,11 @@ class Mail2Handler notfinal
const std::string &body,
const int64_t &money) const = 0;
- virtual bool queueSendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const = 0;
+ virtual void queueCheckName(const MailQueueTypeT type,
+ const std::string &to,
+ const std::string &title,
+ const std::string &body,
+ const int64_t &money) const = 0;
virtual void nextPage(const MailOpenTypeT openType,
const int64_t mailId) const = 0;
diff --git a/src/net/tmwa/mail2handler.cpp b/src/net/tmwa/mail2handler.cpp
index b964af8cd..d79e9585e 100644
--- a/src/net/tmwa/mail2handler.cpp
+++ b/src/net/tmwa/mail2handler.cpp
@@ -56,12 +56,12 @@ void Mail2Handler::sendMail(const std::string &to A_UNUSED,
{
}
-bool Mail2Handler::queueSendMail(const std::string &to A_UNUSED,
- const std::string &title A_UNUSED,
- const std::string &body A_UNUSED,
- const int64_t &money A_UNUSED) const
+void Mail2Handler::queueCheckName(const MailQueueTypeT type A_UNUSED,
+ const std::string &to A_UNUSED,
+ const std::string &title A_UNUSED,
+ const std::string &body A_UNUSED,
+ const int64_t &money A_UNUSED) const
{
- return false;
}
void Mail2Handler::nextPage(const MailOpenTypeT openType A_UNUSED,
diff --git a/src/net/tmwa/mail2handler.h b/src/net/tmwa/mail2handler.h
index 6a3b1639b..e39e99347 100644
--- a/src/net/tmwa/mail2handler.h
+++ b/src/net/tmwa/mail2handler.h
@@ -48,10 +48,11 @@ class Mail2Handler final : public Net::Mail2Handler
const std::string &body,
const int64_t &money) const override final;
- bool queueSendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const override final;
+ void queueCheckName(const MailQueueTypeT type,
+ const std::string &to,
+ const std::string &title,
+ const std::string &body,
+ const int64_t &money) const override final;
void nextPage(const MailOpenTypeT openType,
const int64_t mailId) const override final;
diff --git a/src/resources/mailqueue.h b/src/resources/mailqueue.h
index bf694ad91..6f8fe83ff 100644
--- a/src/resources/mailqueue.h
+++ b/src/resources/mailqueue.h
@@ -21,6 +21,8 @@
#ifndef RESOURCES_MAILQUEUE_H
#define RESOURCES_MAILQUEUE_H
+#include "enums/resources/mailqueuetype.h"
+
#include "localconsts.h"
#include <string>
@@ -32,7 +34,7 @@ struct MailQueue final
title(),
body(),
money(0),
- sendMail(false)
+ type(MailQueueType::Unknown)
{ }
A_DELETE_COPY(MailQueue)
@@ -41,7 +43,7 @@ struct MailQueue final
std::string title;
std::string body;
int money;
- bool sendMail;
+ MailQueueTypeT type;
};
#endif // RESOURCES_MAILQUEUE_H