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();
}
// 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.");
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));
CATCH:
// There are two steps(insert and update) for content registration.
// If the update failed after inserting, the inserted data SHOULD be deleted from here.
- val = media_info_delete_from_db(pStr.get());
+ char* pTempMediaId = null;
+ unique_ptr<char, CharDeleter> pMediaId(null);
+ val = media_info_get_media_id(pMediaInfo.get(), &pTempMediaId);
+ if (pTempMediaId != null)
+ {
+ pMediaId.reset(pTempMediaId);
+ }
+ else
+ {
+ SysLog(NID_CNT, "Failed to perform media_info_get_media_id operation.");
+ return UuId::GetInvalidUuId();
+ }
+
+ val = media_info_delete_from_db(pMediaId.get());
SysLog(NID_CNT, "The result of deletion from database[%d].", val);
return UuId::GetInvalidUuId();
"[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.");
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)
{
}
// Sets the content path
- pInfoImpl->SetContentPath(destinationPath);
+ pInfoImpl->SetContentPath(destPath);
}
else
{
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)
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)
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
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);
if (pMediaInfo != null)
{
- val = media_info_delete_from_db(pStr.get());
+ char* pTempMediaId = null;
+ unique_ptr<char, CharDeleter> pMediaId(null);
+ val = media_info_get_media_id(pMediaInfo.get(), &pTempMediaId);
+ if (pTempMediaId != null)
+ {
+ pMediaId.reset(pTempMediaId);
+ }
+ else
+ {
+ SysLog(NID_CNT, "Failed to perform media_info_get_media_id operation.");
+ return UuId::GetInvalidUuId();
+ }
+
+ val = media_info_delete_from_db(pMediaId.get());
SysLog(NID_CNT, "The result of deletion from database[%d].", val);
}
// 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;
- bool isCopy = false;
-
- if (deleteSource) // move
- {
- r = _FileImpl::Move(sourcePath, destinationPath);
- SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Moving the file failed.", GetErrorMessage(r));
- }
- else // copy
- {
- r = _FileImpl::Copy(sourcePath, destinationPath, true);
- SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
-
- isCopy = true;
- }
+ result r = _FileImpl::Copy(sourcePath, destinationPath, true);
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
int val = 0;
ContentId contentId;
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)
{
}
// Set the content path
- pInfoImpl->SetContentPath(destinationPath);
+ pInfoImpl->SetContentPath(destPath);
}
else
{
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)
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)
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
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);
SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
"[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
+ if (deleteSource)
+ {
+ unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(sourcePath));
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY, "[%s] pContentPath is null.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ r = _FileImpl::Remove(sourcePath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform Remove operation.", GetErrorMessage(r));
+
+ val = media_content_scan_file(pContentPath.get());
+ SysTryLog(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, "Failed to perform media_content_scan_file[%d].", val);
+ }
+
return contentId;
CATCH:
result saveResult = GetLastResult();
- if (isCopy)
- {
- r = _FileImpl::Remove(destinationPath);
- SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
- }
- else
- {
- r = _FileImpl::Move(destinationPath, sourcePath);
- SysLog(NID_CNT, "Move[%s].", GetErrorMessage(r));
- }
+ r = _FileImpl::Remove(destinationPath);
+ SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
if (pMediaInfo != null)
{
- val = media_info_delete_from_db(pStr.get());
+ char* pTempMediaId = null;
+ unique_ptr<char, CharDeleter> pMediaId(null);
+ val = media_info_get_media_id(pMediaInfo.get(), &pTempMediaId);
+ if (pTempMediaId != null)
+ {
+ pMediaId.reset(pTempMediaId);
+ }
+ else
+ {
+ SysLog(NID_CNT, "Failed to perform media_info_get_media_id operation.");
+ return UuId::GetInvalidUuId();
+ }
+
+ val = media_info_delete_from_db(pMediaId.get());
SysLog(NID_CNT, "The result of deletion from database[%d].", val);
}
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));
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));
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));
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));
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.");
"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;
result r = E_SUCCESS;
unique_ptr<char[]> pValue(null);
- if (!pContentInfoImpl->GetAuthor().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetAuthor()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ // author
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetAuthor()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- val = media_info_set_author(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_author failed[%d].", val);
- }
- if (!pContentInfoImpl->GetCategory().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetCategory()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ val = media_info_set_author(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_author failed[%d].", val);
- val = media_info_set_category(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_category failed[%d].", val);
- }
- if (!pContentInfoImpl->GetContentName().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetContentName()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ // category
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetCategory()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- val = media_info_set_content_name(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_content_name failed[%d].", val);
- }
- if (!pContentInfoImpl->GetDescription().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetDescription()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ val = media_info_set_category(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_category failed[%d].", val);
- val = media_info_set_description(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_description failed[%d].", val);
- }
- if (!pContentInfoImpl->GetKeyword().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetKeyword()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ // content name
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetContentName()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- val = media_info_set_keyword(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_keyword failed[%d].", val);
- }
- if (!pContentInfoImpl->GetLocationTag().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetLocationTag()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ val = media_info_set_content_name(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_content_name failed[%d].", val);
- val = media_info_set_location_tag(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_location_tag failed[%d].", val);
- }
- if (!pContentInfoImpl->GetProvider().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetProvider()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ // description
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetDescription()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- val = media_info_set_provider(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_provider failed[%d].", val);
- }
- if (!pContentInfoImpl->GetRating().IsEmpty())
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetRating()));
- SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ val = media_info_set_description(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_description failed[%d].", val);
- val = media_info_set_age_rating(pMediaInfo.get(), pValue.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_set_age_rating failed[%d].", val);
- }
+ // keyword
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetKeyword()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_keyword(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_keyword failed[%d].", val);
+
+ // location tag
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetLocationTag()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_location_tag(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_location_tag failed[%d].", val);
+
+ // provider
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetProvider()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_provider(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_provider failed[%d].", val);
+
+ // rating
+ pValue.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetRating()));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_age_rating(pMediaInfo.get(), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_age_rating failed[%d].", val);
+
+ // latitude, longitude, altitude
if (Double::Compare(pContentInfoImpl->GetLatitude(), DEFAULT_COORDINATE) != 0 &&
Double::Compare(pContentInfoImpl->GetLongitude(), DEFAULT_COORDINATE) != 0)
{
_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.");
{
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());
int val = 0;
unique_ptr<char[]> pStr(null);
- if (pContentInfoImpl->GetAuthor() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetAuthor()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ // author
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetAuthor()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
- val = media_info_set_author(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_author failed[%d].", val);
- }
- if (pContentInfoImpl->GetCategory() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetCategory()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ val = media_info_set_author(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_author failed[%d].", val);
- val = media_info_set_category(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_category failed[%d].", val);
- }
- if (pContentInfoImpl->GetContentName() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetContentName()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ // category
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetCategory()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
- val = media_info_set_content_name(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_content_name failed[%d].", val);
- }
- if (pContentInfoImpl->GetDescription() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetDescription()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ val = media_info_set_category(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_category failed[%d].", val);
- val = media_info_set_description(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_description failed[%d].", val);
- }
- if (pContentInfoImpl->GetKeyword() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetKeyword()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ // content name
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetContentName()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
- val = media_info_set_keyword(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_keyword failed[%d].", val);
- }
- if (pContentInfoImpl->GetLocationTag() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetLocationTag()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ val = media_info_set_content_name(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_content_name failed[%d].", val);
- val = media_info_set_location_tag(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_location_tag failed[%d].", val);
- }
- if (pContentInfoImpl->GetProvider() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetProvider()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ // description
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetDescription()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
- val = media_info_set_provider(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_provider failed[%d].", val);
- }
- if (pContentInfoImpl->GetRating() != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetRating()));
- SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ val = media_info_set_description(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_description failed[%d].", val);
- val = media_info_set_age_rating(pMediaInfo, pStr.get());
- SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
- "media_info_set_age_rating failed[%d].", val);
- }
+ // keyword
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetKeyword()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_keyword(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_keyword failed[%d].", val);
+
+ // location tag
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetLocationTag()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_location_tag(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_location_tag failed[%d].", val);
+
+ // provider
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetProvider()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_provider(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_provider failed[%d].", val);
+
+ // rating
+ pStr.reset(_StringConverter::CopyToCharArrayN(pContentInfoImpl->GetRating()));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_age_rating(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_age_rating failed[%d].", val);
+
+ // latitude, longitude, altitude
if (Double::Compare(pContentInfoImpl->GetLatitude(), DEFAULT_COORDINATE) != 0 &&
Double::Compare(pContentInfoImpl->GetLongitude(), DEFAULT_COORDINATE) != 0)
{
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
String thumbnailPath(pStrValue.get());
pContentInfoImpl->SetThumbnailPath(thumbnailPath);
-
SysLog(NID_CNT, "INFO: thumbnailPath[%ls]", (pContentInfoImpl->GetThumbnailPath()).GetPointer());
}
String dateTaken(pStrValue.get());
String newDateTaken(L"");
- String delim(L": ");
+ // detour the unexpected datetaken format
+ String tempDelim(L"+-Z");
String token;
+ StringTokenizer tempStrTok(dateTaken, tempDelim);
+
+ r = tempStrTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
+
+ dateTaken = token;
+
+ String delim(L": ");
String year(L"");
StringTokenizer strTok(dateTaken, delim);
+ 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.");
pVideoContentInfoImpl->SetDuration(intValue);
SysLog(NID_CNT, "META: duration[%d]", intValue);
- // Get from metadata extractor (framerate, audio bitrate, video bitrate)
- VideoMetadata* pVideoMetadata = ContentManagerUtil::GetVideoMetaN(pVideoContentInfoImpl->GetContentPath());
- result r = GetLastResult();
- SysTryReturnResult(NID_CNT, pVideoMetadata != null, r, "GetVideoMetadata() failed.");
-
- pVideoContentInfoImpl->SetFramerate(pVideoMetadata->GetFramerate());
- pVideoContentInfoImpl->SetAudioBitrate(pVideoMetadata->GetAudioBitrate());
- pVideoContentInfoImpl->SetVideoBitrate(pVideoMetadata->GetVideoBitrate());
+ // Get some information from metadata extractor when calling VideoContentInfo (framerate, audio bitrate, video bitrate)
return E_SUCCESS;
}
}
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))
+ if (!(contentPath.StartsWith(OSP_MEDIA_PHONE, 0)) ||
+ (contentPath.StartsWith(OSP_MEDIA_MMC, 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))
- {
- 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)
{