Fixed: order of MMS attachments 58/85658/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 26 Aug 2016 09:20:36 +0000 (12:20 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 26 Aug 2016 09:20:36 +0000 (12:20 +0300)
Change-Id: Ibc231ec31dc12808aa04aa3b459f1423bca5d5d1
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Conversation/Body/Controller/inc/Body.h
src/Conversation/Body/Controller/src/Body.cpp
src/Conversation/Main/Controller/src/Conversation.cpp

index 9c8b242..4ab041f 100644 (file)
@@ -51,8 +51,8 @@ namespace Msg
             void setListener(IBodyListener *listener);
 
             void enableAutoFocusForAttachments(bool focus);
-            void addMedia(const std::list<std::string> &fileList);
-            void addMedia(const std::string &filePath);
+            void addAttachments(const std::list<std::string> &fileList);
+            void addAttachment(const std::string &filePath);
             void clear();
             bool isEmpty() const;
             bool isMms();
@@ -84,6 +84,7 @@ namespace Msg
             void writeAttachments(const MessageMms &msg);
             void writeTextToFile();
             void runFileProcessing();
+            void addFileToPage(MessageMms &msg, const std::string &filePath);
 
             PopupList &createPopupList(const std::string &title);
 
index 48ff178..8300efb 100644 (file)
@@ -101,19 +101,31 @@ void Body::enableAutoFocusForAttachments(bool focus)
     m_AutoFocusForAttachments = focus;
 }
 
-void Body::addMedia(const std::list<std::string> &fileList)
+void Body::addAttachments(const std::list<std::string> &fileList)
 {
     for(auto& file : fileList)
         m_SelectedFiles.push(file);
     runFileProcessing();
 }
 
-void Body::addMedia(const std::string &filePath)
+void Body::addAttachment(const std::string &filePath)
 {
     m_SelectedFiles.push(filePath);
     runFileProcessing();
 }
 
+void Body::addFileToPage(MessageMms &msg,const std::string &filePath)
+{
+    static const int defaultPageDuration = 5; // sec
+    if(!filePath.empty())
+    {
+        MsgPage &msgPage = msg.addPage();
+        msgPage.setPageDuration(defaultPageDuration);
+        MsgMedia &media = msgPage.addMedia();
+        media.setFilePath(filePath);
+    }
+}
+
 void Body::runFileProcessing()
 {
     if(!m_SelectedFiles.empty())
@@ -269,17 +281,16 @@ void Body::read(MessageSMS &msg)
 
 void Body::read(MessageMms &msg)
 {
-    readAttachments(msg);
     readText(msg);
+    readAttachments(msg);
 }
 
 void Body::readAttachments(MessageMms &msg)
 {
-    const int defaultPageDuration = 5; // sec
     const auto &attachments = getComposeItem().getAttachments();
-    for(auto *attachment : attachments)
+    for(auto *attach : attachments)
     {
-        const std::string &filePath = attachment->getFilePath();
+        const std::string &filePath = attach->getFilePath();
         if(filePath.empty())
             continue;
 
@@ -289,10 +300,7 @@ void Body::readAttachments(MessageMms &msg)
             case MsgMedia::AudioType:
             case MsgMedia::VideoType:
             {
-                MsgPage &msgPage = msg.addPage();
-                msgPage.setPageDuration(defaultPageDuration);
-                MsgMedia &media = msgPage.addMedia();
-                media.setFilePath(filePath);
+                addFileToPage(msg, filePath);
                 break;
             }
             default:
@@ -310,9 +318,7 @@ void Body::readText(MessageMms &msg)
     if(!isEmpty())
     {
         writeTextToFile();
-        MsgPage &msgPage = msg.addPage();
-        MsgMedia &media = msgPage.addMedia();
-        media.setFilePath(m_MmsTextFilePath);
+        addFileToPage(msg, m_MmsTextFilePath);
     }
 }
 
@@ -323,7 +329,7 @@ void Body::execCmd(const AppControlComposeRef &cmd)
     if(!cmd->getVcfInfo().contactsIdList.empty())
         path.push_back(createVcfFile(cmd));
 
-    addMedia(path);
+    addAttachments(path);
 }
 
 void Body::onMaxLengthReached()
index cbcfb93..c3c8fb9 100644 (file)
@@ -1182,7 +1182,7 @@ void Conversation::onConvListItemChecked()
 void Conversation::onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files)
 {
     MSG_LOG("");
-    m_pBody->addMedia(files);
+    m_pBody->addAttachments(files);
 }
 
 void Conversation::onContactChanged()