2 // Tizen Web Device API
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.
21 #include <media_content.h>
22 #include <Commons/Regex.h>
23 #include <Commons/StringUtils.h>
24 #include <CommonsJavaScript/Converter.h>
26 #include "ContentManager.h"
27 #include "ContentFilterValidator.h"
28 #include "ContentUtility.h"
31 using namespace WrtDeviceApis::Commons;
38 int MediacontentManager::m_instanceCount = 0;
40 MediacontentManager::MediacontentManager()
42 //protect for pararel execution
43 DPL::Mutex::ScopedLock mx(&m_constructorMutex);
44 if (m_instanceCount == 0)
46 //when it is first instance then connect to media content service.
47 if( MEDIA_CONTENT_ERROR_NONE != media_content_connect())
49 LoggerD("Media Content Service Connect Fail...");
53 //increase counter of instances
57 MediacontentManager::~MediacontentManager()
59 DPL::Mutex::ScopedLock mx(&m_constructorMutex);
60 //decrease counter of instances
62 if (m_instanceCount == 0)
64 //when it is last instance then clse connection to database
65 if ( MEDIA_CONTENT_ERROR_NONE != media_content_disconnect())
67 LoggerD("Media Content Service Disconnect Fail...");
72 tm* MediacontentManager::toDateTm(time_t date)
74 tm *tm_date = (struct tm *)calloc(1, sizeof(struct tm));
76 localtime_r(&date, tm_date);
81 media_content_orientation_e MediacontentManager::convertToOrientation(string orientation)
83 media_content_orientation_e ret = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
85 if ( orientation.compare("NORMAL")==0)
87 ret = MEDIA_CONTENT_ORIENTATION_NORMAL;
89 else if (orientation.compare("FLIP_HORIZONTAL")==0)
91 ret = MEDIA_CONTENT_ORIENTATION_HFLIP;
93 else if (orientation.compare("ROTATE_180")==0)
95 ret = MEDIA_CONTENT_ORIENTATION_ROT_180;
97 else if (orientation.compare("FLIP_VERTICAL")==0)
99 ret = MEDIA_CONTENT_ORIENTATION_VFLIP;
101 else if (orientation.compare("TRANSPOSE")==0)
103 ret = MEDIA_CONTENT_ORIENTATION_TRANSPOSE;
105 else if (orientation.compare("ROTATE_90")==0)
107 ret = MEDIA_CONTENT_ORIENTATION_ROT_90;
109 else if (orientation.compare("TRANSVERSE")==0)
111 ret =MEDIA_CONTENT_ORIENTATION_TRANSVERSE;
113 else if (orientation.compare("ROTATE_270")==0)
115 ret =MEDIA_CONTENT_ORIENTATION_ROT_270;
119 LoggerD("wrong value.");
120 ret = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
126 void MediacontentManager::convertToPlatformFolder(media_folder_h media_folder, MediacontentFolderPtr& newFolder)
130 media_content_storage_e storageType;
132 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_folder_id(media_folder, &tmpStr))
136 newFolder->setFolderUUID(tmpStr);
142 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_path(media_folder, &tmpStr))
146 newFolder->setFolderPath(ContentUtility::convertPathToUri(tmpStr));
152 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_name(media_folder, &tmpStr))
156 newFolder->setFolderName(tmpStr);
162 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_modified_time(media_folder, &date))
164 newFolder->setFolderModifiedDate(toDateTm(date));
167 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_storage_type(media_folder, &storageType))
170 if(storageType == MEDIA_CONTENT_STORAGE_INTERNAL )
174 else if( storageType == MEDIA_CONTENT_STORAGE_EXTERNAL)
182 newFolder->setFolderStorageType(type);
188 void MediacontentManager::readCommonDataFromMediaInfo(media_info_h info, MediacontentMedia* newMedia)
194 unsigned long long tmpLongLong = 0;
197 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_id(info, &tmpStr) )
201 newMedia->setMediaUUID(tmpStr);
207 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_mime_type(info, &tmpStr) )
211 newMedia->setMimeType(tmpStr);
217 if (MEDIA_CONTENT_ERROR_NONE == media_info_get_display_name(info, &tmpStr) )
221 newMedia->setDisplayName(tmpStr);
227 if (MEDIA_CONTENT_ERROR_NONE == media_info_get_title(info, &tmpStr) )
231 newMedia->setTitle(tmpStr);
237 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_file_path(info, &tmpStr) )
241 newMedia->setFilePath(ContentUtility::convertPathToUri(tmpStr));
247 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_thumbnail_path (info, &tmpStr) )
251 newMedia->setThumbnailPath(ContentUtility::convertPathToUri(tmpStr));
257 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_description(info, &tmpStr) )
261 newMedia->setDescription(tmpStr);
267 //newImage->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
268 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_modified_time (info, &tmpDate) )
272 newMedia->setModifiedDate(toDateTm(tmpDate));
276 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_favorite (info, &tmpBool) )
278 newMedia->setFavorite(tmpBool);
281 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_rating (info, &tmpInt) )
283 newMedia->setRating(tmpInt);
286 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_size(info, &tmpLongLong) )
288 newMedia->setSize(tmpLongLong);
293 void MediacontentManager::readImageFromMediaInfo( media_info_h info, MediacontentImage* newImage)
301 newImage->setMediaType("IMAGE");
303 readCommonDataFromMediaInfo(info, newImage);
307 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_image(info, &img))
310 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_date_taken (img, &tmpStr) )
314 struct tm *result = (struct tm *)calloc(1, sizeof(struct tm));
315 if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
316 LoggerE( "Couldn't convert supplied date.");
319 newImage->setReleasedDate(result);
324 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_width(img, &tmpInt) )
326 newImage->setImageWidth(tmpInt);
329 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_height(img, &tmpInt) )
331 newImage->setImageHeight(tmpInt);
334 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_latitude(info, &tmpDouble) )
336 newImage->setImageLatitude(tmpDouble);
339 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_longitude(info, &tmpDouble) )
341 newImage->setImageLongitude(tmpDouble);
344 media_content_orientation_e orientation;
346 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_orientation(img, &orientation) )
349 string orientationStr;
354 orientationStr = "NORMAL";
357 orientationStr = "FLIP_HORIZONTAL";
360 orientationStr = "ROTATE_180";
363 orientationStr = "FLIP_VERTICAL";
366 orientationStr = "TRANSPOSE";
369 orientationStr = "ROTATE_90";
372 orientationStr = "TRANSVERSE";
375 orientationStr = "ROTATE_270";
379 newImage->setImageOrientation(orientationStr);
384 if ( METADATA_EXTRACTOR_ERROR_NONE != image_meta_destroy(img))
386 LoggerD(" image_meta_destroy is fail... ");
391 LoggerD("fetch Image Info failed..");
397 LoggerD("media info is NULL");
401 void MediacontentManager::readVideoFromMediaInfo( media_info_h info, MediacontentVideo* newVideo)
409 newVideo->setMediaType("VIDEO");
411 readCommonDataFromMediaInfo(info, newVideo); //set common media infomation
415 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_video(info, &video))
418 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_recorded_date(video, &tmpStr) )
422 struct tm *result=(struct tm *)calloc(1, sizeof(struct tm));
423 if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
424 LoggerE( "Couldn't convert supplied date.");
426 newVideo->setReleasedDate(result);
433 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_album(video, &tmpStr) )
437 newVideo->setVideoAlbum(tmpStr);
443 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_artist(video, &tmpStr) )
447 std::vector<std::string> artists = String::split(tmpStr, TAG_DELIMETER);
448 for( unsigned int i=0; i < artists.size(); i++)
450 string artist = artists.at(i);
451 newVideo->appendVideoArtist(artist);
460 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_longitude(info, &tmpDouble) )
462 newVideo->setVideoLongitude(tmpDouble);
465 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_latitude(info, &tmpDouble) )
467 newVideo->setVideoLatitude(tmpDouble);
470 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_width(video, &tmpInt) )
472 newVideo->setVideoWidth(tmpInt);
475 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_height(video, &tmpInt) )
477 newVideo->setVideoHeight(tmpInt);
480 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_duration(video, &tmpInt) )
482 newVideo->setVideoDuration(tmpInt);
485 if ( METADATA_EXTRACTOR_ERROR_NONE != video_meta_destroy(video))
487 LoggerD(" video_meta_destroy is fail... ");
493 LoggerD("fetch Video info fail...");
498 LoggerD("media info is NULL");
503 void MediacontentManager::readMusicFromMediaInfo( media_info_h info, MediacontentAudio* newAudio)
507 unsigned long long tmpLongLong = 0;
511 newAudio->setMediaType("AUDIO");
513 readCommonDataFromMediaInfo(info, newAudio); //set common media infomation
517 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_audio(info, &audio))
519 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_recorded_date(audio, &tmpStr) )
523 struct tm *result = (struct tm *)calloc(1, sizeof(struct tm));
524 if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
525 LoggerE( "Couldn't convert supplied date.");
527 newAudio->setReleasedDate(result);
534 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_album(audio, &tmpStr) )
538 newAudio->setAudioAlbum(tmpStr);
544 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_artist(audio, &tmpStr) )
548 std::vector<std::string> artists = String::split(tmpStr, TAG_DELIMETER);
549 for( unsigned int i=0; i < artists.size(); i++)
551 string artist = artists.at(i);
552 newAudio->appendAudioArtist(artist);
560 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_composer(audio, &tmpStr) )
564 std::vector<std::string> composers = String::split(tmpStr, TAG_DELIMETER);
565 for( unsigned int i=0; i < composers.size(); i++)
567 string composer = composers.at(i);
568 newAudio->appendAudioComposer(composer);
576 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_duration(audio, &tmpInt) )
578 newAudio->setAudioDuration(tmpInt);
581 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_copyright(audio, &tmpStr) )
585 newAudio->setAudioCopyright(tmpStr);
591 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_track_num(audio, &tmpStr) )
597 istringstream(tmpStr) >> trackNum;
599 LoggerD("Track Number type is wrong. (track number:" << tmpStr << ")");
602 newAudio->setAudioTrackNum(trackNum);
608 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_size(info, &tmpLongLong) )
610 newAudio->setAudioSize(tmpLongLong);
613 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_bit_rate(audio, &tmpInt) )
615 newAudio->setAudioBitrate(tmpInt);
618 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_genre(audio, &tmpStr) )
622 std::vector<std::string> genres = String::split(tmpStr, TAG_DELIMETER);
624 for( unsigned int i=0; i < genres.size(); i++)
626 string genre = genres.at(i);
627 newAudio->appendAudioGenre(genre);
635 if ( METADATA_EXTRACTOR_ERROR_NONE != audio_meta_destroy(audio))
637 LoggerD(" audio_meta_destroy is fail... ");
644 LoggerD("fetch Music Info fail...");
651 LoggerD("media info is NULL");
658 bool MediacontentManager::mediaFolderCallback(media_folder_h folder, void *user_data)
660 if (user_data != NULL){
661 IEventFindFolder* event = (IEventFindFolder*)user_data;
664 MediacontentFolderPtr newFolder(new MediacontentFolder());
665 convertToPlatformFolder(folder, newFolder);
667 event->addFolder(newFolder);
672 LoggerD("user data is NULL");
678 bool MediacontentManager::mediaItemCallback(media_info_h info, void* user_data)
680 if (user_data != NULL){
681 IEventBrowseFolder* event = (IEventBrowseFolder*)user_data;
683 media_content_type_e type;
685 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_type( info, &type) )
687 if ( type == MEDIA_CONTENT_TYPE_IMAGE)
689 MediacontentImage *newImage(new MediacontentImage());
690 readImageFromMediaInfo(info, newImage);
691 event->addMedia(newImage);
693 else if ( type == MEDIA_CONTENT_TYPE_VIDEO)
695 MediacontentVideo *newVideo(new MediacontentVideo());
696 readVideoFromMediaInfo(info, newVideo);
697 event->addMedia(newVideo);
699 else if ( type == MEDIA_CONTENT_TYPE_MUSIC)
701 MediacontentAudio *newVAudio(new MediacontentAudio());
702 readMusicFromMediaInfo(info, newVAudio);
703 event->addMedia(newVAudio);
705 else if( type == MEDIA_CONTENT_TYPE_OTHERS)
707 MediacontentMedia *newMedia(new MediacontentMedia());
709 newMedia->setMediaType("OTHER");
710 readCommonDataFromMediaInfo(info, newMedia);
711 event->addMedia(newMedia);
718 LoggerD("event is NULL");
724 void MediacontentManager::OnRequestReceived(const IEventFindFolderPtr &eFolder)
726 filter_h filter = NULL;
728 if ( MEDIA_CONTENT_ERROR_NONE == media_filter_create(&filter))
730 string condition="(FOLDER_STORAGE_TYPE = 0 OR FOLDER_STORAGE_TYPE = 1)";
732 media_filter_set_condition(filter, condition.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT ); //set condition
733 if ( MEDIA_CONTENT_ERROR_NONE !=
734 media_folder_foreach_folder_from_db (filter, mediaFolderCallback, eFolder.Get()))
736 LoggerE("A platform error occurs in media_folder_foreach_folder_from_db");
737 eFolder->setResult(false);
740 eFolder->setResult(true);
742 if ( MEDIA_CONTENT_ERROR_NONE != media_filter_destroy(filter))
744 LoggerE("A platform error occurs in media_filter_destroy");
749 void MediacontentManager::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
751 MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
752 visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
756 filter_h filter = NULL;
759 if ( MEDIA_CONTENT_ERROR_NONE == media_filter_create(&filter))
761 string condition = "(MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE = 1)";;
762 if (eBrowse->getFilterIsSet())
764 FilterPtr jsFilter = eBrowse->getFilter();
765 FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
766 bool success = jsFilter->validate(validator);
769 ThrowMsg(PlatformException, "Invalid attirbutes.");
771 IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
772 jsFilter->travel(IVisitor);
773 condition += " AND ";
774 condition += visitor->getResult();
777 //LoggerI("condition:" << condition);
779 media_filter_set_condition(filter, condition.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT ); //set condition
781 if(eBrowse->getSortModesIsSet())
783 media_content_order_e order;
784 SortModePtr attr = eBrowse->getSortMode();
788 string attriName = attr->getAttributeName();
789 attriName = visitor->getPlatformAttr(attriName);
791 if (attriName.compare("") != 0)
793 if (attr->getOrder() == DeviceAPI::Tizen::ASCENDING_SORT_ORDER)
795 order = MEDIA_CONTENT_ORDER_ASC;
799 order = MEDIA_CONTENT_ORDER_DESC;
802 if ( MEDIA_CONTENT_ERROR_NONE !=
803 media_filter_set_order(filter, order, attriName.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT )) //set order
805 LoggerE("A platform error occurs in media_filter_set_order");
812 if (eBrowse->getLimitIsSet() ||eBrowse->getOffsetIsSet() )
817 if ( eBrowse->getLimitIsSet() )
819 count = eBrowse->getLimit();
822 if ( eBrowse->getOffsetIsSet() )
824 offset = eBrowse->getOffset();
827 if ( MEDIA_CONTENT_ERROR_NONE != media_filter_set_offset(filter, offset, count))
829 LoggerE("A platform error occurs in media_filter_set_offset");
835 LoggerE("A platform error occurs in media_filter_create");
836 eBrowse->setResult(false);
839 if ( eBrowse->getFolderIdIsSet())
841 string folderID = eBrowse->getFolderID();
843 if ( MEDIA_CONTENT_ERROR_NONE !=
844 media_folder_foreach_media_from_db (folderID.c_str(), filter, mediaItemCallback, eBrowse.Get()))
846 LoggerE("A platform error occurs in media_folder_foreach_media_from_db");
847 eBrowse->setResult(false);
851 eBrowse->setResult(true);
856 if ( MEDIA_CONTENT_ERROR_NONE !=
857 media_info_foreach_media_from_db (filter, mediaItemCallback, eBrowse.Get()))
859 LoggerE("A platform error occurs in media_info_foreach_media_from_db");
860 eBrowse->setResult(false);
864 eBrowse->setResult(true);
871 if ( MEDIA_CONTENT_ERROR_NONE != media_filter_destroy(filter))
873 LoggerE("A platform error occurs in media_filter_destroy");
877 catch(const Exception &ex)
879 LoggerE("Exception: " << ex.DumpToString());
880 eBrowse->setResult(false);
885 bool MediacontentManager::updateMediaToDB(MediacontentMediaPtr mediaPtr)
887 string type = mediaPtr->getMediaType(); //media type.
888 string mediaId = mediaPtr->getMediaUUID();
890 media_info_h media = NULL;
894 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_from_db(mediaId.c_str(), &media))
896 if ( mediaPtr->isChangedRating())
898 if ( MEDIA_CONTENT_ERROR_NONE
899 != media_info_set_rating(media, mediaPtr->getRating()))
901 LoggerD("Error: set rating");
904 if ( mediaPtr->isChangedDescription() )
906 if ( MEDIA_CONTENT_ERROR_NONE
907 != media_info_set_description (media, mediaPtr->getDescription().c_str()))
909 LoggerD("Error: set description");
912 if( mediaPtr->isChangedDisplayName())
914 if ( MEDIA_CONTENT_ERROR_NONE
915 != media_info_set_display_name (media, mediaPtr->getDisplayName().c_str()))
917 LoggerD("Error: set displayname");
921 if(type.compare("IMAGE") ==0 )
923 MediacontentImagePtr imagePtr = DPL::DynamicPointerCast<MediacontentImage>(mediaPtr);
927 image_meta_h img=NULL;
928 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_image(media, &img))
930 if(imagePtr->isChangedOrientaion())
932 if ( MEDIA_CONTENT_ERROR_NONE !=
933 image_meta_set_orientation (img, convertToOrientation(imagePtr->getImageOrientation())))
935 LoggerD("Error: set orientation");
940 if ( MEDIA_CONTENT_ERROR_NONE !=
941 media_info_set_latitude(media, imagePtr->getImageLatitude())
944 LoggerD("Error: set Latitude");
948 if ( MEDIA_CONTENT_ERROR_NONE !=
949 media_info_set_longitude(media, imagePtr->getImageLongitude())
952 LoggerD("Error: set Longitude");
956 if ( MEDIA_CONTENT_ERROR_NONE != image_meta_update_to_db (img) )
958 LoggerD("Error: update db");
962 if ( MEDIA_CONTENT_ERROR_NONE != image_meta_destroy(img))
964 LoggerD("Error: destroy media info");
973 LoggerD("Error: get Image from DB");
980 if(type.compare("VIDEO") ==0 )
982 MediacontentVideoPtr videoPtr = DPL::DynamicPointerCast<MediacontentVideo>(mediaPtr);
986 video_meta_h video = NULL;
987 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_video(media, &video))
989 if ( MEDIA_CONTENT_ERROR_NONE !=
990 media_info_set_latitude(media, videoPtr->getVideoLatitude())
993 LoggerD("Error: set Latitude");
997 if ( MEDIA_CONTENT_ERROR_NONE !=
998 media_info_set_longitude(media, videoPtr->getVideoLongitude())
1001 LoggerD("Error: set Latitude");
1006 if ( MEDIA_CONTENT_ERROR_NONE != video_meta_update_to_db (video) )
1008 LoggerD("Error: update db");
1012 if ( MEDIA_CONTENT_ERROR_NONE != video_meta_destroy(video))
1014 LoggerD("Error: destroy video meta");
1027 if(type.compare("AUDIO") ==0 )
1030 MediacontentAudioPtr audioPtr = DPL::DynamicPointerCast<MediacontentAudio>(mediaPtr);
1031 if (audioPtr && ( audioPtr->isChangedAudioArtist () || audioPtr->isChangedAudioAlbum()
1032 || audioPtr->isChangedAudioGenre() ||audioPtr->isChangedAudioComposer()
1033 || audioPtr->isChangedAudioTrackNumber()) )
1036 audio_meta_h audio=NULL;
1037 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_audio(media, &audio))
1039 if ( MEDIA_CONTENT_ERROR_NONE != audio_meta_update_to_db (audio) )
1041 LoggerD("Error: update db");
1045 if ( MEDIA_CONTENT_ERROR_NONE != audio_meta_destroy(audio))
1047 LoggerD("Error: destroy audio meta");
1059 if ( MEDIA_CONTENT_ERROR_NONE != media_info_update_to_db(media))
1061 LoggerD("Error: update to DB");
1068 if ( MEDIA_CONTENT_ERROR_NONE !=media_info_destroy(media))
1070 LoggerD("Error: destroy media info");
1078 void MediacontentManager::OnRequestReceived(const IEventUpdateMediaPtr &eMedia)
1082 MediacontentMediaPtr mediaPtr = eMedia->getMediaItem();
1084 if(updateMediaToDB(mediaPtr))
1086 eMedia->setResult(true);
1090 eMedia->setResult(false);
1091 ThrowMsg(PlatformException, "DB operation is failed");
1094 catch (const Exception &ex)
1096 LoggerE("Exception: " << ex.DumpToString());
1097 eMedia->setResult(false);
1102 void MediacontentManager::OnRequestReceived(const IEventUpdateMediaItemsPtr &eItems)
1106 MediacontentMediaListPtr mediaListPtr = eItems->getMediaItems();
1107 if (mediaListPtr->empty())
1109 LoggerD("Item vector is empty");
1113 for(unsigned int i=0; i<mediaListPtr->size(); i++)
1116 MediacontentMediaPtr mediaPtr = mediaListPtr->at(i);
1117 if(updateMediaToDB(mediaPtr))
1119 eItems->setResult(true);
1120 LoggerD("update success");
1124 eItems->setResult(false);
1125 ThrowMsg(PlatformException, "DB operation is failed");
1131 catch (const Exception &ex)
1133 LoggerE("Exception: " << ex.DumpToString());
1134 eItems->setResult(false);