diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-26 19:33:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-26 19:33:11 +0300 |
commit | 86735e142e86391e46b0eafbcb7ef01e25fc969a (patch) | |
tree | a717ba215baae052de204ed7b8e50b20c453882a /src | |
parent | d3f61bb7da045c7d0a955a3859aac713d1bfc6e7 (diff) | |
download | plus-86735e142e86391e46b0eafbcb7ef01e25fc969a.tar.gz plus-86735e142e86391e46b0eafbcb7ef01e25fc969a.tar.bz2 plus-86735e142e86391e46b0eafbcb7ef01e25fc969a.tar.xz plus-86735e142e86391e46b0eafbcb7ef01e25fc969a.zip |
Add support for getting attached items from mail message.
Diffstat (limited to 'src')
-rw-r--r-- | src/enums/resources/notifytypes.h | 1 | ||||
-rw-r--r-- | src/gui/windows/mailviewwindow.cpp | 36 | ||||
-rw-r--r-- | src/gui/windows/mailviewwindow.h | 6 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 11 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.h | 2 | ||||
-rw-r--r-- | src/net/eathena/mail2recv.cpp | 27 | ||||
-rw-r--r-- | src/resources/notifications.h | 4 |
7 files changed, 79 insertions, 8 deletions
diff --git a/src/enums/resources/notifytypes.h b/src/enums/resources/notifytypes.h index 643aaf2d1..6513c4f4f 100644 --- a/src/enums/resources/notifytypes.h +++ b/src/enums/resources/notifytypes.h @@ -244,6 +244,7 @@ namespace NotifyTypes MAIL_SEND_COUNT_ERROR, MAIL_SEND_ITEM_ERROR, MAIL_SEND_RECEIVER_ERROR, + MAIL_GET_ATTACH_FULL_ERROR, TYPE_END }; diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp index 56367ef78..b250fad43 100644 --- a/src/gui/windows/mailviewwindow.cpp +++ b/src/gui/windows/mailviewwindow.cpp @@ -23,6 +23,7 @@ #include "configuration.h" #include "settings.h" +#include "net/mail2handler.h" #include "net/mailhandler.h" #include "gui/mailmessage.h" @@ -54,7 +55,7 @@ MailViewWindow *mailViewWindow = nullptr; -MailViewWindow::MailViewWindow(const MailMessage *const message, +MailViewWindow::MailViewWindow(MailMessage *const message, const int itemsCount) : // TRANSLATORS: mail view window name Window(_("View mail"), Modal_false, nullptr, "mailview.xml"), @@ -128,7 +129,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message, mGetMoneyButton = new Button(this, // TRANSLATORS: mail view attached money button _("Get money"), - "attach", this); + "money", this); placer(0, n++, mGetMoneyButton); } placer(0, n++, mGetAttachButton); @@ -170,8 +171,23 @@ void MailViewWindow::action(const ActionEvent &event) } else if (eventId == "attach") { - if (mGetAttachButton != nullptr) + if (mUseMail2) + { + mail2Handler->requestItems(mailWindow->getOpenType(), + mMessage->id); + } + else + { mailHandler->getAttach(mMessage->id); + } + } + else if (eventId == "money") + { + if (mUseMail2) + { + mail2Handler->requestMoney(mailWindow->getOpenType(), + mMessage->id); + } } else if (eventId == "next") { @@ -221,3 +237,17 @@ void MailViewWindow::updateItems() mItemContainer->updateMatrix(); updateAttachButton(); } + +void MailViewWindow::removeItems(const int64_t mailId) +{ + if (mailId != mMessage->id) + return; + mInventory->clear(); + mMessage->type = static_cast<MailMessageType::Type>( + CAST_S32(mMessage->type) | CAST_S32(MailMessageType::Item)); + mMessage->type = static_cast<MailMessageType::Type>( + CAST_S32(mMessage->type) ^ CAST_S32(MailMessageType::Item)); + updateAttachButton(); + if (mailWindow) + mailWindow->refreshMailNames(); +} diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h index 524c029d4..13ad25676 100644 --- a/src/gui/windows/mailviewwindow.h +++ b/src/gui/windows/mailviewwindow.h @@ -38,7 +38,7 @@ class MailViewWindow final : public Window, public ActionListener { public: - MailViewWindow(const MailMessage *const message, + MailViewWindow(MailMessage *const message, const int itemsCount) A_NONNULL(2); A_DELETE_COPY(MailViewWindow) @@ -51,10 +51,12 @@ class MailViewWindow final : public Window, void updateItems(); + void removeItems(const int64_t mailId); + private: void updateAttachButton(); - const MailMessage *mMessage; + MailMessage *mMessage; Button *mGetAttachButton; Button *mGetMoneyButton; Button *mCloseButton; diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp index 18371b7ad..5536aecbc 100644 --- a/src/gui/windows/mailwindow.cpp +++ b/src/gui/windows/mailwindow.cpp @@ -375,3 +375,14 @@ void MailWindow::setLastPage() mLastPage = true; mReturnButton->setEnabled(false); } + +void MailWindow::refreshMailNames() +{ + mMailModel->clear(); + FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages) + { + MailMessage *message = *it; + if (message != nullptr) + mMailModel->add(getMailHeader(message)); + } +} diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h index 1639dfed0..6a310fb37 100644 --- a/src/gui/windows/mailwindow.h +++ b/src/gui/windows/mailwindow.h @@ -80,6 +80,8 @@ class MailWindow final : public Window, void setLastPage(); + void refreshMailNames(); + private: void refreshMails(); diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp index 1cb2a7f58..392e679d6 100644 --- a/src/net/eathena/mail2recv.cpp +++ b/src/net/eathena/mail2recv.cpp @@ -467,10 +467,31 @@ void Mail2Recv::processRequestMoney(Net::MessageIn &msg) void Mail2Recv::processRequestItems(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; - msg.readInt64("mail id"); + const int64_t mailId = msg.readInt64("mail id"); msg.readUInt8("open type"); - msg.readUInt8("result"); + const int res = msg.readUInt8("result"); + switch (res) + { + case 0: + NotifyManager::notify( + NotifyTypes::MAIL_GET_ATTACH_OK); + if (mailViewWindow) + mailViewWindow->removeItems(mailId); + break; + case 1: + NotifyManager::notify( + NotifyTypes::MAIL_GET_ATTACH_ERROR); + break; + case 2: + NotifyManager::notify( + NotifyTypes::MAIL_GET_ATTACH_FULL_ERROR); + break; + default: + UNIMPLEMENTEDPACKETFIELD(res); + NotifyManager::notify( + NotifyTypes::MAIL_GET_ATTACH_ERROR); + break; + } } } // namespace EAthena diff --git a/src/resources/notifications.h b/src/resources/notifications.h index a5b7a725f..08526bb81 100644 --- a/src/resources/notifications.h +++ b/src/resources/notifications.h @@ -893,6 +893,10 @@ namespace NotifyManager // TRANSLATORS: notification message N_("Mail send failed. Receiver name wrong or not checked."), NotifyFlags::EMPTY}, + {"mail get attach full error", + // TRANSLATORS: notification message + N_("Error on getting attach. No space or weight too high."), + NotifyFlags::EMPTY}, }; } // namespace NotifyManager #endif // RESOURCES_NOTIFICATIONS_H |