diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-04-29 21:36:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-04-29 21:36:44 +0300 |
commit | 600c370ed33ec9828ef609d68a8e46d564f0f1af (patch) | |
tree | 21b6ee1a0250dfa123858a53bfe991cba33af01a | |
parent | 8e0bbcbabb8752d8c28618e98a1ea46309252f3a (diff) | |
download | mv-600c370ed33ec9828ef609d68a8e46d564f0f1af.tar.gz mv-600c370ed33ec9828ef609d68a8e46d564f0f1af.tar.bz2 mv-600c370ed33ec9828ef609d68a8e46d564f0f1af.tar.xz mv-600c370ed33ec9828ef609d68a8e46d564f0f1af.zip |
eathena: impliment packet SMSG_MAIL_RETURN.
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 31 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.h | 2 | ||||
-rw-r--r-- | src/net/eathena/mailhandler.cpp | 15 | ||||
-rw-r--r-- | src/resources/notifications.h | 8 | ||||
-rw-r--r-- | src/resources/notifytypes.h | 2 |
5 files changed, 54 insertions, 4 deletions
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp index 15faf779a..ecef7b54e 100644 --- a/src/gui/windows/mailwindow.cpp +++ b/src/gui/windows/mailwindow.cpp @@ -164,6 +164,37 @@ void MailWindow::addMail(MailMessage *const message) mMessagesMap[message->id] = message; } +void MailWindow::removeMail(const int id) +{ + std::map<int, MailMessage*>::iterator it1 = mMessagesMap.find(id); + if (it1 != mMessagesMap.end()) + mMessagesMap.erase(it1); + + mMailModel->clear(); + + FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages) + { + MailMessage *message = *it; + if (message && message->id == id) + { + mMessages.erase(it); + delete message; + break; + } + } + + FOR_EACH (std::vector<MailMessage*>::iterator, it, mMessages) + { + MailMessage *message = *it; + if (message) + { + mMailModel->add(strprintf("%s %s", + message->unread ? " " : "U", + message->title.c_str())); + } + } +} + void MailWindow::showMessage(MailMessage *const mail) { if (!mail) diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h index 15964aafe..23f89be0a 100644 --- a/src/gui/windows/mailwindow.h +++ b/src/gui/windows/mailwindow.h @@ -56,6 +56,8 @@ class MailWindow final : public Window, void showMessage(MailMessage *const mail); + void removeMail(const int id); + private: std::vector<MailMessage*> mMessages; std::map<int, MailMessage*> mMessagesMap; diff --git a/src/net/eathena/mailhandler.cpp b/src/net/eathena/mailhandler.cpp index bebd4b10b..e40d34e17 100644 --- a/src/net/eathena/mailhandler.cpp +++ b/src/net/eathena/mailhandler.cpp @@ -227,10 +227,17 @@ void MailHandler::processDeleteAck(Net::MessageIn &msg) void MailHandler::processMailReturn(Net::MessageIn &msg) { - UNIMPLIMENTEDPACKET; - - msg.readInt32("message id"); - msg.readInt16("fail flag"); + const int mail = msg.readInt32("message id"); + const int flag = msg.readInt16("fail flag"); + if (flag) + { + NotifyManager::notify(NotifyTypes::MAIL_RETURN_ERROR); + } + else + { + NotifyManager::notify(NotifyTypes::MAIL_RETURN_OK); + mailWindow->removeMail(mail); + } } void MailHandler::refresh() diff --git a/src/resources/notifications.h b/src/resources/notifications.h index 7c864325b..0aa9d1c08 100644 --- a/src/resources/notifications.h +++ b/src/resources/notifications.h @@ -583,6 +583,14 @@ namespace NotifyManager // TRANSLATORS: notification message N_("Money attach failed."), NotifyFlags::EMPTY}, + {"mail return error", + // TRANSLATORS: notification message + N_("Message return failed."), + NotifyFlags::EMPTY}, + {"mail return ok", + // TRANSLATORS: notification message + N_("Message return success."), + NotifyFlags::EMPTY}, }; } // namespace NotifyManager #endif // RESOURCES_NOTIFICATIONS_H diff --git a/src/resources/notifytypes.h b/src/resources/notifytypes.h index cdd6a22d0..36792b6b9 100644 --- a/src/resources/notifytypes.h +++ b/src/resources/notifytypes.h @@ -164,6 +164,8 @@ namespace NotifyTypes MAIL_SEND_ERROR, MAIL_ATTACH_ITEM_ERROR, MAIL_ATTACH_MONEY_ERROR, + MAIL_RETURN_ERROR, + MAIL_RETURN_OK, TYPE_END }; |