From c0ca5c3a18d852b1353f3c33d3c8eca5fa770306 Mon Sep 17 00:00:00 2001 From: Seokpil Park Date: Mon, 26 Aug 2013 20:39:32 +0900 Subject: [PATCH] Fix : Extract the gps information according to a locale Change-Id: If8a2756f180107c56bfb821bd4a2421b738f463b Signed-off-by: Seokpil Park --- src/FCnt_ContentManagerUtilImpl.cpp | 94 ++++++++++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 18 deletions(-) diff --git a/src/FCnt_ContentManagerUtilImpl.cpp b/src/FCnt_ContentManagerUtilImpl.cpp index 74081ea..3393c15 100755 --- a/src/FCnt_ContentManagerUtilImpl.cpp +++ b/src/FCnt_ContentManagerUtilImpl.cpp @@ -191,8 +191,22 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal) else if (tag == EXIF_TAG_GPS_LATITUDE && !isLatitude) { String tempLatitude(buf); - String delim(L","); + int firstComma = 0; + int lastComma = 0; + r = tempLatitude.IndexOf(',', 0, firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLatitude.SetCharAt('/', firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + + r = tempLatitude.LastIndexOf(',', tempLatitude.GetLength() - 1, lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLatitude.SetCharAt('/', lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + + String delim(L"/"); StringTokenizer strTok(tempLatitude, delim); String token[3] = {L"", }; @@ -202,15 +216,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal) strTok.GetNextToken(token[count++]); } - double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value + double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double mmVal = _LocalizedNumParser::ToDouble(token[1], "C"); // minutes value + double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double ssVal = _LocalizedNumParser::ToDouble(token[2], "C"); // seconds value + double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform ToDouble operation."); @@ -230,8 +244,22 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal) else if (tag == EXIF_TAG_GPS_LONGITUDE && !isLongitude) { String tempLongitude(buf); - String delim(L","); + int firstComma = 0; + int lastComma = 0; + + r = tempLongitude.IndexOf(',', 0, firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLongitude.SetCharAt('/', firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + + r = tempLongitude.LastIndexOf(',', tempLongitude.GetLength() - 1, lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLongitude.SetCharAt('/', lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + String delim(L"/"); StringTokenizer strTok(tempLongitude, delim); String token[3] = {L"", }; @@ -241,15 +269,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal) strTok.GetNextToken(token[count++]); } - double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value + double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double mmVal = _LocalizedNumParser::ToDouble(token[1], "C"); // minutes value + double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double ssVal = _LocalizedNumParser::ToDouble(token[2], "C"); // seconds value + double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); @@ -970,8 +998,22 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer) else if (tag == EXIF_TAG_GPS_LATITUDE && !isLatitude) { String tempLatitude(buf); - String delim(L","); + int firstComma = 0; + int lastComma = 0; + r = tempLatitude.IndexOf(',', 0, firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLatitude.SetCharAt('/', firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + + r = tempLatitude.LastIndexOf(',', tempLatitude.GetLength() - 1, lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLatitude.SetCharAt('/', lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + + String delim(L"/"); StringTokenizer strTok(tempLatitude, delim); String token[3] = {L"", }; @@ -981,15 +1023,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer) strTok.GetNextToken(token[count++]); } - double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value + double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double mmVal = _LocalizedNumParser::ToDouble(token[1], "C"); // minutes value + double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double ssVal = _LocalizedNumParser::ToDouble(token[2], "C"); // seconds value + double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); @@ -1009,8 +1051,22 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer) else if (tag == EXIF_TAG_GPS_LONGITUDE && !isLongitude) { String tempLongitude(buf); - String delim(L","); + int firstComma = 0; + int lastComma = 0; + + r = tempLongitude.IndexOf(',', 0, firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLongitude.SetCharAt('/', firstComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + + r = tempLongitude.LastIndexOf(',', tempLongitude.GetLength() - 1, lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform IndexOf operation.", GetErrorMessage(r)); + + r = tempLongitude.SetCharAt('/', lastComma); + SysTryReturn(NID_CNT, !IsFailed(r), null, E_INVALID_ARG, "[%s] Failed to perform SetCharAt operation.", GetErrorMessage(r)); + String delim(L"/"); StringTokenizer strTok(tempLongitude, delim); String token[3] = {L"", }; @@ -1020,15 +1076,15 @@ _ContentManagerUtilImpl::GetImageMetaN(const ByteBuffer& byteBuffer) strTok.GetNextToken(token[count++]); } - double ddVal = _LocalizedNumParser::ToDouble(token[0], "C"); // degree value + double ddVal = _LocalizedNumParser::ToDouble(token[0], ""); // degree value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double mmVal = _LocalizedNumParser::ToDouble(token[1], "C"); // minutes value + double mmVal = _LocalizedNumParser::ToDouble(token[1], ""); // minutes value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); - double ssVal = _LocalizedNumParser::ToDouble(token[2], "C"); // seconds value + double ssVal = _LocalizedNumParser::ToDouble(token[2], ""); // seconds value r = GetLastResult(); SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[E_INVALID_ARG] Failed to perform ToDouble operation."); @@ -1757,8 +1813,9 @@ _ContentManagerUtilImpl::CheckStream(const String& contentPath) } else { + // The return value is CONTENT_TYPE_VIDEO because CreaetContent have to success, even if the content is invalid. r = ErrorMapToRetVal(retVal); - SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_VIDEO, r, "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r)); } @@ -1769,8 +1826,9 @@ _ContentManagerUtilImpl::CheckStream(const String& contentPath) } else { + // The return value is CONTENT_TYPE_VIDEO because CreaetContent have to success, even if the content is invalid. r = ErrorMapToRetVal(retVal); - SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, contentType, r, + SysTryReturn(NID_CNT, retVal == METADATA_EXTRACTOR_ERROR_NONE, CONTENT_TYPE_VIDEO, r, "[%s] metadata_extractor_get_metadata failed.", GetErrorMessage(r)); } -- 2.7.4