* This file contains implementation of the %_ContentManagerImpl class.
*/
+#include <new>
#include <stdlib.h>
-#include <FBaseSysLog.h>
+#include <aul/aul.h>
#include <FAppApp.h>
+#include <FBaseSysLog.h>
+#include <FBaseDateTime.h>
#include <FBaseInteger.h>
#include <FBaseByteBuffer.h>
+#include <FBaseUtilStringTokenizer.h>
#include <FCntContentManager.h>
+#include <FCntContentManagerUtil.h>
#include <FCntImageContentInfo.h>
#include <FCntAudioContentInfo.h>
#include <FCntVideoContentInfo.h>
#include <FCntIContentUpdateEventListener.h>
#include <FIoDirectory.h>
#include <FSysEnvironment.h>
-#include <FCnt_ContentManagerImpl.h>
-#include <FCnt_ContentManagerUtilImpl.h>
+#include <FApp_AppInfo.h>
#include <FBase_StringConverter.h>
#include <FIo_FileImpl.h>
-#include <FApp_AppInfo.h>
+#include "FCnt_ContentManagerImpl.h"
+#include "FCnt_ContentManagerUtilImpl.h"
+#include "FCnt_ContentInfoImpl.h"
+#include "FCnt_ImageContentInfoImpl.h"
+#include "FCnt_AudioContentInfoImpl.h"
+#include "FCnt_VideoContentInfoImpl.h"
+#include "FCnt_OtherContentInfoImpl.h"
+#include "FCnt_ContentInfoHelper.h"
+using namespace std;
+using namespace Tizen::App;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
using namespace Tizen::Io;
-using namespace Tizen::App;
+using namespace Tizen::Locations;
using namespace Tizen::System;
-using namespace std;
namespace Tizen { namespace Content
{
-static RequestId requestId = 0;
-
static const int SYSTEM_TYPE_IMAGE = 0;
static const int SYSTEM_TYPE_VIDEO = 1;
static const int SYSTEM_TYPE_SOUND = 2;
String scanPath(L"");
IContentScanListener* pListener = null;
RequestId reqId;
- unique_ptr< ScanResult > pScanResult;
+ unique_ptr< _ScanResult > pScanResult;
SysTryLogCatch(NID_CNT, user_data != null, , "OnScanCompleted failed.");
- pScanResult = unique_ptr< ScanResult >(static_cast< ScanResult* >(user_data));
+ pScanResult = unique_ptr< _ScanResult >(static_cast< _ScanResult* >(user_data));
- SysTryLogCatch(NID_CNT, pScanResult != null && pScanResult->pScanPath != null, , "OnScanCompleted failed.");
+ SysTryLogCatch(NID_CNT, pScanResult != null, , "OnScanCompleted failed.");
SysTryLogCatch(NID_CNT, pScanResult->pScanListener != null, , "Listener is null. OnScanCompleted succeeded.");
- scanPath = pScanResult->pScanPath;
+ scanPath = pScanResult->scanPath;
pListener = pScanResult->pScanListener;
reqId = pScanResult->requestId;
SysTryLogReturn(NID_CNT, user_data != null, , "OnContentUpdateCompleted failed.");
_ContentManagerImpl* pTempManagerImpl = static_cast< _ContentManagerImpl* >(user_data);
+ SysTryLogReturn(NID_CNT, pTempManagerImpl != null, , "pTempManagerImpl is null.");
IContentUpdateEventListener* pListener = pTempManagerImpl->GetListener();
SysTryLogReturn(NID_CNT, pListener != null, , "IContentUpdateEventListener is null.");
SysLog(NID_CNT, "update_type is invalid.");
break;
}
+ break;
}
case MEDIA_ITEM_DIRECTORY:
}
_ContentManagerImpl::_ContentManagerImpl(void)
- : Object()
- , __isConnected(false)
+ : __isConnected(false)
, __pListener(null)
{
_ContentManagerImpl::~_ContentManagerImpl(void)
{
- int val = media_content_disconnect();
- SysLog(NID_CNT, "media_content_disconnect result[%d].", val);
+ int val;
- __isConnected = false;
+ if (GetListener())
+ {
+ val = media_content_unset_db_updated_cb();
+ SysLog(NID_CNT, "media_content_unset_db_updated_cb result[%d].", val);
+ }
+
+ val = media_content_disconnect();
+ SysLog(NID_CNT, "media_content_disconnect result[%d].", val);
}
_ContentManagerImpl*
_ContentManagerImpl::GetInstance(ContentManager& contentManager)
{
- return contentManager.__pImpl;
+ return contentManager.__pContentManagerImpl;
}
const _ContentManagerImpl*
_ContentManagerImpl::GetInstance(const ContentManager& contentManager)
{
- return contentManager.__pImpl;
+ return contentManager.__pContentManagerImpl;
}
-//
-// E_SUCCESS
-// E_SYSTEM
-// E_OUT_OF_MEMORY(in public)
-//
result
_ContentManagerImpl::Construct(void)
{
- SysAssertf(!__isConnected,
- "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
-
- ClearLastResult();
-
int val = media_content_connect();
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM,
"The connection failed[%d].", val);
return E_SUCCESS;
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_FILE_NOT_FOUND
-// E_OUT_OF_MEMORY
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-// - E_IO
-//
ContentId
_ContentManagerImpl::CreateContent(const ContentInfo& contentInfo)
{
- SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
-
ClearLastResult();
- // Get common data from ContentInfo class
- ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
- SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
- "[E_INVALID_ARG] pContentData is null.");
+ _ContentInfoImpl* pInfoImpl = const_cast< _ContentInfoImpl* >(_ContentInfoImpl::GetInstance(contentInfo));
+ SysTryReturn(NID_CNT, pInfoImpl != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid argument is used. ContentInfo is invalid.");
+
+ 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, VerifyMediaFilePathCompatibility(pContentData->contentPath, true), UuId::GetInvalidUuId(),
- E_INVALID_ARG, "[E_INVALID_ARG] The contentPath is not compatible.");
- SysTryReturn(NID_CNT, _FileImpl::IsFileExist(pContentData->contentPath), UuId::GetInvalidUuId(), E_FILE_NOT_FOUND,
- "[E_FILE_NOT_FOUND] The file corresponding to contentInfo could not be found.");
- SysTryReturn(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), UuId::GetInvalidUuId(),
+ 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 = pContentData->contentType;
- ContentType sysType = _ContentManagerUtilImpl::CheckContentType(pContentData->contentPath, true);
+ ContentType inputType = pInfoImpl->GetContentType();
+ ContentType sysType = _ContentManagerUtilImpl::CheckContentType(contentPath, true);
+
+ ClearLastResult();
if (inputType != sysType)
{
}
// Save data to database with contentPath.
- unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(pContentData->contentPath));
+ 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.");
- media_info_h __pMediaInfo = null;
- unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ media_info_h tempMediaInfo = null;
+ unique_ptr<media_info_s, _MediaInfoDeleter> pMediaInfo(null);
- // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
- int val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
+ int val = media_info_insert_to_db(pStr.get(), &tempMediaInfo);
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
"The registration to database failed[%d].", val);
- pMediaInfo.reset(&__pMediaInfo);
+ pMediaInfo.reset(tempMediaInfo);
- // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
- ContentId contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
- result r = GetLastResult();
+ ContentId contentId = SaveDataToDatabase(pMediaInfo.get(), pInfoImpl);
+ 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_SUCCESS
-// E_INVALID_ARG
-// E_STORAGE_FULL
-// E_FILE_ALREADY_EXIST
-// E_ILLEGAL_ACCESS
-// E_MAX_EXCEEDED
-// E_IO
-// E_OUT_OF_MEMORY
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-//
ContentId
_ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& destinationPath,
const ContentInfo* pContentInfo)
{
- SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
-
ClearLastResult();
// Check parameters(for length)
"[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.");
SysTryReturn(NID_CNT, pFile != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- // Exception : E_SUCCESS, E_OUT_OF_MEMORY, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO, (E_FILE_NOT_FOUND), E_SYSTEM
result r = pFile->Construct(destinationPath, L"w+");
SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r,
"[%s] The destination file can not be created.", GetErrorMessage(r));
SysTryReturn(NID_CNT, pFileImpl != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_STORAGE_FULL, E_IO
r = pFileImpl->Write(byteBuffer);
SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r,
"[%s] The data can not be written in the destination file.", GetErrorMessage(r));
// for release file pointer
- delete pFile.release();
+ pFile.reset();
int val = 0;
ContentId contentId;
- ContentInfo::_ContentData contentData;
- ContentInfo::_ContentData* pContentData = null;
- media_info_h __pMediaInfo = null;
- unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ _ContentInfoImpl* pInfoImpl = null;
+ _ImageContentInfoImpl imageContentInfoImpl;
+ _AudioContentInfoImpl audioContentInfoImpl;
+ _VideoContentInfoImpl videoContentInfoImpl;
+ _OtherContentInfoImpl otherContentInfoImpl;
+ 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)
{
- pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
- SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
+ pInfoImpl = const_cast< _ContentInfoImpl* >(_ContentInfoImpl::GetInstance(*pContentInfo));
+ SysTryCatch(NID_CNT, pInfoImpl != null, , E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid argument is used. ContentInfo is invalid.");
- SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
+ SysTryCatch(NID_CNT, pInfoImpl->GetContentId() == UuId::GetInvalidUuId(), , E_INVALID_ARG,
"[E_INVALID_ARG] The content already exists in database.");
// Compare the type of input parameter and system
// CheckContentType() need actual file. so it should be checked after creating the file.
ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
- ContentType inputType = pContentData->contentType;
+ ContentType inputType = pInfoImpl->GetContentType();
+
+ ClearLastResult();
if (inputType != sysType)
{
}
// Sets the content path
- (pContentData->contentPath).Clear();
- pContentData->contentPath = destinationPath;
+ pInfoImpl->SetContentPath(destPath);
}
else
{
+ ContentType contentType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
+
+ ClearLastResult();
+
// Set the content path
- contentData.contentPath = destinationPath;
+ if (contentType == CONTENT_TYPE_IMAGE)
+ {
+ r = imageContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for ImageContentInfoImpl.");
+
+ imageContentInfoImpl.SetContentPath(destPath);
+ pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&imageContentInfoImpl);
+ }
+ else if (contentType == CONTENT_TYPE_AUDIO)
+ {
+ r = audioContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for AudioContentInfoImpl.");
+
+ audioContentInfoImpl.SetContentPath(destPath);
+ pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&audioContentInfoImpl);
+ }
+ else if (contentType == CONTENT_TYPE_VIDEO)
+ {
+ r = videoContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for VideoContentInfoImpl.");
+
+ videoContentInfoImpl.SetContentPath(destPath);
+ pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&videoContentInfoImpl);
+ }
+ else
+ {
+ r = otherContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for OtherContentInfoImpl.");
- pContentData = &contentData;
+ 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(), &__pMediaInfo);
+ val = media_info_insert_to_db(pStr.get(), &tempMediaInfo);
SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
"media_info_insert_to_db failed[%d].", val);
- pMediaInfo.reset(&__pMediaInfo);
+ pMediaInfo.reset(tempMediaInfo);
- // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
- contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
+ contentId = SaveDataToDatabase(pMediaInfo.get(), pInfoImpl);
r = GetLastResult();
SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
"[%s] SaveDataToDatabase failed.", 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);
}
return UuId::GetInvalidUuId();
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_FILE_NOT_FOUND
-// E_STORAGE_FULL
-// E_FILE_ALREADY_EXIST
-// E_ILLEGAL_ACCESS
-// E_MAX_EXCEEDED
-// E_IO
-// E_OUT_OF_MEMORY
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-//
ContentId
_ContentManagerImpl::CreateContent(const String& sourcePath, const String& destinationPath, bool deleteSource,
const ContentInfo* pContentInfo)
{
- SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
-
ClearLastResult();
// Check parameters(for type)
// 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;
-
- if (deleteSource) // move
- {
- // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
- r = _FileImpl::Move(sourcePath, destinationPath);
- SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Moving the file failed.", GetErrorMessage(r));
- }
- else // copy
- {
- // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
- r = _FileImpl::Copy(sourcePath, destinationPath, true);
- SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
- }
+ 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;
- ContentInfo::_ContentData contentData;
- ContentInfo::_ContentData* pContentData = null;
- media_info_h __pMediaInfo = null;
- unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ _ContentInfoImpl* pInfoImpl = null;
+ _ImageContentInfoImpl imageContentInfoImpl;
+ _AudioContentInfoImpl audioContentInfoImpl;
+ _VideoContentInfoImpl videoContentInfoImpl;
+ _OtherContentInfoImpl otherContentInfoImpl;
+ 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)
{
- pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
- SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
+ pInfoImpl = const_cast< _ContentInfoImpl* >(_ContentInfoImpl::GetInstance(*pContentInfo));
+ SysTryCatch(NID_CNT, pInfoImpl != null, , E_INVALID_ARG,
+ "[E_INVALID_ARG] Invalid argument is used. ContentInfo is invalid.");
- SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
+ SysTryCatch(NID_CNT, pInfoImpl->GetContentId() == UuId::GetInvalidUuId(), , E_INVALID_ARG,
"[E_INVALID_ARG] The content already exists in database.");
// Compare the type of input parameter and system
// CheckContentType() need actual file. so it should be checked after creating the file.
ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
- ContentType inputType = pContentData->contentType;
+ ContentType inputType = pInfoImpl->GetContentType();
+
+ ClearLastResult();
if (inputType != sysType)
{
}
// Set the content path
- (pContentData->contentPath).Clear();
- pContentData->contentPath = destinationPath;
+ pInfoImpl->SetContentPath(destPath);
}
else
{
+ ContentType contentType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
+
+ ClearLastResult();
+
// Set the content path
- contentData.contentPath = destinationPath;
+ if (contentType == CONTENT_TYPE_IMAGE)
+ {
+ r = imageContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for ImageContentInfoImpl.");
+
+ imageContentInfoImpl.SetContentPath(destPath);
+ pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&imageContentInfoImpl);
+ }
+ else if (contentType == CONTENT_TYPE_AUDIO)
+ {
+ r = audioContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for AudioContentInfoImpl.");
+
+ audioContentInfoImpl.SetContentPath(destPath);
+ pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&audioContentInfoImpl);
+ }
+ else if (contentType == CONTENT_TYPE_VIDEO)
+ {
+ r = videoContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for VideoContentInfoImpl.");
+
+ videoContentInfoImpl.SetContentPath(destPath);
+ pInfoImpl = dynamic_cast< _ContentInfoImpl* >(&videoContentInfoImpl);
+ }
+ else
+ {
+ r = otherContentInfoImpl.Construct(&destinationPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Construct for OtherContentInfoImpl.");
- pContentData = &contentData;
+ 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(), &__pMediaInfo);
+ val = media_info_insert_to_db(pStr.get(), &tempMediaInfo);
SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
"media_info_insert_to_db failed[%d].", val);
- pMediaInfo.reset(&__pMediaInfo);
+ pMediaInfo.reset(tempMediaInfo);
- contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
+ contentId = SaveDataToDatabase(pMediaInfo.get(), pInfoImpl);
r = GetLastResult();
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 the destination file is made by this method, it should be deleted when error occurs.
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);
}
return UuId::GetInvalidUuId();
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_FILE_NOT_FOUND
-// E_OUT_OF_MEMORY
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-//
ContentInfo*
_ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
{
- SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
-
ClearLastResult();
SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), null, E_INVALID_ARG,
unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(contentId.ToString()));
SysTryReturn(NID_CNT, pStr != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
- media_info_h __pMediaInfo = null;
- unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
- int val = media_info_get_media_from_db(pStr.get(), &__pMediaInfo);
+ media_info_h tempMediaInfo = null;
+ unique_ptr<media_info_s, _MediaInfoDeleter> pMediaInfo(null);
+ int val = media_info_get_media_from_db(pStr.get(), &tempMediaInfo);
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
"media_info_get_media_from_db failed[%d].", val);
- pMediaInfo.reset(&__pMediaInfo);
+ pMediaInfo.reset(tempMediaInfo);
media_content_type_e systemType = MEDIA_CONTENT_TYPE_IMAGE;
- val = media_info_get_media_type(*(pMediaInfo.get()), &systemType);
+ val = media_info_get_media_type(pMediaInfo.get(), &systemType);
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
"media_info_get_media_type failed[%d].", val);
- char* __pFilePath = null;
- val = media_info_get_file_path(*(pMediaInfo.get()), &__pFilePath);
+ char* pTempFilePath = null;
+ val = media_info_get_file_path(pMediaInfo.get(), &pTempFilePath);
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
"media_info_get_file_path failed[%d].", val);
- unique_ptr<char, CharDeleter> pFilePath(__pFilePath);
-
- SysTryReturn(NID_CNT, _FileImpl::IsFileExist(String(pFilePath.get())), null, E_FILE_NOT_FOUND,
- "[E_FILE_NOT_FOUND] The file corresponding to contentId could not be found.");
+ unique_ptr<char, CharDeleter> pFilePath(pTempFilePath);
+ String contentPath(pFilePath.get());
+ 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);
+ 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.");
- // Get custom data
- ContentInfo::_ContentData* pContentData = pImageContentInfo->GetContentData();
- SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ r = pImageContentInfo->Construct(&changedPath);
+ r = ConvertErrorToResult(r);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r,
+ "[%s] Failed to perform Construct operation to ImageContentInfo.", GetErrorMessage(r));
- // Get image metadata
- ImageContentInfo::_ImageContentData* pImageContentData = pImageContentInfo->GetImageContentData();
- SysTryReturn(NID_CNT, pImageContentData != null, null, E_OUT_OF_MEMORY,
+ _ImageContentInfoImpl* pImageContentInfoImpl = _ImageContentInfoImpl::GetInstance(*(pImageContentInfo.get()));
+ SysTryReturn(NID_CNT, pImageContentInfoImpl != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- // Set data
- // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
- r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pImageContentData);
+ r = MakeContentInfo(pMediaInfo.get(), systemType, pImageContentInfoImpl);
SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
return pImageContentInfo.release();
}
else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
{
- unique_ptr<AudioContentInfo> pAudioContentInfo(new (nothrow) AudioContentInfo);
+ unique_ptr< AudioContentInfo > pAudioContentInfo(new (nothrow) AudioContentInfo);
SysTryReturn(NID_CNT, pAudioContentInfo != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- ContentInfo::_ContentData* pContentData = pAudioContentInfo->GetContentData();
- SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ r = pAudioContentInfo->Construct(&changedPath);
+ r = ConvertErrorToResult(r);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r,
+ "[%s] Failed to perform Construct operation to AudioContentInfo.", GetErrorMessage(r));
- AudioContentInfo::_AudioContentData* pAudioContentData = pAudioContentInfo->GetAudioContentData();
- SysTryReturn(NID_CNT, pAudioContentData != null, null, E_OUT_OF_MEMORY,
+ _AudioContentInfoImpl* pAudioContentInfoImpl = _AudioContentInfoImpl::GetInstance(*(pAudioContentInfo.get()));
+ SysTryReturn(NID_CNT, pAudioContentInfoImpl != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pAudioContentData);
+ r = MakeContentInfo(pMediaInfo.get(), systemType, pAudioContentInfoImpl);
SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
return pAudioContentInfo.release();
}
else if (systemType == SYSTEM_TYPE_VIDEO)
{
- unique_ptr<VideoContentInfo> pVideoContentInfo(new (nothrow) VideoContentInfo);
+ unique_ptr< VideoContentInfo > pVideoContentInfo(new (nothrow) VideoContentInfo);
SysTryReturn(NID_CNT, pVideoContentInfo != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- ContentInfo::_ContentData* pContentData = pVideoContentInfo->GetContentData();
- SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ r = pVideoContentInfo->Construct(&changedPath);
+ r = ConvertErrorToResult(r);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r,
+ "[%s] Failed to perform Construct operation to VideoContentInfo.", GetErrorMessage(r));
- VideoContentInfo::_VideoContentData* pVideoContentData = pVideoContentInfo->GetVideoContentData();
- SysTryReturn(NID_CNT, pVideoContentData != null, null, E_OUT_OF_MEMORY,
+ _VideoContentInfoImpl* pVideoContentInfoImpl = _VideoContentInfoImpl::GetInstance(*(pVideoContentInfo.get()));
+ SysTryReturn(NID_CNT, pVideoContentInfoImpl != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pVideoContentData);
+ r = MakeContentInfo(pMediaInfo.get(), systemType, pVideoContentInfoImpl);
SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
return pVideoContentInfo.release();
}
else if (systemType == SYSTEM_TYPE_OTHER)
{
- unique_ptr<OtherContentInfo> pOtherContentInfo(new (nothrow) OtherContentInfo);
+ unique_ptr< OtherContentInfo > pOtherContentInfo(new (nothrow) OtherContentInfo);
SysTryReturn(NID_CNT, pOtherContentInfo != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- ContentInfo::_ContentData* pContentData = pOtherContentInfo->GetContentData();
- SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
+ r = pOtherContentInfo->Construct(&changedPath);
+ r = ConvertErrorToResult(r);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r,
+ "[%s] Failed to perform Construct operation to OtherContentInfo.", GetErrorMessage(r));
+
+ _OtherContentInfoImpl* pOtherContentInfoImpl = _OtherContentInfoImpl::GetInstance(*(pOtherContentInfo.get()));
+ SysTryReturn(NID_CNT, pOtherContentInfoImpl != null, null, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] The memory is insufficient.");
- r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, null);
+ r = MakeContentInfo(pMediaInfo.get(), systemType, pOtherContentInfoImpl);
SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
return pOtherContentInfo.release();
}
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_FILE_NOT_FOUND
-// E_OUT_OF_MEMORY
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-//
result
_ContentManagerImpl::UpdateContent(const ContentInfo& contentInfo)
{
- SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+ const _ContentInfoImpl* pInfoImpl = _ContentInfoImpl::GetInstance(contentInfo);
+ SysTryReturnResult(NID_CNT, pInfoImpl != null, E_INVALID_ARG, "Invalid argument is used. ContentInfo is invalid.");
- ClearLastResult();
-
- ContentId contentId = contentInfo.GetContentId();
+ ContentId contentId = pInfoImpl->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,
+ SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(pInfoImpl->GetContentPath()), E_FILE_NOT_FOUND,
"The file corresponding to contentInfo could not be found.");
- // Get common data from ContentInfo class
- ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
- SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
-
- // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SYSTEM, E_SERVICE_BUSY
- result r = this->UpdateDataToDatabase(pContentData);
+ result r = UpdateDataToDatabase(pInfoImpl);
SysTryReturnResult(NID_CNT, !IsFailed(r), r, "UpdateDataToDatabase failed.");
return r;
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_FILE_NOT_FOUND
-// E_OUT_OF_MEMORY
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-// - E_ILLEGAL_ACCESS
-//
result
_ContentManagerImpl::DeleteContent(const ContentId& contentId)
{
- SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
-
- ClearLastResult();
-
SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The contentId is invalid.");
unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN(contentId.ToString()));
result r = E_SUCCESS;
int val = 0;
- media_info_h __pMediaInfo = null;
- unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ media_info_h tempMediaInfo = null;
+ unique_ptr<media_info_s, _MediaInfoDeleter> pMediaInfo(null);
- val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
+ val = media_info_get_media_from_db(pContentId.get(), &tempMediaInfo);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_media_from_db failed[%d].", val);
- pMediaInfo.reset(&__pMediaInfo);
+ pMediaInfo.reset(tempMediaInfo);
- char* __pContentPath = null;
+ char* pTempPath = null;
- val = media_info_get_file_path(*(pMediaInfo.get()), &__pContentPath);
+ val = media_info_get_file_path(pMediaInfo.get(), &pTempPath);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_file_path failed[%d].", val);
- unique_ptr<char, CharDeleter> pContentPath(__pContentPath);
+ 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;
}
-//
-// E_SUCCESS
-// E_OBJ_ALREADY_EXIST
-// E_SYSTEM
-//
result
_ContentManagerImpl::AddContentUpdateEventListener(IContentUpdateEventListener& listener)
{
- ClearLastResult();
-
SysTryReturnResult(NID_CNT, GetListener() == null, E_OBJ_ALREADY_EXIST, "IContentUpdateEventListener is already set.");
SetListener(&listener);
return E_SUCCESS;
}
-//
-// E_SUCCESS
-// E_OBJ_NOT_FOUND
-// E_SYSTEM
-//
result
_ContentManagerImpl::RemoveContentUpdateEventListener(IContentUpdateEventListener& listener)
{
- ClearLastResult();
-
SysTryReturnResult(NID_CNT, GetListener() == &listener, E_OBJ_NOT_FOUND, "The input listener is not equal to the registered listener.");
int val = media_content_unset_db_updated_cb();
return E_SUCCESS;
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-//
result
_ContentManagerImpl::ScanFile(const Tizen::Base::String& contentPath)
{
- ClearLastResult();
-
SysSecureLog(NID_CNT, "The scan path is [%ls].", contentPath.GetPointer());
unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(contentPath));
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val);
val = media_content_scan_file(pContentPath.get());
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_file failed[%d].", val);
+ result r = ConvertError(val);
+ SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , r, "[%s] media_content_scan_file failed[%d].", GetErrorMessage(r), val);
val = media_content_disconnect();
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The disconnection failed[%d].", val);
return E_SUCCESS;
+
+CATCH:
+ val = media_content_disconnect();
+ SysTryLog(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, "The disconnection failed[%d].", val);
+
+ return r;
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_SYSTEM
-// E_SERVICE_BUSY
-// E_PRIVILEGE_DENIED(in public)
-//
result
_ContentManagerImpl::ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId)
{
- ClearLastResult();
+ static RequestId requestId = 0;
SysLog(NID_CNT, "The scan path is [%ls].", directoryPath.GetPointer());
int val = media_content_connect();
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val);
- unique_ptr< ScanResult > pScanResult(new (nothrow) ScanResult);
+ unique_ptr< _ScanResult > pScanResult(new (nothrow) _ScanResult);
SysTryReturnResult(NID_CNT, pScanResult != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
reqId = requestId++;
- pScanResult->pScanPath = pDirPath.get();
+ pScanResult->scanPath = directoryPath;
pScanResult->pScanListener = pListener;
pScanResult->requestId = reqId;
- val = media_content_scan_folder(pDirPath.release(), recursive, OnScanCompleted, pScanResult.release());
+ val = media_content_scan_folder(pDirPath.get(), recursive, OnScanCompleted, pScanResult.release());
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_folder failed[%d].", val);
return E_SUCCESS;
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_OUT_OF_MEMORY
-// E_SYSTEM
-// E_SERVICE_BUSY
-//
result
-_ContentManagerImpl::UpdateDataToDatabase(const ContentInfo::_ContentData* pContentData) const
+_ContentManagerImpl::UpdateDataToDatabase(const _ContentInfoImpl* pContentInfoImpl) const
{
- ClearLastResult();
-
- SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
+ SysTryReturnResult(NID_CNT, pContentInfoImpl != null, E_INVALID_ARG, "pContentInfoImpl is null.");
- media_info_h __pMediaInfo = null;
- unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
- unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN((pContentData->contentId).ToString()));
+ media_info_h tempMediaInfo = null;
+ unique_ptr<media_info_s, _MediaInfoDeleter> pMediaInfo(null);
+ unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN((pContentInfoImpl->GetContentId()).ToString()));
SysTryReturnResult(NID_CNT, pContentId != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- int val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
+ int val = media_info_get_media_from_db(pContentId.get(), &tempMediaInfo);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_media_from_db failed[%d].", val);
- pMediaInfo.reset(&__pMediaInfo);
+ pMediaInfo.reset(tempMediaInfo);
result r = E_SUCCESS;
unique_ptr<char[]> pValue(null);
- if (pContentData->pAuthor != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
- 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 (pContentData->pCategory != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
- 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 (pContentData->pContentName != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
- 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 (pContentData->pDescription != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
- 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 (pContentData->pKeyword != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
- 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 (pContentData->pLocationTag != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
- 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 (pContentData->pProvider != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
- 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 (pContentData->pRating != null)
- {
- pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
- 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);
- }
- if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
- Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
+ // 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)
{
- val = media_info_set_latitude(*(pMediaInfo.get()), pContentData->latitude);
+ val = media_info_set_latitude(pMediaInfo.get(), pContentInfoImpl->GetLatitude());
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_set_latitude failed[%d].", val);
- val = media_info_set_longitude(*(pMediaInfo.get()), pContentData->longitude);
+ val = media_info_set_longitude(pMediaInfo.get(), pContentInfoImpl->GetLongitude());
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_set_longitude failed[%d].", val);
- if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
+ if (Double::Compare(pContentInfoImpl->GetAltitude(), DEFAULT_COORDINATE) != 0)
{
- val = media_info_set_altitude(*(pMediaInfo.get()), pContentData->altitude);
+ val = media_info_set_altitude(pMediaInfo.get(), pContentInfoImpl->GetAltitude());
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_set_altitude failed[%d].", val);
}
}
- val = media_info_update_to_db(*(pMediaInfo.get()));
+ val = media_info_update_to_db(pMediaInfo.get());
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_update_to_db failed[%d].", val);
return r;
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_OUT_OF_MEMORY
-// E_SERVICE_BUSY
-// E_SYSTEM
-//
ContentId
_ContentManagerImpl::SaveDataToDatabase(const media_info_h pMediaInfo,
- ContentInfo::_ContentData* pContentData) const
+ _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(changedPath);
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ ClearLastResult();
+
+ SysLog(NID_CNT, "[%s] Failed to perform GetFileExtension operation.", GetErrorMessage(r));
+
+ 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.");
+
+ char tempType[255] = {0, };
+ int ret = aul_get_mime_from_file(pTempPath.get(), tempType, sizeof(tempType));
+ SysTryReturn(NID_CNT, ret == AUL_R_OK, UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform aul_get_mime_from_file operation.");
- SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
- "[E_INVALID_ARG] pContentData is null.");
+ r = mimeType.Append(tempType);
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform Append operation.");
- // Exception : E_SUCCESS, E_INVALID_ARG
- String extension = _FileImpl::GetFileExtension(pContentData->contentPath);
- result r = GetLastResult();
- SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r, "[%s] Propagating.", GetErrorMessage(r));
+ }
// If the content format is JPG and it has GPS data, it will be saved in database automatically.
- if (extension == L"jpg" || extension == L"jpeg" || extension == L"JPG" || extension == L"JPEG")
+ if (extension == L"jpg" || extension == L"jpeg" || extension == L"JPG" || extension == L"JPEG" || mimeType.Contains(L"jpeg"))
{
SysLog(NID_CNT, "The format of content is jpg.");
- ImageMetadata* pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(pContentData->contentPath, true);
+ ImageMetadata* pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(changedPath, true);
if (pImageMetadata != null)
{
- pContentData->latitude = pImageMetadata->GetLatitude();
- pContentData->longitude = pImageMetadata->GetLongitude();
+ pContentInfoImpl->SetLatitude(pImageMetadata->GetLatitude());
+ pContentInfoImpl->SetLongitude(pImageMetadata->GetLongitude());
delete pImageMetadata;
- pImageMetadata = null;
}
+
+ ClearLastResult();
}
int val = 0;
unique_ptr<char[]> pStr(null);
- if (pContentData->pAuthor != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
- 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 (pContentData->pCategory != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
- 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 (pContentData->pContentName != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
- 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 (pContentData->pDescription != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
- 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 (pContentData->pKeyword != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
- 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 (pContentData->pLocationTag != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
- 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 (pContentData->pProvider != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
- 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 (pContentData->pRating != null)
- {
- pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
- 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);
- }
- if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
- Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
+ // 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)
{
- val = media_info_set_latitude(pMediaInfo, pContentData->latitude);
+ val = media_info_set_latitude(pMediaInfo, pContentInfoImpl->GetLatitude());
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
"media_info_set_latitude failed[%d].", val);
- val = media_info_set_longitude(pMediaInfo, pContentData->longitude);
+ val = media_info_set_longitude(pMediaInfo, pContentInfoImpl->GetLongitude());
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
"media_info_set_longitude failed[%d].", val);
- if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
+ if (Double::Compare(pContentInfoImpl->GetAltitude(), DEFAULT_COORDINATE) != 0)
{
- val = media_info_set_altitude(pMediaInfo, pContentData->altitude);
+ val = media_info_set_altitude(pMediaInfo, pContentInfoImpl->GetAltitude());
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
"media_info_set_altitude failed[%d].", val);
}
SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
"media_info_update_to_db failed[%d].", val);
- char* __pMediaId = null;
+ char* pTempMediaId = null;
unique_ptr<char, CharDeleter> pMediaId(null);
- val = media_info_get_media_id(pMediaInfo, &__pMediaId);
- if (__pMediaId != null)
+ val = media_info_get_media_id(pMediaInfo, &pTempMediaId);
+ if (pTempMediaId != null)
{
- pMediaId.reset(__pMediaId);
+ pMediaId.reset(pTempMediaId);
}
else
{
"media_info_get_media_id failed[%d].", val);
}
- String contentId(pMediaId.get());
+ String tempContentId(pMediaId.get());
+ ContentId contentId;
- r = UuId::Parse(contentId, pContentData->contentId);
+ r = UuId::Parse(tempContentId, contentId);
SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), E_INVALID_ARG,
"[E_INVALID_ARG] UuId::Parse failed.");
- return pContentData->contentId;
+ return contentId;
}
-//
-// E_SUCCESS
-// E_INVALID_ARG
-// E_OUT_OF_MEMORY
-// E_SERVICE_BUSY
-// E_SYSTEM
-//
result
-_ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData,
- int systemType, void* pMetadata) const
+_ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, int systemType, void* pInfoImpl) const
{
- ClearLastResult();
+ SysTryReturnResult(NID_CNT, pMediaInfo != null && pInfoImpl != null, E_INVALID_ARG,
+ "The specified parameter is invalid.");
- if (systemType != SYSTEM_TYPE_OTHER)
- {
- SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null && pMetadata != null, E_INVALID_ARG,
- "The specified parameter is invalid.");
- }
- else // There is no metadata in Other type
- {
- SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null, E_INVALID_ARG,
- "The specified parameter is invalid.");
- }
+ _ContentInfoImpl* pContentInfoImpl = static_cast< _ContentInfoImpl* >(pInfoImpl);
result r = E_SUCCESS;
- char* __pStrValue = null;
+ char* pTempValue = null;
unique_ptr<char, CharDeleter> pStrValue(null);
// contentId
- int val = media_info_get_media_id(pMediaInfo, &__pStrValue);
+ int val = media_info_get_media_id(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_media_id failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
String strContentId(pStrValue.get());
+ ContentId contentId;
- r = UuId::Parse(strContentId, pContentData->contentId);
+ r = UuId::Parse(strContentId, contentId);
SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content id can not be parsed.");
+ pContentInfoImpl->SetContentId(contentId);
+
SysLog(NID_CNT, "INFO: contentId[%ls]", strContentId.GetPointer());
}
// contentPath
- val = media_info_get_file_path(pMediaInfo, &__pStrValue);
+ val = media_info_get_file_path(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_file_path failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
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;
- }
- }
-
- pContentData->contentPath = strFilePath;
-
- SysSecureLog(NID_CNT, "INFO: contentPath[%ls]", strFilePath.GetPointer());
+ pContentInfoImpl->SetContentPath(strFilePath);
+ SysSecureLog(NID_CNT, "INFO: contentPath[%ls]", (pContentInfoImpl->GetContentPath()).GetPointer());
}
// mimeType
- val = media_info_get_mime_type(pMediaInfo, &__pStrValue);
+ val = media_info_get_mime_type(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_mime_type failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->mimeType = pStrValue.get();
+ pContentInfoImpl->SetMimeType(pStrValue.get());
- SysLog(NID_CNT, "INFO: mimeType[%ls]", (pContentData->mimeType).GetPointer());
+ SysLog(NID_CNT, "INFO: mimeType[%ls]", (pContentInfoImpl->GetMimeType()).GetPointer());
}
// contentSize
val = media_info_get_size(pMediaInfo, &longlongValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_size failed[%d].", val);
- pContentData->contentSize = longlongValue;
+ pContentInfoImpl->SetContentSize(longlongValue);
SysLog(NID_CNT, "INFO: contentSize[%llu]", longlongValue);
// storageType
val = media_info_get_storage_type(pMediaInfo, &storageType);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_storage_type failed[%d].", val);
- pContentData->storageType = storageType;
+ pContentInfoImpl->SetStorageType(storageType);
SysLog(NID_CNT, "INFO: storageType[%d]", storageType);
// isDrm
- val = media_info_is_drm(pMediaInfo, &(pContentData->isDrm));
+ bool tempDrm = false;
+
+ val = media_info_is_drm(pMediaInfo, &tempDrm);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_is_drm failed[%d].", val);
- SysLog(NID_CNT, "INFO: isDrm[%d]", pContentData->isDrm);
+
+ pContentInfoImpl->SetDrmProtected(tempDrm);
+
+ SysLog(NID_CNT, "INFO: isDrm[%d]", pContentInfoImpl->IsDrmProtected());
// dateTime
- time_t time = 0;
- val = media_info_get_added_time(pMediaInfo, &time);
+ time_t addedTime = 0;
+ val = media_info_get_added_time(pMediaInfo, &addedTime);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_added_time failed[%d].", val);
- r = (pContentData->dateTime).SetValue(1970, 1, 1);
- SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "SetValue failed.");
- r = (pContentData->dateTime).AddSeconds(time);
- SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "AddSeconds failed.");
- SysLog(NID_CNT, "INFO: dateTime[%ls]", ((pContentData->dateTime).ToString()).GetPointer());
+
+ DateTime dt;
+ r = dt.SetValue(1970, 1, 1);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform datetime.SetValue operation.");
+ r = dt.AddSeconds(addedTime);// need to check addedTime is secs/millisec
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform datetime.AddSeconds operation.");
+
+ pContentInfoImpl->SetDateTime(dt);
+ SysLog(NID_CNT, "INFO: dateTime[%ls]", ((pContentInfoImpl->GetDateTime()).ToString()).GetPointer());
+
+ // modifiedTime
+ time_t modifiedTime = 0;
+ val = media_info_get_modified_time(pMediaInfo, &modifiedTime);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_modified_time failed[%d].", val);
+
+ r = dt.SetValue(1970, 1, 1);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform datetime.SetValue operation.");
+ r = dt.AddSeconds(modifiedTime);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform datetime.AddSeconds operation.");
+
+ pContentInfoImpl->SetModifiedTime(dt);
+ SysLog(NID_CNT, "INFO: modifiedTime[%ls]", ((pContentInfoImpl->GetModifiedTime()).ToString()).GetPointer());
// thumbnailPath
- val = media_info_get_thumbnail_path(pMediaInfo, &__pStrValue);
+ val = media_info_get_thumbnail_path(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_thumbnail_path failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
-
- pContentData->pThumbnailPath = new (nothrow) String(pStrValue.get());
+ pStrValue.reset(pTempValue);
+ String thumbnailPath(pStrValue.get());
- SysLog(NID_CNT, "INFO: thumbnailPath[%ls]", (*pContentData->pThumbnailPath).GetPointer());
+ pContentInfoImpl->SetThumbnailPath(thumbnailPath);
+ SysLog(NID_CNT, "INFO: thumbnailPath[%ls]", (pContentInfoImpl->GetThumbnailPath()).GetPointer());
}
// author
- val = media_info_get_author(pMediaInfo, &__pStrValue);
+ val = media_info_get_author(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_author failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pAuthor = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetAuthor(String(pStrValue.get()));
- SysLog(NID_CNT, "INFO: author[%ls]", (*pContentData->pAuthor).GetPointer());
+ SysLog(NID_CNT, "INFO: author[%ls]", (pContentInfoImpl->GetAuthor()).GetPointer());
}
// category
- val = media_info_get_category(pMediaInfo, &__pStrValue);
+ val = media_info_get_category(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_category failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pCategory = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetCategory(String(pStrValue.get()));
- SysLog(NID_CNT, "INFO: category[%ls]", (*pContentData->pCategory).GetPointer());
+ SysLog(NID_CNT, "INFO: category[%ls]", (pContentInfoImpl->GetCategory()).GetPointer());
}
// contentName
- val = media_info_get_content_name(pMediaInfo, &__pStrValue);
+ val = media_info_get_content_name(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_content_name failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pContentName = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetContentName(String(pStrValue.get()));
- SysSecureLog(NID_CNT, "INFO: contentName[%ls]", (*pContentData->pContentName).GetPointer());
+ SysSecureLog(NID_CNT, "INFO: contentName[%ls]", (pContentInfoImpl->GetContentName()).GetPointer());
}
// description
- val = media_info_get_description(pMediaInfo, &__pStrValue);
+ val = media_info_get_description(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_description failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pDescription = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetDescription(String(pStrValue.get()));
- SysLog(NID_CNT, "INFO: description[%ls]", (*pContentData->pDescription).GetPointer());
+ SysLog(NID_CNT, "INFO: description[%ls]", (pContentInfoImpl->GetDescription()).GetPointer());
}
// keyword
- val = media_info_get_keyword(pMediaInfo, &__pStrValue);
+ val = media_info_get_keyword(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_keyword failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pKeyword = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetKeyword(String(pStrValue.get()));
- SysLog(NID_CNT, "INFO: keyword[%ls]", (*pContentData->pKeyword).GetPointer());
+ SysLog(NID_CNT, "INFO: keyword[%ls]", (pContentInfoImpl->GetKeyword()).GetPointer());
}
// locationTag
- val = media_info_get_location_tag(pMediaInfo, &__pStrValue);
+ val = media_info_get_location_tag(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_location_tag failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pLocationTag = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetLocationTag(String(pStrValue.get()));
- SysSecureLog(NID_CNT, "INFO: locationTag[%ls]", (*pContentData->pLocationTag).GetPointer());
+ SysSecureLog(NID_CNT, "INFO: locationTag[%ls]", (pContentInfoImpl->GetLocationTag()).GetPointer());
}
// provider
- val = media_info_get_provider(pMediaInfo, &__pStrValue);
+ val = media_info_get_provider(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_provider failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pProvider = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetProvider(String(pStrValue.get()));
- SysLog(NID_CNT, "INFO: provider[%ls]", (*pContentData->pProvider).GetPointer());
+ SysLog(NID_CNT, "INFO: provider[%ls]", (pContentInfoImpl->GetProvider()).GetPointer());
}
// rating
- val = media_info_get_age_rating(pMediaInfo, &__pStrValue);
+ val = media_info_get_age_rating(pMediaInfo, &pTempValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
"media_info_get_age_rating failed[%d].", val);
- if (__pStrValue != null)
+ if (pTempValue != null)
{
- pStrValue.reset(__pStrValue);
+ pStrValue.reset(pTempValue);
- pContentData->pRating = new (nothrow) String(pStrValue.get());
+ pContentInfoImpl->SetRating(String(pStrValue.get()));
- SysLog(NID_CNT, "INFO: rating[%ls]", (*pContentData->pRating).GetPointer());
+ SysLog(NID_CNT, "INFO: rating[%ls]", (pContentInfoImpl->GetRating()).GetPointer());
}
// coordinates
+ Coordinates coordinates;
double doubleValue = 0;
val = media_info_get_latitude(pMediaInfo, &doubleValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
{
- pContentData->latitude = doubleValue;
+ pContentInfoImpl->SetLatitude(doubleValue);
+ coordinates.SetLatitude(doubleValue);
}
- SysSecureLog(NID_CNT, "INFO: latitude[%f]", pContentData->latitude);
+ SysSecureLog(NID_CNT, "INFO: latitude[%f]", pContentInfoImpl->GetLatitude());
val = media_info_get_longitude(pMediaInfo, &doubleValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
{
- pContentData->longitude = doubleValue;
+ pContentInfoImpl->SetLongitude(doubleValue);
+ coordinates.SetLongitude(doubleValue);
}
- SysSecureLog(NID_CNT, "INFO: longitude[%f]", pContentData->longitude);
+ SysSecureLog(NID_CNT, "INFO: longitude[%f]", pContentInfoImpl->GetLongitude());
val = media_info_get_altitude(pMediaInfo, &doubleValue);
SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
{
- pContentData->altitude = doubleValue;
+ pContentInfoImpl->SetAltitude(doubleValue);
+ coordinates.SetAltitude(doubleValue);
}
- SysLog(NID_CNT, "INFO: altitude[%f]", pContentData->altitude);
+ SysLog(NID_CNT, "INFO: altitude[%f]", pContentInfoImpl->GetAltitude());
- int intValue = 0;
+ pContentInfoImpl->SetCoordinates(coordinates);
// contentType and metadata
if (systemType == SYSTEM_TYPE_IMAGE)
{
- image_meta_h __pImageMeta = null;
- unique_ptr<image_meta_h, ImageMetaDeleter> pImageMeta(null);
+ r = MakeImageContentInfo(pMediaInfo, pInfoImpl);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform MakeImageContentInfo operation.");
+ }
+ else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
+ {
+ r = MakeAudioContentInfo(pMediaInfo, pInfoImpl);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform MakeAudioContentInfo operation.");
+ }
+ else if (systemType == MEDIA_CONTENT_TYPE_VIDEO)
+ {
+ r = MakeVideoContentInfo(pMediaInfo, pInfoImpl);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform MakeVideoContentInfo operation.");
+ }
+ else if (systemType == SYSTEM_TYPE_OTHER)
+ {
+ pContentInfoImpl->SetContentType(CONTENT_TYPE_OTHER);
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentInfoImpl->GetContentType());
+ }
- pContentData->contentType = CONTENT_TYPE_IMAGE;
- SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+ return r;
+}
- val = media_info_get_image(pMediaInfo, &__pImageMeta);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_get_image failed[%d].", val);
+result
+_ContentManagerImpl::MakeImageContentInfo(const media_info_h pMediaInfo, void* pInfoImpl) const
+{
+ result r = E_SUCCESS;
+ int intValue = 0;
+ bool boolValue = false;
+ image_meta_h pTempMeta = null;
+ unique_ptr<image_meta_h, _ImageMetaDeleter> pImageMeta(null);
- pImageMeta.reset(&__pImageMeta);
+ SysTryReturnResult(NID_CNT, pInfoImpl != null, E_OUT_OF_MEMORY, "pInfoImpl is null.");
- // width
- val = image_meta_get_width(*(pImageMeta.get()), &intValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "image_meta_get_width failed[%d].", val);
+ _ContentInfoImpl* pContentInfoImpl = static_cast< _ContentInfoImpl* >(pInfoImpl);
+ SysTryReturnResult(NID_CNT, pContentInfoImpl != null, E_OUT_OF_MEMORY, "Failed to perform static cast for _ContentInfoImpl.");
- (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->width = intValue;
- SysLog(NID_CNT, "META: width[%d]", intValue);
+ pContentInfoImpl->SetContentType(CONTENT_TYPE_IMAGE);
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentInfoImpl->GetContentType());
- // height
- val = image_meta_get_height(*(pImageMeta.get()), &intValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "image_meta_get_height failed[%d].", val);
+ int val = media_info_get_image(pMediaInfo, &pTempMeta);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_image failed[%d].", val);
- (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->height = intValue;
- SysLog(NID_CNT, "META: height[%d]", intValue);
+ pImageMeta.reset(&pTempMeta);
- // orientation
- media_content_orientation_e orientation;
- val = image_meta_get_orientation(*(pImageMeta.get()), &orientation);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "image_meta_get_orientation failed[%d].", val);
+ _ImageContentInfoImpl* pImageContentInfoImpl = static_cast< _ImageContentInfoImpl* >(pInfoImpl);
+ SysTryReturnResult(NID_CNT, pImageContentInfoImpl != null, E_OUT_OF_MEMORY, "Failed to perform static cast for _ImageContentInfoImpl.");
- (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->orientationType =
- static_cast<ImageOrientationType>(orientation);
- SysLog(NID_CNT, "META: orientation[%d]", orientation);
+ // width
+ val = image_meta_get_width(*(pImageMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_width failed[%d].", val);
- // title
- val = media_info_get_display_name(pMediaInfo, &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_get_display_name failed[%d].", val);
+ pImageContentInfoImpl->SetWidth(intValue);
+ SysLog(NID_CNT, "META: width[%d]", intValue);
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ // height
+ val = image_meta_get_height(*(pImageMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_height failed[%d].", val);
- int pos = 0;
- String fileName;
- String strTitle(pStrValue.get());
+ pImageContentInfoImpl->SetHeight(intValue);
+ SysLog(NID_CNT, "META: height[%d]", intValue);
- r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
- if (r == E_SUCCESS)
- {
- r = strTitle.SubString(0, pos, fileName);
- SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The title is invalid.");
- }
- else
- {
- // Without extension
- r = E_SUCCESS;
- fileName = strTitle;
- }
+ // orientation
+ media_content_orientation_e orientation;
+ val = image_meta_get_orientation(*(pImageMeta.get()), &orientation);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_orientation failed[%d].", val);
+
+ pImageContentInfoImpl->SetOrientation(static_cast< ImageOrientationType >(orientation));
+ SysLog(NID_CNT, "META: orientation[%d]", orientation);
+
+ char* pTempValue = null;
+ unique_ptr<char, CharDeleter> pStrValue(null);
+
+ // title
+ val = media_info_get_display_name(pMediaInfo, &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_display_name failed[%d].", val);
+
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
- (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->title = fileName;
+ int pos = 0;
+ String fileName;
+ String strTitle(pStrValue.get());
- SysLog(NID_CNT, "META: title[%ls]", fileName.GetPointer());
+ result r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
+ if (r == E_SUCCESS)
+ {
+ r = strTitle.SubString(0, pos, fileName);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The title is invalid.");
+ }
+ else
+ {
+ // Without extension
+ r = E_SUCCESS;
+ fileName = strTitle;
}
+
+ pImageContentInfoImpl->SetTitle(fileName);
+
+ SysLog(NID_CNT, "META: title[%ls]", fileName.GetPointer());
}
- else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
+
+ // dateTaken
+ val = image_meta_get_date_taken(*(pImageMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_date_taken failed[%d].", val);
+
+ DateTime dt;
+
+ if (pTempValue != null)
{
- audio_meta_h __pAudioMeta = null;
- unique_ptr<audio_meta_h, AudioMetaDeleter> pAudioMeta(null);
+ pStrValue.reset(pTempValue);
+ String dateTaken(pStrValue.get());
+ String newDateTaken(L"");
- pContentData->contentType = CONTENT_TYPE_AUDIO;
- SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+ // detour the unexpected datetaken format
+ String tempDelim(L"+-Z");
+ String token;
- val = media_info_get_audio(pMediaInfo, &__pAudioMeta);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_get_audio failed[%d].", val);
+ StringTokenizer tempStrTok(dateTaken, tempDelim);
- pAudioMeta.reset(&__pAudioMeta);
+ r = tempStrTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
- // bitrate
- val = audio_meta_get_bit_rate(*(pAudioMeta.get()), &intValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_bit_rate failed[%d].", val);
+ dateTaken = token;
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->bitrate = intValue;
- SysLog(NID_CNT, "META: bitrate[%d]", intValue);
+ String delim(L": ");
+ String year(L"");
- // releaseYear
- val = audio_meta_get_year(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_year failed[%d].", val);
+ StringTokenizer strTok(dateTaken, delim);
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ r = strTok.SetDelimiters(delim);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
- String strYear(pStrValue.get());
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
- if (strYear.CompareTo(L"Unknown") != 0)
- {
- r = Integer::Parse(strYear, intValue);
- if (IsFailed(r))
- {
- // It is one of the metadata. If error occurs, skip it for other metadata.
- intValue = 0;
- r = E_SUCCESS;
- SysLog(NID_CNT, "META: releaseYear - invalid data[%ls]", strYear.GetPointer());
- }
-
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->releaseYear = intValue;
- SysLog(NID_CNT, "META: releaseYear[%d]", intValue);
- }
- }
+ year = token;
- // title
- val = audio_meta_get_title(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_title failed[%d].", val);
+ // Append month
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ r = newDateTaken.Append(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTitle =
- new (nothrow) String(pStrValue.get());
+ r = newDateTaken.Append(L"/");
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
- SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ // Append day
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
- // albumName
- val = audio_meta_get_album(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_album failed[%d].", val);
+ r = newDateTaken.Append(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ r = newDateTaken.Append(L"/");
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pAlbumName =
- new (nothrow) String(pStrValue.get());
+ // Append year
+ r = newDateTaken.Append(year);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
- SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ r = newDateTaken.Append(L" ");
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
- // artist
- val = audio_meta_get_artist(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_artist failed[%d].", val);
+ String newDelim(L" ");
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ r = strTok.SetDelimiters(newDelim);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform SetDelimiters operation.");
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pArtist =
- new (nothrow) String(pStrValue.get());
+ r = strTok.GetNextToken(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform GetNextToken operation.");
- SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ r = newDateTaken.Append(token);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_OUT_OF_MEMORY, "Failed to perform Append operation.");
- // composer
- val = audio_meta_get_composer(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_composer failed[%d].", val);
+ r = DateTime::Parse(newDateTaken, dt);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Failed to perform Parse operation for DateTime.");
+ }
+ else
+ {
+ dt = DateTime::GetMinValue();
+ }
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ pImageContentInfoImpl->SetImageTakenDate(dt);
+ SysLog(NID_CNT, "META: dateTaken[%ls]", dt.ToString().GetPointer());
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pComposer =
- new (nothrow) String(pStrValue.get());
+ // isBurstShot
+ val = image_meta_is_burst_shot(*(pImageMeta.get()), &boolValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_is_burst_shot failed[%d].", val);
- SysLog(NID_CNT, "META: composer[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ pImageContentInfoImpl->SetBurstShot(boolValue);
+ SysLog(NID_CNT, "META: isBurstShot[%d]", boolValue);
- // genre
- val = audio_meta_get_genre(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_genre failed[%d].", val);
+ // burstShotId
+ val = image_meta_get_burst_id(*(pImageMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_burst_id failed[%d].", val);
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
+ String burstShotId(pStrValue.get());
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pGenre =
- new (nothrow) String(pStrValue.get());
+ pImageContentInfoImpl->SetBurstShotId(burstShotId);
+ SysLog(NID_CNT, "META: burstShotId[%ls]", burstShotId.GetPointer());
+ }
- SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ return E_SUCCESS;
+}
- // copyright
- val = audio_meta_get_copyright(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_copyright failed[%d].", val);
+result
+_ContentManagerImpl::MakeAudioContentInfo(const media_info_h pMediaInfo, void* pInfoImpl) const
+{
+ int intValue = 0;
+ audio_meta_h pTempMeta = null;
+ unique_ptr<audio_meta_h, _AudioMetaDeleter> pAudioMeta(null);
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ SysTryReturnResult(NID_CNT, pInfoImpl != null, E_OUT_OF_MEMORY, "pInfoImpl is null.");
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pCopyright =
- new (nothrow) String(pStrValue.get());
+ _ContentInfoImpl* pContentInfoImpl = static_cast< _ContentInfoImpl* >(pInfoImpl);
+ SysTryReturnResult(NID_CNT, pContentInfoImpl != null, E_OUT_OF_MEMORY, "Failed to perform static cast for _ContentInfoImpl.");
- SysLog(NID_CNT, "META: copyright[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ pContentInfoImpl->SetContentType(CONTENT_TYPE_AUDIO);
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentInfoImpl->GetContentType());
- // trackInfo
- val = audio_meta_get_track_num(*(pAudioMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_track_num failed[%d].", val);
+ int val = media_info_get_audio(pMediaInfo, &pTempMeta);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_audio failed[%d].", val);
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ pAudioMeta.reset(&pTempMeta);
+
+ _AudioContentInfoImpl* pAudioContentInfoImpl = static_cast< _AudioContentInfoImpl* >(pInfoImpl);
+ SysTryReturnResult(NID_CNT, pAudioContentInfoImpl != null, E_OUT_OF_MEMORY, "Failed to perform static cast for _AudioContentInfoImpl.");
+
+ // bitrate
+ val = audio_meta_get_bit_rate(*(pAudioMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_bit_rate failed[%d].", val);
+
+ pAudioContentInfoImpl->SetBitrate(intValue);
+ SysLog(NID_CNT, "META: bitrate[%d]", intValue);
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTrackInfo
- = new (nothrow) String(pStrValue.get());
+ char* pTempValue = null;
+ unique_ptr<char, CharDeleter> pStrValue(null);
+
+ // releaseYear
+ val = audio_meta_get_year(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_year failed[%d].", val);
+
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
+
+ String strYear(pStrValue.get());
+
+ if (strYear.CompareTo(L"Unknown") != 0)
+ {
+ result r = Integer::Parse(strYear, intValue);
+ if (IsFailed(r))
+ {
+ // It is one of the metadata. If error occurs, skip it for other metadata.
+ intValue = 0;
+ r = E_SUCCESS;
+ SysLog(NID_CNT, "META: releaseYear - invalid data[%ls]", strYear.GetPointer());
+ }
- SysLog(NID_CNT, "META: trackInfo[%ls]", (String(pStrValue.get())).GetPointer());
+ pAudioContentInfoImpl->SetReleaseYear(intValue);
+ SysLog(NID_CNT, "META: releaseYear[%d]", intValue);
}
+ }
- // duration
- val = audio_meta_get_duration(*(pAudioMeta.get()), &intValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "audio_meta_get_duration failed[%d].", val);
+ // title
+ val = audio_meta_get_title(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_title failed[%d].", val);
+
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
- (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->duration = intValue;
- SysLog(NID_CNT, "META: duration[%d]", intValue);
+ pAudioContentInfoImpl->SetTitle(String(pStrValue.get()));
+ SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
}
- else if (systemType == MEDIA_CONTENT_TYPE_VIDEO)
+
+ // albumName
+ val = audio_meta_get_album(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_album failed[%d].", val);
+
+ if (pTempValue != null)
{
- video_meta_h __pVideoMeta = null;
- unique_ptr<video_meta_h, VideoMetaDeleter> pVideoMeta(null);
+ pStrValue.reset(pTempValue);
- pContentData->contentType = CONTENT_TYPE_VIDEO;
- SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+ pAudioContentInfoImpl->SetAlbumName(String(pStrValue.get()));
- val = media_info_get_video(pMediaInfo, &__pVideoMeta);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "media_info_get_video failed[%d].", val);
+ SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
+ }
- pVideoMeta.reset(&__pVideoMeta);
+ // artist
+ val = audio_meta_get_artist(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_artist failed[%d].", val);
- // width
- val = video_meta_get_width(*(pVideoMeta.get()), &intValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "video_meta_get_width failed[%d].", val);
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
- (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->width = intValue;
- SysLog(NID_CNT, "META: width[%d]", intValue);
+ pAudioContentInfoImpl->SetArtist(String(pStrValue.get()));
- // height
- val = video_meta_get_height(*(pVideoMeta.get()), &intValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "video_meta_get_height failed[%d].", val);
+ SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
+ }
- (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->height = intValue;
- SysLog(NID_CNT, "META: height[%d]", intValue);
+ // composer
+ val = audio_meta_get_composer(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_composer failed[%d].", val);
- // Get from metadata extractor (framerate, audio bitrate, video bitrate)
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
- // artist
- val = video_meta_get_artist(*(pVideoMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "video_meta_get_artist failed[%d].", val);
+ pAudioContentInfoImpl->SetComposer(String(pStrValue.get()));
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ SysLog(NID_CNT, "META: composer[%ls]", (String(pStrValue.get())).GetPointer());
+ }
- (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pArtist
- = new (nothrow) String(pStrValue.get());
+ // genre
+ val = audio_meta_get_genre(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_genre failed[%d].", val);
- SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
- // genre
- val = video_meta_get_genre(*(pVideoMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "video_meta_get_genre failed[%d].", val);
+ pAudioContentInfoImpl->SetGenre(String(pStrValue.get()));
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
+ }
- (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pGenre
- = new (nothrow) String(pStrValue.get());
+ // copyright
+ val = audio_meta_get_copyright(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_copyright failed[%d].", val);
- SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
- // title
- val = video_meta_get_title(*(pVideoMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "video_meta_get_title failed[%d].", val);
+ pAudioContentInfoImpl->SetCopyright(String(pStrValue.get()));
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ SysLog(NID_CNT, "META: copyright[%ls]", (String(pStrValue.get())).GetPointer());
+ }
- (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pTitle
- = new (nothrow) String(pStrValue.get());
+ // trackInfo
+ val = audio_meta_get_track_num(*(pAudioMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_track_num failed[%d].", val);
- SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
- // albumName
- val = video_meta_get_album(*(pVideoMeta.get()), &__pStrValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "video_meta_get_album failed[%d].", val);
+ pAudioContentInfoImpl->SetTrackInfo(String(pStrValue.get()));
- if (__pStrValue != null)
- {
- pStrValue.reset(__pStrValue);
+ SysLog(NID_CNT, "META: trackInfo[%ls]", (String(pStrValue.get())).GetPointer());
+ }
- (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pAlbumName
- = new (nothrow) String(pStrValue.get());
+ // duration
+ val = audio_meta_get_duration(*(pAudioMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_duration failed[%d].", val);
- SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
- }
+ pAudioContentInfoImpl->SetDuration(intValue);
+ SysLog(NID_CNT, "META: duration[%d]", intValue);
- // duration
- val = video_meta_get_duration(*(pVideoMeta.get()), &intValue);
- SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
- "video_meta_get_duration failed[%d].", val);
+ return E_SUCCESS;
+}
+
+result
+_ContentManagerImpl::MakeVideoContentInfo(const media_info_h pMediaInfo, void* pInfoImpl) const
+{
+ int intValue = 0;
+ video_meta_h pTempMeta = null;
+ unique_ptr<video_meta_h, _VideoMetaDeleter> pVideoMeta(null);
+
+ SysTryReturnResult(NID_CNT, pInfoImpl != null, E_OUT_OF_MEMORY, "pInfoImpl is null.");
+
+ _ContentInfoImpl* pContentInfoImpl = static_cast< _ContentInfoImpl* >(pInfoImpl);
+ SysTryReturnResult(NID_CNT, pContentInfoImpl != null, E_OUT_OF_MEMORY, "Failed to perform static cast for _ContentInfoImpl.");
+
+ pContentInfoImpl->SetContentType(CONTENT_TYPE_VIDEO);
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentInfoImpl->GetContentType());
+
+ int val = media_info_get_video(pMediaInfo, &pTempMeta);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_video failed[%d].", val);
+
+ pVideoMeta.reset(&pTempMeta);
+
+ _VideoContentInfoImpl* pVideoContentInfoImpl = static_cast< _VideoContentInfoImpl* >(pInfoImpl);
+ SysTryReturnResult(NID_CNT, pVideoContentInfoImpl != null, E_OUT_OF_MEMORY, "Failed to perform static cast for _VideoContentInfoImpl.");
+
+ // width
+ val = video_meta_get_width(*(pVideoMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_width failed[%d].", val);
- (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->duration = intValue;
- SysLog(NID_CNT, "META: duration[%d]", intValue);
+ pVideoContentInfoImpl->SetWidth(intValue);
+ SysLog(NID_CNT, "META: width[%d]", intValue);
+
+ // height
+ val = video_meta_get_height(*(pVideoMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_height failed[%d].", val);
+
+ pVideoContentInfoImpl->SetHeight(intValue);
+ SysLog(NID_CNT, "META: height[%d]", intValue);
+
+ char* pTempValue = null;
+ unique_ptr<char, CharDeleter> pStrValue(null);
+
+ // artist
+ val = video_meta_get_artist(*(pVideoMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_artist failed[%d].", val);
+
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
+
+ pVideoContentInfoImpl->SetArtist(String(pStrValue.get()));
+
+ SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
}
- else if (systemType == SYSTEM_TYPE_OTHER)
+
+ // genre
+ val = video_meta_get_genre(*(pVideoMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_genre failed[%d].", val);
+
+ if (pTempValue != null)
{
- pContentData->contentType = CONTENT_TYPE_OTHER;
- SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+ pStrValue.reset(pTempValue);
+
+ pVideoContentInfoImpl->SetGenre(String(pStrValue.get()));
+
+ SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
}
- return r;
+ // title
+ val = video_meta_get_title(*(pVideoMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_title failed[%d].", val);
+
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
+
+ pVideoContentInfoImpl->SetTitle(String(pStrValue.get()));
+
+ SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // albumName
+ val = video_meta_get_album(*(pVideoMeta.get()), &pTempValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_album failed[%d].", val);
+
+ if (pTempValue != null)
+ {
+ pStrValue.reset(pTempValue);
+
+ pVideoContentInfoImpl->SetAlbumName(String(pStrValue.get()));
+
+ SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // duration
+ val = video_meta_get_duration(*(pVideoMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_duration failed[%d].", val);
+
+ pVideoContentInfoImpl->SetDuration(intValue);
+ SysLog(NID_CNT, "META: duration[%d]", intValue);
+
+ // Get some information from metadata extractor when calling VideoContentInfo (framerate, audio bitrate, video bitrate)
+
+ return E_SUCCESS;
}
bool
}
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] %ls is not supported.", contentPath.GetPointer());
+ SysLogException(NID_CNT, E_INVALID_ARG, "[%s] This path is not supported.", GetErrorMessage(E_INVALID_ARG));
return false;
}
}
else
{
// prior to 2.0
- if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
- {
- r = (const_cast<String*>(&contentPath))->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 = (const_cast<String*>(&contentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
- SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
- }
- else
+ if (!(contentPath.StartsWith(OSP_MEDIA_PHONE, 0)) ||
+ (contentPath.StartsWith(OSP_MEDIA_MMC, 0)))
{
- // 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)
{
return __pListener;
}
+result
+_ContentManagerImpl::ConvertErrorToResult(result res) const
+{
+ result r = E_SUCCESS;
+
+ switch (res)
+ {
+ case E_IO:
+ r = E_SYSTEM;
+ break;
+
+ default:
+ r = res;
+ break;
+ }
+ return r;
+}
+
}}