2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FCnt_ContentManagerImpl.cpp
19 * @brief This is the implementation file for the %_ContentManagerImpl class.
21 * This file contains implementation of the %_ContentManagerImpl class.
25 #include <FBaseSysLog.h>
27 #include <FBaseInteger.h>
28 #include <FBaseByteBuffer.h>
29 #include <FCntContentManager.h>
30 #include <FCntImageContentInfo.h>
31 #include <FCntAudioContentInfo.h>
32 #include <FCntVideoContentInfo.h>
33 #include <FCntOtherContentInfo.h>
34 #include <FCntImageMetadata.h>
35 #include <FCntAudioMetadata.h>
36 #include <FCntVideoMetadata.h>
37 #include <FCntIContentScanListener.h>
38 #include <FCntIContentUpdateEventListener.h>
39 #include <FIoDirectory.h>
40 #include <FSysEnvironment.h>
41 #include <FCnt_ContentManagerImpl.h>
42 #include <FCnt_ContentManagerUtilImpl.h>
43 #include <FBase_StringConverter.h>
44 #include <FIo_FileImpl.h>
45 #include <FApp_AppInfo.h>
47 using namespace Tizen::Base;
48 using namespace Tizen::Base::Collection;
49 using namespace Tizen::Io;
50 using namespace Tizen::App;
51 using namespace Tizen::System;
54 namespace Tizen { namespace Content
57 static RequestId requestId = 0;
59 static const int SYSTEM_TYPE_IMAGE = 0;
60 static const int SYSTEM_TYPE_VIDEO = 1;
61 static const int SYSTEM_TYPE_SOUND = 2;
62 static const int SYSTEM_TYPE_MUSIC = 3;
63 static const int SYSTEM_TYPE_OTHER = 4;
64 static const double DEFAULT_COORDINATE = -200.0;
65 static const int SOURCE_PATH_LENGTH = 200;
67 // For extern declaration in FCntTypes.h
68 const wchar_t OSP_HOME[] = L"/Home/";
69 const wchar_t OSP_HOME_EXT[] = L"/HomeExt/";
70 const wchar_t OSP_MEDIA_PHONE[] = L"/Media/";
71 const wchar_t OSP_MEDIA_MMC[] = L"/Storagecard/Media/";
74 ConvertError(int error)
80 case MEDIA_CONTENT_ERROR_NONE:
84 case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
88 case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
92 case MEDIA_CONTENT_ERROR_DB_BUSY:
96 case MEDIA_CONTENT_ERROR_DB_FAILED:
109 OnScanCompleted(media_content_error_e error, void* user_data)
113 SysLog(NID_CNT, "OnScanCompleted callback method is called.");
115 if (user_data == null)
117 SysLog(NID_CNT, "OnScanCompleted failed.");
121 ScanResult* pScanResult = static_cast< ScanResult* >(user_data);
123 if (pScanResult == null || pScanResult->pScanPath == null || pScanResult->pScanListener == null)
125 SysLog(NID_CNT, "OnScanCompleted failed.");
129 String scanPath(pScanResult->pScanPath);
130 IContentScanListener* pListener = pScanResult->pScanListener;
131 RequestId reqId = pScanResult->requestId;
135 result r = ConvertError(error);
137 pListener->OnContentScanCompleted(reqId, scanPath, r);
139 int val = media_content_disconnect();
140 SysTryLog(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, "The disconnection failed[%d].", val);
142 SysLog(NID_CNT, "Fire the OnContentScanCompleted method.");
146 OnContentUpdateCompleted(media_content_error_e error, int pid, media_content_db_update_item_type_e update_item,
147 media_content_db_update_type_e update_type, media_content_type_e media_type, char* uuid, char* path, char* mime_type, void* user_data)
149 SysLog(NID_CNT, "OnContentUpdateCompleted callback method is called.");
151 result r = E_SUCCESS;
153 SysTryLogReturn(NID_CNT, user_data != null, , "OnContentUpdateCompleted failed.");
155 _ContentManagerImpl* pTempManagerImpl = static_cast< _ContentManagerImpl* >(user_data);
157 IContentUpdateEventListener* pListener = pTempManagerImpl->GetListener();
158 SysTryLogReturn(NID_CNT, pListener != null, , "IContentUpdateEventListener is null.");
160 if (error != MEDIA_CONTENT_ERROR_NONE)
167 case MEDIA_ITEM_FILE:
169 ContentType contentType = CONTENT_TYPE_UNKNOWN;
173 case MEDIA_CONTENT_TYPE_IMAGE:
174 contentType = CONTENT_TYPE_IMAGE;
177 case MEDIA_CONTENT_TYPE_VIDEO:
178 contentType = CONTENT_TYPE_VIDEO;
181 case MEDIA_CONTENT_TYPE_SOUND:
183 case MEDIA_CONTENT_TYPE_MUSIC:
184 contentType = CONTENT_TYPE_AUDIO;
187 case MEDIA_CONTENT_TYPE_OTHERS:
188 contentType = CONTENT_TYPE_OTHER;
193 SysLog(NID_CNT, "media_type is invalid.");
200 result res = UuId::Parse(str, contentId);
201 SysTryLogReturn(NID_CNT, !IsFailed(res), , "Failed to parse to the content ID.");
205 case MEDIA_CONTENT_INSERT:
206 pListener->OnContentFileCreated(contentId, contentType, r);
209 case MEDIA_CONTENT_DELETE:
210 pListener->OnContentFileDeleted(contentId, contentType, r);
213 case MEDIA_CONTENT_UPDATE:
214 pListener->OnContentFileUpdated(contentId, contentType, r);
218 SysLog(NID_CNT, "update_type is invalid.");
223 case MEDIA_ITEM_DIRECTORY:
225 String directoryPath(path);
227 pListener->OnContentDirectoryScanCompleted(directoryPath, r);
232 SysLog(NID_CNT, "update_item is invalid.");
236 SysLog(NID_CNT, "Fire the OnContentUpdateCompleted method.");
239 _ContentManagerImpl::_ContentManagerImpl(void)
241 , __isConnected(false)
247 _ContentManagerImpl::~_ContentManagerImpl(void)
249 int val = media_content_disconnect();
250 SysLog(NID_CNT, "media_content_disconnect result[%d].", val);
252 __isConnected = false;
256 _ContentManagerImpl::GetInstance(ContentManager& contentManager)
258 return contentManager.__pImpl;
261 const _ContentManagerImpl*
262 _ContentManagerImpl::GetInstance(const ContentManager& contentManager)
264 return contentManager.__pImpl;
270 // E_OUT_OF_MEMORY(in public)
273 _ContentManagerImpl::Construct(void)
275 SysAssertf(!__isConnected,
276 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
280 int val = media_content_connect();
281 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM,
282 "The connection failed[%d].", val);
284 __isConnected = true;
296 // E_PRIVILEGE_DENIED(in public)
300 _ContentManagerImpl::CreateContent(const ContentInfo& contentInfo)
302 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
306 // Get common data from ContentInfo class
307 ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
308 SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
309 "[E_INVALID_ARG] pContentData is null.");
311 SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(pContentData->contentPath, true), UuId::GetInvalidUuId(),
312 E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", (pContentData->contentPath).GetPointer());
313 SysTryReturn(NID_CNT, _FileImpl::IsFileExist(pContentData->contentPath), UuId::GetInvalidUuId(), E_FILE_NOT_FOUND,
314 "[E_FILE_NOT_FOUND] The file corresponding to contentInfo could not be found.");
315 SysTryReturn(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), UuId::GetInvalidUuId(),
316 E_INVALID_ARG, "[E_INVALID_ARG] The contentId is not empty.");
318 // Compare the type of input parameter and system
319 ContentType inputType = pContentData->contentType;
320 ContentType sysType = _ContentManagerUtilImpl::CheckContentType(pContentData->contentPath, true);
322 if (inputType != sysType)
324 if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
326 SysLogException(NID_CNT, E_INVALID_ARG,
327 "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
328 return UuId::GetInvalidUuId();
332 // Save data to database with contentPath.
333 unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(pContentData->contentPath));
334 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
335 "[E_OUT_OF_MEMORY] The memory is insufficient.");
337 media_info_h __pMediaInfo = null;
338 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
340 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
341 int val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
342 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
343 "The registration to database failed[%d].", val);
345 pMediaInfo.reset(&__pMediaInfo);
347 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
348 ContentId contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
349 result r = GetLastResult();
350 SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
351 "[%s] The registration to database failed.", GetErrorMessage(r));
356 // There are two steps(insert and update) for content registration.
357 // If the update failed after inserting, the inserted data SHOULD be deleted from here.
358 val = media_info_delete_from_db(pStr.get());
359 SysLog(NID_CNT, "The result of deletion from database[%d].", val);
361 return UuId::GetInvalidUuId();
368 // E_FILE_ALREADY_EXIST
375 // E_PRIVILEGE_DENIED(in public)
378 _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& destinationPath,
379 const ContentInfo* pContentInfo)
381 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
385 // Check parameters(for length)
386 SysTryReturn(NID_CNT, byteBuffer.GetRemaining() > 0, UuId::GetInvalidUuId(), E_INVALID_ARG,
387 "[E_INVALID_ARG] byteBuffer is invalid.");
389 // Check parameters(for path compatibility)
390 SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
391 E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
392 SysTryReturn(NID_CNT, !_FileImpl::IsFileExist(destinationPath), UuId::GetInvalidUuId(), E_FILE_ALREADY_EXIST,
393 "[E_FILE_ALREADY_EXIST] The specified file already exists.");
395 // Create a file with bytebuffer
396 unique_ptr<File> pFile(new (nothrow) File);
397 SysTryReturn(NID_CNT, pFile != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
398 "[E_OUT_OF_MEMORY] The memory is insufficient.");
400 // 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
401 result r = pFile->Construct(destinationPath, L"w+");
402 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r,
403 "[%s] The destination file can not be created.", GetErrorMessage(r));
405 _FileImpl* pFileImpl = _FileImpl::GetInstance(*pFile);
406 SysTryReturn(NID_CNT, pFileImpl != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
407 "[E_OUT_OF_MEMORY] The memory is insufficient.");
409 // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_STORAGE_FULL, E_IO
410 r = pFileImpl->Write(byteBuffer);
411 SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r,
412 "[%s] The data can not be written in the destination file.", GetErrorMessage(r));
414 // for release file pointer
415 delete pFile.release();
419 ContentInfo::_ContentData contentData;
420 ContentInfo::_ContentData* pContentData = null;
421 media_info_h __pMediaInfo = null;
422 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
423 unique_ptr<char[]> pStr(null);
425 if (pContentInfo != null)
427 pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
428 SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
430 SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
431 "[E_INVALID_ARG] The content already exists in database.");
433 // Compare the type of input parameter and system
434 // CheckContentType() need actual file. so it should be checked after creating the file.
435 ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
436 ContentType inputType = pContentData->contentType;
438 if (inputType != sysType)
440 if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
442 SysLogException(NID_CNT, E_INVALID_ARG,
443 "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
448 // Sets the content path
449 (pContentData->contentPath).Clear();
450 pContentData->contentPath = destinationPath;
454 // Set the content path
455 contentData.contentPath = destinationPath;
457 pContentData = &contentData;
460 // Register the content to database directly.
461 pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
462 SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
464 val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
465 SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
466 "media_info_insert_to_db failed[%d].", val);
468 pMediaInfo.reset(&__pMediaInfo);
470 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
471 contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
473 SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
474 "[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
479 result saveResult = GetLastResult();
481 // If the destination file is made by this method, it should be deleted when error occurs.
482 r = _FileImpl::Remove(destinationPath);
483 SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
485 if (pMediaInfo != null)
487 val = media_info_delete_from_db(pStr.get());
488 SysLog(NID_CNT, "The result of deletion from database[%d].", val);
491 SetLastResult(saveResult);
492 return UuId::GetInvalidUuId();
500 // E_FILE_ALREADY_EXIST
507 // E_PRIVILEGE_DENIED(in public)
510 _ContentManagerImpl::CreateContent(const String& sourcePath, const String& destinationPath, bool deleteSource,
511 const ContentInfo* pContentInfo)
513 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
517 // Check parameters(for type)
518 SysTryReturn(NID_CNT, _FileImpl::GetFileExtension(sourcePath) == _FileImpl::GetFileExtension(destinationPath),
519 UuId::GetInvalidUuId(), E_INVALID_ARG, "[E_INVALID_ARG] There is a mismatch between the type of source and dest path.");
521 // Check parameters(for path compatibility)
522 SysTryReturn(NID_CNT, VerifyHomeFilePathCompatibility(sourcePath), UuId::GetInvalidUuId(), E_INVALID_ARG,
523 "[E_INVALID_ARG] %ls is not compatible.", sourcePath.GetPointer());
524 SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
525 E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
527 result r = E_SUCCESS;
529 if (deleteSource) // move
531 // 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
532 r = _FileImpl::Move(sourcePath, destinationPath);
533 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Moving the file failed.", GetErrorMessage(r));
537 // 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
538 r = _FileImpl::Copy(sourcePath, destinationPath, true);
539 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
544 ContentInfo::_ContentData contentData;
545 ContentInfo::_ContentData* pContentData = null;
546 media_info_h __pMediaInfo = null;
547 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
548 unique_ptr<char[]> pStr(null);
550 if (pContentInfo != null)
552 pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
553 SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
555 SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
556 "[E_INVALID_ARG] The content already exists in database.");
558 // Compare the type of input parameter and system
559 // CheckContentType() need actual file. so it should be checked after creating the file.
560 ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
561 ContentType inputType = pContentData->contentType;
563 if (inputType != sysType)
565 if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
567 SysLogException(NID_CNT, E_INVALID_ARG,
568 "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
573 // Set the content path
574 (pContentData->contentPath).Clear();
575 pContentData->contentPath = destinationPath;
579 // Set the content path
580 contentData.contentPath = destinationPath;
582 pContentData = &contentData;
585 pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
586 SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
588 val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
589 SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
590 "media_info_insert_to_db failed[%d].", val);
592 pMediaInfo.reset(&__pMediaInfo);
594 contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
596 SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
597 "[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
602 result saveResult = GetLastResult();
604 // If the destination file is made by this method, it should be deleted when error occurs.
605 r = _FileImpl::Remove(destinationPath);
606 SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
608 if (pMediaInfo != null)
610 val = media_info_delete_from_db(pStr.get());
611 SysLog(NID_CNT, "The result of deletion from database[%d].", val);
614 SetLastResult(saveResult);
615 return UuId::GetInvalidUuId();
625 // E_PRIVILEGE_DENIED(in public)
628 _ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
630 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
634 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), null, E_INVALID_ARG,
635 "[E_INVALID_ARG] The contentId is invalid.");
637 unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(contentId.ToString()));
638 SysTryReturn(NID_CNT, pStr != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
640 media_info_h __pMediaInfo = null;
641 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
642 int val = media_info_get_media_from_db(pStr.get(), &__pMediaInfo);
643 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
644 "media_info_get_media_from_db failed[%d].", val);
646 pMediaInfo.reset(&__pMediaInfo);
648 media_content_type_e systemType = MEDIA_CONTENT_TYPE_IMAGE;
649 val = media_info_get_media_type(*(pMediaInfo.get()), &systemType);
650 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
651 "media_info_get_media_type failed[%d].", val);
653 char* __pFilePath = null;
654 val = media_info_get_file_path(*(pMediaInfo.get()), &__pFilePath);
655 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
656 "media_info_get_file_path failed[%d].", val);
658 unique_ptr<char, CharDeleter> pFilePath(__pFilePath);
660 SysTryReturn(NID_CNT, _FileImpl::IsFileExist(String(pFilePath.get())), null, E_FILE_NOT_FOUND,
661 "[E_FILE_NOT_FOUND] The file corresponding to contentId could not be found.");
663 result r = E_SUCCESS;
665 if (systemType == SYSTEM_TYPE_IMAGE)
667 unique_ptr<ImageContentInfo> pImageContentInfo(new (nothrow) ImageContentInfo);
668 SysTryReturn(NID_CNT, pImageContentInfo != null, null, E_OUT_OF_MEMORY,
669 "[E_OUT_OF_MEMORY] The memory is insufficient.");
672 ContentInfo::_ContentData* pContentData = pImageContentInfo->GetContentData();
673 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
674 "[E_OUT_OF_MEMORY] The memory is insufficient.");
676 // Get image metadata
677 ImageContentInfo::_ImageContentData* pImageContentData = pImageContentInfo->GetImageContentData();
678 SysTryReturn(NID_CNT, pImageContentData != null, null, E_OUT_OF_MEMORY,
679 "[E_OUT_OF_MEMORY] The memory is insufficient.");
682 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
683 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pImageContentData);
684 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
686 return pImageContentInfo.release();
688 else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
690 unique_ptr<AudioContentInfo> pAudioContentInfo(new (nothrow) AudioContentInfo);
691 SysTryReturn(NID_CNT, pAudioContentInfo != null, null, E_OUT_OF_MEMORY,
692 "[E_OUT_OF_MEMORY] The memory is insufficient.");
694 ContentInfo::_ContentData* pContentData = pAudioContentInfo->GetContentData();
695 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
696 "[E_OUT_OF_MEMORY] The memory is insufficient.");
698 AudioContentInfo::_AudioContentData* pAudioContentData = pAudioContentInfo->GetAudioContentData();
699 SysTryReturn(NID_CNT, pAudioContentData != null, null, E_OUT_OF_MEMORY,
700 "[E_OUT_OF_MEMORY] The memory is insufficient.");
702 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pAudioContentData);
703 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
705 return pAudioContentInfo.release();
707 else if (systemType == SYSTEM_TYPE_VIDEO)
709 unique_ptr<VideoContentInfo> pVideoContentInfo(new (nothrow) VideoContentInfo);
710 SysTryReturn(NID_CNT, pVideoContentInfo != null, null, E_OUT_OF_MEMORY,
711 "[E_OUT_OF_MEMORY] The memory is insufficient.");
713 ContentInfo::_ContentData* pContentData = pVideoContentInfo->GetContentData();
714 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
715 "[E_OUT_OF_MEMORY] The memory is insufficient.");
717 VideoContentInfo::_VideoContentData* pVideoContentData = pVideoContentInfo->GetVideoContentData();
718 SysTryReturn(NID_CNT, pVideoContentData != null, null, E_OUT_OF_MEMORY,
719 "[E_OUT_OF_MEMORY] The memory is insufficient.");
721 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pVideoContentData);
722 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
724 return pVideoContentInfo.release();
726 else if (systemType == SYSTEM_TYPE_OTHER)
728 unique_ptr<OtherContentInfo> pOtherContentInfo(new (nothrow) OtherContentInfo);
729 SysTryReturn(NID_CNT, pOtherContentInfo != null, null, E_OUT_OF_MEMORY,
730 "[E_OUT_OF_MEMORY] The memory is insufficient.");
732 ContentInfo::_ContentData* pContentData = pOtherContentInfo->GetContentData();
733 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
734 "[E_OUT_OF_MEMORY] The memory is insufficient.");
736 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, null);
737 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
739 return pOtherContentInfo.release();
743 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] Unsupported type");
755 // E_PRIVILEGE_DENIED(in public)
758 _ContentManagerImpl::UpdateContent(const ContentInfo& contentInfo)
760 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
764 ContentId contentId = contentInfo.GetContentId();
765 SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The content id is invalid.");
766 SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentInfo.GetContentPath()), E_FILE_NOT_FOUND,
767 "The file corresponding to contentInfo could not be found.");
769 // Get common data from ContentInfo class
770 ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
771 SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
773 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SYSTEM, E_SERVICE_BUSY
774 result r = this->UpdateDataToDatabase(pContentData);
775 SysTryReturnResult(NID_CNT, !IsFailed(r), r, "UpdateDataToDatabase failed.");
787 // E_PRIVILEGE_DENIED(in public)
788 // - E_ILLEGAL_ACCESS
791 _ContentManagerImpl::DeleteContent(const ContentId& contentId)
793 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
797 SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The contentId is invalid.");
799 unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN(contentId.ToString()));
800 SysTryReturnResult(NID_CNT, pContentId != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
802 result r = E_SUCCESS;
804 media_info_h __pMediaInfo = null;
805 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
807 val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
808 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
809 "media_info_get_media_from_db failed[%d].", val);
811 pMediaInfo.reset(&__pMediaInfo);
813 char* __pContentPath = null;
815 val = media_info_get_file_path(*(pMediaInfo.get()), &__pContentPath);
816 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
817 "media_info_get_file_path failed[%d].", val);
819 unique_ptr<char, CharDeleter> pContentPath(__pContentPath);
821 String contentPath = String(pContentPath.get());
822 SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentPath), E_FILE_NOT_FOUND,
823 "The file corresponding to contentId could not be found.");
825 val = media_info_delete_from_db(pContentId.get());
826 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
827 "media_info_delete_From_db failed[%d].", val);
829 r = _FileImpl::Remove(contentPath);
830 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The file is not deleted.");
837 // E_OBJ_ALREADY_EXIST
841 _ContentManagerImpl::AddContentUpdateEventListener(IContentUpdateEventListener& listener)
845 SysTryReturnResult(NID_CNT, GetListener() == null, E_OBJ_ALREADY_EXIST, "IContentUpdateEventListener is already set.");
847 SetListener(&listener);
849 int val = media_content_set_db_updated_cb(OnContentUpdateCompleted, this);
850 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "media_content_set_db_updated_cb failed[%d].", val);
861 _ContentManagerImpl::RemoveContentUpdateEventListener(IContentUpdateEventListener& listener)
865 SysTryReturnResult(NID_CNT, GetListener() == &listener, E_OBJ_NOT_FOUND, "The input listener is not equal to the registered listener.");
867 int val = media_content_unset_db_updated_cb();
868 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "media_content_unset_db_updated_cb failed[%d].", val);
880 // E_PRIVILEGE_DENIED(in public)
883 _ContentManagerImpl::ScanFile(const Tizen::Base::String& contentPath)
887 SysLog(NID_CNT, "The scan path is [%ls].", contentPath.GetPointer());
889 unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(contentPath));
890 SysTryReturnResult(NID_CNT, (pContentPath.get())[0] != null, E_SYSTEM, "pContentPath is NULL.");
892 int val = media_content_connect();
893 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val);
895 val = media_content_scan_file(pContentPath.get());
896 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_file failed[%d].", val);
898 val = media_content_disconnect();
899 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The disconnection failed[%d].", val);
909 // E_PRIVILEGE_DENIED(in public)
912 _ContentManagerImpl::ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId)
916 SysLog(NID_CNT, "The scan path is [%ls].", directoryPath.GetPointer());
918 SysTryReturnResult(NID_CNT, pListener != null, E_INVALID_ARG, "Failed to ScanDirectory method.");
920 unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(directoryPath));
921 SysTryReturnResult(NID_CNT, (pDirPath.get())[0] != null, E_SYSTEM, "pDirPath is NULL.");
923 int val = media_content_connect();
924 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val);
926 ScanResult* pScanResult = new (nothrow) ScanResult;
927 SysTryReturnResult(NID_CNT, pScanResult != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
931 pScanResult->pScanPath = pDirPath.get();
932 pScanResult->pScanListener = pListener;
933 pScanResult->requestId = reqId;
935 val = media_content_scan_folder(pDirPath.release(), recursive, OnScanCompleted, pScanResult);
936 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_folder failed[%d].", val);
949 _ContentManagerImpl::UpdateDataToDatabase(const ContentInfo::_ContentData* pContentData) const
953 SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
955 media_info_h __pMediaInfo = null;
956 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
957 unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN((pContentData->contentId).ToString()));
958 SysTryReturnResult(NID_CNT, pContentId != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
960 int val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
961 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
962 "media_info_get_media_from_db failed[%d].", val);
964 pMediaInfo.reset(&__pMediaInfo);
966 result r = E_SUCCESS;
967 unique_ptr<char[]> pValue(null);
969 if (pContentData->pAuthor != null)
971 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
972 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
974 val = media_info_set_author(*(pMediaInfo.get()), pValue.get());
975 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
976 "media_info_set_author failed[%d].", val);
978 if (pContentData->pCategory != null)
980 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
981 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
983 val = media_info_set_category(*(pMediaInfo.get()), pValue.get());
984 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
985 "media_info_set_category failed[%d].", val);
987 if (pContentData->pContentName != null)
989 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
990 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
992 val = media_info_set_content_name(*(pMediaInfo.get()), pValue.get());
993 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
994 "media_info_set_content_name failed[%d].", val);
996 if (pContentData->pDescription != null)
998 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
999 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1001 val = media_info_set_description(*(pMediaInfo.get()), pValue.get());
1002 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1003 "media_info_set_description failed[%d].", val);
1005 if (pContentData->pKeyword != null)
1007 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
1008 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1010 val = media_info_set_keyword(*(pMediaInfo.get()), pValue.get());
1011 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1012 "media_info_set_keyword failed[%d].", val);
1014 if (pContentData->pLocationTag != null)
1016 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
1017 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1019 val = media_info_set_location_tag(*(pMediaInfo.get()), pValue.get());
1020 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1021 "media_info_set_location_tag failed[%d].", val);
1023 if (pContentData->pProvider != null)
1025 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
1026 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1028 val = media_info_set_provider(*(pMediaInfo.get()), pValue.get());
1029 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1030 "media_info_set_provider failed[%d].", val);
1032 if (pContentData->pRating != null)
1034 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
1035 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1037 val = media_info_set_age_rating(*(pMediaInfo.get()), pValue.get());
1038 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1039 "media_info_set_age_rating failed[%d].", val);
1041 if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
1042 Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
1044 val = media_info_set_latitude(*(pMediaInfo.get()), pContentData->latitude);
1045 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1046 "media_info_set_latitude failed[%d].", val);
1048 val = media_info_set_longitude(*(pMediaInfo.get()), pContentData->longitude);
1049 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1050 "media_info_set_longitude failed[%d].", val);
1052 if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
1054 val = media_info_set_altitude(*(pMediaInfo.get()), pContentData->altitude);
1055 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1056 "media_info_set_altitude failed[%d].", val);
1060 val = media_info_update_to_db(*(pMediaInfo.get()));
1061 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1062 "media_info_update_to_db failed[%d].", val);
1075 _ContentManagerImpl::SaveDataToDatabase(const media_info_h pMediaInfo,
1076 ContentInfo::_ContentData* pContentData) const
1080 SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
1081 "[E_INVALID_ARG] pContentData is null.");
1083 // Exception : E_SUCCESS, E_INVALID_ARG
1084 String extension = _FileImpl::GetFileExtension(pContentData->contentPath);
1085 result r = GetLastResult();
1086 SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r, "[%s] Propagating.", GetErrorMessage(r));
1088 // If the content format is JPG and it has GPS data, it will be saved in database automatically.
1089 if (extension == L"jpg" || extension == L"jpeg" || extension == L"JPG" || extension == L"JPEG")
1091 SysLog(NID_CNT, "The format of content is jpg.");
1093 ImageMetadata* pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(pContentData->contentPath, true);
1094 if (pImageMetadata != null)
1096 pContentData->latitude = pImageMetadata->GetLatitude();
1097 pContentData->longitude = pImageMetadata->GetLongitude();
1099 delete pImageMetadata;
1100 pImageMetadata = null;
1105 unique_ptr<char[]> pStr(null);
1107 if (pContentData->pAuthor != null)
1109 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
1110 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1111 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1113 val = media_info_set_author(pMediaInfo, pStr.get());
1114 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1115 "media_info_set_author failed[%d].", val);
1117 if (pContentData->pCategory != null)
1119 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
1120 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1121 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1123 val = media_info_set_category(pMediaInfo, pStr.get());
1124 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1125 "media_info_set_category failed[%d].", val);
1127 if (pContentData->pContentName != null)
1129 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
1130 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1131 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1133 val = media_info_set_content_name(pMediaInfo, pStr.get());
1134 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1135 "media_info_set_content_name failed[%d].", val);
1137 if (pContentData->pDescription != null)
1139 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
1140 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1141 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1143 val = media_info_set_description(pMediaInfo, pStr.get());
1144 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1145 "media_info_set_description failed[%d].", val);
1147 if (pContentData->pKeyword != null)
1149 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
1150 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1151 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1153 val = media_info_set_keyword(pMediaInfo, pStr.get());
1154 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1155 "media_info_set_keyword failed[%d].", val);
1157 if (pContentData->pLocationTag != null)
1159 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
1160 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1161 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1163 val = media_info_set_location_tag(pMediaInfo, pStr.get());
1164 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1165 "media_info_set_location_tag failed[%d].", val);
1167 if (pContentData->pProvider != null)
1169 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
1170 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1171 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1173 val = media_info_set_provider(pMediaInfo, pStr.get());
1174 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1175 "media_info_set_provider failed[%d].", val);
1177 if (pContentData->pRating != null)
1179 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
1180 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1181 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1183 val = media_info_set_age_rating(pMediaInfo, pStr.get());
1184 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1185 "media_info_set_age_rating failed[%d].", val);
1187 if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
1188 Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
1190 val = media_info_set_latitude(pMediaInfo, pContentData->latitude);
1191 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1192 "media_info_set_latitude failed[%d].", val);
1194 val = media_info_set_longitude(pMediaInfo, pContentData->longitude);
1195 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1196 "media_info_set_longitude failed[%d].", val);
1198 if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
1200 val = media_info_set_altitude(pMediaInfo, pContentData->altitude);
1201 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1202 "media_info_set_altitude failed[%d].", val);
1206 val = media_info_update_to_db(pMediaInfo);
1207 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1208 "media_info_update_to_db failed[%d].", val);
1210 char* __pMediaId = null;
1211 unique_ptr<char, CharDeleter> pMediaId(null);
1213 val = media_info_get_media_id(pMediaInfo, &__pMediaId);
1214 if (__pMediaId != null)
1216 pMediaId.reset(__pMediaId);
1220 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1221 "media_info_get_media_id failed[%d].", val);
1224 String contentId(pMediaId.get());
1226 r = UuId::Parse(contentId, pContentData->contentId);
1227 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), E_INVALID_ARG,
1228 "[E_INVALID_ARG] UuId::Parse failed.");
1230 return pContentData->contentId;
1241 _ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData,
1242 int systemType, void* pMetadata) const
1246 if (systemType != SYSTEM_TYPE_OTHER)
1248 SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null && pMetadata != null, E_INVALID_ARG,
1249 "The specified parameter is invalid.");
1251 else // There is no metadata in Other type
1253 SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null, E_INVALID_ARG,
1254 "The specified parameter is invalid.");
1257 result r = E_SUCCESS;
1258 char* __pStrValue = null;
1259 unique_ptr<char, CharDeleter> pStrValue(null);
1262 int val = media_info_get_media_id(pMediaInfo, &__pStrValue);
1263 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1264 "media_info_get_media_id failed[%d].", val);
1266 if (__pStrValue != null)
1268 pStrValue.reset(__pStrValue);
1270 String strContentId(pStrValue.get());
1272 r = UuId::Parse(strContentId, pContentData->contentId);
1273 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content id can not be parsed.");
1275 SysLog(NID_CNT, "INFO: contentId[%ls]", strContentId.GetPointer());
1279 val = media_info_get_file_path(pMediaInfo, &__pStrValue);
1280 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1281 "media_info_get_file_path failed[%d].", val);
1283 if (__pStrValue != null)
1285 pStrValue.reset(__pStrValue);
1287 String strFilePath(pStrValue.get());
1289 // If the api version is 2.0, the content path has to be changed.
1290 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
1292 if (strFilePath.StartsWith(Environment::GetMediaPath(), 0))
1294 r = strFilePath.Replace(Environment::GetMediaPath(), OSP_MEDIA_PHONE);
1295 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content path is not changed.");
1297 else if (strFilePath.StartsWith(Environment::GetExternalStoragePath(), 0))
1299 r = strFilePath.Replace(Environment::GetExternalStoragePath(), OSP_MEDIA_MMC);
1300 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Replace failed.");
1304 SysLogException(NID_CNT, E_INVALID_ARG,
1305 "[E_INVALID_ARG] The content path is not supported[%ls].", strFilePath.GetPointer());
1306 return E_INVALID_ARG;
1310 pContentData->contentPath = strFilePath;
1312 SysLog(NID_CNT, "INFO: contentPath[%ls]", strFilePath.GetPointer());
1316 val = media_info_get_mime_type(pMediaInfo, &__pStrValue);
1317 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1318 "media_info_get_mime_type failed[%d].", val);
1320 if (__pStrValue != null)
1322 pStrValue.reset(__pStrValue);
1324 pContentData->mimeType = pStrValue.get();
1326 SysLog(NID_CNT, "INFO: mimeType[%ls]", (pContentData->mimeType).GetPointer());
1330 unsigned long long longlongValue = 0;
1331 val = media_info_get_size(pMediaInfo, &longlongValue);
1332 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1333 "media_info_get_size failed[%d].", val);
1334 pContentData->contentSize = longlongValue;
1335 SysLog(NID_CNT, "INFO: contentSize[%llu]", longlongValue);
1338 media_content_storage_e storageType;
1339 val = media_info_get_storage_type(pMediaInfo, &storageType);
1340 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1341 "media_info_get_storage_type failed[%d].", val);
1342 pContentData->storageType = storageType;
1343 SysLog(NID_CNT, "INFO: storageType[%d]", storageType);
1346 val = media_info_is_drm(pMediaInfo, &(pContentData->isDrm));
1347 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1348 "media_info_is_drm failed[%d].", val);
1349 SysLog(NID_CNT, "INFO: isDrm[%d]", pContentData->isDrm);
1353 val = media_info_get_added_time(pMediaInfo, &time);
1354 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1355 "media_info_get_added_time failed[%d].", val);
1356 r = (pContentData->dateTime).SetValue(1970, 1, 1);
1357 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "SetValue failed.");
1358 r = (pContentData->dateTime).AddSeconds(time);
1359 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "AddSeconds failed.");
1360 SysLog(NID_CNT, "INFO: dateTime[%ls]", ((pContentData->dateTime).ToString()).GetPointer());
1363 val = media_info_get_thumbnail_path(pMediaInfo, &__pStrValue);
1364 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1365 "media_info_get_thumbnail_path failed[%d].", val);
1367 if (__pStrValue != null)
1369 pStrValue.reset(__pStrValue);
1371 pContentData->pThumbnailPath = new (nothrow) String(pStrValue.get());
1373 SysLog(NID_CNT, "INFO: thumbnailPath[%ls]", (*pContentData->pThumbnailPath).GetPointer());
1377 val = media_info_get_author(pMediaInfo, &__pStrValue);
1378 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1379 "media_info_get_author failed[%d].", val);
1381 if (__pStrValue != null)
1383 pStrValue.reset(__pStrValue);
1385 pContentData->pAuthor = new (nothrow) String(pStrValue.get());
1387 SysLog(NID_CNT, "INFO: author[%ls]", (*pContentData->pAuthor).GetPointer());
1391 val = media_info_get_category(pMediaInfo, &__pStrValue);
1392 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1393 "media_info_get_category failed[%d].", val);
1395 if (__pStrValue != null)
1397 pStrValue.reset(__pStrValue);
1399 pContentData->pCategory = new (nothrow) String(pStrValue.get());
1401 SysLog(NID_CNT, "INFO: category[%ls]", (*pContentData->pCategory).GetPointer());
1405 val = media_info_get_content_name(pMediaInfo, &__pStrValue);
1406 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1407 "media_info_get_content_name failed[%d].", val);
1409 if (__pStrValue != null)
1411 pStrValue.reset(__pStrValue);
1413 pContentData->pContentName = new (nothrow) String(pStrValue.get());
1415 SysLog(NID_CNT, "INFO: contentName[%ls]", (*pContentData->pContentName).GetPointer());
1419 val = media_info_get_description(pMediaInfo, &__pStrValue);
1420 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1421 "media_info_get_description failed[%d].", val);
1423 if (__pStrValue != null)
1425 pStrValue.reset(__pStrValue);
1427 pContentData->pDescription = new (nothrow) String(pStrValue.get());
1429 SysLog(NID_CNT, "INFO: description[%ls]", (*pContentData->pDescription).GetPointer());
1433 val = media_info_get_keyword(pMediaInfo, &__pStrValue);
1434 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1435 "media_info_get_keyword failed[%d].", val);
1437 if (__pStrValue != null)
1439 pStrValue.reset(__pStrValue);
1441 pContentData->pKeyword = new (nothrow) String(pStrValue.get());
1443 SysLog(NID_CNT, "INFO: keyword[%ls]", (*pContentData->pKeyword).GetPointer());
1447 val = media_info_get_location_tag(pMediaInfo, &__pStrValue);
1448 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1449 "media_info_get_location_tag failed[%d].", val);
1451 if (__pStrValue != null)
1453 pStrValue.reset(__pStrValue);
1455 pContentData->pLocationTag = new (nothrow) String(pStrValue.get());
1457 SysLog(NID_CNT, "INFO: locationTag[%ls]", (*pContentData->pLocationTag).GetPointer());
1461 val = media_info_get_provider(pMediaInfo, &__pStrValue);
1462 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1463 "media_info_get_provider failed[%d].", val);
1465 if (__pStrValue != null)
1467 pStrValue.reset(__pStrValue);
1469 pContentData->pProvider = new (nothrow) String(pStrValue.get());
1471 SysLog(NID_CNT, "INFO: provider[%ls]", (*pContentData->pProvider).GetPointer());
1475 val = media_info_get_age_rating(pMediaInfo, &__pStrValue);
1476 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1477 "media_info_get_age_rating failed[%d].", val);
1479 if (__pStrValue != null)
1481 pStrValue.reset(__pStrValue);
1483 pContentData->pRating = new (nothrow) String(pStrValue.get());
1485 SysLog(NID_CNT, "INFO: rating[%ls]", (*pContentData->pRating).GetPointer());
1489 double doubleValue = 0;
1490 val = media_info_get_latitude(pMediaInfo, &doubleValue);
1491 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1492 "media_info_get_latitude failed[%d].", val);
1494 if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
1496 pContentData->latitude = doubleValue;
1498 SysLog(NID_CNT, "INFO: latitude[%f]", pContentData->latitude);
1500 val = media_info_get_longitude(pMediaInfo, &doubleValue);
1501 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1502 "media_info_get_longitude failed[%d].", val);
1504 if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
1506 pContentData->longitude = doubleValue;
1508 SysLog(NID_CNT, "INFO: longitude[%f]", pContentData->longitude);
1510 val = media_info_get_altitude(pMediaInfo, &doubleValue);
1511 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1512 "media_info_get_altitude failed[%d].", val);
1514 if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
1516 pContentData->altitude = doubleValue;
1518 SysLog(NID_CNT, "INFO: altitude[%f]", pContentData->altitude);
1522 // contentType and metadata
1523 if (systemType == SYSTEM_TYPE_IMAGE)
1525 image_meta_h __pImageMeta = null;
1526 unique_ptr<image_meta_h, ImageMetaDeleter> pImageMeta(null);
1528 pContentData->contentType = CONTENT_TYPE_IMAGE;
1529 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1531 val = media_info_get_image(pMediaInfo, &__pImageMeta);
1532 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1533 "media_info_get_image failed[%d].", val);
1535 pImageMeta.reset(&__pImageMeta);
1538 val = image_meta_get_width(*(pImageMeta.get()), &intValue);
1539 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1540 "image_meta_get_width failed[%d].", val);
1542 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->width = intValue;
1543 SysLog(NID_CNT, "META: width[%d]", intValue);
1546 val = image_meta_get_height(*(pImageMeta.get()), &intValue);
1547 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1548 "image_meta_get_height failed[%d].", val);
1550 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->height = intValue;
1551 SysLog(NID_CNT, "META: height[%d]", intValue);
1554 media_content_orientation_e orientation;
1555 val = image_meta_get_orientation(*(pImageMeta.get()), &orientation);
1556 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1557 "image_meta_get_orientation failed[%d].", val);
1559 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->orientationType =
1560 static_cast<ImageOrientationType>(orientation);
1561 SysLog(NID_CNT, "META: orientation[%d]", orientation);
1564 val = media_info_get_display_name(pMediaInfo, &__pStrValue);
1565 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1566 "media_info_get_display_name failed[%d].", val);
1568 if (__pStrValue != null)
1570 pStrValue.reset(__pStrValue);
1574 String strTitle(pStrValue.get());
1576 r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
1579 r = strTitle.SubString(0, pos, fileName);
1580 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The title is invalid.");
1584 // Without extension
1586 fileName = strTitle;
1589 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->title = fileName;
1591 SysLog(NID_CNT, "META: title[%ls]", fileName.GetPointer());
1594 else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
1596 audio_meta_h __pAudioMeta = null;
1597 unique_ptr<audio_meta_h, AudioMetaDeleter> pAudioMeta(null);
1599 pContentData->contentType = CONTENT_TYPE_AUDIO;
1600 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1602 val = media_info_get_audio(pMediaInfo, &__pAudioMeta);
1603 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1604 "media_info_get_audio failed[%d].", val);
1606 pAudioMeta.reset(&__pAudioMeta);
1609 val = audio_meta_get_bit_rate(*(pAudioMeta.get()), &intValue);
1610 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1611 "audio_meta_get_bit_rate failed[%d].", val);
1613 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->bitrate = intValue;
1614 SysLog(NID_CNT, "META: bitrate[%d]", intValue);
1617 val = audio_meta_get_year(*(pAudioMeta.get()), &__pStrValue);
1618 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1619 "audio_meta_get_year failed[%d].", val);
1621 if (__pStrValue != null)
1623 pStrValue.reset(__pStrValue);
1625 String strYear(pStrValue.get());
1627 if (strYear.CompareTo(L"Unknown") != 0)
1629 r = Integer::Parse(strYear, intValue);
1632 // It is one of the metadata. If error occurs, skip it for other metadata.
1635 SysLog(NID_CNT, "META: releaseYear - invalid data[%ls]", strYear.GetPointer());
1638 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->releaseYear = intValue;
1639 SysLog(NID_CNT, "META: releaseYear[%d]", intValue);
1644 val = audio_meta_get_title(*(pAudioMeta.get()), &__pStrValue);
1645 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1646 "audio_meta_get_title failed[%d].", val);
1648 if (__pStrValue != null)
1650 pStrValue.reset(__pStrValue);
1652 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTitle =
1653 new (nothrow) String(pStrValue.get());
1655 SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
1659 val = audio_meta_get_album(*(pAudioMeta.get()), &__pStrValue);
1660 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1661 "audio_meta_get_album failed[%d].", val);
1663 if (__pStrValue != null)
1665 pStrValue.reset(__pStrValue);
1667 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pAlbumName =
1668 new (nothrow) String(pStrValue.get());
1670 SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
1674 val = audio_meta_get_artist(*(pAudioMeta.get()), &__pStrValue);
1675 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1676 "audio_meta_get_artist failed[%d].", val);
1678 if (__pStrValue != null)
1680 pStrValue.reset(__pStrValue);
1682 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pArtist =
1683 new (nothrow) String(pStrValue.get());
1685 SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
1689 val = audio_meta_get_composer(*(pAudioMeta.get()), &__pStrValue);
1690 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1691 "audio_meta_get_composer failed[%d].", val);
1693 if (__pStrValue != null)
1695 pStrValue.reset(__pStrValue);
1697 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pComposer =
1698 new (nothrow) String(pStrValue.get());
1700 SysLog(NID_CNT, "META: composer[%ls]", (String(pStrValue.get())).GetPointer());
1704 val = audio_meta_get_genre(*(pAudioMeta.get()), &__pStrValue);
1705 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1706 "audio_meta_get_genre failed[%d].", val);
1708 if (__pStrValue != null)
1710 pStrValue.reset(__pStrValue);
1712 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pGenre =
1713 new (nothrow) String(pStrValue.get());
1715 SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
1719 val = audio_meta_get_copyright(*(pAudioMeta.get()), &__pStrValue);
1720 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1721 "audio_meta_get_copyright failed[%d].", val);
1723 if (__pStrValue != null)
1725 pStrValue.reset(__pStrValue);
1727 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pCopyright =
1728 new (nothrow) String(pStrValue.get());
1730 SysLog(NID_CNT, "META: copyright[%ls]", (String(pStrValue.get())).GetPointer());
1734 val = audio_meta_get_track_num(*(pAudioMeta.get()), &__pStrValue);
1735 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1736 "audio_meta_get_track_num failed[%d].", val);
1738 if (__pStrValue != null)
1740 pStrValue.reset(__pStrValue);
1742 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTrackInfo
1743 = new (nothrow) String(pStrValue.get());
1745 SysLog(NID_CNT, "META: trackInfo[%ls]", (String(pStrValue.get())).GetPointer());
1749 val = audio_meta_get_duration(*(pAudioMeta.get()), &intValue);
1750 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1751 "audio_meta_get_duration failed[%d].", val);
1753 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->duration = intValue;
1754 SysLog(NID_CNT, "META: duration[%d]", intValue);
1757 else if (systemType == MEDIA_CONTENT_TYPE_VIDEO)
1759 video_meta_h __pVideoMeta = null;
1760 unique_ptr<video_meta_h, VideoMetaDeleter> pVideoMeta(null);
1762 pContentData->contentType = CONTENT_TYPE_VIDEO;
1763 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1765 val = media_info_get_video(pMediaInfo, &__pVideoMeta);
1766 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1767 "media_info_get_video failed[%d].", val);
1769 pVideoMeta.reset(&__pVideoMeta);
1772 val = video_meta_get_width(*(pVideoMeta.get()), &intValue);
1773 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1774 "video_meta_get_width failed[%d].", val);
1776 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->width = intValue;
1777 SysLog(NID_CNT, "META: width[%d]", intValue);
1780 val = video_meta_get_height(*(pVideoMeta.get()), &intValue);
1781 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1782 "video_meta_get_height failed[%d].", val);
1784 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->height = intValue;
1785 SysLog(NID_CNT, "META: height[%d]", intValue);
1787 // Get from metadata extractor (framerate, audio bitrate, video bitrate)
1790 val = video_meta_get_artist(*(pVideoMeta.get()), &__pStrValue);
1791 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1792 "video_meta_get_artist failed[%d].", val);
1794 if (__pStrValue != null)
1796 pStrValue.reset(__pStrValue);
1798 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pArtist
1799 = new (nothrow) String(pStrValue.get());
1801 SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
1805 val = video_meta_get_genre(*(pVideoMeta.get()), &__pStrValue);
1806 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1807 "video_meta_get_genre failed[%d].", val);
1809 if (__pStrValue != null)
1811 pStrValue.reset(__pStrValue);
1813 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pGenre
1814 = new (nothrow) String(pStrValue.get());
1816 SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
1820 val = video_meta_get_title(*(pVideoMeta.get()), &__pStrValue);
1821 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1822 "video_meta_get_title failed[%d].", val);
1824 if (__pStrValue != null)
1826 pStrValue.reset(__pStrValue);
1828 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pTitle
1829 = new (nothrow) String(pStrValue.get());
1831 SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
1835 val = video_meta_get_album(*(pVideoMeta.get()), &__pStrValue);
1836 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1837 "video_meta_get_album failed[%d].", val);
1839 if (__pStrValue != null)
1841 pStrValue.reset(__pStrValue);
1843 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pAlbumName
1844 = new (nothrow) String(pStrValue.get());
1846 SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
1850 val = video_meta_get_duration(*(pVideoMeta.get()), &intValue);
1851 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1852 "video_meta_get_duration failed[%d].", val);
1854 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->duration = intValue;
1855 SysLog(NID_CNT, "META: duration[%d]", intValue);
1857 else if (systemType == SYSTEM_TYPE_OTHER)
1859 pContentData->contentType = CONTENT_TYPE_OTHER;
1860 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1867 _ContentManagerImpl::VerifyHomeFilePathCompatibility(const String& contentPath) const
1869 if (!_AppInfo::IsOspCompat())
1871 if (contentPath.StartsWith(OSP_HOME, 0) || contentPath.StartsWith(OSP_HOME_EXT, 0))
1873 SysLogException(NID_CNT, E_INVALID_ARG,
1874 "[E_INVALID_ARG] /Home/ or /HomeExt/ is not supported from Tizen 2.0.");
1877 if (!(contentPath.StartsWith(App::App::GetInstance()->GetAppRootPath(), 0) ||
1878 contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
1880 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] %ls is not supported.", contentPath.GetPointer());
1886 SysTryReturn(NID_CNT, contentPath.StartsWith(OSP_HOME, 0) || contentPath.StartsWith(OSP_HOME_EXT, 0),
1887 false, E_INVALID_ARG, "[E_INVALID_ARG] The path should start with /Home or /HomeExt.");
1894 _ContentManagerImpl::VerifyMediaFilePathCompatibility(const String& contentPath, bool checkVersion) const
1898 result r = E_SUCCESS;
1900 if (!_AppInfo::IsOspCompat())
1902 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0) || contentPath.StartsWith(OSP_MEDIA_MMC, 0))
1904 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] /Media or /Storagecard/Media is not supported.");
1907 if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0) ||
1908 contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
1910 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] %ls is not supported.", contentPath.GetPointer());
1917 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
1919 r = (const_cast<String*>(&contentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
1920 SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
1922 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
1924 r = (const_cast<String*>(&contentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
1925 SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
1929 // CreateContent(const ByteBuffer&, ...) and CreateContent (const Sring&, ...) can receive old path like /Media/.
1930 // but CreateContent(const ContentInfo&) always receive new path like /opt/media/ because ContentInfo class convert the path from /Media/ to /opt/media.
1933 SysLogException(NID_CNT, E_INVALID_ARG,
1934 "[E_INVALID_ARG] The path should start with /Home, /Media, or /Storagecard/Media.");
1944 _ContentManagerImpl::SetListener(IContentUpdateEventListener* pListener)
1946 __pListener = pListener;
1949 IContentUpdateEventListener*
1950 _ContentManagerImpl::GetListener(void) const