Fix : Extract the gps information according to a locale
[platform/framework/native/content.git] / src / FCnt_ImageContentInfoImpl.cpp
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);