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;
66 // For extern declaration in FCntTypes.h
67 const wchar_t OSP_HOME[] = L"/Home/";
68 const wchar_t OSP_HOME_EXT[] = L"/HomeExt/";
69 const wchar_t OSP_MEDIA_PHONE[] = L"/Media/";
70 const wchar_t OSP_MEDIA_MMC[] = L"/Storagecard/Media/";
73 ConvertError(int error)
79 case MEDIA_CONTENT_ERROR_NONE:
83 case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
87 case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
91 case MEDIA_CONTENT_ERROR_DB_BUSY:
95 case MEDIA_CONTENT_ERROR_DB_FAILED:
108 OnScanCompleted(media_content_error_e error, void* user_data)
110 SysLog(NID_CNT, "OnScanCompleted callback method is called.");
113 result r = E_SUCCESS;
114 String scanPath(L"");
115 IContentScanListener* pListener = null;
117 unique_ptr< ScanResult > pScanResult;
119 SysTryLogCatch(NID_CNT, user_data != null, , "OnScanCompleted failed.");
121 pScanResult = unique_ptr< ScanResult >(static_cast< ScanResult* >(user_data));
123 SysTryLogCatch(NID_CNT, pScanResult != null && pScanResult->pScanPath != null, , "OnScanCompleted failed.");
124 SysTryLogCatch(NID_CNT, pScanResult->pScanListener != null, , "Listener is null. OnScanCompleted succeeded.");
126 scanPath = pScanResult->pScanPath;
127 pListener = pScanResult->pScanListener;
128 reqId = pScanResult->requestId;
130 r = ConvertError(error);
132 pListener->OnContentScanCompleted(reqId, scanPath, r);
133 SysLog(NID_CNT, "OnContentScanCompleted fired.");
136 int val = media_content_disconnect();
137 SysTryLog(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, "The disconnection failed[%d].", val);
141 OnContentUpdateCompleted(media_content_error_e error, int pid, media_content_db_update_item_type_e update_item,
142 media_content_db_update_type_e update_type, media_content_type_e media_type, char* uuid, char* path, char* mime_type, void* user_data)
144 SysLog(NID_CNT, "OnContentUpdateCompleted callback method is called.");
146 result r = E_SUCCESS;
148 SysTryLogReturn(NID_CNT, user_data != null, , "OnContentUpdateCompleted failed.");
150 _ContentManagerImpl* pTempManagerImpl = static_cast< _ContentManagerImpl* >(user_data);
152 IContentUpdateEventListener* pListener = pTempManagerImpl->GetListener();
153 SysTryLogReturn(NID_CNT, pListener != null, , "IContentUpdateEventListener is null.");
155 if (error != MEDIA_CONTENT_ERROR_NONE)
162 case MEDIA_ITEM_FILE:
164 ContentType contentType = CONTENT_TYPE_UNKNOWN;
168 case MEDIA_CONTENT_TYPE_IMAGE:
169 contentType = CONTENT_TYPE_IMAGE;
172 case MEDIA_CONTENT_TYPE_VIDEO:
173 contentType = CONTENT_TYPE_VIDEO;
176 case MEDIA_CONTENT_TYPE_SOUND:
178 case MEDIA_CONTENT_TYPE_MUSIC:
179 contentType = CONTENT_TYPE_AUDIO;
182 case MEDIA_CONTENT_TYPE_OTHERS:
183 contentType = CONTENT_TYPE_OTHER;
188 SysLog(NID_CNT, "media_type is invalid.");
195 result res = UuId::Parse(str, contentId);
196 SysTryLogReturn(NID_CNT, !IsFailed(res), , "Failed to parse to the content ID.");
200 case MEDIA_CONTENT_INSERT:
201 pListener->OnContentFileCreated(contentId, contentType, r);
204 case MEDIA_CONTENT_DELETE:
205 pListener->OnContentFileDeleted(contentId, contentType, r);
208 case MEDIA_CONTENT_UPDATE:
209 pListener->OnContentFileUpdated(contentId, contentType, r);
213 SysLog(NID_CNT, "update_type is invalid.");
218 case MEDIA_ITEM_DIRECTORY:
220 String directoryPath(path);
222 pListener->OnContentDirectoryScanCompleted(directoryPath, r);
227 SysLog(NID_CNT, "update_item is invalid.");
231 SysLog(NID_CNT, "Fire the OnContentUpdateCompleted method.");
234 _ContentManagerImpl::_ContentManagerImpl(void)
236 , __isConnected(false)
242 _ContentManagerImpl::~_ContentManagerImpl(void)
244 int val = media_content_disconnect();
245 SysLog(NID_CNT, "media_content_disconnect result[%d].", val);
247 __isConnected = false;
251 _ContentManagerImpl::GetInstance(ContentManager& contentManager)
253 return contentManager.__pImpl;
256 const _ContentManagerImpl*
257 _ContentManagerImpl::GetInstance(const ContentManager& contentManager)
259 return contentManager.__pImpl;
265 // E_OUT_OF_MEMORY(in public)
268 _ContentManagerImpl::Construct(void)
270 SysAssertf(!__isConnected,
271 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
275 int val = media_content_connect();
276 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM,
277 "The connection failed[%d].", val);
279 SysLog(NID_CNT, "media_content_connect result[%d].", val);
281 __isConnected = true;
293 // E_PRIVILEGE_DENIED(in public)
297 _ContentManagerImpl::CreateContent(const ContentInfo& contentInfo)
299 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
303 // Get common data from ContentInfo class
304 ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
305 SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
306 "[E_INVALID_ARG] pContentData is null.");
308 SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(pContentData->contentPath, true), UuId::GetInvalidUuId(),
309 E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", (pContentData->contentPath).GetPointer());
310 SysTryReturn(NID_CNT, _FileImpl::IsFileExist(pContentData->contentPath), UuId::GetInvalidUuId(), E_FILE_NOT_FOUND,
311 "[E_FILE_NOT_FOUND] The file corresponding to contentInfo could not be found.");
312 SysTryReturn(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), UuId::GetInvalidUuId(),
313 E_INVALID_ARG, "[E_INVALID_ARG] The contentId is not empty.");
315 // Compare the type of input parameter and system
316 ContentType inputType = pContentData->contentType;
317 ContentType sysType = _ContentManagerUtilImpl::CheckContentType(pContentData->contentPath, true);
319 if (inputType != sysType)
321 if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
323 SysLogException(NID_CNT, E_INVALID_ARG,
324 "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
325 return UuId::GetInvalidUuId();
329 // Save data to database with contentPath.
330 unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(pContentData->contentPath));
331 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
332 "[E_OUT_OF_MEMORY] The memory is insufficient.");
334 media_info_h __pMediaInfo = null;
335 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
337 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
338 int val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
339 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
340 "The registration to database failed[%d].", val);
342 pMediaInfo.reset(&__pMediaInfo);
344 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
345 ContentId contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
346 result r = GetLastResult();
347 SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
348 "[%s] The registration to database failed.", GetErrorMessage(r));
353 // There are two steps(insert and update) for content registration.
354 // If the update failed after inserting, the inserted data SHOULD be deleted from here.
355 val = media_info_delete_from_db(pStr.get());
356 SysLog(NID_CNT, "The result of deletion from database[%d].", val);
358 return UuId::GetInvalidUuId();
365 // E_FILE_ALREADY_EXIST
372 // E_PRIVILEGE_DENIED(in public)
375 _ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& destinationPath,
376 const ContentInfo* pContentInfo)
378 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
382 // Check parameters(for length)
383 SysTryReturn(NID_CNT, byteBuffer.GetRemaining() > 0, UuId::GetInvalidUuId(), E_INVALID_ARG,
384 "[E_INVALID_ARG] byteBuffer is invalid.");
386 // Check parameters(for path compatibility)
387 SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
388 E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
389 SysTryReturn(NID_CNT, !_FileImpl::IsFileExist(destinationPath), UuId::GetInvalidUuId(), E_FILE_ALREADY_EXIST,
390 "[E_FILE_ALREADY_EXIST] The specified file already exists.");
392 // Create a file with bytebuffer
393 unique_ptr<File> pFile(new (nothrow) File);
394 SysTryReturn(NID_CNT, pFile != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
395 "[E_OUT_OF_MEMORY] The memory is insufficient.");
397 // 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
398 result r = pFile->Construct(destinationPath, L"w+");
399 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r,
400 "[%s] The destination file can not be created.", GetErrorMessage(r));
402 _FileImpl* pFileImpl = _FileImpl::GetInstance(*pFile);
403 SysTryReturn(NID_CNT, pFileImpl != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
404 "[E_OUT_OF_MEMORY] The memory is insufficient.");
406 // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_STORAGE_FULL, E_IO
407 r = pFileImpl->Write(byteBuffer);
408 SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r,
409 "[%s] The data can not be written in the destination file.", GetErrorMessage(r));
411 // for release file pointer
412 delete pFile.release();
416 ContentInfo::_ContentData contentData;
417 ContentInfo::_ContentData* pContentData = null;
418 media_info_h __pMediaInfo = null;
419 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
420 unique_ptr<char[]> pStr(null);
422 if (pContentInfo != null)
424 pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
425 SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
427 SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
428 "[E_INVALID_ARG] The content already exists in database.");
430 // Compare the type of input parameter and system
431 // CheckContentType() need actual file. so it should be checked after creating the file.
432 ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
433 ContentType inputType = pContentData->contentType;
435 if (inputType != sysType)
437 if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
439 SysLogException(NID_CNT, E_INVALID_ARG,
440 "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
445 // Sets the content path
446 (pContentData->contentPath).Clear();
447 pContentData->contentPath = destinationPath;
451 // Set the content path
452 contentData.contentPath = destinationPath;
454 pContentData = &contentData;
457 // Register the content to database directly.
458 pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
459 SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
461 val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
462 SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
463 "media_info_insert_to_db failed[%d].", val);
465 pMediaInfo.reset(&__pMediaInfo);
467 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
468 contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
470 SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
471 "[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
476 result saveResult = GetLastResult();
478 // If the destination file is made by this method, it should be deleted when error occurs.
479 r = _FileImpl::Remove(destinationPath);
480 SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
482 if (pMediaInfo != null)
484 val = media_info_delete_from_db(pStr.get());
485 SysLog(NID_CNT, "The result of deletion from database[%d].", val);
488 SetLastResult(saveResult);
489 return UuId::GetInvalidUuId();
497 // E_FILE_ALREADY_EXIST
504 // E_PRIVILEGE_DENIED(in public)
507 _ContentManagerImpl::CreateContent(const String& sourcePath, const String& destinationPath, bool deleteSource,
508 const ContentInfo* pContentInfo)
510 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
514 // Check parameters(for type)
515 SysTryReturn(NID_CNT, _FileImpl::GetFileExtension(sourcePath) == _FileImpl::GetFileExtension(destinationPath),
516 UuId::GetInvalidUuId(), E_INVALID_ARG, "[E_INVALID_ARG] There is a mismatch between the type of source and dest path.");
518 // Check parameters(for path compatibility)
519 SysTryReturn(NID_CNT, VerifyHomeFilePathCompatibility(sourcePath), UuId::GetInvalidUuId(), E_INVALID_ARG,
520 "[E_INVALID_ARG] %ls is not compatible.", sourcePath.GetPointer());
521 SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
522 E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
524 result r = E_SUCCESS;
526 if (deleteSource) // move
528 // 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
529 r = _FileImpl::Move(sourcePath, destinationPath);
530 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Moving the file failed.", GetErrorMessage(r));
534 // 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
535 r = _FileImpl::Copy(sourcePath, destinationPath, true);
536 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
541 ContentInfo::_ContentData contentData;
542 ContentInfo::_ContentData* pContentData = null;
543 media_info_h __pMediaInfo = null;
544 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
545 unique_ptr<char[]> pStr(null);
547 if (pContentInfo != null)
549 pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
550 SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
552 SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
553 "[E_INVALID_ARG] The content already exists in database.");
555 // Compare the type of input parameter and system
556 // CheckContentType() need actual file. so it should be checked after creating the file.
557 ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
558 ContentType inputType = pContentData->contentType;
560 if (inputType != sysType)
562 if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
564 SysLogException(NID_CNT, E_INVALID_ARG,
565 "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
570 // Set the content path
571 (pContentData->contentPath).Clear();
572 pContentData->contentPath = destinationPath;
576 // Set the content path
577 contentData.contentPath = destinationPath;
579 pContentData = &contentData;
582 pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
583 SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
585 val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
586 SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
587 "media_info_insert_to_db failed[%d].", val);
589 pMediaInfo.reset(&__pMediaInfo);
591 contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
593 SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
594 "[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
599 result saveResult = GetLastResult();
601 // If the destination file is made by this method, it should be deleted when error occurs.
602 r = _FileImpl::Remove(destinationPath);
603 SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
605 if (pMediaInfo != null)
607 val = media_info_delete_from_db(pStr.get());
608 SysLog(NID_CNT, "The result of deletion from database[%d].", val);
611 SetLastResult(saveResult);
612 return UuId::GetInvalidUuId();
622 // E_PRIVILEGE_DENIED(in public)
625 _ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
627 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
631 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), null, E_INVALID_ARG,
632 "[E_INVALID_ARG] The contentId is invalid.");
634 unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(contentId.ToString()));
635 SysTryReturn(NID_CNT, pStr != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
637 media_info_h __pMediaInfo = null;
638 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
639 int val = media_info_get_media_from_db(pStr.get(), &__pMediaInfo);
640 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
641 "media_info_get_media_from_db failed[%d].", val);
643 pMediaInfo.reset(&__pMediaInfo);
645 media_content_type_e systemType = MEDIA_CONTENT_TYPE_IMAGE;
646 val = media_info_get_media_type(*(pMediaInfo.get()), &systemType);
647 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
648 "media_info_get_media_type failed[%d].", val);
650 char* __pFilePath = null;
651 val = media_info_get_file_path(*(pMediaInfo.get()), &__pFilePath);
652 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
653 "media_info_get_file_path failed[%d].", val);
655 unique_ptr<char, CharDeleter> pFilePath(__pFilePath);
657 SysTryReturn(NID_CNT, _FileImpl::IsFileExist(String(pFilePath.get())), null, E_FILE_NOT_FOUND,
658 "[E_FILE_NOT_FOUND] The file corresponding to contentId could not be found.");
660 result r = E_SUCCESS;
662 if (systemType == SYSTEM_TYPE_IMAGE)
664 unique_ptr<ImageContentInfo> pImageContentInfo(new (nothrow) ImageContentInfo);
665 SysTryReturn(NID_CNT, pImageContentInfo != null, null, E_OUT_OF_MEMORY,
666 "[E_OUT_OF_MEMORY] The memory is insufficient.");
669 ContentInfo::_ContentData* pContentData = pImageContentInfo->GetContentData();
670 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
671 "[E_OUT_OF_MEMORY] The memory is insufficient.");
673 // Get image metadata
674 ImageContentInfo::_ImageContentData* pImageContentData = pImageContentInfo->GetImageContentData();
675 SysTryReturn(NID_CNT, pImageContentData != null, null, E_OUT_OF_MEMORY,
676 "[E_OUT_OF_MEMORY] The memory is insufficient.");
679 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
680 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pImageContentData);
681 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
683 return pImageContentInfo.release();
685 else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
687 unique_ptr<AudioContentInfo> pAudioContentInfo(new (nothrow) AudioContentInfo);
688 SysTryReturn(NID_CNT, pAudioContentInfo != null, null, E_OUT_OF_MEMORY,
689 "[E_OUT_OF_MEMORY] The memory is insufficient.");
691 ContentInfo::_ContentData* pContentData = pAudioContentInfo->GetContentData();
692 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
693 "[E_OUT_OF_MEMORY] The memory is insufficient.");
695 AudioContentInfo::_AudioContentData* pAudioContentData = pAudioContentInfo->GetAudioContentData();
696 SysTryReturn(NID_CNT, pAudioContentData != null, null, E_OUT_OF_MEMORY,
697 "[E_OUT_OF_MEMORY] The memory is insufficient.");
699 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pAudioContentData);
700 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
702 return pAudioContentInfo.release();
704 else if (systemType == SYSTEM_TYPE_VIDEO)
706 unique_ptr<VideoContentInfo> pVideoContentInfo(new (nothrow) VideoContentInfo);
707 SysTryReturn(NID_CNT, pVideoContentInfo != null, null, E_OUT_OF_MEMORY,
708 "[E_OUT_OF_MEMORY] The memory is insufficient.");
710 ContentInfo::_ContentData* pContentData = pVideoContentInfo->GetContentData();
711 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
712 "[E_OUT_OF_MEMORY] The memory is insufficient.");
714 VideoContentInfo::_VideoContentData* pVideoContentData = pVideoContentInfo->GetVideoContentData();
715 SysTryReturn(NID_CNT, pVideoContentData != null, null, E_OUT_OF_MEMORY,
716 "[E_OUT_OF_MEMORY] The memory is insufficient.");
718 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pVideoContentData);
719 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
721 return pVideoContentInfo.release();
723 else if (systemType == SYSTEM_TYPE_OTHER)
725 unique_ptr<OtherContentInfo> pOtherContentInfo(new (nothrow) OtherContentInfo);
726 SysTryReturn(NID_CNT, pOtherContentInfo != null, null, E_OUT_OF_MEMORY,
727 "[E_OUT_OF_MEMORY] The memory is insufficient.");
729 ContentInfo::_ContentData* pContentData = pOtherContentInfo->GetContentData();
730 SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
731 "[E_OUT_OF_MEMORY] The memory is insufficient.");
733 r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, null);
734 SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
736 return pOtherContentInfo.release();
740 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] Unsupported type");
752 // E_PRIVILEGE_DENIED(in public)
755 _ContentManagerImpl::UpdateContent(const ContentInfo& contentInfo)
757 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
761 ContentId contentId = contentInfo.GetContentId();
762 SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The content id is invalid.");
763 SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentInfo.GetContentPath()), E_FILE_NOT_FOUND,
764 "The file corresponding to contentInfo could not be found.");
766 // Get common data from ContentInfo class
767 ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
768 SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
770 // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SYSTEM, E_SERVICE_BUSY
771 result r = this->UpdateDataToDatabase(pContentData);
772 SysTryReturnResult(NID_CNT, !IsFailed(r), r, "UpdateDataToDatabase failed.");
784 // E_PRIVILEGE_DENIED(in public)
785 // - E_ILLEGAL_ACCESS
788 _ContentManagerImpl::DeleteContent(const ContentId& contentId)
790 SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
794 SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The contentId is invalid.");
796 unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN(contentId.ToString()));
797 SysTryReturnResult(NID_CNT, pContentId != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
799 result r = E_SUCCESS;
801 media_info_h __pMediaInfo = null;
802 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
804 val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
805 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
806 "media_info_get_media_from_db failed[%d].", val);
808 pMediaInfo.reset(&__pMediaInfo);
810 char* __pContentPath = null;
812 val = media_info_get_file_path(*(pMediaInfo.get()), &__pContentPath);
813 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
814 "media_info_get_file_path failed[%d].", val);
816 unique_ptr<char, CharDeleter> pContentPath(__pContentPath);
818 String contentPath = String(pContentPath.get());
819 SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentPath), E_FILE_NOT_FOUND,
820 "The file corresponding to contentId could not be found.");
822 val = media_info_delete_from_db(pContentId.get());
823 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
824 "media_info_delete_From_db failed[%d].", val);
826 r = _FileImpl::Remove(contentPath);
827 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The file is not deleted.");
834 // E_OBJ_ALREADY_EXIST
838 _ContentManagerImpl::AddContentUpdateEventListener(IContentUpdateEventListener& listener)
842 SysTryReturnResult(NID_CNT, GetListener() == null, E_OBJ_ALREADY_EXIST, "IContentUpdateEventListener is already set.");
844 SetListener(&listener);
846 int val = media_content_set_db_updated_cb(OnContentUpdateCompleted, this);
847 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "media_content_set_db_updated_cb failed[%d].", val);
858 _ContentManagerImpl::RemoveContentUpdateEventListener(IContentUpdateEventListener& listener)
862 SysTryReturnResult(NID_CNT, GetListener() == &listener, E_OBJ_NOT_FOUND, "The input listener is not equal to the registered listener.");
864 int val = media_content_unset_db_updated_cb();
865 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "media_content_unset_db_updated_cb failed[%d].", val);
877 // E_PRIVILEGE_DENIED(in public)
880 _ContentManagerImpl::ScanFile(const Tizen::Base::String& contentPath)
884 SysLog(NID_CNT, "The scan path is [%ls].", contentPath.GetPointer());
886 unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(contentPath));
887 SysTryReturnResult(NID_CNT, (pContentPath.get())[0] != null, E_SYSTEM, "pContentPath is NULL.");
889 int val = media_content_connect();
890 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val);
892 val = media_content_scan_file(pContentPath.get());
893 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_file failed[%d].", val);
895 val = media_content_disconnect();
896 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The disconnection failed[%d].", val);
906 // E_PRIVILEGE_DENIED(in public)
909 _ContentManagerImpl::ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, IContentScanListener* pListener, RequestId& reqId)
913 SysLog(NID_CNT, "The scan path is [%ls].", directoryPath.GetPointer());
915 unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(directoryPath));
916 SysTryReturnResult(NID_CNT, (pDirPath.get())[0] != null, E_SYSTEM, "pDirPath is NULL.");
918 int val = media_content_connect();
919 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "The connection failed[%d].", val);
921 unique_ptr< ScanResult > pScanResult(new (nothrow) ScanResult);
922 SysTryReturnResult(NID_CNT, pScanResult != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
926 pScanResult->pScanPath = pDirPath.get();
927 pScanResult->pScanListener = pListener;
928 pScanResult->requestId = reqId;
930 val = media_content_scan_folder(pDirPath.release(), recursive, OnScanCompleted, pScanResult.release());
931 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val), "media_content_scan_folder failed[%d].", val);
944 _ContentManagerImpl::UpdateDataToDatabase(const ContentInfo::_ContentData* pContentData) const
948 SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
950 media_info_h __pMediaInfo = null;
951 unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
952 unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN((pContentData->contentId).ToString()));
953 SysTryReturnResult(NID_CNT, pContentId != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
955 int val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
956 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
957 "media_info_get_media_from_db failed[%d].", val);
959 pMediaInfo.reset(&__pMediaInfo);
961 result r = E_SUCCESS;
962 unique_ptr<char[]> pValue(null);
964 if (pContentData->pAuthor != null)
966 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
967 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
969 val = media_info_set_author(*(pMediaInfo.get()), pValue.get());
970 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
971 "media_info_set_author failed[%d].", val);
973 if (pContentData->pCategory != null)
975 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
976 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
978 val = media_info_set_category(*(pMediaInfo.get()), pValue.get());
979 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
980 "media_info_set_category failed[%d].", val);
982 if (pContentData->pContentName != null)
984 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
985 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
987 val = media_info_set_content_name(*(pMediaInfo.get()), pValue.get());
988 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
989 "media_info_set_content_name failed[%d].", val);
991 if (pContentData->pDescription != null)
993 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
994 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
996 val = media_info_set_description(*(pMediaInfo.get()), pValue.get());
997 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
998 "media_info_set_description failed[%d].", val);
1000 if (pContentData->pKeyword != null)
1002 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
1003 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1005 val = media_info_set_keyword(*(pMediaInfo.get()), pValue.get());
1006 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1007 "media_info_set_keyword failed[%d].", val);
1009 if (pContentData->pLocationTag != null)
1011 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
1012 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1014 val = media_info_set_location_tag(*(pMediaInfo.get()), pValue.get());
1015 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1016 "media_info_set_location_tag failed[%d].", val);
1018 if (pContentData->pProvider != null)
1020 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
1021 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1023 val = media_info_set_provider(*(pMediaInfo.get()), pValue.get());
1024 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1025 "media_info_set_provider failed[%d].", val);
1027 if (pContentData->pRating != null)
1029 pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
1030 SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
1032 val = media_info_set_age_rating(*(pMediaInfo.get()), pValue.get());
1033 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1034 "media_info_set_age_rating failed[%d].", val);
1036 if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
1037 Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
1039 val = media_info_set_latitude(*(pMediaInfo.get()), pContentData->latitude);
1040 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1041 "media_info_set_latitude failed[%d].", val);
1043 val = media_info_set_longitude(*(pMediaInfo.get()), pContentData->longitude);
1044 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1045 "media_info_set_longitude failed[%d].", val);
1047 if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
1049 val = media_info_set_altitude(*(pMediaInfo.get()), pContentData->altitude);
1050 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1051 "media_info_set_altitude failed[%d].", val);
1055 val = media_info_update_to_db(*(pMediaInfo.get()));
1056 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1057 "media_info_update_to_db failed[%d].", val);
1070 _ContentManagerImpl::SaveDataToDatabase(const media_info_h pMediaInfo,
1071 ContentInfo::_ContentData* pContentData) const
1075 SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
1076 "[E_INVALID_ARG] pContentData is null.");
1078 // Exception : E_SUCCESS, E_INVALID_ARG
1079 String extension = _FileImpl::GetFileExtension(pContentData->contentPath);
1080 result r = GetLastResult();
1081 SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r, "[%s] Propagating.", GetErrorMessage(r));
1083 // If the content format is JPG and it has GPS data, it will be saved in database automatically.
1084 if (extension == L"jpg" || extension == L"jpeg" || extension == L"JPG" || extension == L"JPEG")
1086 SysLog(NID_CNT, "The format of content is jpg.");
1088 ImageMetadata* pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(pContentData->contentPath, true);
1089 if (pImageMetadata != null)
1091 pContentData->latitude = pImageMetadata->GetLatitude();
1092 pContentData->longitude = pImageMetadata->GetLongitude();
1094 delete pImageMetadata;
1095 pImageMetadata = null;
1100 unique_ptr<char[]> pStr(null);
1102 if (pContentData->pAuthor != null)
1104 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
1105 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1106 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1108 val = media_info_set_author(pMediaInfo, pStr.get());
1109 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1110 "media_info_set_author failed[%d].", val);
1112 if (pContentData->pCategory != null)
1114 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
1115 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1116 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1118 val = media_info_set_category(pMediaInfo, pStr.get());
1119 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1120 "media_info_set_category failed[%d].", val);
1122 if (pContentData->pContentName != null)
1124 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
1125 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1126 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1128 val = media_info_set_content_name(pMediaInfo, pStr.get());
1129 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1130 "media_info_set_content_name failed[%d].", val);
1132 if (pContentData->pDescription != null)
1134 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
1135 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1136 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1138 val = media_info_set_description(pMediaInfo, pStr.get());
1139 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1140 "media_info_set_description failed[%d].", val);
1142 if (pContentData->pKeyword != null)
1144 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
1145 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1146 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1148 val = media_info_set_keyword(pMediaInfo, pStr.get());
1149 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1150 "media_info_set_keyword failed[%d].", val);
1152 if (pContentData->pLocationTag != null)
1154 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
1155 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1156 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1158 val = media_info_set_location_tag(pMediaInfo, pStr.get());
1159 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1160 "media_info_set_location_tag failed[%d].", val);
1162 if (pContentData->pProvider != null)
1164 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
1165 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1166 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1168 val = media_info_set_provider(pMediaInfo, pStr.get());
1169 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1170 "media_info_set_provider failed[%d].", val);
1172 if (pContentData->pRating != null)
1174 pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
1175 SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
1176 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1178 val = media_info_set_age_rating(pMediaInfo, pStr.get());
1179 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1180 "media_info_set_age_rating failed[%d].", val);
1182 if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
1183 Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
1185 val = media_info_set_latitude(pMediaInfo, pContentData->latitude);
1186 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1187 "media_info_set_latitude failed[%d].", val);
1189 val = media_info_set_longitude(pMediaInfo, pContentData->longitude);
1190 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1191 "media_info_set_longitude failed[%d].", val);
1193 if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
1195 val = media_info_set_altitude(pMediaInfo, pContentData->altitude);
1196 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1197 "media_info_set_altitude failed[%d].", val);
1201 val = media_info_update_to_db(pMediaInfo);
1202 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1203 "media_info_update_to_db failed[%d].", val);
1205 char* __pMediaId = null;
1206 unique_ptr<char, CharDeleter> pMediaId(null);
1208 val = media_info_get_media_id(pMediaInfo, &__pMediaId);
1209 if (__pMediaId != null)
1211 pMediaId.reset(__pMediaId);
1215 SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
1216 "media_info_get_media_id failed[%d].", val);
1219 String contentId(pMediaId.get());
1221 r = UuId::Parse(contentId, pContentData->contentId);
1222 SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), E_INVALID_ARG,
1223 "[E_INVALID_ARG] UuId::Parse failed.");
1225 return pContentData->contentId;
1236 _ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData,
1237 int systemType, void* pMetadata) const
1241 if (systemType != SYSTEM_TYPE_OTHER)
1243 SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null && pMetadata != null, E_INVALID_ARG,
1244 "The specified parameter is invalid.");
1246 else // There is no metadata in Other type
1248 SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null, E_INVALID_ARG,
1249 "The specified parameter is invalid.");
1252 result r = E_SUCCESS;
1253 char* __pStrValue = null;
1254 unique_ptr<char, CharDeleter> pStrValue(null);
1257 int val = media_info_get_media_id(pMediaInfo, &__pStrValue);
1258 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1259 "media_info_get_media_id failed[%d].", val);
1261 if (__pStrValue != null)
1263 pStrValue.reset(__pStrValue);
1265 String strContentId(pStrValue.get());
1267 r = UuId::Parse(strContentId, pContentData->contentId);
1268 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content id can not be parsed.");
1270 SysLog(NID_CNT, "INFO: contentId[%ls]", strContentId.GetPointer());
1274 val = media_info_get_file_path(pMediaInfo, &__pStrValue);
1275 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1276 "media_info_get_file_path failed[%d].", val);
1278 if (__pStrValue != null)
1280 pStrValue.reset(__pStrValue);
1282 String strFilePath(pStrValue.get());
1284 // If the api version is 2.0, the content path has to be changed.
1285 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
1287 if (strFilePath.StartsWith(Environment::GetMediaPath(), 0))
1289 r = strFilePath.Replace(Environment::GetMediaPath(), OSP_MEDIA_PHONE);
1290 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content path is not changed.");
1292 else if (strFilePath.StartsWith(Environment::GetExternalStoragePath(), 0))
1294 r = strFilePath.Replace(Environment::GetExternalStoragePath(), OSP_MEDIA_MMC);
1295 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Replace failed.");
1299 SysLogException(NID_CNT, E_INVALID_ARG,
1300 "[E_INVALID_ARG] The content path is not supported[%ls].", strFilePath.GetPointer());
1301 return E_INVALID_ARG;
1305 pContentData->contentPath = strFilePath;
1307 SysLog(NID_CNT, "INFO: contentPath[%ls]", strFilePath.GetPointer());
1311 val = media_info_get_mime_type(pMediaInfo, &__pStrValue);
1312 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1313 "media_info_get_mime_type failed[%d].", val);
1315 if (__pStrValue != null)
1317 pStrValue.reset(__pStrValue);
1319 pContentData->mimeType = pStrValue.get();
1321 SysLog(NID_CNT, "INFO: mimeType[%ls]", (pContentData->mimeType).GetPointer());
1325 unsigned long long longlongValue = 0;
1326 val = media_info_get_size(pMediaInfo, &longlongValue);
1327 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1328 "media_info_get_size failed[%d].", val);
1329 pContentData->contentSize = longlongValue;
1330 SysLog(NID_CNT, "INFO: contentSize[%llu]", longlongValue);
1333 media_content_storage_e storageType;
1334 val = media_info_get_storage_type(pMediaInfo, &storageType);
1335 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1336 "media_info_get_storage_type failed[%d].", val);
1337 pContentData->storageType = storageType;
1338 SysLog(NID_CNT, "INFO: storageType[%d]", storageType);
1341 val = media_info_is_drm(pMediaInfo, &(pContentData->isDrm));
1342 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1343 "media_info_is_drm failed[%d].", val);
1344 SysLog(NID_CNT, "INFO: isDrm[%d]", pContentData->isDrm);
1348 val = media_info_get_added_time(pMediaInfo, &time);
1349 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1350 "media_info_get_added_time failed[%d].", val);
1351 r = (pContentData->dateTime).SetValue(1970, 1, 1);
1352 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "SetValue failed.");
1353 r = (pContentData->dateTime).AddSeconds(time);
1354 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "AddSeconds failed.");
1355 SysLog(NID_CNT, "INFO: dateTime[%ls]", ((pContentData->dateTime).ToString()).GetPointer());
1358 val = media_info_get_thumbnail_path(pMediaInfo, &__pStrValue);
1359 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1360 "media_info_get_thumbnail_path failed[%d].", val);
1362 if (__pStrValue != null)
1364 pStrValue.reset(__pStrValue);
1366 pContentData->pThumbnailPath = new (nothrow) String(pStrValue.get());
1368 SysLog(NID_CNT, "INFO: thumbnailPath[%ls]", (*pContentData->pThumbnailPath).GetPointer());
1372 val = media_info_get_author(pMediaInfo, &__pStrValue);
1373 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1374 "media_info_get_author failed[%d].", val);
1376 if (__pStrValue != null)
1378 pStrValue.reset(__pStrValue);
1380 pContentData->pAuthor = new (nothrow) String(pStrValue.get());
1382 SysLog(NID_CNT, "INFO: author[%ls]", (*pContentData->pAuthor).GetPointer());
1386 val = media_info_get_category(pMediaInfo, &__pStrValue);
1387 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1388 "media_info_get_category failed[%d].", val);
1390 if (__pStrValue != null)
1392 pStrValue.reset(__pStrValue);
1394 pContentData->pCategory = new (nothrow) String(pStrValue.get());
1396 SysLog(NID_CNT, "INFO: category[%ls]", (*pContentData->pCategory).GetPointer());
1400 val = media_info_get_content_name(pMediaInfo, &__pStrValue);
1401 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1402 "media_info_get_content_name failed[%d].", val);
1404 if (__pStrValue != null)
1406 pStrValue.reset(__pStrValue);
1408 pContentData->pContentName = new (nothrow) String(pStrValue.get());
1410 SysLog(NID_CNT, "INFO: contentName[%ls]", (*pContentData->pContentName).GetPointer());
1414 val = media_info_get_description(pMediaInfo, &__pStrValue);
1415 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1416 "media_info_get_description failed[%d].", val);
1418 if (__pStrValue != null)
1420 pStrValue.reset(__pStrValue);
1422 pContentData->pDescription = new (nothrow) String(pStrValue.get());
1424 SysLog(NID_CNT, "INFO: description[%ls]", (*pContentData->pDescription).GetPointer());
1428 val = media_info_get_keyword(pMediaInfo, &__pStrValue);
1429 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1430 "media_info_get_keyword failed[%d].", val);
1432 if (__pStrValue != null)
1434 pStrValue.reset(__pStrValue);
1436 pContentData->pKeyword = new (nothrow) String(pStrValue.get());
1438 SysLog(NID_CNT, "INFO: keyword[%ls]", (*pContentData->pKeyword).GetPointer());
1442 val = media_info_get_location_tag(pMediaInfo, &__pStrValue);
1443 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1444 "media_info_get_location_tag failed[%d].", val);
1446 if (__pStrValue != null)
1448 pStrValue.reset(__pStrValue);
1450 pContentData->pLocationTag = new (nothrow) String(pStrValue.get());
1452 SysLog(NID_CNT, "INFO: locationTag[%ls]", (*pContentData->pLocationTag).GetPointer());
1456 val = media_info_get_provider(pMediaInfo, &__pStrValue);
1457 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1458 "media_info_get_provider failed[%d].", val);
1460 if (__pStrValue != null)
1462 pStrValue.reset(__pStrValue);
1464 pContentData->pProvider = new (nothrow) String(pStrValue.get());
1466 SysLog(NID_CNT, "INFO: provider[%ls]", (*pContentData->pProvider).GetPointer());
1470 val = media_info_get_age_rating(pMediaInfo, &__pStrValue);
1471 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1472 "media_info_get_age_rating failed[%d].", val);
1474 if (__pStrValue != null)
1476 pStrValue.reset(__pStrValue);
1478 pContentData->pRating = new (nothrow) String(pStrValue.get());
1480 SysLog(NID_CNT, "INFO: rating[%ls]", (*pContentData->pRating).GetPointer());
1484 double doubleValue = 0;
1485 val = media_info_get_latitude(pMediaInfo, &doubleValue);
1486 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1487 "media_info_get_latitude failed[%d].", val);
1489 if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
1491 pContentData->latitude = doubleValue;
1493 SysLog(NID_CNT, "INFO: latitude[%f]", pContentData->latitude);
1495 val = media_info_get_longitude(pMediaInfo, &doubleValue);
1496 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1497 "media_info_get_longitude failed[%d].", val);
1499 if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
1501 pContentData->longitude = doubleValue;
1503 SysLog(NID_CNT, "INFO: longitude[%f]", pContentData->longitude);
1505 val = media_info_get_altitude(pMediaInfo, &doubleValue);
1506 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1507 "media_info_get_altitude failed[%d].", val);
1509 if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
1511 pContentData->altitude = doubleValue;
1513 SysLog(NID_CNT, "INFO: altitude[%f]", pContentData->altitude);
1517 // contentType and metadata
1518 if (systemType == SYSTEM_TYPE_IMAGE)
1520 image_meta_h __pImageMeta = null;
1521 unique_ptr<image_meta_h, ImageMetaDeleter> pImageMeta(null);
1523 pContentData->contentType = CONTENT_TYPE_IMAGE;
1524 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1526 val = media_info_get_image(pMediaInfo, &__pImageMeta);
1527 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1528 "media_info_get_image failed[%d].", val);
1530 pImageMeta.reset(&__pImageMeta);
1533 val = image_meta_get_width(*(pImageMeta.get()), &intValue);
1534 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1535 "image_meta_get_width failed[%d].", val);
1537 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->width = intValue;
1538 SysLog(NID_CNT, "META: width[%d]", intValue);
1541 val = image_meta_get_height(*(pImageMeta.get()), &intValue);
1542 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1543 "image_meta_get_height failed[%d].", val);
1545 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->height = intValue;
1546 SysLog(NID_CNT, "META: height[%d]", intValue);
1549 media_content_orientation_e orientation;
1550 val = image_meta_get_orientation(*(pImageMeta.get()), &orientation);
1551 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1552 "image_meta_get_orientation failed[%d].", val);
1554 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->orientationType =
1555 static_cast<ImageOrientationType>(orientation);
1556 SysLog(NID_CNT, "META: orientation[%d]", orientation);
1559 val = media_info_get_display_name(pMediaInfo, &__pStrValue);
1560 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1561 "media_info_get_display_name failed[%d].", val);
1563 if (__pStrValue != null)
1565 pStrValue.reset(__pStrValue);
1569 String strTitle(pStrValue.get());
1571 r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
1574 r = strTitle.SubString(0, pos, fileName);
1575 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The title is invalid.");
1579 // Without extension
1581 fileName = strTitle;
1584 (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->title = fileName;
1586 SysLog(NID_CNT, "META: title[%ls]", fileName.GetPointer());
1589 else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
1591 audio_meta_h __pAudioMeta = null;
1592 unique_ptr<audio_meta_h, AudioMetaDeleter> pAudioMeta(null);
1594 pContentData->contentType = CONTENT_TYPE_AUDIO;
1595 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1597 val = media_info_get_audio(pMediaInfo, &__pAudioMeta);
1598 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1599 "media_info_get_audio failed[%d].", val);
1601 pAudioMeta.reset(&__pAudioMeta);
1604 val = audio_meta_get_bit_rate(*(pAudioMeta.get()), &intValue);
1605 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1606 "audio_meta_get_bit_rate failed[%d].", val);
1608 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->bitrate = intValue;
1609 SysLog(NID_CNT, "META: bitrate[%d]", intValue);
1612 val = audio_meta_get_year(*(pAudioMeta.get()), &__pStrValue);
1613 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1614 "audio_meta_get_year failed[%d].", val);
1616 if (__pStrValue != null)
1618 pStrValue.reset(__pStrValue);
1620 String strYear(pStrValue.get());
1622 if (strYear.CompareTo(L"Unknown") != 0)
1624 r = Integer::Parse(strYear, intValue);
1627 // It is one of the metadata. If error occurs, skip it for other metadata.
1630 SysLog(NID_CNT, "META: releaseYear - invalid data[%ls]", strYear.GetPointer());
1633 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->releaseYear = intValue;
1634 SysLog(NID_CNT, "META: releaseYear[%d]", intValue);
1639 val = audio_meta_get_title(*(pAudioMeta.get()), &__pStrValue);
1640 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1641 "audio_meta_get_title failed[%d].", val);
1643 if (__pStrValue != null)
1645 pStrValue.reset(__pStrValue);
1647 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTitle =
1648 new (nothrow) String(pStrValue.get());
1650 SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
1654 val = audio_meta_get_album(*(pAudioMeta.get()), &__pStrValue);
1655 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1656 "audio_meta_get_album failed[%d].", val);
1658 if (__pStrValue != null)
1660 pStrValue.reset(__pStrValue);
1662 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pAlbumName =
1663 new (nothrow) String(pStrValue.get());
1665 SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
1669 val = audio_meta_get_artist(*(pAudioMeta.get()), &__pStrValue);
1670 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1671 "audio_meta_get_artist failed[%d].", val);
1673 if (__pStrValue != null)
1675 pStrValue.reset(__pStrValue);
1677 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pArtist =
1678 new (nothrow) String(pStrValue.get());
1680 SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
1684 val = audio_meta_get_composer(*(pAudioMeta.get()), &__pStrValue);
1685 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1686 "audio_meta_get_composer failed[%d].", val);
1688 if (__pStrValue != null)
1690 pStrValue.reset(__pStrValue);
1692 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pComposer =
1693 new (nothrow) String(pStrValue.get());
1695 SysLog(NID_CNT, "META: composer[%ls]", (String(pStrValue.get())).GetPointer());
1699 val = audio_meta_get_genre(*(pAudioMeta.get()), &__pStrValue);
1700 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1701 "audio_meta_get_genre failed[%d].", val);
1703 if (__pStrValue != null)
1705 pStrValue.reset(__pStrValue);
1707 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pGenre =
1708 new (nothrow) String(pStrValue.get());
1710 SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
1714 val = audio_meta_get_copyright(*(pAudioMeta.get()), &__pStrValue);
1715 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1716 "audio_meta_get_copyright failed[%d].", val);
1718 if (__pStrValue != null)
1720 pStrValue.reset(__pStrValue);
1722 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pCopyright =
1723 new (nothrow) String(pStrValue.get());
1725 SysLog(NID_CNT, "META: copyright[%ls]", (String(pStrValue.get())).GetPointer());
1729 val = audio_meta_get_track_num(*(pAudioMeta.get()), &__pStrValue);
1730 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1731 "audio_meta_get_track_num failed[%d].", val);
1733 if (__pStrValue != null)
1735 pStrValue.reset(__pStrValue);
1737 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTrackInfo
1738 = new (nothrow) String(pStrValue.get());
1740 SysLog(NID_CNT, "META: trackInfo[%ls]", (String(pStrValue.get())).GetPointer());
1744 val = audio_meta_get_duration(*(pAudioMeta.get()), &intValue);
1745 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1746 "audio_meta_get_duration failed[%d].", val);
1748 (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->duration = intValue;
1749 SysLog(NID_CNT, "META: duration[%d]", intValue);
1752 else if (systemType == MEDIA_CONTENT_TYPE_VIDEO)
1754 video_meta_h __pVideoMeta = null;
1755 unique_ptr<video_meta_h, VideoMetaDeleter> pVideoMeta(null);
1757 pContentData->contentType = CONTENT_TYPE_VIDEO;
1758 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1760 val = media_info_get_video(pMediaInfo, &__pVideoMeta);
1761 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1762 "media_info_get_video failed[%d].", val);
1764 pVideoMeta.reset(&__pVideoMeta);
1767 val = video_meta_get_width(*(pVideoMeta.get()), &intValue);
1768 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1769 "video_meta_get_width failed[%d].", val);
1771 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->width = intValue;
1772 SysLog(NID_CNT, "META: width[%d]", intValue);
1775 val = video_meta_get_height(*(pVideoMeta.get()), &intValue);
1776 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1777 "video_meta_get_height failed[%d].", val);
1779 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->height = intValue;
1780 SysLog(NID_CNT, "META: height[%d]", intValue);
1782 // Get from metadata extractor (framerate, audio bitrate, video bitrate)
1785 val = video_meta_get_artist(*(pVideoMeta.get()), &__pStrValue);
1786 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1787 "video_meta_get_artist failed[%d].", val);
1789 if (__pStrValue != null)
1791 pStrValue.reset(__pStrValue);
1793 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pArtist
1794 = new (nothrow) String(pStrValue.get());
1796 SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
1800 val = video_meta_get_genre(*(pVideoMeta.get()), &__pStrValue);
1801 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1802 "video_meta_get_genre failed[%d].", val);
1804 if (__pStrValue != null)
1806 pStrValue.reset(__pStrValue);
1808 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pGenre
1809 = new (nothrow) String(pStrValue.get());
1811 SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
1815 val = video_meta_get_title(*(pVideoMeta.get()), &__pStrValue);
1816 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1817 "video_meta_get_title failed[%d].", val);
1819 if (__pStrValue != null)
1821 pStrValue.reset(__pStrValue);
1823 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pTitle
1824 = new (nothrow) String(pStrValue.get());
1826 SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
1830 val = video_meta_get_album(*(pVideoMeta.get()), &__pStrValue);
1831 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1832 "video_meta_get_album failed[%d].", val);
1834 if (__pStrValue != null)
1836 pStrValue.reset(__pStrValue);
1838 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pAlbumName
1839 = new (nothrow) String(pStrValue.get());
1841 SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
1845 val = video_meta_get_duration(*(pVideoMeta.get()), &intValue);
1846 SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
1847 "video_meta_get_duration failed[%d].", val);
1849 (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->duration = intValue;
1850 SysLog(NID_CNT, "META: duration[%d]", intValue);
1852 else if (systemType == SYSTEM_TYPE_OTHER)
1854 pContentData->contentType = CONTENT_TYPE_OTHER;
1855 SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
1862 _ContentManagerImpl::VerifyHomeFilePathCompatibility(const String& contentPath) const
1864 if (!_AppInfo::IsOspCompat())
1866 if (contentPath.StartsWith(OSP_HOME, 0) || contentPath.StartsWith(OSP_HOME_EXT, 0))
1868 SysLogException(NID_CNT, E_INVALID_ARG,
1869 "[E_INVALID_ARG] /Home/ or /HomeExt/ is not supported from Tizen 2.0.");
1872 if (!(contentPath.StartsWith(App::App::GetInstance()->GetAppRootPath(), 0) ||
1873 contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
1875 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] %ls is not supported.", contentPath.GetPointer());
1881 SysTryReturn(NID_CNT, contentPath.StartsWith(OSP_HOME, 0) || contentPath.StartsWith(OSP_HOME_EXT, 0),
1882 false, E_INVALID_ARG, "[E_INVALID_ARG] The path should start with /Home or /HomeExt.");
1889 _ContentManagerImpl::VerifyMediaFilePathCompatibility(const String& contentPath, bool checkVersion) const
1893 result r = E_SUCCESS;
1895 if (!_AppInfo::IsOspCompat())
1897 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0) || contentPath.StartsWith(OSP_MEDIA_MMC, 0))
1899 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] /Media or /Storagecard/Media is not supported.");
1902 if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0) ||
1903 contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
1905 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] %ls is not supported.", contentPath.GetPointer());
1912 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
1914 r = (const_cast<String*>(&contentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
1915 SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
1917 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
1919 r = (const_cast<String*>(&contentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
1920 SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
1924 // CreateContent(const ByteBuffer&, ...) and CreateContent (const Sring&, ...) can receive old path like /Media/.
1925 // but CreateContent(const ContentInfo&) always receive new path like /opt/media/ because ContentInfo class convert the path from /Media/ to /opt/media.
1928 SysLogException(NID_CNT, E_INVALID_ARG,
1929 "[E_INVALID_ARG] The path should start with /Home, /Media, or /Storagecard/Media.");
1939 _ContentManagerImpl::SetListener(IContentUpdateEventListener* pListener)
1941 __pListener = pListener;
1944 IContentUpdateEventListener*
1945 _ContentManagerImpl::GetListener(void) const