From: Seokpil Park Date: Wed, 4 Sep 2013 06:29:10 +0000 (+0900) Subject: Fix : Search APIs don't return exception despite the content in DB doesn't match... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9219c323428b23a6e5b8d955bea5a2a4b8035ab7;p=platform%2Fframework%2Fnative%2Fcontent.git Fix : Search APIs don't return exception despite the content in DB doesn't match up to the actual file Change-Id: I3120c073dd95bfdc23eae2f2224883dfb9217bb2 Signed-off-by: Seokpil Park --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 151f0db..db54ead 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined - TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS}) TARGET_LINK_LIBRARIES(${this_target} "-losp-locations") -TARGET_LINK_LIBRARIES(${this_target} "-lexif" ) +TARGET_LINK_LIBRARIES(${this_target} "-lexif") TARGET_LINK_LIBRARIES(${this_target} "-lcapi-web-url-download") TARGET_LINK_LIBRARIES(${this_target} "-lpthread") diff --git a/src/FCntAudioContentInfo.cpp b/src/FCntAudioContentInfo.cpp index da9483c..0221df5 100644 --- a/src/FCntAudioContentInfo.cpp +++ b/src/FCntAudioContentInfo.cpp @@ -48,7 +48,7 @@ AudioContentInfo::Construct(const String& contentPath, const String& thumbnailPa { result r = E_SUCCESS; - SysAssertf(__pAudioContentInfoImpl == null, + SysAssertf(__pAudioContentInfoImpl == null || __pAudioContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); _AudioContentInfoImpl* pAudioContentInfoImpl = new (std::nothrow) _AudioContentInfoImpl(); @@ -59,8 +59,18 @@ AudioContentInfo::Construct(const String& contentPath, const String& thumbnailPa _ContentInfoHelper::SetContentInfoImpl(this, pAudioContentInfoImpl); + delete __pAudioContentInfoImpl; __pAudioContentInfoImpl = pAudioContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pAudioContentInfoImpl->SetReconstructable(true); + } + else + { + __pAudioContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: @@ -74,19 +84,29 @@ AudioContentInfo::Construct(const String* pContentPath) { result r = E_SUCCESS; - SysAssertf(__pAudioContentInfoImpl == null, + SysAssertf(__pAudioContentInfoImpl == null || __pAudioContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); _AudioContentInfoImpl* pAudioContentInfoImpl = new (std::nothrow) _AudioContentInfoImpl(); SysTryReturnResult(NID_CNT, pAudioContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed."); r = pAudioContentInfoImpl->Construct(pContentPath); - SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r)); _ContentInfoHelper::SetContentInfoImpl(this, pAudioContentInfoImpl); + delete __pAudioContentInfoImpl; __pAudioContentInfoImpl = pAudioContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pAudioContentInfoImpl->SetReconstructable(true); + } + else + { + __pAudioContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: diff --git a/src/FCntImageContentInfo.cpp b/src/FCntImageContentInfo.cpp index 489abd6..5d6994f 100644 --- a/src/FCntImageContentInfo.cpp +++ b/src/FCntImageContentInfo.cpp @@ -47,7 +47,7 @@ ImageContentInfo::Construct(const String& contentPath, const String& thumbnailPa { result r = E_SUCCESS; - SysAssertf(__pImageContentInfoImpl == null, + SysAssertf(__pImageContentInfoImpl == null || __pImageContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); _ImageContentInfoImpl* pImageContentInfoImpl = new (std::nothrow) _ImageContentInfoImpl(); @@ -58,8 +58,18 @@ ImageContentInfo::Construct(const String& contentPath, const String& thumbnailPa _ContentInfoHelper::SetContentInfoImpl(this, pImageContentInfoImpl); + delete __pImageContentInfoImpl; __pImageContentInfoImpl = pImageContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pImageContentInfoImpl->SetReconstructable(true); + } + else + { + __pImageContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: @@ -73,19 +83,29 @@ ImageContentInfo::Construct(const String* pContentPath) { result r = E_SUCCESS; - SysAssertf(__pImageContentInfoImpl == null, + SysAssertf(__pImageContentInfoImpl == null || __pImageContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); _ImageContentInfoImpl* pImageContentInfoImpl = new (std::nothrow) _ImageContentInfoImpl(); SysTryReturnResult(NID_CNT, pImageContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed."); r = pImageContentInfoImpl->Construct(pContentPath); - SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r)); _ContentInfoHelper::SetContentInfoImpl(this, pImageContentInfoImpl); + delete __pImageContentInfoImpl; __pImageContentInfoImpl = pImageContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pImageContentInfoImpl->SetReconstructable(true); + } + else + { + __pImageContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: diff --git a/src/FCntOtherContentInfo.cpp b/src/FCntOtherContentInfo.cpp index 41da4d4..9bbc74c 100644 --- a/src/FCntOtherContentInfo.cpp +++ b/src/FCntOtherContentInfo.cpp @@ -47,7 +47,7 @@ OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPa { result r = E_SUCCESS; - SysAssertf(__pOtherContentInfoImpl == null, + SysAssertf(__pOtherContentInfoImpl == null || __pOtherContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); _OtherContentInfoImpl* pOtherContentInfoImpl = new (std::nothrow) _OtherContentInfoImpl(); @@ -58,8 +58,18 @@ OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPa _ContentInfoHelper::SetContentInfoImpl(this, pOtherContentInfoImpl); + delete __pOtherContentInfoImpl; __pOtherContentInfoImpl = pOtherContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pOtherContentInfoImpl->SetReconstructable(true); + } + else + { + __pOtherContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: @@ -73,19 +83,29 @@ OtherContentInfo::Construct(const String* pContentPath) { result r = E_SUCCESS; - SysAssertf(__pOtherContentInfoImpl == null, + SysAssertf(__pOtherContentInfoImpl == null || __pOtherContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); _OtherContentInfoImpl* pOtherContentInfoImpl = new (std::nothrow) _OtherContentInfoImpl(); SysTryReturnResult(NID_CNT, pOtherContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed."); r = pOtherContentInfoImpl->Construct(pContentPath); - SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r)); _ContentInfoHelper::SetContentInfoImpl(this, pOtherContentInfoImpl); + delete __pOtherContentInfoImpl; __pOtherContentInfoImpl = pOtherContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pOtherContentInfoImpl->SetReconstructable(true); + } + else + { + __pOtherContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: diff --git a/src/FCntVideoContentInfo.cpp b/src/FCntVideoContentInfo.cpp index 6d8079b..2223cb8 100644 --- a/src/FCntVideoContentInfo.cpp +++ b/src/FCntVideoContentInfo.cpp @@ -46,7 +46,7 @@ VideoContentInfo::~VideoContentInfo(void) result VideoContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps) { - SysAssertf(__pVideoContentInfoImpl == null, + SysAssertf(__pVideoContentInfoImpl == null || __pVideoContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); result r = E_SUCCESS; @@ -59,8 +59,18 @@ VideoContentInfo::Construct(const String& contentPath, const String& thumbnailPa _ContentInfoHelper::SetContentInfoImpl(this, pVideoContentInfoImpl); + delete __pVideoContentInfoImpl; __pVideoContentInfoImpl = pVideoContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pVideoContentInfoImpl->SetReconstructable(true); + } + else + { + __pVideoContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: @@ -72,7 +82,7 @@ CATCH: result VideoContentInfo::Construct(const String* pContentPath) { - SysAssertf(__pVideoContentInfoImpl == null, + SysAssertf(__pVideoContentInfoImpl == null || __pVideoContentInfoImpl->IsReconstructable(), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); result r = E_SUCCESS; @@ -81,12 +91,22 @@ VideoContentInfo::Construct(const String* pContentPath) SysTryReturnResult(NID_CNT, pVideoContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed."); r = pVideoContentInfoImpl->Construct(pContentPath); - SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r)); _ContentInfoHelper::SetContentInfoImpl(this, pVideoContentInfoImpl); + delete __pVideoContentInfoImpl; __pVideoContentInfoImpl = pVideoContentInfoImpl; + if (r == E_FILE_NOT_FOUND) + { + __pVideoContentInfoImpl->SetReconstructable(true); + } + else + { + __pVideoContentInfoImpl->SetReconstructable(false); + } + return r; CATCH: diff --git a/src/FCnt_ContentDirectoryImpl.cpp b/src/FCnt_ContentDirectoryImpl.cpp index 3b3889d..05b7c7f 100644 --- a/src/FCnt_ContentDirectoryImpl.cpp +++ b/src/FCnt_ContentDirectoryImpl.cpp @@ -908,8 +908,11 @@ _ContentDirectoryImpl::ConvertErrorToResult(result res) const switch (res) { + // It is processed by normal case when the content exist in DB but the actual file doesn't exist. case E_FILE_NOT_FOUND: - // Fall through + r = E_SUCCESS; + break; + case E_IO: r = E_SYSTEM; break; diff --git a/src/FCnt_ContentInfoImpl.cpp b/src/FCnt_ContentInfoImpl.cpp index f9c19a6..b80b880 100644 --- a/src/FCnt_ContentInfoImpl.cpp +++ b/src/FCnt_ContentInfoImpl.cpp @@ -67,6 +67,7 @@ _ContentInfoImpl::_ContentInfoImpl(void) , __provider(L"") , __rating(L"") , __mediaFormat(L"") + , __isConstructed(false) { } @@ -462,4 +463,16 @@ _ContentInfoImpl::GetCompatContentPath(const String& contentPath, String& change return r; } +bool +_ContentInfoImpl::IsReconstructable(void) const +{ + return __isConstructed; +} + +void +_ContentInfoImpl::SetReconstructable(bool isConstructed) +{ + __isConstructed = isConstructed; +} + }} diff --git a/src/FCnt_ContentSearchImpl.cpp b/src/FCnt_ContentSearchImpl.cpp index a32f1ba..03714c8 100644 --- a/src/FCnt_ContentSearchImpl.cpp +++ b/src/FCnt_ContentSearchImpl.cpp @@ -1592,7 +1592,10 @@ _ContentSearchImpl::ConvertErrorToResult(result res) const switch (res) { case E_FILE_NOT_FOUND: - // Fall through + // It is processed by normal case when the content exist in DB but the actual file doesn't exist. + r = E_SUCCESS; + break; + case E_IO: r = E_SYSTEM; break; diff --git a/src/FCnt_PlayListImpl.cpp b/src/FCnt_PlayListImpl.cpp index 666c4e7..ec682e2 100644 --- a/src/FCnt_PlayListImpl.cpp +++ b/src/FCnt_PlayListImpl.cpp @@ -816,9 +816,12 @@ _PlayListImpl::ConvertErrorToResult(result res) const switch (res) { - case E_INVALID_ARG: - // Fall through + // It is processed by normal case when the content exist in DB but the actual file doesn't exist. case E_FILE_NOT_FOUND: + r = E_SUCCESS; + break; + + case E_INVALID_ARG: // Fall through case E_IO: r = E_SYSTEM; diff --git a/src/inc/FCnt_ContentInfoImpl.h b/src/inc/FCnt_ContentInfoImpl.h index b594e50..95842a8 100644 --- a/src/inc/FCnt_ContentInfoImpl.h +++ b/src/inc/FCnt_ContentInfoImpl.h @@ -145,6 +145,10 @@ public: result GetCompatContentPath(const Tizen::Base::String& contentPath, Tizen::Base::String& changedPath) const; + bool IsReconstructable(void) const; + + void SetReconstructable(bool isConstructed); + static _ContentInfoImpl* GetInstance(ContentInfo& contentInfo); static const _ContentInfoImpl* GetInstance(const ContentInfo& contentInfo); @@ -178,6 +182,7 @@ private: Tizen::Base::String __rating; Tizen::Base::String __mediaFormat; Tizen::Locations::Coordinates __coordinates; + bool __isConstructed; }; // _ContentInfoImpl