Fix build breaks in contact
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Mediacontent / Mediacontent.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 3795c4f..0e145fe
 #include "Mediacontent.h"
 #include "MediacontentManager.h"
 #include "MediaFilterValidator.h"
-#include "MediaSearchVisitor.h"
-
-#include <mm_file.h>
-#include <mm_error.h>
-
+#include <Commons/StringUtils.h>
 
+#include <time.h>
 
 using namespace TizenApis::Api::Mediacontent;
 using namespace WrtDeviceApis::Commons;
 
 #define MEDIA_DEBUG 0
-
-const string SELECT_FOLDER_QUERY = 
-       "select folder_uuid, path, title, storage_type,modified_date from (select folder_uuid, path, folder_name as title, storage_type,modified_date from visual_folder where valid=1 union select folder_uuid, path, folder_name as title, storage_type,modified_date from audio_folder) where 1  ";
-
-const string VIEW_MEDIA_QUERY_WITH_FOLDER =
-       "select visual_uuid, folder_uuid, content_type, display_name, path, thumbnail_path,created_date, released_date, modified_date, description,rating, album, artist, last_played_time, played_count,longitude, latitude, width, height, orientation, genre, author, duration,size from \
-       (select visual_uuid,folder_uuid, content_type, display_name, path, thumbnail_path,null as created_date, released_date, modified_date, description,rating, album, artist, last_played_time, null as played_count,longitude, latitude, width, height, orientation,null as genre, null as author, duration,size from visual_media join \
-               (select * from \
-                       (select visual_uuid as meta_uuid, longitude, latitude, description, width, height, datetaken as released_date, orientation,null as album, null as artist, null as last_played_time,null as duration from image_meta \
-                       union all \
-                       select visual_uuid as meta_uuid, longitude, latitude, description, width, height, datetaken as released_date, null as orientation, album, artist, last_played_time,duration from video_meta)) \
-       on visual_uuid=meta_uuid \
-       union all \
-               select audio_uuid, folder_uuid as folder_uuid, content_type, title as display_name, path, thumbnail_path, added_time, year, modified_date, description, favourite, album, artist, last_played_time, played_count, null as longitude, null as latitude, null as width, null as height, null as orientation, genre, author, duration, size from audio_media) where 1 ";
-
-const string SELECT_MEDIA_ID_WITH_FOLDER = 
-       "select item_id from item_view where folder_uuid=";
-const string SELECT_EXTRA_AUDIO = 
-       "select copyright,bitrate,track_num,size from audio_media where audio_uuid=";
-
+#define TAG_DELIMETER '/'  //After reviewing the ID3v2.3 spec the delimiter is a "/" for multiple entries.
 
 namespace TizenApis {
 namespace Platform {
@@ -58,870 +36,1279 @@ namespace Mediacontent{
 
 Mediacontent::Mediacontent()
 {
-    LogDebug("entered");
-
-//     int ret;
-
-       db_connnect_count++;
-
-       db_util_open(MEDIA_DB_PATH, &hDBCt, 0);
-       LogDebug("hDBCt:" << hDBCt);            
+   LogDebug("entered");        
 }
 
 Mediacontent::~Mediacontent()
 {
-    LogDebug("entered");
-       int ret;
-       db_connnect_count--;
-       if(db_connnect_count == 0)
-       {
-               ret = db_util_close(hDBCt);
-               if(ret != SQLITE_OK)
-                       ret = -1;
-               else
-                       hDBCt = NULL;
-       }
+   LogDebug("entered");
 }
 
 tm Mediacontent::toDateTm(time_t date)
 {
        tm tm_date;
-       
-       tm_date.tm_year = (date / 10000) - 1900;
-       tm_date.tm_mon = ((date - ((tm_date.tm_year + 1900) * 10000)) / 100) - 1;
-       tm_date.tm_mday = (date - ((tm_date.tm_year + 1900) * 10000) - tm_date.tm_mon * 100);
 
-       return tm_date;
-}      
+       localtime_r(&date, &tm_date);
 
+       return tm_date;
+}
 
-void Mediacontent::convertToPlatformFolder(folder_s &media_folder, MediacontentFolderPtr& newFolder)
+media_content_orientation_e Mediacontent::convertToOrientation(string orientation)
 {
-       if(media_folder.folder_uuid != NULL)
+       media_content_orientation_e ret = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
+
+       if ( orientation.compare("NORMAL")==0)
        {
-               newFolder->setFolderUUID(media_folder.folder_uuid);
+               ret = MEDIA_CONTENT_ORIENTATION_NORMAL;
        }
-       if(media_folder.folder_path != NULL)
+       else if (orientation.compare("FLIP_HORIZONTAL")==0)
        {
-               newFolder->setFolderName(media_folder.folder_name);
+               ret = MEDIA_CONTENT_ORIENTATION_HFLIP;
        }
-       if(media_folder.folder_name != NULL)
+       else if (orientation.compare("ROTATE_180")==0)
        {
-               newFolder->setFolderPath(media_folder.folder_path);
+               ret = MEDIA_CONTENT_ORIENTATION_ROT_180;
        }
-
-       newFolder->setFolderModifiedDate(toDateTm(media_folder.modified_date));
-
-       string storageType;
-       
-       if(media_folder.storage_type == 0)
+       else if (orientation.compare("FLIP_VERTICAL")==0)
+       {
+               ret = MEDIA_CONTENT_ORIENTATION_VFLIP;
+       }
+       else if (orientation.compare("TRANSPOSE")==0)
+       {
+               ret = MEDIA_CONTENT_ORIENTATION_TRANSPOSE;
+       }
+       else if (orientation.compare("ROTATE_90")==0)
        {
-               storageType = "INTERNAL";
+               ret = MEDIA_CONTENT_ORIENTATION_ROT_90;
        }
-       else if( media_folder.storage_type == 1)
+       else if (orientation.compare("TRANSVERSE")==0)
        {
-               storageType = "EXTERNAL";
+               ret =MEDIA_CONTENT_ORIENTATION_TRANSVERSE;
        }
+       else if (orientation.compare("ROTATE_270")==0)
+       {
+               ret =MEDIA_CONTENT_ORIENTATION_ROT_270;
+       }       
        else
        {
-               storageType = "UNKNOWN";
+               LogDebug("wrong value.");
+               ret = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
        }
-       newFolder->setFolderStorageType(storageType);
-}
-
 
+       return ret;
+}
 
-string Mediacontent::makeQuerySortMode(SortModeArrayPtr attr)
+void Mediacontent::convertToPlatformFolder(media_folder_h media_folder, MediacontentFolderPtr& newFolder)
 {
-       string query("");
-       string attriName;
-       int cnt = 0;
-       SortModeArray::iterator it = attr->begin();
-       
-       for (;it!=attr->end(); ++it) 
+       char* tmpStr = NULL;
+       time_t date;
+       media_content_storage_e storageType;
+
+       if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_folder_id(media_folder, &tmpStr))
        {
-               attriName = (*it)->getAttributeName();
-               //convert to attribue's name
-               MediaSearchVisitor visitor;
-               attriName = visitor.getPlatformAttr(attriName);
-               if (attriName.compare("") != 0) 
-               { 
-                       if (cnt == 0) 
-                       {
-                               query.append(" ORDER BY ");
-                       } else 
-                       {
-                               query.append(", ");
-                       }
-                       query.append(attriName);
+               if ( tmpStr )
+               {
+                       LogDebug("Folder UUID : " << tmpStr);
+                       newFolder->setFolderUUID(tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
+               }
+       }
 
-                       if ((*it)->getOrder() == Api::Tizen::ASCENDING_SORT_ORDER) 
-                       {
-                               query.append(" ASC");
-                       } 
-                       else 
-                       {
-                               query.append(" DESC");
-                       }
-                       cnt++;
+       if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_path(media_folder, &tmpStr))
+       {
+               if ( tmpStr )
+               {               
+                       LogDebug("Folder path : " << tmpStr);
+                       newFolder->setFolderPath(tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
                }
        }
 
-       return query;
+       if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_name(media_folder, &tmpStr))
+       {
+               if ( tmpStr )
+               {               
+                       LogDebug("Folder name : " << tmpStr);
+                       newFolder->setFolderName(tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;  
+               }
+       }
+       
+       if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_modified_time(media_folder, &date))
+       {
+               LogDebug("get Modified Time ");
+               newFolder->setFolderModifiedDate(toDateTm(date));
+       }
+       
+       if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_storage_type(media_folder, &storageType))
+       {       
+               LogDebug("storage Type=" << storageType);
+               string type;
+               if(storageType == MEDIA_CONTENT_STORAGE_INTERNAL )
+               {
+                       type = "INTERNAL";
+               }
+               else if( storageType == MEDIA_CONTENT_STORAGE_EXTERNAL)
+               {
+                       type = "EXTERNAL";
+               }
+               else
+               {
+                       type = "UNKNOWN";
+               }
+               newFolder->setFolderStorageType(type);
+       }
+               
+               
 }
 
+void Mediacontent::readCommonDataFromMediaInfo(media_info_h info, MediacontentMedia* newMedia)
+{      
 
+       char* tmpStr = NULL;
+       time_t tmpDate;
+       int tmpInt = 0;
+       unsigned long long tmpLongLong = 0;
+       bool tmpBool= false;
 
-void Mediacontent::OnRequestReceived(const IEventFindFolderPtr &eFolder)
-{
-    LogDebug("entered");
-
-       string projection;
-       string sortMode;
-       string limitOffset;
-       string condition;
-       string query(SELECT_FOLDER_QUERY);
-
-       //set condition
-       MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
+       LogDebug("enter Common Data type : " << newMedia->getMediaType());
        
-       if(eFolder->getFilterIsSet())
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_id(info, &tmpStr) )
        {
-               FilterPtr filter = eFolder->getFilter();
-/*
-               FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_FOLDER);
-               bool success = filter->validate(validator);
-
-               if(!success)
-                       ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
-*/
-               IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
-
-               visitor->setQueryType(MediaSearchVisitor::QUERY_FOLDER);
-               filter->travel(IVisitor);
-               condition = visitor->getResult();
-
-               query.append(" and ");
-               query.append(condition);
+               if (tmpStr)
+               {
+                       newMedia->setMediaUUID(tmpStr);
+                       LogDebug("UUID : " << tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
+               }
        }
 
-       if(eFolder->getSortModesIsSet()) 
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_mime_type(info, &tmpStr) )
        {
-               sortMode = makeQuerySortMode(eFolder->getSortModes());  
-
-               query.append(sortMode);
-       }
-       
-       //set limit/offset
-       if (eFolder->getLimitIsSet()) 
-       {
-               limitOffset.append(" LIMIT ");
-               std::stringstream limitStream;
-               limitStream << eFolder->getLimit();
-               limitOffset.append(limitStream.str());
-               if(eFolder->getOffsetIsSet()) 
+               if (tmpStr)
                {
-                       limitOffset.append(" OFFSET ");
-                       std::stringstream offsetStream;
-                       offsetStream << eFolder->getOffset();
-                       limitOffset.append(offsetStream.str());
+                       newMedia->setMimeType(tmpStr);
+                       LogDebug("MineType : " << tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
                }
-
-               query.append(limitOffset);
        }
-       LogDebug("execute condition [" << condition << "]");
-       LogDebug("execute projection [" << projection << "]");
-       LogDebug("execute sortMode [" << sortMode << "]");
-       LogDebug("execute limitOffset [" << limitOffset << "]");        
-       LogDebug("execute query [" << query << "]");    
 
-       try
+       if ( newMedia->getMediaType().compare("IMAGE") == 0 
+               && MEDIA_CONTENT_ERROR_NONE == media_info_get_display_name(info, &tmpStr) )
        {
-               sqlite3_stmt* pStmt = NULL;
-               folder_s media_folder;
-               sqlite3_prepare_v2(hDBCt, (char *)(query.c_str()), strlen((char *)(query.c_str())), &pStmt, NULL);
-               while( sqlite3_step(pStmt) == SQLITE_ROW)
+               if (tmpStr)
                {
-                       media_folder.folder_uuid = (char *)sqlite3_column_text(pStmt, 0);
-                       media_folder.folder_path = (char *)sqlite3_column_text(pStmt, 1);
-                       media_folder.folder_name = (char *)sqlite3_column_text(pStmt, 2);
-                       media_folder.storage_type = sqlite3_column_int(pStmt, 3);
-                       media_folder.modified_date = sqlite3_column_int(pStmt, 4);      
-
-                       MediacontentFolderPtr newFolder(new MediacontentFolder());
-                       convertToPlatformFolder(media_folder, newFolder);
-
-                       eFolder->addFolder(newFolder);
+                       newMedia->setDisplayName(tmpStr);
+                       LogDebug("Display Name : " << tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
                }
-               sqlite3_finalize(pStmt);
-               eFolder->setResult(true);
-
        }
-       catch (const Exception &ex)
+
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_file_path(info, &tmpStr) )
        {
-               LogError("Exception: " << ex.DumpToString());
-               eFolder->setResult(false);
+               if (tmpStr)
+               {
+                       newMedia->setFilePath(tmpStr);
+                       LogDebug("Path : " << tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
+               }
        }
-       eFolder->setCancelAllowed(true);
-}
-
-
-void Mediacontent::OnRequestReceived(const IEventFindMediaPtr &eMedia)
-{
-    LogDebug("OnRequestReceived::IEventFindMediaPtr entered");
-
-       string projection;
-       string sortMode;
-       string limitOffset;
-       string condition;
-       
-       string query(VIEW_MEDIA_QUERY_WITH_FOLDER);
 
-       MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_thumbnail_path (info, &tmpStr) )
+       {
+               if (tmpStr)
+               {
+                       newMedia->setThumbnailPath(tmpStr);
+                       LogDebug("Thumnail Path : " << tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
+               }
+       }
        
-       if(eMedia->getFilterIsSet())
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_description(info, &tmpStr) )
        {
-               FilterPtr filter = eMedia->getFilter();
-
-               // FIXME validator have to be placed at JS binding.
-/*             FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
-               bool success = filter->validate(validator);
-
-               if(!success)
-                       ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
-*/
-               IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
-
-               visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
-               filter->travel(IVisitor);
-               condition = visitor->getResult();
-               query.append(" and ");
-               query.append(condition);                
+               if (tmpStr)
+               {
+                       newMedia->setDescription(tmpStr);
+                       LogDebug("Desc : " << tmpStr);
+                       free(tmpStr);
+                       tmpStr = NULL;
+               }
        }
 
-       if(eMedia->getSortModesIsSet()) 
+       //newImage->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_modified_time (info, &tmpDate) )
        {
-               sortMode = makeQuerySortMode(eMedia->getSortModes());   
+               newMedia->setModifiedDate(Mediacontent::toDateTm(tmpDate));
+       }
 
-               query.append(sortMode);
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_favorite (info, &tmpBool) )
+       {
+               newMedia->setFavorite(tmpBool);
+               LogDebug("favorite " << tmpBool);
        }
-       if (eMedia->getLimitIsSet()) 
+
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_rating  (info, &tmpInt) )
        {
-               limitOffset.append(" LIMIT ");
-               std::stringstream limitStream;
-               limitStream << eMedia->getLimit();
-               limitOffset.append(limitStream.str());
-               if(eMedia->getOffsetIsSet()) 
-               {
-                       limitOffset.append(" OFFSET ");
-                       std::stringstream offsetStream;
-                       offsetStream << eMedia->getOffset();
-                       limitOffset.append(offsetStream.str());
-               }
+               newMedia->setRating(tmpInt);
+               LogDebug("rating " << tmpInt);
+       }
 
-               query.append(limitOffset);
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_size(info, &tmpLongLong) )
+       {
+               newMedia->setSize(tmpLongLong);
+               LogDebug("Size : " << tmpLongLong);
        }
        
-       LogDebug("execute condition [" << condition << "]");
-       LogDebug("execute projection [" << projection << "]");
-       LogDebug("execute sortMode [" << sortMode << "]");
-       LogDebug("execute limitOffset [" << limitOffset << "]");        
-       LogDebug("execute query [" << query << "]");
-       
+}
 
-       int ret;
+void Mediacontent::readImageFromMediaInfo( media_info_h info, MediacontentImage* newImage)
+{      
+       char* tmpStr = NULL;
+       double tmpDouble;
+       int tmpInt = 0;
        
-    try
+       if ( info) 
        {
-               sqlite3_stmt* pStmt = NULL;
-               int content_type;
-               ret = sqlite3_prepare_v2(hDBCt, (char *)(query.c_str()), query.length(), &pStmt, NULL);
+               newImage->setMediaType("IMAGE");
 
-               while( sqlite3_step(pStmt) == SQLITE_ROW)
-               {
+               readCommonDataFromMediaInfo(info, newImage);
 
-                       content_type = sqlite3_column_int(pStmt, 2);    
+               image_meta_h img;
+               
+               if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_image(info, &img))
+               {
+                       //created time
+                       if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_date_taken (img, &tmpStr) )
+                       {       
+                               if ( tmpStr )
+                               {
+                                       struct tm result;
+                                       if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", &result) == NULL) {
+                                               LogError( "Couldn't convert supplied date.");
+                                       }
+                               
+                                       LogDebug("image_meta_get_date_taken : " <<  tmpStr); //time??
+                                       newImage->setReleasedDate(result);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
 
-                       if(content_type == MEDIA_TYPE_IMAGE)
+                       if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_width(img, &tmpInt) )
                        {
+                               newImage->setImageWidth(tmpInt);
+                               LogDebug("Image Width " << tmpInt);
+                       }
 
-                               MediacontentImage *newImage(new MediacontentImage());
-                               readImageFromDB(pStmt,newImage);
-                               eMedia->addMedia(newImage);
+                       if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_height(img, &tmpInt) )
+                       {
+                               newImage->setImageHeight(tmpInt);
+                               LogDebug("Image Height " << tmpInt);
                        }
-                       else if(content_type == MEDIA_TYPE_VIDEO)
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_latitude(info, &tmpDouble) )
                        {
-                               MediacontentVideo *newVideo(new MediacontentVideo());
-                               readVideoFromDB(pStmt,newVideo);
-                               eMedia->addMedia(newVideo);
+                               newImage->setImageLatitude(tmpDouble);
+                               LogDebug("Image Latitude " << tmpDouble);
                        }
-                       else if(content_type == MEDIA_TYPE_AUDIO)
+                       
+                       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_longitude(info, &tmpDouble) )
                        {
-                               MediacontentAudio *newVAudio(new MediacontentAudio());
-                               readAudioFromDB(pStmt,newVAudio);
-                               eMedia->addMedia(newVAudio);
+                               newImage->setImageLongitude(tmpDouble);
+                               LogDebug("Image Longitude " << tmpDouble);
+                       }
+                                       
+                       media_content_orientation_e orientation;
+                       
+                       if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_orientation(img, &orientation) )
+                       {       
+       
+                               string orientationStr;
+                               switch(orientation)
+                               {
+                                       case 0:
+                                       case 1: 
+                                               orientationStr = "NORMAL";
+                                               break;
+                                       case 2: 
+                                               orientationStr = "FLIP_HORIZONTAL";
+                                               break;
+                                       case 3: 
+                                               orientationStr = "ROTATE_180";
+                                               break;
+                                       case 4: 
+                                               orientationStr = "FLIP_VERTICAL";
+                                               break;
+                                       case 5: 
+                                               orientationStr = "TRANSPOSE";
+                                               break;
+                                       case 6: 
+                                               orientationStr = "ROTATE_90";
+                                               break;
+                                       case 7: 
+                                               orientationStr = "TRANSVERSE";
+                                               break;
+                                       case 8: 
+                                               orientationStr = "ROTATE_270";
+                                               break;
+                               }       
+                               
+                               newImage->setImageOrientation(orientationStr);
+                               LogDebug(" image Orientation. " << orientationStr);
 
                        }
 
-               }
-               sqlite3_finalize(pStmt);
-               eMedia->setResult(true);
 
+                       if ( METADATA_EXTRACTOR_ERROR_NONE != image_meta_destroy(img))
+                       {
+                               LogDebug(" image_meta_destroy is fail... ");
+                       }
+                                               
+               }
+               else {
+                       LogDebug("fetch Image Info failed..");                  
+               }
+                       
+       }
+       else
+       {
+               LogDebug("media info is NULL");
        }
-    catch (const Exception &ex)
-    {
-        LogError("Exception: " << ex.DumpToString());
-        eMedia->setResult(false);
-    }
-    eMedia->setCancelAllowed(true);
 }
 
-void Mediacontent::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
-{
-    LogDebug("OnRequestReceived::IEventFindMediaPtr entered");
-
-       string projection;
-       string sortMode;
-       string limitOffset;
-       string condition;
+void Mediacontent::readVideoFromMediaInfo( media_info_h info, MediacontentVideo* newVideo)
+{      
+       char* tmpStr;
+       int tmpInt = 0;
+       double tmpDouble;
+       time_t tmpDate;
        
-       string query(VIEW_MEDIA_QUERY_WITH_FOLDER);
-       std::stringstream folderStream;
-       folderStream <<" and folder_uuid='" << eBrowse->getFolderID() <<"' ";
-       query.append(folderStream.str());
-
-       MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
-
-       if(eBrowse->getFilterIsSet())
+       if ( info) 
        {
-               FilterPtr filter = eBrowse->getFilter();
-
-               // FIXME validator have to be placed at JS binding.
-               FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
-               bool success = filter->validate(validator);
-
-               if(!success)
-                       ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
-
-               IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
+               newVideo->setMediaType("VIDEO");        
 
-               visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
-               filter->travel(IVisitor);
-               condition = visitor->getResult();
-               query.append(" and ");
-               query.append(condition);                
-       }
-
-       if(eBrowse->getSortModesIsSet()) 
-       {
-               sortMode = makeQuerySortMode(eBrowse->getSortModes());  
+               readCommonDataFromMediaInfo(info, newVideo);    //set common media infomation
 
-               query.append(sortMode);
-       }
-       if (eBrowse->getLimitIsSet()) 
-       {
-               limitOffset.append(" LIMIT ");
-               std::stringstream limitStream;
-               limitStream << eBrowse->getLimit();
-               limitOffset.append(limitStream.str());
-               if(eBrowse->getOffsetIsSet()) 
+               video_meta_h video;
+               
+               if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_video(info, &video))
                {
-                       limitOffset.append(" OFFSET ");
-                       std::stringstream offsetStream;
-                       offsetStream << eBrowse->getOffset();
-                       limitOffset.append(offsetStream.str());
-               }
 
-               query.append(limitOffset);
-       }
-       
-       LogDebug("execute condition [" << condition << "]");
-       LogDebug("execute projection [" << projection << "]");
-       LogDebug("execute sortMode [" << sortMode << "]");
-       LogDebug("execute limitOffset [" << limitOffset << "]");        
-       LogDebug("execute query [" << query << "]");
-       
-       int ret;
-    try
-       {
-               sqlite3_stmt* pStmt = NULL;
-               int content_type;
-               ret = sqlite3_prepare_v2(hDBCt, (char *)(query.c_str()), query.length(), &pStmt, NULL);
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_recorded_date(video, &tmpStr) )
+                       {
+                               if ( tmpStr )
+                               {       
+                                       struct tm result;
+                                       if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", &result) == NULL) {
+                                               LogError( "Couldn't convert supplied date.");
+                                       }
+                                       newVideo->setReleasedDate(result);
+                                       
+                                       LogDebug("audio_meta_get_recorded_date : " << tmpStr);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
+               
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_album(video, &tmpStr) )
+                       {
+                               if( tmpStr )
+                               {
+                                       newVideo->setVideoAlbum(tmpStr);
+                                       LogDebug(" Video Album. " << tmpStr);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
 
-               while( sqlite3_step(pStmt) == SQLITE_ROW)
-               {
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_title(video, &tmpStr) )
+                       {
+                               if( tmpStr )
+                               {
+                                       newVideo->setDisplayName(tmpStr);
+                                       LogDebug(" Video Title. " << tmpStr);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_artist(video, &tmpStr) )
+                       {       
+                               if ( tmpStr)
+                               {
+                                       std::vector<std::string> artists = String::split(tmpStr, TAG_DELIMETER);
+                                       for( unsigned int i=0; i < artists.size(); i++)
+                                       {
+                                               string artist = artists.at(i);
+                                               LogDebug("Audio artist: " << artist);
+                                               newVideo->appendVideoArtist(artist);
+                                       }
+                                       
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
 
-                       content_type = sqlite3_column_int(pStmt, 2);    
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_played_position(video, &tmpInt) )
+                       {       
+                               newVideo->setVideoPlayedTime(tmpInt);
+                               LogDebug(" Video PlayedTime. " << tmpInt);
+                       }
 
-                       if(content_type == MEDIA_TYPE_IMAGE)
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_played_count(video, &tmpInt) )
+                       {
+                               newVideo->setVideoPlayCount(tmpInt);
+                               LogDebug(" Video PlayedCount. " << tmpInt);
+                       }
+                       
+                       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_longitude(info, &tmpDouble) )
                        {
+                               newVideo->setVideoLongitude(tmpDouble);
+                       }
 
-                               MediacontentImage *newImage(new MediacontentImage());
-                               readImageFromDB(pStmt,newImage);
-                               eBrowse->addMedia(newImage);
+                       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_latitude(info, &tmpDouble) )
+                       {
+                               newVideo->setVideoLatitude(tmpDouble);
                        }
-                       else if(content_type == MEDIA_TYPE_VIDEO)
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_width(video, &tmpInt) )
                        {
-                               MediacontentVideo *newVideo(new MediacontentVideo());
-                               readVideoFromDB(pStmt,newVideo);
-                               eBrowse->addMedia(newVideo);
+                               newVideo->setVideoWidth(tmpInt);
                        }
-                       else if(content_type == MEDIA_TYPE_AUDIO)
+                       
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_height(video, &tmpInt) )
                        {
-                               MediacontentAudio *newVAudio(new MediacontentAudio());
-                               readAudioFromDB(pStmt,newVAudio);
-                               eBrowse->addMedia(newVAudio);
+                               newVideo->setVideoHeight(tmpInt);
+                       }
 
+                       if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_duration(video, &tmpInt) )
+                       {
+                               newVideo->setVideoDuration(tmpInt);
                        }
 
+                       if ( METADATA_EXTRACTOR_ERROR_NONE != video_meta_destroy(video))
+                       {
+                               LogDebug(" video_meta_destroy is fail... ");
+                       }
+                                               
+               }
+               else
+               {
+                       LogDebug("fetch Video info fail...");
                }
-               sqlite3_finalize(pStmt);
-               eBrowse->setResult(true);
-
        }
-    catch (const Exception &ex)
-    {
-        LogError("Exception: " << ex.DumpToString());
-        eBrowse->setResult(false);
-    }
-
-    eBrowse->setCancelAllowed(true);
-
+       else
+       {
+               LogDebug("media info is NULL");
+       }
 }
 
-bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
-{
-       int err;
-       char *errMsg = NULL;
 
-       bool ret = false;
-       string type  = mediaPtr->getMediaType();
+void Mediacontent::readMusicFromMediaInfo( media_info_h info, MediacontentAudio* newAudio)
+{      
+       char* tmpStr;
+       int tmpInt = 0;
+       unsigned long long tmpLongLong = 0;
                
-       if(type.compare("IMAGE")==0)
+       if ( info) 
        {
-               LogDebug("Image11");
-               MediacontentImagePtr imagePtr = DPL::DynamicPointerCast<MediacontentImage>(mediaPtr);
-               if(imagePtr != NULL)
-               {
-                       string query;   
-                       LogDebug("Image22");
-                       if(imagePtr->getIsChangedFavorite())
-                       {
-                               query.append("update visual_media set rating=");
-                               std::stringstream offsetStream;
-                               offsetStream << imagePtr->getFavorite();
-                               query.append(offsetStream.str());
-                               query.append(" where visual_uuid='");
-                               query.append(imagePtr->getMediaUUID());
-                               query.append("'");
-                               LogDebug("QUERY : " << query);
-
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
-                               if (SQLITE_OK != err)
-                               {                                       
-                                       if(errMsg)
-                                       {
-                                               sqlite3_free(errMsg);
-                                       }       
+               newAudio->setMediaType("AUDIO");        
+               
+               readCommonDataFromMediaInfo(info, newAudio);    //set common media infomation
+
+               audio_meta_h audio;
+               
+               if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_audio(info, &audio))
+               {       
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_recorded_date(audio, &tmpStr) )
+                       {
+                               if ( tmpStr )
+                               {       
+                                       struct tm result;
+                                       if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", &result) == NULL) {
+                                               LogError( "Couldn't convert supplied date.");
+                                       }
+                                       newAudio->setReleasedDate(result);
+                                       
+                                       LogDebug("audio_meta_get_recorded_date : " << tmpStr);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
                                }
                        }
-               }
-               ret = true;
-       }
-       if(type.compare("VIDEO")==0)
-       {
-               LogDebug("Video11");
-               MediacontentVideoPtr videoPtr = DPL::DynamicPointerCast<MediacontentVideo>(mediaPtr);
-               if(videoPtr != NULL)
-               {
-                       string query;   
-                       if(videoPtr->getIsChangedFavorite())
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_title(audio, &tmpStr) )
                        {
-                               std::stringstream offsetStream;
-                               offsetStream << "update visual_media set rating=" << videoPtr->getFavorite() << " where visual_uuid=" << "'" << videoPtr->getMediaUUID() << "'";
-                               query = offsetStream.str();                     
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
-                               if (SQLITE_OK != err)
-                               {                                       
-                                       if(errMsg)
-                                       {
-                                               sqlite3_free(errMsg);
-                                       }
+                               if (tmpStr)
+                               {
+                                       newAudio->setDisplayName(tmpStr);
+                                       LogDebug("Audio Title : " << tmpStr);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
                                }
                        }
-                       if(videoPtr->isChangedPlayedTime() || videoPtr->isChangedPlayCount())
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_album(audio, &tmpStr) )
                        {
-                               std::stringstream offsetStream;
-                               offsetStream << "update video_meta set last_played_time=" << videoPtr->getVideoPlayedTime() << " where visual_uuid=" << "'" << videoPtr->getMediaUUID() << "'";
-                               query = offsetStream.str();                     
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
-                               if (SQLITE_OK != err)
-                               {                                       
-                                       if(errMsg)
+                               if (tmpStr)
+                               {
+                                       newAudio->setAudioAlbum(tmpStr);
+                                       LogDebug("Audio Album : " << tmpStr);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_artist(audio, &tmpStr) )
+                       {       
+                               if (tmpStr)
+                               {
+                                       std::vector<std::string> artists = String::split(tmpStr, TAG_DELIMETER);
+                                       for( unsigned int i=0; i < artists.size(); i++)
                                        {
-                                               sqlite3_free(errMsg);
+                                               string artist = artists.at(i);
+                                               LogDebug("Audio artist: " << artist);
+                                               newAudio->appendAudioArtist(artist);
                                        }
-                               }                                               
+                                       
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
                        }
-               }       
-               ret = true;
-       }
-       if(type.compare("AUDIO")==0)
-       {
-               LogDebug("Audio11");
-               MediacontentAudioPtr audioPtr = DPL::DynamicPointerCast<MediacontentAudio>(mediaPtr);
-               if(audioPtr != NULL)
-               {
-                       string query;   
-                       if(audioPtr->getIsChangedFavorite())
+               
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_played_position (audio, &tmpInt) )
+                       {
+                               newAudio->setAudioPlayedTime(tmpInt);
+                               LogDebug("Audio Played Time : " << tmpInt);
+                       }
+               
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_played_count(audio, &tmpInt) )
+                       {
+                               newAudio->setAudioPlayCount(tmpInt);
+                               LogDebug("Audio Played Count : " << tmpInt);
+                       }
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_composer(audio, &tmpStr) )
                        {
-                               std::stringstream offsetStream;
-                               offsetStream << "update audio_media set rating=" << audioPtr->getFavorite() << " where audio_uuid=" << "'" << audioPtr->getMediaUUID() << "'";
-                               query = offsetStream.str();
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
-                               if (SQLITE_OK != err)
-                               {                                       
-                                       if(errMsg)
+                               if (tmpStr)
+                               {       
+                                       std::vector<std::string> composers = String::split(tmpStr, TAG_DELIMETER);
+                                       for( unsigned int i=0; i < composers.size(); i++)
                                        {
-                                               sqlite3_free(errMsg);
-                                               //throw error
+                                               string composer = composers.at(i);
+                                               LogDebug("Audio Composer : " << composer);
+                                               newAudio->appendAudioComposer(composer);
                                        }
                                        
-                               }                                       
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
                        }
-                       if(audioPtr->isChangedPlayedTime() || audioPtr->isChangedPlayCount())
+                       
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_duration(audio, &tmpInt) )
                        {
-                               std::stringstream offsetStream;
-                               offsetStream << "update audio_media set last_played_time=" <<audioPtr->getAudioPlayedTime()<< ",played_count="<<audioPtr->getAudioPlayCount()<<" where audio_uuid=" << "'" << audioPtr->getMediaUUID() << "'";
-                               query = offsetStream.str();                     
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
-                               if (SQLITE_OK != err)
-                               {                                       
-                                       if(errMsg)
-                                       {
-                                               sqlite3_free(errMsg);
-                                               //throw error
+                               newAudio->setAudioDuration(tmpInt);
+                               LogDebug("Audio Duration : " << tmpInt);
+                       }
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_copyright(audio, &tmpStr) )
+                       {
+                               if (tmpStr)
+                               {
+                                       newAudio->setAudioCopyright(tmpStr);
+                                       LogDebug("Audio CopyRight: " << tmpStr);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
+               
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_track_num(audio, &tmpStr) )
+                       {       
+                               int trackNum = 0;
+                               if (tmpStr)
+                               {
+                                       LogDebug("trackNum: " << tmpStr);
+                                       try {
+                                               istringstream(tmpStr) >> trackNum;
+                                       } catch (...) {
+                                               LogDebug("Track Number type is wrong. (track number:" << tmpStr << ")");
+                                               trackNum = 0;
                                        }
-                               }                                               
+                       
+                                       newAudio->setAudioTrackNum(trackNum);
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
                        }
-               }       
-               ret = true;
-       }
-       return ret;
-}
 
-void Mediacontent::OnRequestReceived(const IEventUpdateMediaPtr &eMedia)
-{
-    LogDebug("OnRequestReceived::IEventUpdateMediaPtr entered");
-       try
-       {
-               MediacontentMediaPtr mediaPtr = eMedia->getMediaItem();
+                       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_size(info, &tmpLongLong) )
+                       {       
+                               LogDebug("size");
+                               newAudio->setAudioSize(tmpLongLong);
+                               LogDebug("Audio Size: " << tmpLongLong);
+                       }
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_bit_rate(audio, &tmpInt) )
+                       {       
+                               LogDebug("bitrate");
+                               newAudio->setAudioBitrate(tmpInt);
+                               LogDebug("Audio Bitrate: " << tmpInt);
+                       }
+
+                       if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_genre(audio, &tmpStr) )
+                       {       
+                               LogDebug("gener");
+                               if (tmpStr)
+                               {
+                                       std::vector<std::string> genres = String::split(tmpStr, TAG_DELIMETER);
+
+                                       for( unsigned int i=0; i < genres.size(); i++)
+                                       {
+                                               string genre = genres.at(i);
+                                               LogDebug("Audio Genre: " << genre);
+                                               newAudio->appendAudioGenre(genre);
+                                       }
+                                       
+                                       free(tmpStr);
+                                       tmpStr = NULL;
+                               }
+                       }
+                                               
+                       if ( METADATA_EXTRACTOR_ERROR_NONE != audio_meta_destroy(audio))
+                       {
+                               LogDebug(" audio_meta_destroy is fail... ");
+                       }
+                       
 
-               if(updateMediaToDB(mediaPtr))
-               {
-                       eMedia->setResult(true);
                }
                else
                {
-                       eMedia->setResult(false);
+                       LogDebug("fetch Music Info fail...");
                }
+               
+                       
+       }
+       else
+       {
+               LogDebug("media info is NULL");
        }
-    catch (const Exception &ex)
-    {
-        LogError("Exception: " << ex.DumpToString());
-        eMedia->setResult(false);
-    }
-    eMedia->setCancelAllowed(true);
 }
 
 
-void Mediacontent::OnRequestReceived(const IEventUpdateMediaItemsPtr &eItems)
-{
-       LogDebug("OnRequestReceived::IEventUpdateMediaItemsPtr entered");
 
-       try
+//Callback.
+bool Mediacontent::mediaFolderCallback(media_folder_h folder, void *user_data)
+{      
+       LogDebug("enter");
+       if (user_data != NULL){
+               IEventFindFolder* event = (IEventFindFolder*)user_data;
+               LogDebug("user data is valide");
+               if ( folder )
+               {
+                       LogDebug("folder is valide");
+                       MediacontentFolderPtr newFolder(new MediacontentFolder());
+                       convertToPlatformFolder(folder, newFolder);
+                       LogDebug("folder type" << newFolder->getFolderStorageType());
+                       
+                       event->addFolder(newFolder);
+               }
+       }
+       else
        {
-               MediacontentMediaListPtr mediaListPtr = eItems->getMediaItems();
-        if (mediaListPtr->empty()) 
-               {
-            ThrowMsg(NullPointerException, "Item vector parameter is empty");
-        }
+               LogDebug("user data is NULL");
+       }
+       
+       return true;
+
+}
+
+bool Mediacontent::mediaItemCallback(media_info_h info, void* user_data)
+{
+       if (user_data != NULL){
+               IEventBrowseFolder* event = (IEventBrowseFolder*)user_data;
 
-        for(unsigned int i=0; i<mediaListPtr->size(); i++)
-        {
-                       MediacontentMediaPtr mediaPtr = mediaListPtr->at(i);
-                       if(!updateMediaToDB(mediaPtr))
+               media_content_type_e type;
+               
+               if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_type( info, &type) )
+               {
+                       if ( type == MEDIA_CONTENT_TYPE_IMAGE)
+                       {
+                               MediacontentImage *newImage(new MediacontentImage());
+                               readImageFromMediaInfo(info, newImage);
+                               event->addMedia(newImage);
+                       }
+                       else if ( type == MEDIA_CONTENT_TYPE_VIDEO)
+                       {
+                               MediacontentVideo *newVideo(new MediacontentVideo());
+                               readVideoFromMediaInfo(info, newVideo);
+                               event->addMedia(newVideo);
+                       }
+                       else if ( type == MEDIA_CONTENT_TYPE_MUSIC)
                        {
-                               ThrowMsg(NullPointerException, "DB operation is failed");
+                               MediacontentAudio *newVAudio(new MediacontentAudio());
+                               readMusicFromMediaInfo(info, newVAudio);
+                               event->addMedia(newVAudio);
+                       }
+                       else 
+                       {       
+                               LogDebug("other type");
                        }
+
                }
-               eItems->setResult(true);
-        }
-        catch (const Exception &ex)
-        {
-                LogError("Exception: " << ex.DumpToString());
-                eItems->setResult(false);
-        }
-        eItems->setCancelAllowed(true);
+       }
+       else 
+       {
+               LogDebug("event is NULL");      
+       }
 
+       return true;
 }
 
-void Mediacontent::readImageFromDB(sqlite3_stmt* pStmt, MediacontentImage* newImage)
+void Mediacontent::OnRequestReceived(const IEventFindFolderPtr &eFolder)
 {
-       char* tmp;
-       if(pStmt != NULL)
+       LogDebug("entered");
+               
+       if ( MEDIA_CONTENT_ERROR_NONE != 
+               media_folder_foreach_folder_from_db (NULL, mediaFolderCallback, eFolder.Get()))
+       {       
+               LogError("error ( media_folder_foreach_folder_from_db ) : ");
+               eFolder->setResult(false);
+       }
+       else
        {
-
-               tmp = (char*)sqlite3_column_text(pStmt,0);
-               if( tmp != NULL)
-                       newImage->setMediaUUID(tmp);
-
-               newImage->setMediaType("IMAGE");
-       
-               //setMimeType //2
-               tmp = (char*)sqlite3_column_text(pStmt,3);
-               if( tmp != NULL)
-                       newImage->setDisplayName(tmp);
-
-               tmp = (char*)sqlite3_column_text(pStmt,4);
-               if( tmp != NULL)
-                       newImage->setFilePath(tmp);
-
-               tmp = (char*)sqlite3_column_text(pStmt,5);
-               if( tmp != NULL)
-                       newImage->setThumbnailPath(tmp);
-
-               newImage->setCreatedDate(toDateTm(sqlite3_column_int(pStmt,6)));
-               newImage->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
-               newImage->setModifiedDate(toDateTm(sqlite3_column_int(pStmt,8)));
-
-               tmp = (char*)sqlite3_column_text(pStmt,9);
-               if( tmp != NULL)
-                       newImage->setDescription(tmp);
-
-               newImage->setFavorite(sqlite3_column_int(pStmt,10));    
-               newImage->setImageLatitude(sqlite3_column_double(pStmt,15));
-               newImage->setImageLongitude(sqlite3_column_double(pStmt,16));   
-               newImage->setImageWidth(sqlite3_column_int(pStmt,17));
-               newImage->setImageHeight(sqlite3_column_int(pStmt,18));
-               int orientation = (sqlite3_column_int(pStmt,19));
-               string orientationStr;
-               switch(orientation)
-               {
-                       case 1: 
-                               orientationStr = "NORMAL";
-                               break;
-                       case 2: 
-                               orientationStr = "FLIP_HORIZONTAL";
-                               break;
-                       case 3: 
-                               orientationStr = "ROTATE_180";
-                               break;
-                       case 4: 
-                               orientationStr = "FLIP_VERTICAL";
-                               break;
-                       case 5: 
-                               orientationStr = "TRANSPOSE";
-                               break;
-                       case 6: 
-                               orientationStr = "ROTATE_90";
-                               break;
-                       case 7: 
-                               orientationStr = "TRANSVERSE";
-                               break;
-                       case 8: 
-                               orientationStr = "ROTATE_270";
-                               break;
-               }               
-               newImage->setImageOrientation(orientationStr);
-               newImage->setSize(sqlite3_column_double(pStmt,23));
+               eFolder->setResult(true);
        }
-       
-}
 
 
+       LogDebug("end");
+}
 
-void Mediacontent::readVideoFromDB(sqlite3_stmt* pStmt, MediacontentVideo* newVideo)
+void Mediacontent::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
 {
-       char* tmp;
-       if(pStmt != NULL)
-       {
+       LogDebug("OnRequestReceived::IEventBrowseFolderPtr entered");
+
+       MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
+       visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
+       int ret = MEDIA_CONTENT_ERROR_NONE;
 
-               tmp = (char*)sqlite3_column_text(pStmt,0);
-               if( tmp != NULL)
-                       newVideo->setMediaUUID(tmp);
+       try{
+               filter_h filter = NULL;
 
-               newVideo->setMediaType("VIDEO");
+               if(eBrowse->getFilterIsSet() || eBrowse->getFolderIdIsSet() || eBrowse->getSortModesIsSet()
+                       || eBrowse->getLimitIsSet() ||eBrowse->getOffsetIsSet() )
+               {
+                       //set filter
+                       if ( MEDIA_CONTENT_ERROR_NONE == media_filter_create(&filter))
+                       {
+                               if (eBrowse->getFilterIsSet())
+                               {
+                                       string condition;
+                                       FilterPtr jsFilter = eBrowse->getFilter();
 
-               //setMimeType 
-               tmp = (char*)sqlite3_column_text(pStmt,3);
-               if( tmp != NULL)
-                       newVideo->setDisplayName(tmp);
+                                       FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
+                                       bool success = jsFilter->validate(validator);
 
-               tmp = (char*)sqlite3_column_text(pStmt,4);
-               if( tmp != NULL)
-                       newVideo->setFilePath(tmp);
+                                       if(!success)
+                                               ThrowMsg(PlatformException, "Invalid attirbutes.");
+                                       
+                                       IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
 
-               tmp = (char*)sqlite3_column_text(pStmt,5);
-               if( tmp != NULL)
-                       newVideo->setThumbnailPath(tmp);
+                                       jsFilter->travel(IVisitor);
+                                       condition = visitor->getResult();
 
-               newVideo->setCreatedDate(toDateTm(sqlite3_column_int(pStmt,6)));
-               newVideo->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
-               newVideo->setModifiedDate(toDateTm(sqlite3_column_int(pStmt,8)));
+                                       LogDebug("execute condition [" << condition << "]");
+                                       media_filter_set_condition(filter, condition.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT );  //set condition
+                               }
 
-               tmp = (char*)sqlite3_column_text(pStmt,9);
-               if( tmp != NULL)
-                       newVideo->setDescription(tmp);
+                               if(eBrowse->getSortModesIsSet()) 
+                               {
+                                       media_content_order_e order;
 
-               newVideo->setFavorite(sqlite3_column_int(pStmt,10));    
+                                       SortModePtr attr = eBrowse->getSortMode();
 
-               tmp = (char*)sqlite3_column_text(pStmt,11);
-               if( tmp != NULL)
-                       newVideo->setVideoAlbum(tmp);
+                                       if ( attr )
+                                       {
+                                               string attriName = attr->getAttributeName();
+                                               attriName = visitor->getPlatformAttr(attriName);
+                                               LogDebug("Attribute Name [" << attriName << "]");
+
+                                               if (attriName.compare("") != 0) 
+                                               {       
+                                                       if (attr->getOrder() == Api::Tizen::ASCENDING_SORT_ORDER) 
+                                                       {
+                                                               order = MEDIA_CONTENT_ORDER_ASC;
+                                                       } 
+                                                       else 
+                                                       {
+                                                               order = MEDIA_CONTENT_ORDER_DESC;
+                                                       }
+
+                                                       if ( attriName.compare( "MEDIA_TITLE") == 0 )
+                                                       {
+                                                               attriName.append(", MEDIA_DISPLAY_NAME");
+                                                       }
+                                                       if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                               media_filter_set_order(filter, order, attriName.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT ))               //set order
+                                                       {       
+                                                               LogDebug("media_filter_set_order fail...");     
+                                                       }
+                                               }
+                                       }
+                                       
+                               }                               
 
-               tmp = (char*)sqlite3_column_text(pStmt,12);
-               if( tmp != NULL)                        
-                       newVideo->setVideoArtist(tmp);
+                               if (eBrowse->getLimitIsSet() ||eBrowse->getOffsetIsSet() ) 
+                               {       
+                                       LogDebug("limit or offset");
+                                       
+                                       long count = -1;
+                                       long offset = 0;
+                                       
+                                       if ( eBrowse->getLimitIsSet() )
+                                       {
+                                               count =  eBrowse->getLimit();
+                                               LogDebug("limit is " << count);
+                                       }
+                                       
+                                       if ( eBrowse->getOffsetIsSet() )
+                                       {
+                                               offset = eBrowse->getOffset();
+                                               LogDebug("offset is " << offset);
+                                       }
+                                       
+                                       if ( MEDIA_CONTENT_ERROR_NONE != media_filter_set_offset(filter, offset, count))
+                                       {
+                                               LogDebug("set limit or offset fail...");
+                                       }
+                               }
+                               
+                       }
+                       else
+                       {
+                               
+                               LogError("error ( media filter create ) : ");
+                               eBrowse->setResult(false);
+                       }
+               }
 
-               newVideo->setVideoPlayedTime(sqlite3_column_int(pStmt,13));     
-               newVideo->setVideoPlayCount(sqlite3_column_int(pStmt,14)); 
+               if ( eBrowse->getFolderIdIsSet())
+               {       
+                       string folderID = eBrowse->getFolderID();
+                       LogDebug("FolderID :" << folderID);
+                       
+                       if ( MEDIA_CONTENT_ERROR_NONE !=  
+                               media_folder_foreach_media_from_db (folderID.c_str(), filter, mediaItemCallback, eBrowse.Get()))
+                       {       
+                               LogError("error ( media_folder_foreach_folder_from_db ) : " << ret);
+                               eBrowse->setResult(false);
+                       }
+                       else
+                       {       
+                               eBrowse->setResult(true);
+                       }
+               }
+               else
+               {
+                       if ( MEDIA_CONTENT_ERROR_NONE !=  
+                               media_info_foreach_media_from_db (filter, mediaItemCallback, eBrowse.Get()))
+                       {       
+                               LogError("error ( media_folder_foreach_folder_from_db ) : " << ret);
+                               eBrowse->setResult(false);
+                       }
+                       else
+                       {       
+                               eBrowse->setResult(true);
+                       }
+               }
 
-               newVideo->setVideoLongitude(sqlite3_column_double(pStmt,15));   
-               newVideo->setVideoLatitude(sqlite3_column_double(pStmt,16));
+               //destory Filter
+               if(filter)
+               {
+                       if ( MEDIA_CONTENT_ERROR_NONE != media_filter_destroy(filter))
+                       {
+                               LogError("media_filter_create Error: " << ret);
+                       }
+               }
                
-               newVideo->setVideoWidth(sqlite3_column_int(pStmt,17));
-               newVideo->setVideoHeight(sqlite3_column_int(pStmt,18));
-       
-               newVideo->setVideoDuration(sqlite3_column_int(pStmt,22));
-               newVideo->setSize(sqlite3_column_double(pStmt,23));
+       }
+       catch(const Exception &ex){
+                       LogError("Exception: " << ex.DumpToString());
+                       eBrowse->setResult(false);
+                       return;
+       }
 
-       }               
 
+       
 }
 
-void Mediacontent::readAudioFromDB(sqlite3_stmt* pStmt, MediacontentAudio* newAudio)
-{
-       char* tmp;
-       if(pStmt != NULL)
+bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
+{      
+       string type  = mediaPtr->getMediaType();        //media type.
+       string mediaId = mediaPtr->getMediaUUID();
+
+       LogDebug("MediaId : " << mediaId);
+       media_info_h media = NULL;
+       
+       bool ret = true;
+       
+       if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_from_db(mediaId.c_str(), &media))
        {
+               if ( mediaPtr->isChangedRating() 
+                       || mediaPtr->isChangedDisplayName() 
+                       || mediaPtr->isChangedDescription() )
+               {       
+                       
+                               if ( mediaPtr->isChangedRating())
+                               {
+                                       if ( MEDIA_CONTENT_ERROR_NONE 
+                                               != media_info_set_rating(media, mediaPtr->getRating()))
+                                       {
+                                               LogDebug("Error: set rating");  
+                                       }               
+                               }
+                               else if ( mediaPtr->isChangedDisplayName() )
+                               {
+                                       if ( MEDIA_CONTENT_ERROR_NONE 
+                                               != media_info_set_description (media, mediaPtr->getDescription().c_str()))
+                                       {
+                                               LogDebug("Error: set description"); 
+                                       }
+                               }
+                               else 
+                               {
+                                       if ( MEDIA_CONTENT_ERROR_NONE 
+                                               != media_info_set_display_name (media, mediaPtr->getDisplayName().c_str()))
+                                       {
+                                               LogDebug("Error: set displayname"); 
+                                       }
+                               }
+       
 
-               tmp = (char*)sqlite3_column_text(pStmt,0);
-               if( tmp != NULL)
-                       newAudio->setMediaUUID(tmp);
+               }
 
-               newAudio->setMediaType("AUDIO");
+               if(type.compare("IMAGE") ==0 )
+               {
+                       MediacontentImagePtr imagePtr = DPL::DynamicPointerCast<MediacontentImage>(mediaPtr);
+                       
+                       if(imagePtr && (imagePtr->isChangedOrientaion() 
+                               || imagePtr->isChangedLatitude() || imagePtr->isChangedLongitude()))
+                       {
+                               image_meta_h img=NULL;
+                               if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_image(media, &img))
+                               {
+                                       if(imagePtr->isChangedOrientaion())
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       image_meta_set_orientation (img, convertToOrientation(imagePtr->getImageOrientation())))
+                                               {
+                                                       LogDebug("Error: set orientation"); 
+                                                       ret = false;
+                                               }
+                                       }
+                       
+                                       if (  imagePtr->isChangedLatitude() )
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       media_info_set_latitude(media, imagePtr->getImageLatitude())
+                                                       )
+                                               {
+                                                       LogDebug("Error: set Latitude"); 
+                                                       ret = false;
+                                               }
+                                       }
+                                       if (  imagePtr->isChangedLongitude() )
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       media_info_set_longitude(media, imagePtr->getImageLongitude())
+                                                       )
+                                               {
+                                                       LogDebug("Error: set Latitude"); 
+                                                       ret = false;
+                                               }                                               
+                                       }
 
-               //setMimeType 
-               tmp = (char*)sqlite3_column_text(pStmt,3);
-               if( tmp != NULL)
-                       newAudio->setDisplayName(tmp);
+                                       if ( MEDIA_CONTENT_ERROR_NONE != image_meta_update_to_db (img) )
+                                       {
+                                               LogDebug("Error: update db");
+                                               ret = false;
+                                       }
+                                                                       
+                                       if ( MEDIA_CONTENT_ERROR_NONE != image_meta_destroy(img))
+                                       {
+                                               LogDebug("Error: destroy media info");  
+                                               ret = false;
+                                       }
+                                       
+                                       img = NULL;
+                                       
+                               }
+                               else
+                               {
+                                       LogDebug("Error: get Image from DB");
+                                       ret = false;
+                               }
+                       }
+                       
+               }
 
-               tmp = (char*)sqlite3_column_text(pStmt,4);
-               if( tmp != NULL)
-                       newAudio->setFilePath(tmp);
+               if(type.compare("VIDEO") ==0 )
+               {       
+                       MediacontentVideoPtr videoPtr = DPL::DynamicPointerCast<MediacontentVideo>(mediaPtr);
+                       if (videoPtr && ( videoPtr->isChangedPlayCount () || videoPtr->isChangedPlayedTime () 
+                               ||videoPtr->isChangedArtists () ||  videoPtr->isChangedAlbum() 
+                               || videoPtr->isChangedLatitude() ||videoPtr->isChangedLongitude()) )
+                       {
 
-               tmp = (char*)sqlite3_column_text(pStmt,5);
-               if( tmp != NULL)
-                       newAudio->setThumbnailPath(tmp);
+                               video_meta_h video = NULL;
+                               if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_video(media, &video))
+                               {
+                                       if (  videoPtr->isChangedPlayCount() )
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       video_meta_set_played_count (video, videoPtr->getVideoPlayCount()))
+                                               {
+                                                       LogDebug("Error: set play count"); 
+                                                       ret = false;
+                                                       
+                                               }       
+                                       }
+                                       
+                                       if (videoPtr->isChangedPlayedTime())
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       video_meta_set_played_position (video, videoPtr->getVideoPlayedTime()))
+                                               {
+                                                       LogDebug("Error: set played time"); 
+                                                       ret = false;
+                                               }
+                                       }
+#if 0 //NOT support
+                                       if (videoPtr->isChangedAlbum())
+                                       {
+                                               LogDebug("Not support - Album API"); 
+                                               ret = false;
+                                       }
 
-               newAudio->setCreatedDate(toDateTm(sqlite3_column_int(pStmt,6)));
-               newAudio->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
-               newAudio->setModifiedDate(toDateTm(sqlite3_column_int(pStmt,8)));
+                                       if (videoPtr->isChangedArtists())
+                                       {
+                                               LogDebug("Not support - Artist API"); 
+                                               ret = false;
+                                       }
+#endif                                                                 
+                                       if (  videoPtr->isChangedLatitude() )
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       media_info_set_latitude(media, videoPtr->getVideoLatitude())
+                                                       )
+                                               {
+                                                       LogDebug("Error: set Latitude"); 
+                                                       ret = false;
+                                               }
+                                       }
+                                       if (  videoPtr->isChangedLongitude() )
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       media_info_set_longitude(media, videoPtr->getVideoLongitude())
+                                                       )
+                                               {
+                                                       LogDebug("Error: set Latitude"); 
+                                                       ret = false;
+                                               }                                               
+                                       }
+                                       
+                                       if ( MEDIA_CONTENT_ERROR_NONE != video_meta_update_to_db (video) )
+                                       {
+                                               LogDebug("Error: update db");
+                                               ret = false;
+                                       }
+                                       
+                                       if ( MEDIA_CONTENT_ERROR_NONE != video_meta_destroy(video))
+                                       {
+                                               LogDebug("Error: destroy video meta");  
+                                               ret = false;
+                                       }
 
-               tmp = (char*)sqlite3_column_text(pStmt,9);
-               if( tmp != NULL)
-                       newAudio->setDescription(tmp);
+                                       video = NULL;
+                                       
+                               }                               
+                       }
+                       
+               } //video
 
-               newAudio->setFavorite(sqlite3_column_int(pStmt,10));    
+               
 
-               tmp = (char*)sqlite3_column_text(pStmt,11);
-               if( tmp != NULL)
-                       newAudio->setAudioAlbum(tmp);
+               if(type.compare("AUDIO") ==0 )
+               {
+                       
+                       MediacontentAudioPtr audioPtr = DPL::DynamicPointerCast<MediacontentAudio>(mediaPtr);
+                       if (audioPtr && ( audioPtr->isChangedPlayCount () || audioPtr->isChangedPlayedTime () 
+                               ||audioPtr->isChangedAudioArtist () ||  audioPtr->isChangedAudioAlbum() 
+                               || audioPtr->isChangedAudioGenre() ||audioPtr->isChangedAudioComposer()
+                               || audioPtr->isChangedAudioTrackNumber()) )
+                       {
 
-               tmp = (char*)sqlite3_column_text(pStmt,12);
-               if( tmp != NULL)                        
-                       newAudio->setAudioArtist(tmp);
+                               audio_meta_h audio=NULL;
+                               if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_audio(media, &audio))
+                               {
+                                       if (  audioPtr->isChangedPlayCount() )
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       audio_meta_set_played_count (audio, audioPtr->getAudioPlayCount()))
+                                               {
+                                                       LogDebug("Error: set play count"); 
+                                                       ret = false;
+                                               }       
+                                       }
+                                       
+                                       if (audioPtr->isChangedPlayedTime())
+                                       {
+                                               if ( MEDIA_CONTENT_ERROR_NONE != 
+                                                       audio_meta_set_played_position (audio, audioPtr->getAudioPlayedTime()))
+                                               {
+                                                       LogDebug("Error: set played time"); 
+                                                       ret = false;
+                                               }
+                                       }
+#if 0 //NOT support
+                                       if (audioPtr->isChangedAudioArtist())
+                                       {
+                                               LogDebug("Not Support API"); 
+                                               ret = false;
+                                       }
 
-               newAudio->setAudioPlayedTime(sqlite3_column_int(pStmt,13));     
-               newAudio->setAudioPlayCount(sqlite3_column_int(pStmt,14));
+                                       if (audioPtr->isChangedAudioAlbum())
+                                       {
+                                               LogDebug("Not Support API"); 
+                                               ret = false;
+                                       }
 
-               tmp = (char*)sqlite3_column_text(pStmt,20);
-               if( tmp != NULL)                        
-                       newAudio->setAudioGenre(tmp);
+                                       if (audioPtr->isChangedAudioGenre())
+                                       {
+                                               LogDebug("Not Support API"); 
+                                               ret = false;
+                                       }
 
-               tmp = (char*)sqlite3_column_text(pStmt,21);
-               if( tmp != NULL)                        
-                       newAudio->setAudioComposer(tmp);
+                                       if (audioPtr->isChangedAudioComposer())
+                                       {
+                                               LogDebug("Not Support API"); 
+                                               ret = false;
+                                       }
 
-               newAudio->setAudioDuration(sqlite3_column_int(pStmt,22));
-               newAudio->setSize(sqlite3_column_double(pStmt,23));
+                                       if (audioPtr->isChangedAudioTrackNumber())
+                                       {
+                                               LogDebug("Not Support API"); 
+                                               ret = false;
+                                       }
+#endif
+                                       if ( MEDIA_CONTENT_ERROR_NONE != audio_meta_update_to_db (audio) )
+                                       {
+                                               LogDebug("Error: update db");
+                                               ret = false;
+                                       }
+                                       
+                                       if ( MEDIA_CONTENT_ERROR_NONE != audio_meta_destroy(audio))
+                                       {
+                                               LogDebug("Error: destroy audio meta");
+                                               ret = false;
+                                       }
+                                       audio = NULL;
+                               }
 
-               string queryExtraAudio(SELECT_EXTRA_AUDIO);
-               queryExtraAudio.append("'");
-               queryExtraAudio.append(newAudio->getMediaUUID());
-               queryExtraAudio.append("'");
-               sqlite3_stmt* pStmt1 = NULL;
-               //"select copyright,bitrate,track_num,size from audio_media where audio_id=";
-               if(sqlite3_prepare_v2(hDBCt, (char *)(queryExtraAudio.c_str()), strlen((char *)(queryExtraAudio.c_str())), &pStmt1, NULL) == SQLITE_OK)
-               {
-                       while( sqlite3_step(pStmt1) == SQLITE_ROW)
-                       {
-                               tmp = (char*)sqlite3_column_text(pStmt,0);
-                               if( tmp != NULL)                        
-                                       newAudio->setAudioCopyright(tmp);
-                               newAudio->setAudioBitrate(sqlite3_column_int(pStmt,1));
-                               newAudio->setAudioTrackNum(sqlite3_column_int(pStmt,2));
-                               newAudio->setAudioSize(sqlite3_column_int(pStmt,3));
                        }
-                       sqlite3_finalize(pStmt1);
+
+               }
+               
+               
+               //update media info
+               if ( MEDIA_CONTENT_ERROR_NONE != media_info_update_to_db(media))
+               {
+                       LogDebug("Error: update to DB");
+                       ret = false;
                }
+                                       
+               if ( MEDIA_CONTENT_ERROR_NONE !=media_info_destroy(media))
+               {
+                       LogDebug("Error: destroy media info");  
+                       ret = false;
+               }       
+       
+       }
 
-               MMHandleType tag_attrs = 0;
-               LogDebug("AUDIO PATH: " << newAudio->getFilePath());
-               int ret = mm_file_create_tag_attrs(&tag_attrs, newAudio->getFilePath().c_str());
+       return ret;
+
+}
+
+void Mediacontent::OnRequestReceived(const IEventUpdateMediaPtr &eMedia)
+{
+    LogDebug("OnRequestReceived::IEventUpdateMediaPtr entered");
+       try
+       {
+               MediacontentMediaPtr mediaPtr = eMedia->getMediaItem();
 
-               char *err_attr_name = NULL;
-               char* unSyncText;
-               int unSyncLen;
-               int syncTextNum;                
-               if (ret == MM_ERROR_NONE && tag_attrs) 
+               if(updateMediaToDB(mediaPtr))
                {
-                       ret = mm_file_get_attrs( tag_attrs,
-                                                                               &err_attr_name,
-                                                                               MM_FILE_TAG_UNSYNCLYRICS, &unSyncText, &unSyncLen,
-                                                                               MM_FILE_TAG_SYNCLYRICS_NUM, &syncTextNum,
-                                                                               NULL);          
+                       eMedia->setResult(true);
+                       LogDebug("update success");
                }
-               if (ret != MM_ERROR_NONE &&  err_attr_name)
+               else
                {
-                       MediacontentLyricsPtr lyricsPtr(new MediacontentLyrics());
-                       if(syncTextNum > 0)
-                       {
-                               lyricsPtr->setMediaLyricsType("SYNCHRONIZED");
-                               for(int i=0; i < syncTextNum; i++)
-                               {       
-                                       unsigned long time_info = 0;
-                                       char * lyrics_info = NULL;
-                                       mm_file_get_synclyrics_info(tag_attrs,i,&time_info,&lyrics_info);
-                                       lyricsPtr->addMediaLyricsTimeStamp(time_info);
-                                       lyricsPtr->addMediaLyricsText(lyrics_info);
-                                       LogDebug("SYNCHRONIZED: " << lyrics_info);
+                       eMedia->setResult(false);
+                       ThrowMsg(PlatformException, "DB operation is failed");
+               }
+       }
+    catch (const Exception &ex)
+    {
+        LogError("Exception: " << ex.DumpToString());
+        eMedia->setResult(false);
+    }
+}
+
+
+void Mediacontent::OnRequestReceived(const IEventUpdateMediaItemsPtr &eItems)
+{
+       LogDebug("OnRequestReceived::IEventUpdateMediaItemsPtr entered");
+
+       try
+       {
+               MediacontentMediaListPtr mediaListPtr = eItems->getMediaItems();
+               if (mediaListPtr->empty()) 
+               { 
+                   LogDebug("Item vector is empty");
+               }
+               else
+               {
+                        for(unsigned int i=0; i<mediaListPtr->size(); i++)
+                       {
+                               
+                               MediacontentMediaPtr mediaPtr = mediaListPtr->at(i);
+                               if(updateMediaToDB(mediaPtr))
+                               {
+                                       eItems->setResult(true);
+                                       LogDebug("update success");
                                }
+                               else
+                               {
+                                       eItems->setResult(false);
+                                       ThrowMsg(PlatformException, "DB operation is failed");
+                               }
+                               
                        }
-                       else
-                       {
-                               LogDebug("UNSYNCHRONIZED: " << unSyncText);
-                               lyricsPtr->setMediaLyricsType("UNSYNCHRONIZED");
-                               lyricsPtr->addMediaLyricsTimeStamp(0);
-                               lyricsPtr->addMediaLyricsText(unSyncText);
-       
-                       }
-                       newAudio->setAudioLyrics(lyricsPtr);
                }
-               
        }
-
+       catch (const Exception &ex)
+       {
+                LogError("Exception: " << ex.DumpToString());
+                eItems->setResult(false);
+       }
+       //eItems->setCancelAllowed(false);
+       
 }