[Messaging] Removed hard coded paths.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 3 Jun 2015 11:49:45 +0000 (13:49 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 3 Jun 2015 11:49:45 +0000 (13:49 +0200)
[Verification] TCT tests for MMS did not change.

Change-Id: I9abe92491d58807224c1d7695c7c7515d2321345
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/messaging/message_attachment.cc

index ec102c860d6ef0cb1d09fabe4d1eff55e42f581d..d778962b273b0dd77be3f0f7cdc52f9d6a8918c0 100755 (executable)
@@ -20,6 +20,7 @@
 #include "message_attachment.h"
 
 #include "common/logger.h"
+#include "common/virtual_fs.h"
 
 namespace extension {
 namespace messaging {
@@ -138,50 +139,11 @@ std::string MessageAttachment::getShortFileName() const
     return m_filePath.substr(pos + 1);
 }
 
-namespace {
-
-const std::unordered_map<std::string, std::string> virtualToReal = {
-    { "downloads", "/opt/usr/media/Downloads" },
-    { "documents", "/opt/usr/media/Documents" },
-    { "music"    , "/opt/usr/media/Sounds" },
-    { "images"   , "/opt/usr/media/Images" },
-    { "videos"   , "/opt/usr/media/Videos" },
-    { "ringtones", "/opt/usr/share/settings/Ringtones" },
-    { "camera"   , "/opt/usr/media/DCIM/Camera" }
-};
-
-const char PATH_SEPARATOR = '/';
-
-} // namespace
-
 void MessageAttachment::setFilePath(const std::string &value)
 {
     LoggerD("Entered");
-    std::string tmp = value;
-    // change to lower case
-    for (int i = 0; i < tmp.length() && i < 4; i++) {
-        tmp[i] = tolower(tmp[i]);
-    }
-    if (tmp.find("file://") != std::string::npos) {
-        m_filePath = value.substr(7);
-    } else {
-        m_filePath = value;
-    }
-
-    if (PATH_SEPARATOR != m_filePath[0]) {
-        auto pos = m_filePath.find(PATH_SEPARATOR);
-
-        if (pos == std::string::npos) {
-            pos = m_filePath.length();
-        }
-
-        auto path = virtualToReal.find(m_filePath.substr(0, pos));
-
-        if (virtualToReal.end() != path) {
-            m_filePath = path->second + m_filePath.substr(pos);
-        }
-    }
 
+    m_filePath = common::VirtualFs::GetInstance().GetRealPath(value);
     m_isFilePathSet = true;
 }