[content] Fix compat TC fails
authorSeokpil Park <seokpil.park@samsung.com>
Tue, 20 Aug 2013 05:51:06 +0000 (14:51 +0900)
committerSeokpil Park <seokpil.park@samsung.com>
Tue, 20 Aug 2013 05:51:10 +0000 (14:51 +0900)
Change-Id: I81c8de51cce05ca9d901fe97e75d0ef4a5248d6b
Signed-off-by: Seokpil Park <seokpil.park@samsung.com>
12 files changed:
src/FCntContentManager.cpp
src/FCnt_AudioContentInfoImpl.cpp
src/FCnt_ContentInfoImpl.cpp
src/FCnt_ContentManagerImpl.cpp
src/FCnt_ContentManagerUtilImpl.cpp
src/FCnt_ContentSearchImpl.cpp
src/FCnt_ImageContentInfoImpl.cpp
src/FCnt_OtherContentInfoImpl.cpp
src/FCnt_VideoContentInfoImpl.cpp
src/inc/FCnt_ContentInfoImpl.h
src/inc/FCnt_ContentManagerImpl.h
src/inc/FCnt_ContentManagerUtilImpl.h

index 4956e00..07e97c7 100644 (file)
@@ -138,13 +138,7 @@ ContentManager::GetContentInfoN(const ContentId& contentId) const
 {
        ClearLastResult();
        result r = E_SUCCESS;
-
        ContentInfo* pContentInfo = null;
-       ImageContentInfo* pImageContentInfo = null;
-       AudioContentInfo* pAudioContentInfo = null;
-       VideoContentInfo* pVideoContentInfo = null;
-       OtherContentInfo* pOtherContentInfo = null;
-       ContentType contentType;
 
        // Checks the privilege
        r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
index b41f135..88a0e50 100644 (file)
@@ -75,11 +75,31 @@ result
 _AudioContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
 {
        result r = E_SUCCESS;
-       int contentLength = 0;
-       FileAttributes attribute;
+       String tempPath(contentPath);
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
+               {
+                       // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+                       // it should be converted in 2.0.
+                       r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
+               {
+                       r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else
+               {
+                       SysLogException(NID_CNT, E_INVALID_ARG,
+                                       "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+                       return E_INVALID_ARG;
+               }
+       }
 
        // checks parameters
-       contentLength = contentPath.GetLength();
        SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
                        "The contentPath should start with /Media or /Storagecard/Media.");
        SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
@@ -96,7 +116,7 @@ _AudioContentInfoImpl::Construct(const String& contentPath, const String& thumbn
                SysLog(NID_CNT, "The setGps is not supported.");
        }
 
-       SetContentPath(contentPath);
+       SetContentPath(tempPath);
        SetContentType(CONTENT_TYPE_AUDIO);
 
        return r;
@@ -146,7 +166,7 @@ _AudioContentInfoImpl::Construct(const String* pContentPath)
                int length = contentPath.GetLength();
                SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
                                "The length of pContentPath is 0.");
-               SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+               SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
                                "The file corresponding to pContentPath could not be found.");
 
                SetContentPath(contentPath);
index 2c0b6e9..f9c19a6 100644 (file)
 #include <FGrpBitmap.h>
 #include <FMediaImage.h>
 #include <FApp_AppInfo.h>
+#include <FIo_FileImpl.h>
 #include "FCnt_ContentInfoImpl.h"
 
 using namespace std;
+using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Io;
 using namespace Tizen::Locations;
 using namespace Tizen::Graphics;
 using namespace Tizen::Media;
-using namespace Tizen::App;
 
 namespace Tizen { namespace Content
 {
@@ -132,6 +133,16 @@ _ContentInfoImpl::GetContentName(void) const
 String
 _ContentInfoImpl::GetContentPath(void) const
 {
+       String changedPath(L"");
+       result r = GetCompatContentPath(__contentPath, changedPath);
+       SysTryLogReturn(NID_CNT, !IsFailed(r), L"", "Failed to perform GetCompatContentPath.");
+
+       return changedPath;
+}
+
+String
+_ContentInfoImpl::GetPhysicalContentPath(void) const
+{
        return __contentPath;
 }
 
@@ -222,6 +233,10 @@ _ContentInfoImpl::GetThumbnailN(void) const
        SysTryReturn(NID_CNT, !__thumbnailPath.IsEmpty(), null, E_DATA_NOT_FOUND,
                        "[E_DATA_NOT_FOUND] GetThumbnailN() failed.");
 
+       String changedPath(L"");
+       r = GetCompatContentPath(__thumbnailPath, changedPath);
+       SysTryReturn(NID_CNT, !IsFailed(r), null, E_DATA_NOT_FOUND, "[%s] Failed to perform GetCompatContentPath.", GetErrorMessage(E_DATA_NOT_FOUND));
+
        if (__contentType == CONTENT_TYPE_IMAGE || __contentType == CONTENT_TYPE_AUDIO
                || __contentType == CONTENT_TYPE_VIDEO)
        {
@@ -230,11 +245,11 @@ _ContentInfoImpl::GetThumbnailN(void) const
 
                if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
                {
-                       pBitmap = image.DecodeN(__thumbnailPath, BITMAP_PIXEL_FORMAT_ARGB8888, _THUMBNAIL_IMAGE_WIDTH, _THUMBNAIL_IMAGE_HEIGHT);
+                       pBitmap = image.DecodeN(changedPath, BITMAP_PIXEL_FORMAT_ARGB8888, _THUMBNAIL_IMAGE_WIDTH, _THUMBNAIL_IMAGE_HEIGHT);
                }
                else
                {
-                       pBitmap = image.DecodeN(__thumbnailPath, BITMAP_PIXEL_FORMAT_ARGB8888);
+                       pBitmap = image.DecodeN(changedPath, BITMAP_PIXEL_FORMAT_ARGB8888);
                }
 
                if (pBitmap == null)
@@ -430,4 +445,21 @@ _ContentInfoImpl::SetModifiedTime(const DateTime& modifiedTime)
        __modifiedTime = modifiedTime;
 }
 
+result
+_ContentInfoImpl::GetCompatContentPath(const String& contentPath, String& changedPath) const
+{
+       result r = E_SUCCESS;
+       changedPath = contentPath;
+
+       // If the api version is 2.0, the content path has to be changed.
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               r = _FileImpl::ConvertPhysicalToVirtualPath(contentPath, changedPath);
+               SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+                               "[%s] Failed to convert physical path to virtual path.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       return r;
+}
+
 }}
index 766e317..0a649fd 100644 (file)
@@ -299,16 +299,21 @@ _ContentManagerImpl::CreateContent(const ContentInfo& contentInfo)
        SysTryReturn(NID_CNT, pInfoImpl != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
                        "[E_INVALID_ARG] Invalid argument is used. ContentInfo is invalid.");
 
-       SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(pInfoImpl->GetContentPath(), true), UuId::GetInvalidUuId(),
-                       E_INVALID_ARG, "[E_INVALID_ARG] The contentPath is not compatible.");
-       SysTryReturn(NID_CNT, _FileImpl::IsFileExist(pInfoImpl->GetContentPath()), UuId::GetInvalidUuId(), E_FILE_NOT_FOUND,
-                       "[E_FILE_NOT_FOUND] The file corresponding to contentInfo could not be found.");
+       String contentPath(pInfoImpl->GetPhysicalContentPath());
+       String changedPath(L"");
+
+       result r = ChangeTizenPathToCompat(contentPath, changedPath);
+       SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform ChangeTizenPathToCompat.", GetErrorMessage(r));
+
+       SysTryReturn(NID_CNT, _FileImpl::IsFileExist(changedPath), UuId::GetInvalidUuId(), E_FILE_NOT_FOUND,
+                       "[%s] The file cound not be found.", GetErrorMessage(E_FILE_NOT_FOUND));
+
        SysTryReturn(NID_CNT, pInfoImpl->GetContentId() == UuId::GetInvalidUuId(), UuId::GetInvalidUuId(),
                        E_INVALID_ARG, "[E_INVALID_ARG] The contentId is not empty.");
 
        // Compare the type of input parameter and system
        ContentType inputType = pInfoImpl->GetContentType();
-       ContentType sysType = _ContentManagerUtilImpl::CheckContentType(pInfoImpl->GetContentPath(), true);
+       ContentType sysType = _ContentManagerUtilImpl::CheckContentType(contentPath, true);
 
        ClearLastResult();
 
@@ -323,7 +328,7 @@ _ContentManagerImpl::CreateContent(const ContentInfo& contentInfo)
        }
 
        // Save data to database with contentPath.
-       unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(contentInfo.GetContentPath()));
+       unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(contentPath));
        SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
                        "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
@@ -337,7 +342,7 @@ _ContentManagerImpl::CreateContent(const ContentInfo& contentInfo)
        pMediaInfo.reset(tempMediaInfo);
 
        ContentId contentId = SaveDataToDatabase(pMediaInfo.get(), pInfoImpl);
-       result r = GetLastResult();
+       r = GetLastResult();
        SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
                        "[%s] The registration to database failed.", GetErrorMessage(r));
 
@@ -363,7 +368,7 @@ _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& d
                        "[E_INVALID_ARG] byteBuffer is invalid.");
 
        // Check parameters(for path compatibility)
-       SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
+       SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath), UuId::GetInvalidUuId(),
                        E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
        SysTryReturn(NID_CNT, !_FileImpl::IsFileExist(destinationPath), UuId::GetInvalidUuId(), E_FILE_ALREADY_EXIST,
                        "[E_FILE_ALREADY_EXIST] The specified file already exists.");
@@ -398,6 +403,10 @@ _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& d
        media_info_h tempMediaInfo = null;
        unique_ptr<media_info_s, _MediaInfoDeleter> pMediaInfo(null);
        unique_ptr<char[]> pStr(null);
+       String destPath(L"");
+
+       r = ChangeCompatPathToTizen(destinationPath, destPath);
+       SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform ChangedCompatPathToTizen.", GetErrorMessage(r));
 
        if (pContentInfo != null)
        {
@@ -426,7 +435,7 @@ _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& d
                }
 
                // Sets the content path
-               pInfoImpl->SetContentPath(destinationPath);
+               pInfoImpl->SetContentPath(destPath);
        }
        else
        {
@@ -441,7 +450,7 @@ _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& d
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for ImageContentInfoImpl.");
 
-                       imageContentInfoImpl.SetContentPath(destinationPath);
+                       imageContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&imageContentInfoImpl);
                }
                else if (contentType == CONTENT_TYPE_AUDIO)
@@ -450,7 +459,7 @@ _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& d
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for AudioContentInfoImpl.");
 
-                       audioContentInfoImpl.SetContentPath(destinationPath);
+                       audioContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&audioContentInfoImpl);
                }
                else if (contentType == CONTENT_TYPE_VIDEO)
@@ -459,7 +468,7 @@ _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& d
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for VideoContentInfoImpl.");
 
-                       videoContentInfoImpl.SetContentPath(destinationPath);
+                       videoContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&videoContentInfoImpl);
                }
                else
@@ -468,13 +477,13 @@ _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& d
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for OtherContentInfoImpl.");
 
-                       otherContentInfoImpl.SetContentPath(destinationPath);
+                       otherContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&otherContentInfoImpl);
                }
        }
 
        // Register the content to database directly.
-       pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
+       pStr.reset(_StringConverter::CopyToCharArrayN(destPath));
        SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        val = media_info_insert_to_db(pStr.get(), &tempMediaInfo);
@@ -520,7 +529,7 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
        // Check parameters(for path compatibility)
        SysTryReturn(NID_CNT, VerifyHomeFilePathCompatibility(sourcePath), UuId::GetInvalidUuId(), E_INVALID_ARG,
                        "[E_INVALID_ARG] %ls is not compatible.", sourcePath.GetPointer());
-       SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
+       SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath), UuId::GetInvalidUuId(),
                        E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
 
        result r = E_SUCCESS;
@@ -549,6 +558,10 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
        media_info_h tempMediaInfo = null;
        unique_ptr<media_info_s, _MediaInfoDeleter> pMediaInfo(null);
        unique_ptr<char[]> pStr(null);
+       String destPath(L"");
+
+       r = ChangeCompatPathToTizen(destinationPath, destPath);
+       SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform ChangedCompatPathToTizen.", GetErrorMessage(r));
 
        if (pContentInfo != null)
        {
@@ -577,7 +590,7 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
                }
 
                // Set the content path
-               pInfoImpl->SetContentPath(destinationPath);
+               pInfoImpl->SetContentPath(destPath);
        }
        else
        {
@@ -592,7 +605,7 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for ImageContentInfoImpl.");
 
-                       imageContentInfoImpl.SetContentPath(destinationPath);
+                       imageContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&imageContentInfoImpl);
                }
                else if (contentType == CONTENT_TYPE_AUDIO)
@@ -601,7 +614,7 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for AudioContentInfoImpl.");
 
-                       audioContentInfoImpl.SetContentPath(destinationPath);
+                       audioContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&audioContentInfoImpl);
                }
                else if (contentType == CONTENT_TYPE_VIDEO)
@@ -610,7 +623,7 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for VideoContentInfoImpl.");
 
-                       videoContentInfoImpl.SetContentPath(destinationPath);
+                       videoContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&videoContentInfoImpl);
                }
                else
@@ -619,12 +632,12 @@ _ContentManagerImpl::CreateContent(const String& sourcePath, const String& desti
                        SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
                                        "[E_OUT_OF_MEMORY] Failed to perform Construct for OtherContentInfoImpl.");
 
-                       otherContentInfoImpl.SetContentPath(destinationPath);
+                       otherContentInfoImpl.SetContentPath(destPath);
                        pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&otherContentInfoImpl);
                }
        }
 
-       pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
+       pStr.reset(_StringConverter::CopyToCharArrayN(destPath));
        SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        val = media_info_insert_to_db(pStr.get(), &tempMediaInfo);
@@ -695,19 +708,23 @@ _ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
 
        unique_ptr<char, CharDeleter> pFilePath(pTempFilePath);
        String contentPath(pFilePath.get());
-
-       SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), null, E_FILE_NOT_FOUND,
-                       "[E_FILE_NOT_FOUND] The file corresponding to contentId could not be found.");
+       String changedPath(L"");
 
        result r = E_SUCCESS;
 
+       r = ChangeTizenPathToCompat(contentPath, changedPath);
+       SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform ChangeTizenPathToCompat.", GetErrorMessage(r));
+
+       SysTryReturn(NID_CNT, _FileImpl::IsFileExist(changedPath), null, E_FILE_NOT_FOUND,
+                       "[E_FILE_NOT_FOUND] The file corresponding to contentId could not be found.");
+
        if (systemType == SYSTEM_TYPE_IMAGE)
        {
                unique_ptr< ImageContentInfo > pImageContentInfo(new (nothrow) ImageContentInfo);
                SysTryReturn(NID_CNT, pImageContentInfo != null, null, E_OUT_OF_MEMORY,
                                "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-               r = pImageContentInfo->Construct(&contentPath);
+               r = pImageContentInfo->Construct(&changedPath);
                r = ConvertErrorToResult(r);
                SysTryReturn(NID_CNT, !IsFailed(r), null, r,
                                "[%s] Failed to perform Construct operation to ImageContentInfo.", GetErrorMessage(r));
@@ -727,7 +744,7 @@ _ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
                SysTryReturn(NID_CNT, pAudioContentInfo != null, null, E_OUT_OF_MEMORY,
                                "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-               r = pAudioContentInfo->Construct(&contentPath);
+               r = pAudioContentInfo->Construct(&changedPath);
                r = ConvertErrorToResult(r);
                SysTryReturn(NID_CNT, !IsFailed(r), null, r,
                                "[%s] Failed to perform Construct operation to AudioContentInfo.", GetErrorMessage(r));
@@ -747,7 +764,7 @@ _ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
                SysTryReturn(NID_CNT, pVideoContentInfo != null, null, E_OUT_OF_MEMORY,
                                "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-               r = pVideoContentInfo->Construct(&contentPath);
+               r = pVideoContentInfo->Construct(&changedPath);
                r = ConvertErrorToResult(r);
                SysTryReturn(NID_CNT, !IsFailed(r), null, r,
                                "[%s] Failed to perform Construct operation to VideoContentInfo.", GetErrorMessage(r));
@@ -767,7 +784,7 @@ _ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
                SysTryReturn(NID_CNT, pOtherContentInfo != null, null, E_OUT_OF_MEMORY,
                                "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
-               r = pOtherContentInfo->Construct(&contentPath);
+               r = pOtherContentInfo->Construct(&changedPath);
                r = ConvertErrorToResult(r);
                SysTryReturn(NID_CNT, !IsFailed(r), null, r,
                                "[%s] Failed to perform Construct operation to OtherContentInfo.", GetErrorMessage(r));
@@ -791,14 +808,14 @@ _ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
 result
 _ContentManagerImpl::UpdateContent(const ContentInfo& contentInfo)
 {
-       ContentId contentId = contentInfo.GetContentId();
-       SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The content id is invalid.");
-       SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentInfo.GetContentPath()), E_FILE_NOT_FOUND,
-                       "The file corresponding to contentInfo could not be found.");
-
        const _ContentInfoImpl* pInfoImpl = _ContentInfoImpl::GetInstance(contentInfo);
        SysTryReturnResult(NID_CNT, pInfoImpl != null, E_INVALID_ARG, "Invalid argument is used. ContentInfo is invalid.");
 
+       ContentId contentId = pInfoImpl->GetContentId();
+       SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The content id is invalid.");
+       SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(pInfoImpl->GetContentPath()), E_FILE_NOT_FOUND,
+                       "The file corresponding to contentInfo could not be found.");
+
        result r = UpdateDataToDatabase(pInfoImpl);
        SysTryReturnResult(NID_CNT, !IsFailed(r), r, "UpdateDataToDatabase failed.");
 
@@ -831,16 +848,20 @@ _ContentManagerImpl::DeleteContent(const ContentId& contentId)
                        "media_info_get_file_path failed[%d].", val);
 
        unique_ptr<char, CharDeleter> pContentPath(pTempPath);
+       String contentPath(pContentPath.get());
+       String changedPath(L"");
 
-       String contentPath = String(pContentPath.get());
-       SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+       r = ChangeTizenPathToCompat(contentPath, changedPath);
+       SysTryReturnResult(NID_CNT, !IsFailed(r), r, "[%s] Failed to perform ChangeTizenPathToCompat.", GetErrorMessage(r));
+
+       SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(changedPath), E_FILE_NOT_FOUND,
                        "The file corresponding to contentId could not be found.");
 
        val = media_info_delete_from_db(pContentId.get());
        SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
                        "media_info_delete_From_db failed[%d].", val);
 
-       r = _FileImpl::Remove(contentPath);
+       r = _FileImpl::Remove(changedPath);
        SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The file is not deleted.");
 
        return r;
@@ -1049,20 +1070,28 @@ _ContentManagerImpl::SaveDataToDatabase(const media_info_h pMediaInfo,
                                                                                                _ContentInfoImpl* pContentInfoImpl) const
 {
        ClearLastResult();
+       result r = E_SUCCESS;
 
        SysTryReturn(NID_CNT, pContentInfoImpl != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
                        "[E_INVALID_ARG] Invalid argument is used. ContentInfo is invalid.");
 
+       String contentPath(pContentInfoImpl->GetPhysicalContentPath());
+       String changedPath(L"");
+
+       r = ChangeTizenPathToCompat(contentPath, changedPath);
+       SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r,
+                       "[%s] Failed to perform ChangeTizenPathToCompat.", GetErrorMessage(r));
+
        String mimeType(L"");
-       String extension = _FileImpl::GetFileExtension(pContentInfoImpl->GetContentPath());
-       result r = GetLastResult();
+       String extension = _FileImpl::GetFileExtension(changedPath);
+       r = GetLastResult();
        if (IsFailed(r))
        {
                ClearLastResult();
 
                SysLog(NID_CNT, "[%s] Failed to perform GetFileExtension operation.", GetErrorMessage(r));
 
-               unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetContentPath()));
+               unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(contentPath));
                SysTryReturn(NID_CNT, pTempPath != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
                                "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
@@ -1082,7 +1111,7 @@ _ContentManagerImpl::SaveDataToDatabase(const media_info_h pMediaInfo,
        {
                SysLog(NID_CNT, "The format of content is jpg.");
 
-               ImageMetadata* pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(pContentInfoImpl->GetContentPath(), true);
+               ImageMetadata* pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(changedPath, true);
                if (pImageMetadata != null)
                {
                        pContentInfoImpl->SetLatitude(pImageMetadata->GetLatitude());
@@ -1267,30 +1296,8 @@ _ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, int systemTy
 
                String strFilePath(pStrValue.get());
 
-               // If the api version is 2.0, the content path has to be changed.
-               if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
-               {
-                       if (strFilePath.StartsWith(Environment::GetMediaPath(), 0))
-                       {
-                               r = strFilePath.Replace(Environment::GetMediaPath(), OSP_MEDIA_PHONE);
-                               SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content path is not changed.");
-                       }
-                       else if (strFilePath.StartsWith(Environment::GetExternalStoragePath(), 0))
-                       {
-                               r = strFilePath.Replace(Environment::GetExternalStoragePath(), OSP_MEDIA_MMC);
-                               SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Replace failed.");
-                       }
-                       else
-                       {
-                               SysLogException(NID_CNT, E_INVALID_ARG,
-                                               "[E_INVALID_ARG] The content path is not supported.");
-                               return E_INVALID_ARG;
-                       }
-               }
-
                pContentInfoImpl->SetContentPath(strFilePath);
-
-               SysSecureLog(NID_CNT, "INFO: contentPath[%ls]", strFilePath.GetPointer());
+               SysSecureLog(NID_CNT, "INFO: contentPath[%ls]", (pContentInfoImpl->GetContentPath()).GetPointer());
        }
 
        // mimeType
@@ -1374,7 +1381,6 @@ _ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, int systemTy
                String thumbnailPath(pStrValue.get());
 
                pContentInfoImpl->SetThumbnailPath(thumbnailPath);
-
                SysLog(NID_CNT, "INFO: thumbnailPath[%ls]", (pContentInfoImpl->GetThumbnailPath()).GetPointer());
        }
 
@@ -2067,57 +2073,67 @@ _ContentManagerImpl::VerifyHomeFilePathCompatibility(const String& contentPath)
 }
 
 bool
-_ContentManagerImpl::VerifyMediaFilePathCompatibility(const String& contentPath, bool checkVersion) const
+_ContentManagerImpl::VerifyMediaFilePathCompatibility(const String& contentPath) const
 {
        ClearLastResult();
 
-       result r = E_SUCCESS;
-
        if (!_AppInfo::IsOspCompat())
        {
-               if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0) || contentPath.StartsWith(OSP_MEDIA_MMC, 0))
-               {
-                       SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] /Media or /Storagecard/Media is not supported.");
-                       return false;
-               }
                if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0) ||
                                contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
                {
-                       SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] This path is not supported.");
+                       SysLogException(NID_CNT, E_INVALID_ARG, "[%s] This path is not supported.", GetErrorMessage(E_INVALID_ARG));
                        return false;
                }
        }
        else
        {
-               String tempPath(contentPath);
-
                // prior to 2.0
-               if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
-               {
-                       r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
-                       SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
-               }
-               else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
+               if (!(contentPath.StartsWith(OSP_MEDIA_PHONE, 0)) ||
+                               (contentPath.StartsWith(OSP_MEDIA_MMC, 0)))
                {
-                       r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
-                       SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
-               }
-               else
-               {
-                       // CreateContent(const ByteBuffer&, ...) and CreateContent (const Sring&, ...) can receive old path like /Media/.
-                       // but CreateContent(const ContentInfo&) always receive new path like /opt/media/ because ContentInfo class convert the path from /Media/ to /opt/media.
-                       if (!checkVersion)
-                       {
-                               SysLogException(NID_CNT, E_INVALID_ARG,
-                                               "[E_INVALID_ARG] The path should start with /Home, /Media, or /Storagecard/Media.");
-                               return false;
-                       }
+                       SysLogException(NID_CNT, E_INVALID_ARG, "[%s] The path should start with /Media, or /Storagecard/Media.", GetErrorMessage(E_INVALID_ARG));
+                       return false;
                }
        }
 
        return true;
 }
 
+result
+_ContentManagerImpl::ChangeTizenPathToCompat(const String& contentPath, String& changedPath) const
+{
+       result r = E_SUCCESS;
+       changedPath = contentPath;
+
+       // If the api version is 2.0, the content path has to be changed.
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               r = _FileImpl::ConvertPhysicalToVirtualPath(contentPath, changedPath);
+               SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+                               "[%s] Failed to convert physical path to virtual path.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       return r;
+}
+
+result
+_ContentManagerImpl::ChangeCompatPathToTizen(const String& contentPath, String& changedPath) const
+{
+       result r = E_SUCCESS;
+       changedPath = contentPath;
+
+       // If the api version is 2.0, the content path has to be changed.
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               r = _FileImpl::ConvertVirtualToPhysicalPath(contentPath, changedPath);
+               SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+                               "[%s] Failed to convert virtual path to physical path.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       return r;
+}
+
 void
 _ContentManagerImpl::SetListener(IContentUpdateEventListener* pListener)
 {
index 581eea8..74081ea 100755 (executable)
@@ -105,9 +105,14 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
        pMetadata->height = dim.height;
        pMetadata->contentPath = contentPath;
 
+       String tizenPath(L"");
+       String changedPath(L"");
+       r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+       SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to perform ChangeMediaFilePath.", GetErrorMessage(r));
+
        if (imgType == IMG_FORMAT_JPG)
        {
-               unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
+               unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(tizenPath));
                SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
                                "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
@@ -296,11 +301,16 @@ _ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath)
 
        pMetadata->contentPath = contentPath;
 
+       String tizenPath(L"");
+       String changedPath(L"");
+       result r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+       SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to perform ChangeMediaFilePath.", GetErrorMessage(r));
+
        // Create the metadata extractor handle
        metadata_extractor_h tempExtractor = NULL;
 
        int retVal = metadata_extractor_create(&tempExtractor);
-       result r = ErrorMapToRetVal(retVal);
+       r = ErrorMapToRetVal(retVal);
        SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
                        "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
 
@@ -309,7 +319,7 @@ _ContentManagerUtilImpl::GetAudioMetaN(const String& contentPath)
                        "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
        // Set file path of content to extract the metadata
-       unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
+       unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(tizenPath));
        SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
                        "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
@@ -638,11 +648,16 @@ _ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath)
 
        pMetadata->contentPath = contentPath;
 
+       String tizenPath(L"");
+       String changedPath(L"");
+       result r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+       SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to perform ChangeMediaFilePath.", GetErrorMessage(r));
+
        // Create the metadata extractor handle
        metadata_extractor_h tempExtractor = NULL;
 
        int retVal = metadata_extractor_create(&tempExtractor);
-       result r = ErrorMapToRetVal(retVal);
+       r = ErrorMapToRetVal(retVal);
        SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, null, r,
                        "[%s] metadata_extractor_create failed.", GetErrorMessage(r));
 
@@ -651,7 +666,7 @@ _ContentManagerUtilImpl::GetVideoMetaN(const String& contentPath)
                                "[E_OUT_OF_MEMORY] The memory insufficient.");
 
        // Set file path of content to extract the metadata
-       unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
+       unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(tizenPath));
        SysTryReturn(NID_CNT, pFileName != null, null, E_OUT_OF_MEMORY,
                        "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
@@ -1611,13 +1626,19 @@ _ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool intern
                SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), contentType, E_INVALID_ARG,
                                "[E_INVALID_ARG] The path is not compatible.");
        }
-       SysTryReturn(NID_CNT, contentPath.GetLength() != 0, contentType, E_INVALID_ARG,
+
+       String tizenPath(L"");
+       String changedPath(L"");
+       result r = ChangeMediaFilePath(contentPath, tizenPath, changedPath);
+       SysTryReturn(NID_CNT, !IsFailed(r), contentType, r, "[%s] Failed to perform ChangeMediaFilePathCompat.", GetErrorMessage(r));
+
+       SysTryReturn(NID_CNT, changedPath.GetLength() != 0, contentType, E_INVALID_ARG,
                        "[E_INVALID_ARG] The length of contentPath is 0.");
-       SysTryReturn(NID_CNT, _FileImpl::IsFileExist(contentPath), contentType, E_FILE_NOT_FOUND,
+       SysTryReturn(NID_CNT, _FileImpl::IsFileExist(changedPath), contentType, E_FILE_NOT_FOUND,
                        "[E_FILE_NOT_FOUND] The file corresponding to contentPath could not be found.");
 
-       String fileExt = _FileImpl::GetFileExtension(contentPath);
-       result r = GetLastResult();
+       String fileExt = _FileImpl::GetFileExtension(changedPath);
+       r = GetLastResult();
 
        if (!IsFailed(r))
        {
@@ -1647,7 +1668,7 @@ _ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool intern
 
                SysLog(NID_CNT, "[%s] Failed to perform GetFileExtension operation.", GetErrorMessage(r));
 
-               unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(contentPath));
+               unique_ptr<char[]> pTempPath(_StringConverter::CopyToCharArrayN(tizenPath));
                SysTryReturn(NID_CNT, pTempPath != null, contentType, E_OUT_OF_MEMORY,
                                "[E_OUT_OF_MEMORY] The memory is insufficient.");
 
@@ -1678,7 +1699,7 @@ _ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool intern
        {
                if (mimeType == L"video/3gpp" || mimeType == L"video/mp4")
                {
-                       return CheckStream(contentPath);
+                       return CheckStream(tizenPath);
                }
                return CONTENT_TYPE_VIDEO;
        }
@@ -1877,4 +1898,41 @@ _ContentManagerUtilImpl::MoveToMediaDirectory(const String& srcContentPath, cons
        return r;
 }
 
+result
+_ContentManagerUtilImpl::ChangeMediaFilePath(const String& contentPath, String& tizenPath, String& changedPath)
+{
+       result r = E_SUCCESS;
+
+       tizenPath = contentPath;
+       changedPath = contentPath;
+
+       // If the api version is 2.0, the content path has to be changed.
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if ((contentPath.StartsWith(Environment::GetMediaPath(), 0)) || (contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
+               {
+                       tizenPath = contentPath;
+
+                       r = _FileImpl::ConvertPhysicalToVirtualPath(contentPath, changedPath);
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+                                       "[%s] Failed to convert physical path to virtual path.", GetErrorMessage(E_INVALID_ARG));
+               }
+               else if ((contentPath.StartsWith(OSP_MEDIA_PHONE, 0)) || (contentPath.StartsWith(OSP_MEDIA_MMC, 0)) || (contentPath.StartsWith(OSP_HOME, 0)))
+               {
+                       changedPath = contentPath;
+
+                       r = _FileImpl::ConvertVirtualToPhysicalPath(contentPath, tizenPath);
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+                                       "[%s] Failed to convert virtual path to physical path.", GetErrorMessage(E_INVALID_ARG));
+               }
+               else
+               {
+                       SysLogException(NID_CNT, E_INVALID_ARG, "[%s] The path is not supported.", GetErrorMessage(E_INVALID_ARG));
+                       return E_INVALID_ARG;
+               }
+       }
+
+       return r;
+}
+
 }}
index 0edb6ce..82e616d 100644 (file)
 #include <FBaseUtilStringTokenizer.h>
 #include <FCntContentSearch.h>
 #include <FCntContentSearchResult.h>
+#include <FSysEnvironment.h>
+#include <FApp_AppInfo.h>
 #include <FBase_StringConverter.h>
 #include <FBase_LocalizedNumParser.h>
+#include <FIo_FileImpl.h>
 #include "FCnt_ContentUtility.h"
 #include "FCnt_ContentSearchImpl.h"
 #include "FCnt_ContentInfoImpl.h"
 #include "FCnt_OtherContentInfoImpl.h"
 #include "FCnt_ContentInfoHelper.h"
 
+using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
 using namespace Tizen::Io;
+using namespace Tizen::System;
 
 namespace Tizen { namespace Content
 {
@@ -284,7 +289,7 @@ _ContentSearchImpl::ReplaceOspColumnNameWithSlp(void) const
        int             maxCols = 0;
 
        int indexOf = 0;
-       
+
        String strToBeReplaced(L"\\'");
        int strLen = strToBeReplaced.GetLength();
        int startIndex = 0;
@@ -496,12 +501,12 @@ _ContentSearchImpl::ReplaceDateTimeStringWithInt(void) const
                                SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to parse DateTime.");
 
                                int year = dt.GetYear();
-                               int month = dt.GetMonth(); 
+                               int month = dt.GetMonth();
                                int day = dt.GetDay();
                                int hour = dt.GetHour();
-                               int minute = dt.GetMinute(); 
+                               int minute = dt.GetMinute();
                                int second = dt.GetSecond();
-                               
+
                                time_t rawTime;
                                struct tm* timeInfo;
 
@@ -806,6 +811,15 @@ _ContentSearchImpl::ExecuteAndFillFinalOutList(void) const
 
                pMediaPath.reset(pTempPath);
                String contentPath(pMediaPath.get());
+               String changedPath(contentPath);
+
+               // If the api version is 2.0, the content path has to be changed.
+               if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+               {
+                       r = _FileImpl::ConvertPhysicalToVirtualPath(contentPath, changedPath);
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG,
+                                       "[%s] Failed to convert physical path to virtual path.", GetErrorMessage(E_INVALID_ARG));
+               }
 
                switch (mediaType)
                {
@@ -813,7 +827,7 @@ _ContentSearchImpl::ExecuteAndFillFinalOutList(void) const
                        pOtherContentInfo = std::unique_ptr<OtherContentInfo>(new (std::nothrow) OtherContentInfo);
                        SysTryReturnResult(NID_CNT, pOtherContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pOtherContentInfo.");
 
-                       r = pOtherContentInfo->Construct(&contentPath);
+                       r = pOtherContentInfo->Construct(&changedPath);
                        r = ConvertErrorToResult(r);
                        SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Construct operation to OtherContentInfo.");
 
@@ -841,7 +855,7 @@ _ContentSearchImpl::ExecuteAndFillFinalOutList(void) const
                        pImageContentInfo = std::unique_ptr<ImageContentInfo>(new (std::nothrow) ImageContentInfo);
                        SysTryReturnResult(NID_CNT, pImageContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pImageContentInfo.");
 
-                       r = pImageContentInfo->Construct(&contentPath);
+                       r = pImageContentInfo->Construct(&changedPath);
                        r = ConvertErrorToResult(r);
                        SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Construct operation to ImageContentInfo.");
 
@@ -874,7 +888,7 @@ _ContentSearchImpl::ExecuteAndFillFinalOutList(void) const
                        pAudioContentInfo = std::unique_ptr<AudioContentInfo>(new (std::nothrow) AudioContentInfo);
                        SysTryReturnResult(NID_CNT, pAudioContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pAudioContentInfo.");
 
-                       r = pAudioContentInfo->Construct(&contentPath);
+                       r = pAudioContentInfo->Construct(&changedPath);
                        r = ConvertErrorToResult(r);
                        SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Construct operation to AudioContentInfo.");
 
@@ -905,7 +919,7 @@ _ContentSearchImpl::ExecuteAndFillFinalOutList(void) const
                        pVideoContentInfo = std::unique_ptr<VideoContentInfo>(new (std::nothrow) VideoContentInfo);
                        SysTryReturnResult(NID_CNT, pVideoContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pVideoContentInfo.");
 
-                       r = pVideoContentInfo->Construct(&contentPath);
+                       r = pVideoContentInfo->Construct(&changedPath);
                        r = ConvertErrorToResult(r);
                        SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Construct operation to VideoContentInfo.");
 
@@ -1281,11 +1295,7 @@ _ContentSearchImpl::FillColumnsList(int pageNo, int countPerPage, int& totalPage
                        totalPageCount = (totalCount / countPerPage) + 1;
                }
 
-               if ((pageNo < 1) || (pageNo > totalPageCount))
-               {
-                       r = E_INVALID_ARG;
-                       SysTryReturnResult(NID_CNT, !IsFailed(r), r, "(pageNo < 1) || (pageNo > totalPageCount).");
-               }
+               SysTryReturnResult(NID_CNT, ((pageNo >= 1) && (pageNo <= totalPageCount)) , r, "(pageNo < 1) || (pageNo > totalPageCount).");
 
                offset = (pageNo * countPerPage) - countPerPage;
 
index c42a94f..32ff68f 100644 (file)
@@ -70,11 +70,31 @@ result
 _ImageContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
 {
        result r = E_SUCCESS;
-       int contentLength = 0;
-       FileAttributes attribute;
+       String tempPath(contentPath);
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
+               {
+                       // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+                       // it should be converted in 2.0.
+                       r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
+               {
+                       r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else
+               {
+                       SysLogException(NID_CNT, E_INVALID_ARG,
+                                       "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+                       return E_INVALID_ARG;
+               }
+       }
 
        // checks parameters
-       contentLength = contentPath.GetLength();
        SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
                        "The contentPath should start with /Media or /Storagecard/Media.");
        SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
@@ -91,7 +111,7 @@ _ImageContentInfoImpl::Construct(const String& contentPath, const String& thumbn
                SysLog(NID_CNT, "The setGps is not supported.");
        }
 
-       SetContentPath(contentPath);
+       SetContentPath(tempPath);
        SetContentType(CONTENT_TYPE_IMAGE);
 
        return r;
@@ -141,7 +161,7 @@ _ImageContentInfoImpl::Construct(const String* pContentPath)
                int length = contentPath.GetLength();
                SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
                                "The length of pContentPath is 0.");
-               SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+               SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
                                "The file corresponding to pContentPath could not be found.");
 
                SetContentPath(contentPath);
index e423305..3874cc4 100644 (file)
@@ -62,11 +62,31 @@ result
 _OtherContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
 {
        result r = E_SUCCESS;
-       int contentLength = 0;
-       FileAttributes attribute;
+       String tempPath(contentPath);
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
+               {
+                       // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+                       // it should be converted in 2.0.
+                       r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
+               {
+                       r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else
+               {
+                       SysLogException(NID_CNT, E_INVALID_ARG,
+                                       "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+                       return E_INVALID_ARG;
+               }
+       }
 
        // checks parameters
-       contentLength = contentPath.GetLength();
        SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
                        "The contentPath should start with /Media or /Storagecard/Media.");
        SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
@@ -82,7 +102,7 @@ _OtherContentInfoImpl::Construct(const String& contentPath, const String& thumbn
                SysLog(NID_CNT, "The setGps is not supported.");
        }
 
-       SetContentPath(contentPath);
+       SetContentPath(tempPath);
        SetContentType(CONTENT_TYPE_OTHER);
 
        return r;
@@ -132,7 +152,7 @@ _OtherContentInfoImpl::Construct(const String* pContentPath)
                int length = contentPath.GetLength();
                SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
                                "The length of pContentPath is 0.");
-               SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+               SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
                                "The file corresponding to pContentPath could not be found.");
 
                SetContentPath(contentPath);
index 7d546d3..ea5f45d 100644 (file)
@@ -76,11 +76,31 @@ result
 _VideoContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
 {
        result r = E_SUCCESS;
-       int contentLength = 0;
-       FileAttributes attribute;
+       String tempPath(contentPath);
+
+       if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
+               {
+                       // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+                       // it should be converted in 2.0.
+                       r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
+               {
+                       r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+                       SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+               }
+               else
+               {
+                       SysLogException(NID_CNT, E_INVALID_ARG,
+                                       "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+                       return E_INVALID_ARG;
+               }
+       }
 
        // checks parameters
-       contentLength = contentPath.GetLength();
        SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
                        "The contentPath should start with /Media or /Storagecard/Media.");
        SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
@@ -97,7 +117,7 @@ _VideoContentInfoImpl::Construct(const String& contentPath, const String& thumbn
                SysLog(NID_CNT, "The setGps is not supported.");
        }
 
-       SetContentPath(contentPath);
+       SetContentPath(tempPath);
        SetContentType(CONTENT_TYPE_VIDEO);
 
        return r;
@@ -147,7 +167,7 @@ _VideoContentInfoImpl::Construct(const String* pContentPath)
                int length = contentPath.GetLength();
                SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
                                "The length of pContentPath is 0.");
-               SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+               SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
                                "The file corresponding to pContentPath could not be found.");
 
                SetContentPath(contentPath);
index 81a0bd4..b594e50 100644 (file)
@@ -61,7 +61,9 @@ public:
 
        Tizen::Base::String GetContentName(void) const;
 
-       virtual Tizen::Base::String GetContentPath(void) const;
+       Tizen::Base::String GetContentPath(void) const;
+
+       Tizen::Base::String GetPhysicalContentPath(void) const;
 
        Tizen::Base::String GetLocationTag(void) const;
 
@@ -141,6 +143,8 @@ public:
 
        void SetModifiedTime(const Tizen::Base::DateTime& modifiedTime);
 
+       result GetCompatContentPath(const Tizen::Base::String& contentPath, Tizen::Base::String& changedPath) const;
+
        static _ContentInfoImpl* GetInstance(ContentInfo& contentInfo);
 
        static const _ContentInfoImpl* GetInstance(const ContentInfo& contentInfo);
index 109d0da..0e8ef79 100644 (file)
@@ -178,8 +178,12 @@ private:
        result MakeImageContentInfo(const media_info_h pMediaInfo, void* pInfoImpl) const;
        result MakeAudioContentInfo(const media_info_h pMediaInfo, void* pInfoImpl) const;
        result MakeVideoContentInfo(const media_info_h pMediaInfo, void* pInfoImpl) const;
-       bool VerifyMediaFilePathCompatibility(const Tizen::Base::String& contentPath, bool checkVersion) const;
+       bool VerifyMediaFilePathCompatibility(const Tizen::Base::String& contentPath) const;
        bool VerifyHomeFilePathCompatibility(const Tizen::Base::String& contentPath) const;
+       result ChangeTizenPathToCompat(const Tizen::Base::String& contentPath, Tizen::Base::String& changedPath) const;
+       result ChangeCompatPathToTizen(const Tizen::Base::String& contentPath, Tizen::Base::String& changedPath) const;
+
+
        result ConvertErrorToResult(result res) const;
        _ContentManagerImpl& operator =(const _ContentManagerImpl& rhs);
 
index ef9bc6f..8bd3491 100644 (file)
@@ -122,6 +122,7 @@ private:
        _ContentManagerUtilImpl& operator =(const _ContentManagerUtilImpl& rhs);
        static result ErrorMapToRetVal(int retVal);
        static ContentType CheckStream(const Tizen::Base::String& contentPath);
+       static result   ChangeMediaFilePath(const Tizen::Base::String& contentPath, Tizen::Base::String& tizenPath, Tizen::Base::String& changedPath);
 
 };  // class _ContentManagerUtilImpl