Fixed: TSAM-5490 Delivery/Read Report maker 36/76636/1 submit/tizen/20160627.085237
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 24 Jun 2016 11:58:12 +0000 (14:58 +0300)
committerAndrey Klimenko <and.klimenko@samsung.com>
Fri, 24 Jun 2016 13:31:03 +0000 (16:31 +0300)
Change-Id: I9107bfeb318f8611ee09c2c1438bae036d339ee6
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/MsgEngine/inc/MsgStorage.h
src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp
src/Common/MsgEngine/src/private/MsgStoragePrivate.h
src/Conversation/Utils/inc/MessageDetailContent.h
src/Conversation/Utils/src/MessageDetailContent.cpp

index acf7a80..dbcb8a9 100644 (file)
@@ -65,7 +65,8 @@ namespace Msg
             virtual MessageListRef searchMessage(const std::string &word) = 0;
             virtual void setReadStatus(MsgId id, bool status) = 0;
             virtual MsgReportListRef getMsgReportList(MsgId msgId) = 0;
-            virtual bool isReadReportChecked(MsgId msgId) = 0; //TODO: remove to MmsMessage
+            virtual bool isReadReportChecked(MsgId msgId) = 0; // TODO: remove to MmsMessage
+            virtual bool isDeliverReportChecked(MsgId msgId) = 0;  //TODO: remove to MmsMessage
 
             // Conversation:
             virtual MsgConversationListRef getConversationList(ThreadId id) = 0;
index 1965c41..3e7d5d8 100644 (file)
@@ -411,7 +411,7 @@ MsgReportListRef MsgStoragePrivate::getMsgReportList(MsgId msgId)
 bool MsgStoragePrivate::isReadReportChecked(MsgId msgId)
 {
     bool readFlag = false;
-    msg_struct_t mmsSendOpt = NULL;
+    msg_struct_t mmsSendOpt = nullptr;
     msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
     msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
 
@@ -424,6 +424,20 @@ bool MsgStoragePrivate::isReadReportChecked(MsgId msgId)
     return readFlag;
 }
 
+bool MsgStoragePrivate::isDeliverReportChecked(MsgId msgId)
+{
+    bool deliverFlag = false;
+    msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
+    msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+
+    msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt);
+    msg_get_bool_value(sendOpt, MSG_SEND_OPT_DELIVER_REQ_BOOL, &deliverFlag);
+
+    msg_release_struct(&msgInfo);
+    msg_release_struct(&sendOpt);
+    return deliverFlag;
+}
+
 ThreadId MsgStoragePrivate::getThreadId(MsgId id)
 {
     int threadId = -1;
index 8d05bd5..de56e3c 100644 (file)
@@ -64,6 +64,7 @@ namespace Msg
             virtual void setReadStatus(MsgId id, bool status);
             virtual MsgReportListRef getMsgReportList(MsgId msgId);
             virtual bool isReadReportChecked(MsgId msgId);
+            virtual bool isDeliverReportChecked(MsgId msgId);
 
             // Conversation:
             virtual MsgConversationListRef getConversationList(ThreadId id);
index c88051a..eacefd7 100644 (file)
@@ -35,7 +35,7 @@ namespace Msg
             static std::string getMessageType(Message::Type msgType);
             static std::string getContactsInfo(App &app, Message::Direction m_Direction, ThreadId msgThreadId);
             static std::string getSentReceivedTime(MsgStorage &msgStorage, Message::Direction msgDirection, MsgId msgId);
-            static std::string makeReportResult(App &app, Message::NetworkStatus msgStatus, Message::Type msgType, ThreadId msgThreadId, MsgId msgId);
+            static std::string makeDeliveryReportResult(App &app, Message::NetworkStatus msgStatus, Message::Type msgType, ThreadId msgThreadId, MsgId msgId);
             static std::string getSubscriberNumber();
             static std::string getSmsStatus(Message::NetworkStatus msgStatus);
             static std::string getMmsSubject(App &app, MsgId msgId);
index 387a574..4d910df 100644 (file)
@@ -48,7 +48,7 @@ std::string MessageDetailContent::createMsgDetailsPopupText(App &app, MsgId msgI
     if(msgDirection == Message::MD_Sent && msgType == Message::MT_SMS)
     {
         msgDetails.append("<br/>");
-        msgDetails += makeReportResult(app, msgStatus, msgType, msgThreadId, msgId);
+        msgDetails += makeDeliveryReportResult(app, msgStatus, msgType, msgThreadId, msgId);
         msgDetails += getSmsStatus(msgStatus);
     }
     else if(msgType == Message::MT_MMS_Noti)
@@ -67,7 +67,7 @@ std::string MessageDetailContent::createMsgDetailsPopupText(App &app, MsgId msgI
         if(msgDirection == Message::MD_Sent)
         {
             msgDetails.append("<br/>");
-            msgDetails += makeReportResult(app, msgStatus, msgType, msgThreadId, msgId);
+            msgDetails += makeDeliveryReportResult(app, msgStatus, msgType, msgThreadId, msgId);
             msgDetails += makeReadReportResult(app, msgId, msgThreadId, msgStatus);
         }
     }
@@ -176,63 +176,61 @@ std::string MessageDetailContent::getSentReceivedTime(MsgStorage &msgStorage, Me
     return msgDetails;
 }
 
-std::string MessageDetailContent::makeReportResult(App &app, Message::NetworkStatus msgStatus, Message::Type msgType, ThreadId msgThreadId, MsgId msgId)
+std::string MessageDetailContent::makeDeliveryReportResult(App &app, Message::NetworkStatus msgStatus, Message::Type msgType, ThreadId msgThreadId, MsgId msgId)
 {
     std::string deliverText;
 
-    if(msgStatus == Message::NS_Send_Success || msgStatus == Message::NS_Deliver_Success)
+    bool deliverFlag = app.getMsgEngine().getStorage().isDeliverReportChecked(msgId);
+    if(deliverFlag)
     {
         MsgReportListRef reportList = app.getMsgEngine().getStorage().getMsgReportList(msgId);
-        MsgAddressListRef addrList = app.getMsgEngine().getStorage().getAddressList(msgThreadId);
+        int size = reportList->getLength();
+        bool isDelivReportExists = false;
 
-        int size = addrList->getLength();
         for(int i = 0; i < size; i++)
         {
-            if(reportList->getLength() != 0)
+            const MsgReport &report = reportList->at(i);
+            if(report.getType() == MsgReport::TypeDelivery)
             {
+                isDelivReportExists = true;
+
                 deliverText.append("<br/>");
-                deliverText.append(addrList->at(i).getAddress());
+                deliverText.append(report.getAddress());
                 deliverText.append(" - ");
-                if(reportList->at(i).getType() == MsgReport::TypeDelivery)
+
+                if(report.getDeliveryStatus() == MsgReport::StatusSuccess)
                 {
-                    if(reportList->at(i).getDeliveryStatus() == MsgReport::StatusSuccess)
-                    {
-                        deliverText.append(msg("IDS_MSGF_BODY_RECEIVED"));
-                        deliverText.append(" (");
-
-                        time_t time = reportList->at(i).getTime();
-                        if(MsgUtils::isMms(msgType))
-                            deliverText.append(TimeUtils::makeMmsReportTimeString(time));
-                        else
-                            deliverText.append(TimeUtils::makeSmsReportTimeString(time));
-
-                        deliverText.append(")");
-                    }
-                    else if(reportList->at(i).getDeliveryStatus() == MsgReport::StatusExpired)
-                    {
-                        deliverText.append(msg("IDS_MSGF_BODY_EXPIRED"));
-                    }
-                    else if(reportList->at(i).getDeliveryStatus() == MsgReport::StatusRejected)
-                    {
-                        deliverText.append(msg("IDS_MSGF_POP_REJECTED"));
-                    }
+                    deliverText.append(msg("IDS_MSGF_BODY_RECEIVED"));
+                    deliverText.append(" (");
+
+                    time_t time = report.getTime();
+                    if(MsgUtils::isMms(msgType))
+                        deliverText.append(TimeUtils::makeMmsReportTimeString(time));
                     else
-                    {
-                        if(MsgUtils::isMms(msgType))
-                            deliverText.append(msg("IDS_MSGF_BODY_UNKNOWN"));
-                        else
-                            deliverText.append(msg("IDS_MSGF_BODY_REQUESTED"));
-                    }
+                        deliverText.append(TimeUtils::makeSmsReportTimeString(time));
+
+                    deliverText.append(")");
+                }
+                else if(report.getDeliveryStatus() == MsgReport::StatusExpired)
+                {
+                    deliverText.append(msg("IDS_MSGF_BODY_EXPIRED"));
+                }
+                else if(report.getDeliveryStatus() == MsgReport::StatusRejected)
+                {
+                    deliverText.append(msg("IDS_MSGF_POP_REJECTED"));
+                }
+                else if(report.getDeliveryStatus() == MsgReport::StatusNone)
+                {
+                    deliverText.append(msg("IDS_MSGF_BODY_REQUESTED"));
+                }
+                else
+                {
+                    deliverText.append(msg("IDS_MSGF_BODY_UNKNOWN"));
                 }
-            }
-            else
-            {
-                deliverText.append("<br/>");
-                deliverText.append(addrList->at(i).getAddress());
-                deliverText.append(" - ");
-                deliverText.append(msg("IDS_MSGC_BODY_NOT_REQUESTED"));
             }
         }
+        if(!isDelivReportExists)
+            deliverText.append(msg("IDS_MSGF_BODY_UNKNOWN"));
     }
     else
     {
@@ -349,38 +347,49 @@ std::string MessageDetailContent::makeReadReportResult(App &app, MsgId msgId, Th
 {
     std::string readReport;
     bool readFlag = app.getMsgEngine().getStorage().isReadReportChecked(msgId);
-
-    if((msgStatus == Message::NS_Send_Success || msgStatus == Message::NS_Deliver_Success) && readFlag)
+    if(readFlag)
     {
         MsgReportListRef reportList = app.getMsgEngine().getStorage().getMsgReportList(msgId);
-        MsgAddressListRef addrList = app.getMsgEngine().getStorage().getAddressList(msgThreadId);
 
-        int size = addrList->getLength();
+        int size = reportList->getLength();
+        bool isReadReportExists = false;
+
         for(int i = 0; i < size; i++)
         {
-            readReport.append("<br/>");
-            readReport.append(addrList->at(i).getAddress());
-            readReport.append(" - ");
-            if(reportList->at(i).getType() == MsgReport::TypeRead)
+            const MsgReport &report = reportList->at(i);
+            if(report.getType() == MsgReport::TypeRead)
             {
-                if(reportList->at(i).getReadStatus() == MsgReport::ReadStatusIsRead)
+                isReadReportExists = true;
+
+                readReport.append("<br/>");
+                readReport.append(report.getAddress());
+                readReport.append(" - ");
+
+                if(report.getReadStatus() == MsgReport::ReadStatusIsRead)
                 {
                     readReport.append(msg("IDS_MSGF_BODY_MMSREADREPLYMSGREAD"));
                     readReport.append(" (");
-                    time_t time = reportList->at(i).getTime();
+                    time_t time = report.getTime();
                     readReport.append(TimeUtils::makeDateTimeString(time));
                     readReport.append(")");
                 }
-                else if(reportList->at(i).getReadStatus() == MsgReport::ReadStatusIsDeleted)
+                else if(report.getReadStatus() == MsgReport::ReadStatusIsDeleted)
                 {
                     readReport.append(msg("IDS_MSG_POP_DELETED"));
                 }
-                else if(reportList->at(i).getReadStatus() == MsgReport::ReadStatusNone)
+                else if(report.getReadStatus() == MsgReport::ReadStatusNone)
                 {
                     readReport.append(msg("IDS_MSGF_BODY_REQUESTED"));
                 }
+                else
+                {
+                    readReport.append(msg("IDS_MSGF_BODY_UNKNOWN"));
+                }
             }
         }
+
+        if(!isReadReportExists)
+            readReport.append(msg("IDS_MSGF_BODY_UNKNOWN"));
     }
     else
     {