From: Pawel Andruszkiewicz
Date: Wed, 3 Jun 2015 11:49:45 +0000 (+0200)
Subject: [Messaging] Removed hard coded paths.
X-Git-Tag: submit/tizen_mobile/20150612.133019^2~2^2~45^2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35e1c3bed21a6356835b807f2aae9ebb65d05d0a;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Messaging] Removed hard coded paths.
[Verification] TCT tests for MMS did not change.
Change-Id: I9abe92491d58807224c1d7695c7c7515d2321345
Signed-off-by: Pawel Andruszkiewicz
---
diff --git a/src/messaging/message_attachment.cc b/src/messaging/message_attachment.cc
index ec102c86..d778962b 100755
--- a/src/messaging/message_attachment.cc
+++ b/src/messaging/message_attachment.cc
@@ -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 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;
}