From 9d4a19f37f13aa7d142774a90fd5fa57f3ba2d94 Mon Sep 17 00:00:00 2001 From: Denis Dolzhenko Date: Fri, 16 Sep 2016 12:23:01 +0300 Subject: [PATCH] TizenRefApp-6847 Notification not displayed when resending message in DPM Change-Id: I91f54ada2eb9f54f589e3a1ecd17f6a38a8f7507 Signed-off-by: Denis Dolzhenko --- .../ConvList/Controller/inc/ConvList.h | 2 + .../ConvList/Controller/inc/ConvListItem.h | 2 +- .../ConvList/Controller/src/ConvList.cpp | 6 + .../ConvList/Controller/src/ConvListItem.cpp | 13 +- .../Main/Controller/inc/Conversation.h | 6 +- .../Main/Controller/src/Conversation.cpp | 143 +++++++++++++----- 6 files changed, 121 insertions(+), 51 deletions(-) diff --git a/src/Conversation/ConvList/Controller/inc/ConvList.h b/src/Conversation/ConvList/Controller/inc/ConvList.h index 661d541b..35d4086d 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvList.h +++ b/src/Conversation/ConvList/Controller/inc/ConvList.h @@ -167,6 +167,7 @@ namespace Msg // IConvListItemListener: virtual void onEditDraftMsg(ConvListItem &item); virtual void onForwardMsg(ConvListItem &item); + virtual void onResendMsg(ConvListItem &item); virtual void onSlideShow(ConvListItem &item); // IContactManagerListener: @@ -208,6 +209,7 @@ namespace Msg virtual void onEditDraftMsg(MsgId id) {}; virtual void onForwardMsg(MsgId id) {}; virtual void onConvListItemChecked() {}; + virtual void onResendMsg(MsgId id) {}; }; } diff --git a/src/Conversation/ConvList/Controller/inc/ConvListItem.h b/src/Conversation/ConvList/Controller/inc/ConvListItem.h index bf88213c..4dd42774 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvListItem.h +++ b/src/Conversation/ConvList/Controller/inc/ConvListItem.h @@ -119,7 +119,6 @@ namespace Msg void onCancelButtonClicked(Popup &popup, int buttonId); void onFailedResendButtonClicked(Popup &popup, int buttonId); void onDeleteButtonClicked(Popup &popup, int buttonId); - void onPopupDel(Evas_Object *popup, void *eventInfo); // IBubbleViewItemListener virtual void onAction(BubbleViewItem &item); @@ -146,6 +145,7 @@ namespace Msg virtual ~IConvListItemListener() {} virtual void onEditDraftMsg(ConvListItem &item) {}; virtual void onForwardMsg(ConvListItem &item) {}; + virtual void onResendMsg(ConvListItem &item) {}; virtual void onSlideShow(ConvListItem &item) {}; }; } diff --git a/src/Conversation/ConvList/Controller/src/ConvList.cpp b/src/Conversation/ConvList/Controller/src/ConvList.cpp index ed6c5376..3e943c62 100644 --- a/src/Conversation/ConvList/Controller/src/ConvList.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvList.cpp @@ -415,6 +415,12 @@ void ConvList::onSlideShow(ConvListItem &item) m_pListener->onSlideShow(item.getMsgId()); } +void ConvList::onResendMsg(ConvListItem &item) +{ + if(m_pListener) + m_pListener->onResendMsg(item.getMsgId()); +} + void ConvList::onEditDraftMsg(ConvListItem &item) { if(m_pListener) diff --git a/src/Conversation/ConvList/Controller/src/ConvListItem.cpp b/src/Conversation/ConvList/Controller/src/ConvListItem.cpp index d654e3b2..4a7ee275 100644 --- a/src/Conversation/ConvList/Controller/src/ConvListItem.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvListItem.cpp @@ -394,7 +394,6 @@ void ConvListItem::showDraftListPopup() void ConvListItem::showFailedToSendPopup() { Popup &popup = m_App.getPopupManager().getPopup(); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(ConvListItem, onPopupDel), this); popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this); popup.addButton(msgt("IDS_MSG_BUTTON_RESEND_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onFailedResendButtonClicked), this); popup.setTitle(msgt("IDS_MSG_HEADER_COULDNT_SEND_MESSAGE_ABB")); @@ -406,7 +405,6 @@ void ConvListItem::onDeleteItemPressed(PopupListItem &item) { item.getParent().destroy(); Popup &popup = m_App.getPopupManager().getPopup(); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(ConvListItem, onPopupDel), this); popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this); popup.addButton(msgt("IDS_MSG_BUTTON_DELETE_ABB4"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onDeleteButtonClicked), this); popup.setTitle(msgt("IDS_MSG_HEADER_DELETE")); @@ -556,11 +554,9 @@ void ConvListItem::onCancelButtonClicked(Popup &popup, int buttonId) void ConvListItem::onFailedResendButtonClicked(Popup &popup, int buttonId) { MSG_LOG(""); - MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId); - if(msg) - m_App.getMsgEngine().getTransport().sendMessage(msg); - popup.destroy(); + if(m_pListener) + m_pListener->onResendMsg(*this); } void ConvListItem::onDeleteButtonClicked(Popup &popup, int buttonId) @@ -568,8 +564,3 @@ void ConvListItem::onDeleteButtonClicked(Popup &popup, int buttonId) m_App.getMsgEngine().getStorage().deleteMessage(getMsgId()); popup.destroy(); } - -void ConvListItem::onPopupDel(Evas_Object *popup, void *eventInfo) -{ - MSG_LOG(""); -} diff --git a/src/Conversation/Main/Controller/inc/Conversation.h b/src/Conversation/Main/Controller/inc/Conversation.h index 3c84ef84..d5487738 100644 --- a/src/Conversation/Main/Controller/inc/Conversation.h +++ b/src/Conversation/Main/Controller/inc/Conversation.h @@ -132,6 +132,7 @@ namespace Msg virtual void onAllConvItemsDeleted(ConvList &list); virtual void onEditDraftMsg(MsgId id); virtual void onForwardMsg(MsgId id); + virtual void onResendMsg(MsgId id); virtual void onSlideShow(MsgId id); virtual void onConvListItemChecked(); @@ -181,11 +182,14 @@ namespace Msg void showMainPopup(); void showNoRecipPopup(); PopupList &createPopupList(const std::string &title); - void showSendResultPopup(MsgTransport::SendResult result); void showMobileDataPopup(); + void showSendDpmNotif(const MsgAddressList &addressList); void showUnsavedRecipientPopup(const std::string &address); void showSavedRecipientPopup(const std::string &title, int contactId, ContactAddress::OwnerType ownerType); + void sendMessage(MsgId msgId); void sendMessage(); + bool checkBeforeSend(const Message &msg); + void handleSendResult(const Message &msg, MsgTransport::SendResult result); bool read(Message &msg); bool readMsgAddress(Message &msg); void write(const Message &msg); diff --git a/src/Conversation/Main/Controller/src/Conversation.cpp b/src/Conversation/Main/Controller/src/Conversation.cpp index af71d1e6..ba34840d 100644 --- a/src/Conversation/Main/Controller/src/Conversation.cpp +++ b/src/Conversation/Main/Controller/src/Conversation.cpp @@ -55,6 +55,19 @@ std::string makeKbStr(long long bytes) return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB"); } +namespace +{ + std::string makeDispAddress(std::string address, std::string dispName) + { + if(dispName.empty()) + return std::move(address); + std::string res = std::move(dispName); + res += " ("; + res += std::move(address) + ')'; + return res; + } +} + Conversation::Conversation(NaviFrameController &parent) : FrameController(parent) , m_Mode(InitMode) @@ -519,30 +532,68 @@ bool Conversation::readMsgAddress(Message &msg) return res; } -void Conversation::sendMessage() +void Conversation::handleSendResult(const Message &msg, MsgTransport::SendResult result) { - if(m_pRecipPanel && - m_pRecipPanel->getEntryFocus() && - !m_pRecipPanel->getEntryText().empty() && - !m_pRecipPanel->addRecipientsFromEntry()) + if(result == MsgTransport::SendSuccess) + return; + + const char *strId = nullptr; + switch(result) + { + case MsgTransport::SendNoSIM: + strId = "IDS_MSG_BODY_UNABLE_TO_SEND_THIS_MESSAGE_INSERT_YOUR_SIM_CARD_AND_TRY_AGAIN"; + break; + case MsgTransport::SendDPMRestricted: + showSendDpmNotif(msg.getAddressList()); return; + default: + strId = "IDS_MSGC_BODY_UNABLE_TO_SEND_MESSAGE"; + }; + auto &popupMngr = getApp().getPopupManager(); + Popup &popup = popupMngr.getPopup(); + popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this); + popup.setContent(msgt(strId)); + popup.show(); +} +bool Conversation::checkBeforeSend(const Message &msg) +{ if(!getApp().getSysSettingsManager().isSimInserted()) { - showSendResultPopup(MsgTransport::SendNoSIM); - return; + handleSendResult(msg, MsgTransport::SendNoSIM); // Show no SIM card + return false; } - if(m_IsMms && !getApp().getSysSettingsManager().isMobileDataEnabled()) + if(msg.isMms() && !getApp().getSysSettingsManager().isMobileDataEnabled()) { showMobileDataPopup(); - return; + return false; } - auto msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS); + return true; +} + +void Conversation::sendMessage(MsgId msgId) +{ + MessageRef msg = getMsgEngine().getStorage().getMessage(msgId); + if(msg && checkBeforeSend(*msg)) + { + auto sentRes = getMsgEngine().getTransport().sendMessage(msg); + handleSendResult(*msg, sentRes); + } +} + +void Conversation::sendMessage() +{ + if(m_pRecipPanel && + m_pRecipPanel->getEntryFocus() && + !m_pRecipPanel->getEntryText().empty() && + !m_pRecipPanel->addRecipientsFromEntry()) + return; - if(!read(*msg)) + auto msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS); + if(!msg || !read(*msg) || !checkBeforeSend(*msg)) return; MSG_LOG("Old threadId = ", m_ThreadId); @@ -560,7 +611,7 @@ void Conversation::sendMessage() } else { - showSendResultPopup(sendRes); + handleSendResult(*msg, sendRes); } if(m_pListener) @@ -729,6 +780,42 @@ PopupList &Conversation::createPopupList(const std::string &title) return popup; } +void Conversation::showSendDpmNotif(const MsgAddressList &addressList) +{ + int len = addressList.getLength(); + std::string addresses; + + for(int i = 0; i < len; ++i) + { + std::string address = addressList[i].getAddress(); + std::string dispName; + if(!address.empty()) + { + ContactAddressRef rec = getApp().getContactManager().getContactAddress(address); + if(rec) + dispName = rec->getDispName(); + addresses += makeDispAddress(address, dispName); + if(i < len - 1) + addresses += "
"; + } + } + + if(len <= 1) + { + std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_PS", addresses.c_str()); + notification_status_message_post(text.c_str()); + } + else + { + std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_THE_FOLLOWING_RECIPIENTS_C_NPS", addresses.c_str()); + auto &popupMngr = getApp().getPopupManager(); + Popup &popup = popupMngr.getPopup(); + popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId); + popup.setContent(text); + popup.show(); + } +} + void Conversation::showNoRecipPopup() { Popup &popup = getApp().getPopupManager().getPopup(); @@ -740,32 +827,6 @@ void Conversation::showNoRecipPopup() popup.show(); } -void Conversation::showSendResultPopup(MsgTransport::SendResult result) -{ - if(result == MsgTransport::SendSuccess) - return; - - const char *strId = nullptr; - switch(result) - { - case MsgTransport::SendNoSIM: - strId = "IDS_MSG_BODY_UNABLE_TO_SEND_THIS_MESSAGE_INSERT_YOUR_SIM_CARD_AND_TRY_AGAIN"; - break; - case MsgTransport::SendDPMRestricted: - strId = "IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_THE_USE_OF_SMS_MMS"; - break; - default: - strId = "IDS_MSGC_BODY_UNABLE_TO_SEND_MESSAGE"; - }; - - auto &popupMngr = getApp().getPopupManager(); - Popup &popup = popupMngr.getPopup(); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onPopupDel), this); - popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this); - popup.setContent(msgt(strId)); - popup.show(); -} - void Conversation::showMobileDataPopup() { auto &popupMngr = getApp().getPopupManager(); @@ -1249,6 +1310,12 @@ void Conversation::onForwardMsg(MsgId id) forwardMsg(id); } +void Conversation::onResendMsg(MsgId id) +{ + MSG_LOG(""); + sendMessage(id); +} + void Conversation::onSlideShow(MsgId id) { MSG_LOG(""); -- 2.34.1