TizenRefApp-6870 Read report request isn't displayed on Tizen device 35/89035/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 21 Sep 2016 15:31:12 +0000 (18:31 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 21 Sep 2016 15:31:12 +0000 (18:31 +0300)
Change-Id: I3c7cb6c8707fd0a6aab077a0abaa1e86d7a1a35b
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
16 files changed:
src/Common/MsgEngine/inc/MsgTransport.h
src/Common/MsgEngine/src/MsgTransport.cpp
src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp
src/Common/MsgEngine/src/private/MsgTransportPrivate.h
src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp
src/Common/MsgEngine/src/private/MsgUtilsPrivate.h
src/Common/View/inc/ListView.h
src/Conversation/ConvList/Controller/inc/BubbleDownloadButtonEntity.h
src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h
src/Conversation/ConvList/Controller/inc/ConvList.h
src/Conversation/ConvList/Controller/inc/ConvListItem.h
src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp
src/Conversation/ConvList/Controller/src/ConvList.cpp
src/Conversation/ConvList/Controller/src/ConvListItem.cpp
src/Conversation/Main/Controller/inc/Conversation.h
src/Conversation/Main/Controller/src/Conversation.cpp

index 5923354..6d708e3 100644 (file)
@@ -21,6 +21,7 @@
 #include "Message.h"
 #include "MessageMms.h"
 #include "MessageSMS.h"
+#include "MsgReport.h"
 
 namespace Msg
 {
@@ -35,12 +36,12 @@ namespace Msg
              */
             enum SendResult
             {
-                SendSuccess           = 0,      /**< Sending successful.*/
-                SendFail              = -1,     /**< Sending failure.*/
-                SendNullPointer       = -2,     /**< Invalid parameter passed into sendMessage().*/
-                SendNoSIM             = -3,     /**< No SIM was found.*/
-                SendMemoryFull        = -4,     /**< No free space available for message-storage.*/
-                SendDPMRestricted     = -5,     /**< Sending message is restricted by DPM.*/
+                SendSuccess               = 0,      /**< Sending successful.*/
+                SendFail                  = -1,     /**< Sending failure.*/
+                SendNoSIM                 = -2,     /**< No SIM was found.*/
+                SendDPMRestricted         = -3,     /**< Sending message is restricted by DPM.*/
+                SendReadReportNotReq      = -4,     /**< Read report not requested.*/
+                SendReadReportAlreadySent = -5,     /**< Read report already dent.*/
             };
 
         public:
@@ -83,7 +84,13 @@ namespace Msg
              * @brief Manually downloads MMS by demand.
              * @param[in] msgId id of message to be downloaded.
              */
-            virtual void retrieveMessage(MsgId msgId) = 0;
+            virtual SendResult retrieveMessage(MsgId msgId) = 0;
+
+            /**
+             * @brief Send read report (for MMS only)
+             * @param[in] msgId id of message (MMS)
+             */
+            virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) = 0;
     };
 }
 
index 799e1cb..31f186c 100644 (file)
@@ -31,15 +31,15 @@ MsgTransport::~MsgTransport()
 
 MsgTransport::SendResult MsgTransport::sendMessage(MessageRef &msg, ThreadId *threadId)
 {
-    return msg ? sendMessage(*msg, threadId) : MsgTransport::SendNullPointer;
+    return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail;
 }
 
 MsgTransport::SendResult MsgTransport::sendMessage(MessageMmsRef &msg, ThreadId *threadId)
 {
-    return msg ? sendMessage(*msg, threadId) : MsgTransport::SendNullPointer;
+    return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail;
 }
 
 MsgTransport::SendResult MsgTransport::sendMessage(MessageSMSRef &msg, ThreadId *threadId)
 {
-    return msg ? sendMessage(*msg, threadId) : MsgTransport::SendNullPointer;
+    return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail;
 }
index 73f5775..8e0e72c 100644 (file)
 
 #include "MsgTransportPrivate.h"
 #include "MessagePrivate.h"
+#include "MsgUtilsPrivate.h"
 #include "Logger.h"
 
 using namespace Msg;
 
+
 MsgTransportPrivate::MsgTransportPrivate(msg_handle_t serviceHandle)
     : MsgTransport()
     , m_ServiceHandle(serviceHandle)
@@ -61,39 +63,12 @@ MsgTransport::SendResult MsgTransportPrivate::sendMessage(Message &msg, ThreadId
         msg_get_thread_id_by_address2(m_ServiceHandle, privMsg.getAddressList(), (msg_thread_id_t*)threadId);
     msg_release_struct(&req);
 
-    if(err == MSG_SUCCESS)
-    {
-        MSG_LOG("sending success");
-        return SendSuccess;
-    }
-    else if (err == MSG_ERR_INVALID_PARAMETER)
-    {
-        MSG_LOG_ERROR("sending failed error code INVALID_PARAM: ", err);
-        return SendNullPointer;
-    }
-    else if (err == MSG_ERR_NO_SIM)
-    {
-        MSG_LOG_ERROR("sending failed error code NO SIM: ", err);
-        return SendNoSIM;
-    }
-    else if (err == MSG_ERR_PLUGIN_STORAGE)
-    {
-        MSG_LOG_ERROR("sending failed error code MSG_ERR_PLUGIN_STORAGE: ", err);
-        return SendMemoryFull;
-    }
-    else if (err == MSG_ERR_DPM_RESTRICT)
-    {
-        MSG_LOG_ERROR("sending failed error code MSG_ERR_DPM_RESTRICT: ", err);
-        return SendDPMRestricted;
-    }
-    else
-    {
-        MSG_LOG_ERROR("[DEBUG] sending failed error code: ", err);
-        return SendFail;
-    }
+    MsgTransport::SendResult sendRes= MsgUtilsPrivate::nativeToSendResult(err);
+    MSG_LOG("Send result: ", sendRes);
+    return sendRes;
 }
 
-void MsgTransportPrivate::retrieveMessage(MsgId msgId)
+MsgTransport::SendResult MsgTransportPrivate::retrieveMessage(MsgId msgId)
 {
     msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO);
     msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
@@ -109,4 +84,16 @@ void MsgTransportPrivate::retrieveMessage(MsgId msgId)
     msg_release_struct(&retrieveMsg);
     msg_release_struct(&sendOpt);
     msg_release_struct(&req);
+
+    MsgTransport::SendResult sendRes= MsgUtilsPrivate::nativeToSendResult(err);
+    MSG_LOG("Send result: ", sendRes);
+    return sendRes;
+}
+
+MsgTransport::SendResult MsgTransportPrivate::sendReadReport(MsgId msgId, MsgReport::ReadStatus status)
+{
+    msg_error_t err = msg_mms_send_read_report(m_ServiceHandle, msgId, MsgUtilsPrivate::reportReadReportStatusToNative(status));
+    MsgTransport::SendResult sendRes= MsgUtilsPrivate::nativeToSendResult(err);
+    MSG_LOG("Send result: ", sendRes);
+    return sendRes;
 }
index 3a18405..6ed8a6a 100644 (file)
@@ -36,7 +36,8 @@ namespace Msg
             virtual ~MsgTransportPrivate();
 
             virtual SendResult sendMessage(Message &msg, ThreadId *threadId);
-            virtual void retrieveMessage(MsgId msgId);
+            virtual SendResult retrieveMessage(MsgId msgId);
+            virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status);
 
         private:
             msg_handle_t m_ServiceHandle;
index 1797950..09aae4f 100644 (file)
@@ -132,6 +132,25 @@ MsgReport::ReadStatus MsgUtilsPrivate::nativeToReportReadStatus(int status)
     }
 }
 
+int MsgUtilsPrivate::reportReadReportStatusToNative(MsgReport::ReadStatus status)
+{
+    switch(status)
+    {
+        case MsgReport::ReadStatusIsRead:
+            return MSG_READ_REPORT_IS_READ;
+
+        case MsgReport::ReadStatusIsDeleted:
+            return MSG_READ_REPORT_IS_DELETED;
+
+        case MsgReport::ReadStatusRejectByUser:
+            return MSG_READ_REPORT_REJECT_BY_USER;
+
+        default:
+        case MsgReport::ReadStatusNone:
+            return MSG_READ_REPORT_NONE;
+    }
+}
+
 MsgReport::Type MsgUtilsPrivate::nativeToReportType(int type)
 {
     switch(type)
@@ -326,3 +345,22 @@ int MsgUtilsPrivate::activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy po
     }
     return 0;
 }
+
+MsgTransport::SendResult MsgUtilsPrivate::nativeToSendResult(int sendRes)
+{
+    switch(sendRes)
+    {
+        case MSG_SUCCESS:
+            return MsgTransport::SendSuccess;
+        case MSG_ERR_NO_SIM:
+            return MsgTransport::SendNoSIM;
+        case MSG_ERR_DPM_RESTRICT:
+            return MsgTransport::SendDPMRestricted;
+        case MSG_ERR_READREPORT_NOT_REQUESTED:
+            return MsgTransport::SendReadReportNotReq;
+        case MSG_ERR_READREPORT_ALEADY_SENT:
+            return MsgTransport::SendReadReportAlreadySent;
+        default:
+            return MsgTransport::SendFail;
+    }
+}
index ed0f42c..1843289 100644 (file)
@@ -22,6 +22,7 @@
 #include "MsgReport.h"
 #include "MsgUtils.h"
 #include "MsgSettings.h"
+#include "MsgTransport.h"
 
 #include <msg_storage.h>
 #include <msg_types.h>
@@ -43,12 +44,14 @@ namespace Msg
             static MsgAddress::RecipientType nativeToRecipientType(int type);
             static MsgReport::DeliveryStatus nativeToReportDeliveryStatus(int status);
             static MsgReport::ReadStatus nativeToReportReadStatus(int status);
+            static int reportReadReportStatusToNative(MsgReport::ReadStatus status);
             static MsgReport::Type nativeToReportType(int type);
             static Message::Type nativeToMessageType(int type);
             static MsgMedia::Type nativeToSmilType(int type);
             static int smilTypeToNative(MsgMedia::Type type);
             static Message::NetworkStatus nativeToNetworkStatus(int status);
             static int activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy);
+            static MsgTransport::SendResult nativeToSendResult(int sendRes);
 
             static std::string getStr(msg_struct_t msgStruct, int field, int maxStrLen);
             static int setStr(msg_struct_t msgStruct, int field, const std::string &text);
index c5ba9d5..e48f629 100644 (file)
@@ -279,6 +279,7 @@ namespace Msg
     std::vector<T*> ListView::getItems() const
     {
         std::vector<T*> list;
+        list.reserve(elm_genlist_items_count(getEo()));
         Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo());
         while(elmItem)
         {
index 9d5d363..44673d2 100644 (file)
@@ -27,7 +27,7 @@ namespace Msg
         : public BubbleEntity
     {
         public:
-            BubbleDownloadButtonEntity(Message::Direction direction);
+            BubbleDownloadButtonEntity();
             virtual ~BubbleDownloadButtonEntity();
 
             void disabled(bool status);
@@ -37,8 +37,8 @@ namespace Msg
             bool m_Disabled;
     };
 
-    inline BubbleDownloadButtonEntity::BubbleDownloadButtonEntity(Message::Direction direction)
-        : BubbleEntity(DownloadButtonItem, direction)
+    inline BubbleDownloadButtonEntity::BubbleDownloadButtonEntity()
+        : BubbleEntity(DownloadButtonItem, Message::MD_Received)
         , m_Disabled(false)
     {
     }
index 0a945f1..7fbdf31 100644 (file)
@@ -46,7 +46,7 @@ namespace Msg
             BubbleEntity *createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction);
             BubbleEntity *createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction);
             BubbleTextEntity *createTextEntity(std::string text, BubbleBgViewItem::BgType bgType, Message::Direction direction);
-            BubbleDownloadButtonEntity *createDownloadButtonEntity(Message::Direction direction);
+            BubbleDownloadButtonEntity *createDownloadButtonEntity();
 
         private:
             BubbleEntity *createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction);
index 7afe209..68f9ef3 100644 (file)
@@ -132,6 +132,12 @@ namespace Msg
              */
             ComposeListItem &getComposeItem();
 
+            /**
+             * @brief Get conversation(ConvListItem type) items
+             * @return conversation items.
+             */
+            std::vector<ConvListItem*> getConvItems() const;
+
         private:
             typedef std::unordered_map<MsgId::Type, ConvListItem*> ConvListItemMap;
             typedef std::unordered_set<std::string> DateLineItemSet;
index a46c31c..944d160 100644 (file)
@@ -73,6 +73,7 @@ namespace Msg
 
             void updateStatus();
             void updateTime();
+            bool isNeededReadReport() const;
 
         protected:
             // ConvListViewItem:
@@ -88,8 +89,8 @@ namespace Msg
         private:
             ConvListViewItem::ConvItemType getConvItemType(const MsgConversationItem &item);
             void prepareBubble(const MsgConversationItem &item, const std::string &searchWord);
-            BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, const MsgConvMedia &media, std::string searchWord);
-            BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, std::string searchWord);
+            BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, const MsgConvMedia &media, std::string searchWord);
+            BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, std::string text, bool markup, std::string searchWord);
             void addEntity(BubbleEntity *entity);
             void updateEntityBgType(BubbleBgViewItem::BgType bgType);
             BubbleBgViewItem::BgType getBubbleBgType(const MsgConversationItem &item);
@@ -129,6 +130,7 @@ namespace Msg
             WorkingDirRef m_WorkingDir;
             MsgId m_MsgId;
             bool m_IsDraft;
+            Message::Direction m_Direction;
             Message::NetworkStatus m_NetworkStatus;
             Message::Type m_Type;
             time_t m_Time;
@@ -137,6 +139,7 @@ namespace Msg
             const ThumbId &m_ThumbId;
             BubbleEntityFactory &m_BubbleEntityFactory;
             bool m_IsRestrictedByDpm;
+            bool m_IsNeededReadReport;
     };
 
     class IConvListItemListener
index 24b24d0..58ac400 100644 (file)
@@ -70,9 +70,9 @@ BubbleTextEntity *BubbleEntityFactory::createTextEntity(std::string text, Bubble
     return text.empty() ? nullptr : new BubbleTextEntity(bgType, direction, std::move(text));
 }
 
-BubbleDownloadButtonEntity *BubbleEntityFactory::createDownloadButtonEntity(Message::Direction direction)
+BubbleDownloadButtonEntity *BubbleEntityFactory::createDownloadButtonEntity()
 {
-    return new BubbleDownloadButtonEntity(direction);
+    return new BubbleDownloadButtonEntity;
 }
 
 BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction)
index 94ed19f..3007a34 100644 (file)
@@ -283,7 +283,7 @@ void ConvList::clear()
 
 void ConvList::deleteSelectedItems()
 {
-    auto items = m_pList->getItems<ConvListItem>();
+    auto items = getConvItems();
     MsgIdList messages;
     for(ConvListItem *item : items)
     {
@@ -295,13 +295,13 @@ void ConvList::deleteSelectedItems()
 
 int ConvList::getMessageCount() const
 {
-    auto items = m_pList->getItems<ConvListItem>();
+    auto items = getConvItems();
     return (int)items.size();
 }
 
 int ConvList::getMessageCheckedCount() const
 {
-    auto items = m_pList->getItems<ConvListItem>();
+    auto items = getConvItems();
     int count = 0;
     for(ConvListItem *item : items)
     {
@@ -314,7 +314,7 @@ int ConvList::getMessageCheckedCount() const
 bool ConvList::isAllListItemSelected() const
 {
     // Simple but not fast impl:
-    auto items = m_pList->getItems<ConvListItem>();
+    auto items = getConvItems();
     for(ConvListItem *item : items)
     {
         if(!item->getCheckedState())
@@ -341,6 +341,11 @@ ComposeListItem &ConvList::getComposeItem()
     return *m_pComposeItem;
 }
 
+std::vector<ConvListItem*> ConvList::getConvItems() const
+{
+    return m_pList->getItems<ConvListItem>();
+}
+
 void ConvList::onListItemLongPressed(ListItem &listItem)
 {
     ConvListItem *item = dynamic_cast<ConvListItem*>(&listItem);
@@ -443,7 +448,7 @@ void ConvList::onContactChanged()
 void ConvList::onTimeFormatChanged()
 {
     MSG_LOG("");
-    auto items = m_pList->getItems<ConvListItem>();
+    auto items = getConvItems();
     for(ConvListItem *item : items)
     {
         item->updateTime();
@@ -456,7 +461,7 @@ void ConvList::onLanguageChanged()
     MSG_LOG("");
 
     // Update ConvListItem:
-    auto convListItems = m_pList->getItems<ConvListItem>();
+    auto convListItems = getConvItems();
     for(ConvListItem *item : convListItems)
     {
         item->updateTime();
index b67931b..064dae2 100644 (file)
@@ -53,13 +53,16 @@ ConvListItem::ConvListItem(const MsgConversationItem &item,
     , m_App(app)
     , m_MsgId(item.getMsgId())
     , m_IsDraft(item.isDraft())
+    , m_Direction(item.getDirection())
     , m_NetworkStatus(item.getNetworkStatus())
     , m_Type(item.getType())
     , m_Time(item.getTime())
     , m_ThumbId(thumbId)
     , m_BubbleEntityFactory(bubbleEntityFactory)
     , m_IsRestrictedByDpm(item.isRestrictedByDpm())
+    , m_IsNeededReadReport(false)
 {
+    m_IsNeededReadReport = m_Direction == MsgUtils::isMms(m_Type) && Message::MD_Received && !item.isRead();
     prepareBubble(item, searchWord);
 }
 
@@ -116,6 +119,11 @@ void ConvListItem::updateTime()
     m_TimeStr.clear();
 }
 
+bool ConvListItem::isNeededReadReport() const
+{
+    return m_IsNeededReadReport && !m_IsRestrictedByDpm;
+}
+
 ConvListViewItem::ConvItemType ConvListItem::getConvItemType(const MsgConversationItem &item)
 {
     ConvItemType type = ConvItemType::Sent;
@@ -150,17 +158,17 @@ BubbleBgViewItem::BgType ConvListItem::getBubbleBgType(const MsgConversationItem
     return type;
 }
 
-BubbleTextEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, const MsgConvMedia &media, std::string searchWord)
+BubbleTextEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, const MsgConvMedia &media, std::string searchWord)
 {
     std::string filePath = media.getPath();
     std::string text = FileUtils::readTextFile(filePath);
-    BubbleTextEntity *entity = createTextEntity(bgType, direction, std::move(text), true, std::move(searchWord));
+    BubbleTextEntity *entity = createTextEntity(bgType, std::move(text), true, std::move(searchWord));
     if(entity)
         entity->setFilePath(std::move(filePath));
     return entity;
 }
 
-BubbleTextEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, std::string searchWord)
+BubbleTextEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, std::string text, bool markup, std::string searchWord)
 {
     bool found = false;
     std::string markupText = markup ? utf8ToMarkup(text) : std::move(text);
@@ -170,7 +178,7 @@ BubbleTextEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType
     if(found)
         showSearch();
 
-    return m_BubbleEntityFactory.createTextEntity(std::move(resText), bgType, direction);
+    return m_BubbleEntityFactory.createTextEntity(std::move(resText), bgType, m_Direction);
 }
 
 BubbleDownloadButtonEntity *ConvListItem::findDownloadButton() const
@@ -209,20 +217,19 @@ void ConvListItem::updateEntityBgType(BubbleBgViewItem::BgType bgType)
 void ConvListItem::prepareBubble(const MsgConversationItem &item, const std::string &searchWord)
 {
     BubbleBgViewItem::BgType bgType = getBubbleBgType(item);
-    Message::Direction direction = item.getDirection();
     if(m_IsRestrictedByDpm)
     {
-        addEntity(createTextEntity(BubbleBgViewItem::RestrictedStyle, direction, msg("IDS_MSG_BODY_COULDNT_RECEIVE_THIS_MESSAGE_THE_SECURITY_POLICY_PREVENTS_RECEIVING_MESSAGES"), false, ""));
+        addEntity(createTextEntity(BubbleBgViewItem::RestrictedStyle, msg("IDS_MSG_BODY_COULDNT_RECEIVE_THIS_MESSAGE_THE_SECURITY_POLICY_PREVENTS_RECEIVING_MESSAGES"), false, ""));
     }
     else if(!MsgUtils::isMms(m_Type))
     {
-        addEntity(createTextEntity(bgType, direction, item.getText(), true, searchWord));
+        addEntity(createTextEntity(bgType, item.getText(), true, searchWord));
     }
     else if(m_Type == Message::MT_MMS_Noti)
     {
         std::string text = MessageDetailContent::getMmsNotiConvListItemContent(m_App, m_MsgId);
-        addEntity(createTextEntity(bgType, direction, std::move(text), false, searchWord));
-        addEntity(m_BubbleEntityFactory.createDownloadButtonEntity(direction));
+        addEntity(createTextEntity(bgType, std::move(text), false, searchWord));
+        addEntity(m_BubbleEntityFactory.createDownloadButtonEntity());
         updateDownloadButton();
     }
     else
@@ -234,9 +241,9 @@ void ConvListItem::prepareBubble(const MsgConversationItem &item, const std::str
             std::string mime = media.getMime();
             std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
             if(mime == "text/plain")
-                addEntity(createTextEntity(bgType, direction, media, searchWord));
+                addEntity(createTextEntity(bgType, media, searchWord));
             else if(mime != "application/smil")
-                addEntity(m_BubbleEntityFactory.createEntity(media, bgType, direction));
+                addEntity(m_BubbleEntityFactory.createEntity(media, bgType, m_Direction));
         }
     }
 }
index c033c0f..9e88d49 100644 (file)
@@ -36,6 +36,7 @@
 #include "ContactManager.h"
 #include "SystemSettingsManager.h"
 #include "WorkingDir.h"
+#include "MsgReport.h"
 
 #include <functional>
 
@@ -114,6 +115,8 @@ namespace Msg
             virtual void onContactListChanged();
 
              // Popup callbacks:
+            void onSendReadReportPopupDel(Evas_Object *popup, void *eventInfo);
+            void onSendReadReportPopupButtonClicked(Popup &popup, int buttonId);
             void onPopupDel(Evas_Object *popup, void *eventInfo);
             void onRecipPopupDel(Evas_Object *popup, void *eventInfo);
             void onMsgSendErrorButtonClicked(Popup &popup, int buttonId);
@@ -180,7 +183,9 @@ namespace Msg
             void setRecipEntryFocus();
             void resetMsgThread();
             void updateActiveNotifPolicy();
+            std::vector<MsgId> getMsgIdListForReadReport() const;
 
+            void showSendReadReportPopup();
             void showMainPopup();
             void showNoRecipPopup();
             PopupList &createPopupList(const std::string &title);
@@ -188,6 +193,8 @@ namespace Msg
             void showSendDpmNotif(const MsgAddressList &addressList);
             void showUnsavedRecipientPopup(const std::string &address);
             void showSavedRecipientPopup(const std::string &title, int contactId, ContactAddress::OwnerType ownerType);
+            void sendReadReport(MsgReport::ReadStatus status);
+            bool sendReadReportIfNeeded();
             void sendMessage(MsgId msgId);
             void sendMessage();
             bool checkBeforeSend(const Message &msg);
index 5786177..74a366b 100644 (file)
@@ -99,12 +99,15 @@ Conversation::~Conversation()
         m_pRecipPanel->setListener(nullptr);
     if(m_pContactsList)
         m_pContactsList->setListener(nullptr);
+    if(m_pConvList)
+        m_pConvList->setListener(nullptr);
     m_AttachPanel.setListener(nullptr);
     if(m_NnotifyConvertMsgTypeIdler)
     {
         ecore_idler_del(m_NnotifyConvertMsgTypeIdler);
         m_NnotifyConvertMsgTypeIdler = nullptr;
     }
+    markAsRead();
 }
 
 void Conversation::execCmd(const AppControlComposeRef &cmd)
@@ -189,7 +192,8 @@ void Conversation::create()
 
 void Conversation::markAsRead()
 {
-    if(m_ThreadId.isValid())
+    // Warning thread and messages marks as read only for ConversationMode.
+    if(m_ThreadId.isValid() && m_Mode == ConversationMode)
         getMsgEngine().getStorage().setReadStatus(m_ThreadId);
 }
 
@@ -577,6 +581,47 @@ bool Conversation::checkBeforeSend(const Message &msg)
     return true;
 }
 
+std::vector<MsgId> Conversation::getMsgIdListForReadReport() const
+{
+    std::vector<MsgId> msgIds;
+    if(m_pConvList)
+    {
+        auto items = m_pConvList->getConvItems();
+        for(ConvListItem *item : items)
+        {
+            if(item->isNeededReadReport())
+                msgIds.push_back(item->getMsgId());
+        }
+    }
+
+    return msgIds;
+}
+
+bool Conversation::sendReadReportIfNeeded()
+{
+    if(getMsgEngine().getSettings().getMmsReadReport() &&
+      !getApp().getSysSettingsManager().isMessagingRestrictedByDpm())
+    {
+        auto msgIds = getMsgIdListForReadReport();
+        if(!msgIds.empty())
+        {
+            showSendReadReportPopup();
+            return true;
+        }
+    }
+
+    return false;
+}
+
+void Conversation::sendReadReport(MsgReport::ReadStatus status)
+{
+    auto ids = getMsgIdListForReadReport();
+    for(MsgId id : ids)
+    {
+        getMsgEngine().getTransport().sendReadReport(id, status);
+    }
+}
+
 void Conversation::sendMessage(MsgId msgId)
 {
     MessageRef msg = getMsgEngine().getStorage().getMessage(msgId);
@@ -843,6 +888,18 @@ void Conversation::showMobileDataPopup()
     popup.show();
 }
 
+void Conversation::showSendReadReportPopup()
+{
+    auto &popupMngr = getApp().getPopupManager();
+    Popup &popup = popupMngr.getPopup();
+    popup.setTitle(msgt("IDS_MSGF_OPT_SEND_READ_REPORT"));
+    popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onSendReadReportPopupDel), this);
+    popup.addButton(msgt("IDS_MSG_BUTTON_SEND_ABB3"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onSendReadReportPopupButtonClicked), this);
+    popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB2"), Popup::CancelButtonId, POPUP_BUTTON_CB(Conversation, onSendReadReportPopupButtonClicked), this);
+    popup.setContent(msgt("IDS_MSG_POP_THE_SENDER_HAS_REQUESTED_A_READ_REPORT_TAP_SEND_TO_SEND_ONE"));
+    popup.show();
+}
+
 void Conversation::showMainPopup()
 {
     PopupList &popup = getApp().getPopupManager().getPopupList();
@@ -1061,22 +1118,25 @@ void Conversation::onHwBackButtonClicked()
         updateNavibar();
         return;
     }
+
     if(m_pRecipPanel)
     {
         if(m_pRecipPanel->isMbeVisible() || m_pRecipPanel->getItemsCount() == 0)
             m_pRecipPanel->addRecipientsFromEntry(false);
         m_pRecipPanel->clearEntry();
     }
+
     if(!isRecipExists() && !isBodyEmpty() && m_Mode == NewMessageMode)
     {
         showNoRecipPopup();
         return;
     }
-    else
-    {
-        saveDraftMsg();
-        pop();
-    }
+
+    if(sendReadReportIfNeeded())
+        return;
+
+    saveDraftMsg();
+    pop();
 }
 
 void Conversation::onHwMoreButtonClicked()
@@ -1159,6 +1219,20 @@ void Conversation::onPopupDel(Evas_Object *popup, void *eventInfo)
     m_pBody->setFocus(true);
 }
 
+void Conversation::onSendReadReportPopupDel(Evas_Object *popup, void *eventInfo)
+{
+    MSG_LOG("");
+    pop();
+}
+
+void Conversation::onSendReadReportPopupButtonClicked(Popup &popup, int buttonId)
+{
+    MSG_LOG("");
+    if(buttonId == Popup::OkButtonId)
+        sendReadReport(MsgReport::ReadStatusIsRead);
+    popup.destroy();
+}
+
 void Conversation::onRecipPopupDel(Evas_Object *popup, void *eventInfo)
 {
     MSG_LOG("");