From 1bf783640104a7f52172b4a7097a801c7c9a77c0 Mon Sep 17 00:00:00 2001 From: Seokpil Park Date: Mon, 7 Oct 2013 18:05:48 +0900 Subject: [PATCH] Fix : Return DateTime::GetMinValue() when the date taken value of content is invalid Change-Id: I59deea9e18fd374bd251e0b47ebbdaeeae849d4e Signed-off-by: Seokpil Park --- src/FCnt_ContentManagerImpl.cpp | 142 ++++++++++++++++++++++------------------ src/FCnt_ContentUtility.cpp | 141 +++++++++++++++++++++------------------ 2 files changed, 159 insertions(+), 124 deletions(-) diff --git a/src/FCnt_ContentManagerImpl.cpp b/src/FCnt_ContentManagerImpl.cpp index 83abde8..e8ba508 100644 --- a/src/FCnt_ContentManagerImpl.cpp +++ b/src/FCnt_ContentManagerImpl.cpp @@ -66,6 +66,8 @@ using namespace Tizen::System; namespace Tizen { namespace Content { +static const int DATE_TIME_TOKEN_COUNT = 6; + static const int SYSTEM_TYPE_IMAGE = 0; static const int SYSTEM_TYPE_VIDEO = 1; static const int SYSTEM_TYPE_SOUND = 2; @@ -1692,51 +1694,59 @@ _ContentManagerImpl::MakeImageContentInfo(const media_info_h pMediaInfo, void* p r = strTok.SetDelimiters(delim); SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + int tokenCount = strTok.GetTokenCount(); + if (tokenCount == DATE_TIME_TOKEN_COUNT) + { + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - year = token; + year = token; - // Append month - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append month + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newDateTaken.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newDateTaken.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append day - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append day + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newDateTaken.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newDateTaken.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append year - r = newDateTaken.Append(year); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + // Append year + r = newDateTaken.Append(year); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newDateTaken.Append(L" "); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(L" "); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - String newDelim(L" "); + String newDelim(L" "); - r = strTok.SetDelimiters(newDelim); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); + r = strTok.SetDelimiters(newDelim); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newDateTaken.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = DateTime::Parse(newDateTaken, dt); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + r = DateTime::Parse(newDateTaken, dt); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + } + else + { + dt = DateTime::GetMinValue(); + } } else { @@ -2096,51 +2106,59 @@ _ContentManagerImpl::MakeVideoContentInfo(const media_info_h pMediaInfo, void* p r = strTok.SetDelimiters(delim); SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + int tokenCount = strTok.GetTokenCount(); + if (tokenCount == DATE_TIME_TOKEN_COUNT) + { + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - year = token; + year = token; - // Append month - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append month + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newRecordedDate.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newRecordedDate.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append day - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append day + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newRecordedDate.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newRecordedDate.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append year - r = newRecordedDate.Append(year); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + // Append year + r = newRecordedDate.Append(year); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newRecordedDate.Append(L" "); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(L" "); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - String newDelim(L" "); + String newDelim(L" "); - r = strTok.SetDelimiters(newDelim); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); + r = strTok.SetDelimiters(newDelim); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newRecordedDate.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = DateTime::Parse(newRecordedDate, dt); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + r = DateTime::Parse(newRecordedDate, dt); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + } + else + { + dt = DateTime::GetMinValue(); + } } else { diff --git a/src/FCnt_ContentUtility.cpp b/src/FCnt_ContentUtility.cpp index 3350de7..9e0ae21 100644 --- a/src/FCnt_ContentUtility.cpp +++ b/src/FCnt_ContentUtility.cpp @@ -43,6 +43,7 @@ using namespace Tizen::Locations; namespace Tizen { namespace Content { +static const int DATE_TIME_TOKEN_COUNT = 6; static const double DEFAULT_COORDINATE = -200.0; // Default constructor @@ -532,51 +533,59 @@ _ContentUtility::FillImageContentData(media_info_h mediaHandle, _ImageContentInf r = strTok.SetDelimiters(delim); SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + int tokenCount = strTok.GetTokenCount(); + if (tokenCount == DATE_TIME_TOKEN_COUNT) + { + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - year = token; + year = token; - // Append month - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append month + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newDateTaken.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newDateTaken.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append day - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append day + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newDateTaken.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newDateTaken.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append year - r = newDateTaken.Append(year); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + // Append year + r = newDateTaken.Append(year); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newDateTaken.Append(L" "); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(L" "); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - String newDelim(L" "); + String newDelim(L" "); - r = strTok.SetDelimiters(newDelim); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); + r = strTok.SetDelimiters(newDelim); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newDateTaken.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newDateTaken.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = DateTime::Parse(newDateTaken, dt); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + r = DateTime::Parse(newDateTaken, dt); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + } + else + { + dt = DateTime::GetMinValue(); + } } else { @@ -946,51 +955,59 @@ _ContentUtility::FillVideoContentData(media_info_h mediaHandle, _VideoContentInf r = strTok.SetDelimiters(delim); SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + int tokenCount = strTok.GetTokenCount(); + if (tokenCount == DATE_TIME_TOKEN_COUNT) + { + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - year = token; + year = token; - // Append month - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append month + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newRecordedDate.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newRecordedDate.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append day - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + // Append day + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newRecordedDate.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newRecordedDate.Append(L"/"); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(L"/"); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - // Append year - r = newRecordedDate.Append(year); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + // Append year + r = newRecordedDate.Append(year); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = newRecordedDate.Append(L" "); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(L" "); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - String newDelim(L" "); + String newDelim(L" "); - r = strTok.SetDelimiters(newDelim); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); + r = strTok.SetDelimiters(newDelim); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation."); - r = strTok.GetNextToken(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); + r = strTok.GetNextToken(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation."); - r = newRecordedDate.Append(token); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); + r = newRecordedDate.Append(token); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation."); - r = DateTime::Parse(newRecordedDate, dt); - SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + r = DateTime::Parse(newRecordedDate, dt); + SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime."); + } + else + { + dt = DateTime::GetMinValue(); + } } else { -- 2.7.4