TSAM-4157: Message display adnormal when recived MMS 96/72096/2 submit/tizen/20160530.132552
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 30 May 2016 12:42:23 +0000 (15:42 +0300)
committerAndrey Klimenko <and.klimenko@samsung.com>
Mon, 30 May 2016 12:58:25 +0000 (05:58 -0700)
Change-Id: I1a7647867b5e9c473d72ad75f6b9984918f1871c
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/MsgEngine/inc/MediaType.h
src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp
src/Conversation/Body/Controller/src/Body.cpp
src/Conversation/Body/Controller/src/Page.cpp
src/Conversation/ConvList/Controller/src/ConvListItem.cpp
src/Conversation/Utils/src/AttachmentHandler.cpp

index ab4d1d4fee976c1767d008ebb6f752a4fb42620a..9e07939c1b3dc56e45df81d8a550ed5e0e7d917b 100644 (file)
@@ -40,7 +40,7 @@ namespace Msg
         MsgMedia::Type type;
     };
 
-    const std::unordered_multimap<std::string, MediaTypeData> mediaTypeMap =
+    const std::unordered_multimap<std::string, MediaTypeData> mediaTypeByExtMap =
     {
         // Sound:
         {"aac", {"audio/aac", MsgMedia::AudioType}},
@@ -174,7 +174,113 @@ namespace Msg
         {"xxx", {"application/octet-stream", MsgMedia::UnknownType}},
     };
 
-    inline static const MediaTypeData getMediaType(const std::string &filePath)
+    const std::unordered_multimap<std::string, MsgMedia::Type> mediaTypeByMimeMap =
+    {
+        // Sound:
+        {"audio/aac", MsgMedia::AudioType},
+        {"audio/amr", MsgMedia::AudioType},
+        {"audio/x-amr", MsgMedia::AudioType},
+        {"audio/amr-wb", MsgMedia::AudioType},
+        {"audio/imelody", MsgMedia::AudioType},
+        {"audio/imy", MsgMedia::AudioType},
+        {"audio/iMelody", MsgMedia::AudioType},
+        {"audio/melody", MsgMedia::AudioType},
+        {"audio/x-iMelody", MsgMedia::AudioType},
+        {"text/iMelody", MsgMedia::AudioType},
+        {"text/x-iMelody", MsgMedia::AudioType},
+        {"text/x-imelody", MsgMedia::AudioType},
+        {"audio/mid", MsgMedia::AudioType},
+        {"audio/midi", MsgMedia::AudioType},
+        {"audio/x-mid", MsgMedia::AudioType},
+        {"audio/x-midi", MsgMedia::AudioType},
+        {"audio/mid", MsgMedia::AudioType},
+        {"application/vnd.smaf", MsgMedia::AudioType},
+        {"application/x-smaf", MsgMedia::AudioType},
+        {"audio/mmf", MsgMedia::AudioType},
+        {"audio/smaf", MsgMedia::AudioType},
+        {"audio/x-mmf", MsgMedia::AudioType},
+        {"audio/x-smaf", MsgMedia::AudioType},
+        {"audio/mpeg", MsgMedia::AudioType},
+        {"audio/mp3", MsgMedia::AudioType},
+        {"audio/mpg3", MsgMedia::AudioType},
+        {"audio/mpeg3", MsgMedia::AudioType},
+        {"audio/mpg", MsgMedia::AudioType},
+        {"audio/x-mp3", MsgMedia::AudioType},
+        {"audio/x-mpeg", MsgMedia::AudioType},
+        {"audio/x-mpeg3", MsgMedia::AudioType},
+        {"audio/x-mpegaudio", MsgMedia::AudioType},
+        {"audio/x-mpg", MsgMedia::AudioType},
+        {"audio/x-mpeg", MsgMedia::AudioType},
+        {"audio/m4a", MsgMedia::AudioType},
+        {"audio/x-pn-realaudio", MsgMedia::AudioType},
+        {"audio/vnd.rn-realaudio", MsgMedia::AudioType},
+        {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType},
+        {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType},
+        {"audio/sp-midi", MsgMedia::AudioType},
+        {"audio/wav", MsgMedia::AudioType},
+        {"audio/wave", MsgMedia::AudioType},
+        {"audio/x-wav", MsgMedia::AudioType},
+        {"audio/x-wave", MsgMedia::AudioType},
+        {"audio/wma", MsgMedia::AudioType},
+        {"audio/x-ms-wma", MsgMedia::AudioType},
+        {"audio/mobile-xmf", MsgMedia::AudioType},
+        {"audio/xmf", MsgMedia::AudioType},
+        {"audio/x-xmf", MsgMedia::AudioType},
+        {"audio/3gpp", MsgMedia::AudioType},
+        {"audio/mp4", MsgMedia::AudioType},
+        {"audio/MP4A-LATM", MsgMedia::AudioType},
+        {"audio/mpeg4", MsgMedia::AudioType},
+
+        // Image:
+        {"image/bmp", MsgMedia::ImageType},
+        {"image/x-bmp", MsgMedia::ImageType},
+        {"image/gif", MsgMedia::ImageType},
+        {"image/gif", MsgMedia::ImageType},
+        {"image/vnd.tmo.my5-gif", MsgMedia::ImageType},
+        {"image/jpg", MsgMedia::ImageType},
+        {"image/jpeg", MsgMedia::ImageType},
+        {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType},
+        {"image/jpeg", MsgMedia::ImageType},
+        {"image/jpeg", MsgMedia::ImageType},
+        {"image/pjpeg", MsgMedia::ImageType},
+        {"image/jpeg", MsgMedia::ImageType},
+        {"image/png", MsgMedia::ImageType},
+        {"image/vnd.wap.wbmp", MsgMedia::ImageType},
+        {"image/wbmp", MsgMedia::ImageType},
+        {"application/x-shockwave-flash", MsgMedia::UnknownType},
+        {"image/tiff", MsgMedia::ImageType},
+        {"image/tif", MsgMedia::ImageType},
+        {"audio/pmd", MsgMedia::ImageType},
+
+        // Video:
+        {"video/3gpp", MsgMedia::VideoType},
+        {"video/3gp", MsgMedia::VideoType},
+        {"video/h263", MsgMedia::VideoType},
+        {"video/mp4v-es", MsgMedia::VideoType},
+        {"audio/x-ms-asf", MsgMedia::VideoType},
+        {"video/x-ms-asf", MsgMedia::VideoType},
+        {"video/x-ms-asf", MsgMedia::VideoType},
+        {"video/avi", MsgMedia::VideoType},
+        {"video/mpeg", MsgMedia::VideoType},
+        {"video/mp4", MsgMedia::VideoType},
+        {"video/mpeg4", MsgMedia::VideoType},
+        {"video/x-mp4", MsgMedia::VideoType},
+        {"video/x-pv-mp4", MsgMedia::VideoType},
+        {"video/mpeg", MsgMedia::VideoType},
+        {"video/mpeg", MsgMedia::VideoType},
+        {"video/x-pn-multirate-realvideo", MsgMedia::VideoType},
+        {"video/vnd.rn-realmedia", MsgMedia::VideoType},
+        {"video/vnd.rn-realvideo", MsgMedia::VideoType},
+        {"video/x-pn-realvideo", MsgMedia::VideoType},
+        {"application/sdp", MsgMedia::VideoType},
+        {"video/sdp", MsgMedia::VideoType},
+        {"video/x-ms-wmv", MsgMedia::VideoType},
+
+        // Text:
+        {"text/plain", MsgMedia::TextType}
+    };
+
+    inline static const MediaTypeData getMsgMediaTypeByFileExt(const std::string &filePath)
     {
         std::string base;
         std::string name;
@@ -182,8 +288,16 @@ namespace Msg
 
         FileUtils::splitPath(filePath, base, name, ext);
         std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
-        auto it = mediaTypeMap.find(ext);
-        return it != mediaTypeMap.end() ? it->second : MediaTypeData("", MsgMedia::UnknownType);
+        auto it = mediaTypeByExtMap.find(ext);
+        return it != mediaTypeByExtMap.end() ? it->second : MediaTypeData("", MsgMedia::UnknownType);
+    }
+
+    inline static MsgMedia::Type getMsgMediaTypeByMime(std::string mime)
+    {
+        std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
+
+        auto it = mediaTypeByMimeMap.find(mime);
+        return it != mediaTypeByMimeMap.end() ? it->second : MsgMedia::UnknownType;
     }
 }
 
index ebf989a879182ac99550e6aef731063cccbc33ab..9a7de0c0fdd9b489ebe2628105840b1d96f4655e 100644 (file)
@@ -104,7 +104,7 @@ void MsgMediaPrivate::setMime(const std::string &mime)
 void MsgMediaPrivate::setFilePath(const std::string &path)
 {
     MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, path);
-    MediaTypeData mediaData = getMediaType(path);
+    MediaTypeData mediaData = getMsgMediaTypeByFileExt(path);
     setMime(mediaData.mime);
     setType(mediaData.type);
 }
index 61de4ab91f5f5fa1d6f14310a1ffa3416c505458..a0b2a54c89be12e7c5995d61b4da7b1a9ea1390f 100644 (file)
@@ -284,7 +284,7 @@ void Body::readAttachments(MessageMms &msg)
     for(BodyAttachmentViewItem *attachView : attachments)
     {
         std::string resPath= attachView->getResourcePath();
-        std::string mime = getMediaType(resPath).mime;
+        std::string mime = getMsgMediaTypeByFileExt(resPath).mime;
         long long fileSize = FileUtils::getFileSize(resPath);
 
         MsgAttachment &msgAttach = msg.addAttachment();
@@ -552,7 +552,7 @@ void Body::onFileReady(const std::string &filePath)
         showTooMuchAttachedPopup();
         return;
     }
-    MediaTypeData mediaType = getMediaType(filePath);
+    MediaTypeData mediaType = getMsgMediaTypeByFileExt(filePath);
     MSG_LOG("Media type: ", mediaType.mime);
 
     Page *page = nullptr;
index 01b095dcbaf389f5cc8a53523ee88ce3f7dea289..74c3d21c941a5250ddc2b3613002e33110b1fbf4 100644 (file)
@@ -119,7 +119,7 @@ bool Page::isMms()
 
 bool Page::addMedia(const std::string &filePath)
 {
-    MediaTypeData typeData = getMediaType(filePath);
+    MediaTypeData typeData = getMsgMediaTypeByFileExt(filePath);
     MSG_LOG("Media type: ", typeData.mime);
 
    switch(typeData.type)
index bc42575dd7841666f2d0f0303fbd35e9973adef4..5426e7afe1b8ccd64d8cfdc147b01bc02296e45a 100644 (file)
@@ -191,9 +191,10 @@ void ConvListItem::prepareBubble(const MsgConversationItem &item, const std::str
         for(int i = 0; i < list.getLength(); i++)
         {
             const MsgConvMedia &media = list.at(i);
-            MediaTypeData mediaType = getMediaType(media.getPath());
+            std::string mime = media.getMime();
+            MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime);
 
-            switch(mediaType.type)
+            switch(msgMediaType)
             {
                 case MsgMedia::TextType:
                     addTextItem(media, searchWord);
@@ -208,7 +209,7 @@ void ConvListItem::prepareBubble(const MsgConversationItem &item, const std::str
                     addVideoItem(media);
                     break;
                 default:
-                    if(mediaType.mime != "application/smil")
+                    if(mime != "application/smil")
                         addAttachedFileItem(media);
                     break;
             }
index 536ff39513d4aa4556c5e8134fbba71250ce061f..53639fba3553b0e24edc0b14f3b27411c7319b7b 100644 (file)
@@ -112,8 +112,8 @@ void AttachmentHandler::onRoutine()
         ecore_main_loop_thread_safe_call_sync(safeCallOnFreeSpaceRequest, this);
         if(FileUtils::getFileSize(m_CurrentFile) > m_CurrentFreeSpace)
         {
-            if((getMediaType(m_CurrentFile).type == MsgMedia::ImageType && MediaUtils::downgradeImageQuality(m_CurrentFile) > m_CurrentFreeSpace)
-                    || getMediaType(m_CurrentFile).type != MsgMedia::ImageType)
+            bool isImage = getMsgMediaTypeByFileExt(m_CurrentFile).type == MsgMedia::ImageType;
+            if((isImage && MediaUtils::downgradeImageQuality(m_CurrentFile) > m_CurrentFreeSpace) || !isImage)
             {
                 m_WorkingDir->removeFile(m_CurrentFile);
                 ecore_main_loop_thread_safe_call_sync(safeCallOnFileFails, this);